Raspberry Pi Pet Detector Camera Using Python, TensorFlow, and Twilio [video]
youtube.com
youtube.com
Also, I am wondering how dogs know when to expect you back. Is their sense of time that accurate and they can easily realize that 9-ish hours passed?
I'm not exactly sure how they know when to expect me home, but they seem to have a decent sense of time or are sensitive enough to external triggers that condition them, like neighbors arriving home after work, rush hour traffic, etc.
They do exhibit certain behaviors when it's feeding time (hasn't been automated yet), which is the same every night and that is consistent through daylight savings changes and day lengths varying with seasons. So I assume they have some rudimentary sense of time.
Was fairly straightforward--required just a USB dial-up modem, WiFi card, switch with some lights, a case, and a little Python programming. Oddly enough, the hardest part of the whole setup was "reverse engineering" what the proprietary Netscape dial-up app was doing with her password before sending it out--turned out it was lowercasing it! Facepalmed real hard there. After figuring that out, everything worked in Linux beautifully.
It's not using machine learning, but I'm just now finishing up a Christmas present; a web accessible treat dispense with live video. I know those exist commercially, but it has been a fun project to build one anyway.
Terrible quality pictures:
Raspberry Pi Zero W for the brains; Pimoroni speaker hat; cheap stepper motor and bridge; IR emitter and transistor create an IR break beam to detect when treats are dispensed; Raspberry Pi camera for live video feed; all controlled by a custom AppEngine deployment which provides a nice web interface for dispensing treats, viewing the video, and even uploading their own sounds which get played before the treats come out.
The most difficult thing has been the mechanical engineering; something I have little to no experience with. The whole CAD process took me a few weeks of working on and off. Then another two weeks of printing and iterating the parts. The main body itself is a 14 hour print even at high speed. I ended up using FreeCAD for the whole design. Not sure if that was a mistake or not. I like supporting open source software, but ... I have this terrible notion that something like Fusion360 would have made the whole process 10x faster... But it's all printed and working!
Since this is going as a gift to someone else, I also had to take a lot of time to make it easy to use; it couldn't just be a fiddly hack. So, for example, I got a nice setup procedure built into it for setting up wifi. You just hold the button on the back to put it into setup mode, and then show it a QR code on your phone with your Wifi network's details. And since there's a speaker, I'm using some text-to-speech to walk them through the setup. It turned out nice.
And using the magic of ffmpeg, I was able to get the Raspberry's camera feed into an HLS stream, which gets securely uploaded to the AppEngine server. So it's a live video, rather than still pictures or delayed video uploads. Was really happy when that got working. (I use hls.js to handle desktop browser compatibility. Works a treat. Also, FFMpeg is supposed to be able to upload the HLS stream itself to a server, but that was broken or something; had to use some Python to pipe it manually.)
Just putting the finishing touches on the frontend now. 4 days to go... wish me luck!
Unfortunately the community definitely seems more geared towards fusion360. My gut reaction is that in general they don't value the open source aspect of freecad, but maybe it is just subpar for now.
Did you buy a 3d printer for this project? Don't have any source code available?
I love supporting open source. For example, the 3D printer I have is the Lulzbot Mini 2. The company behind it is ... aggressively open source, to put it mildly (_everything_ is open source. Even their manuals for factory assembly are online.). Which is why I went with FreeCAD initially. But I lost a lot of time to A) the awkward UI; and B) bugs. Having just now, the day before Christmas, finished wrapping the gift ... I wonder how much time I would have saved using a "professional" CAD solution. shrug
Words of advice if you do go down the FreeCAD route; learn about dataplanes and shapebinder (check YouTube for tutorial videos). They are somewhat recent features. If you just look up FreeCAD tutorials you'll find a lot that tell you to bind sketches to faces. That's the old way of doing it and it can lead to a lot of problems. Dataplanes are the new way of doing it.
And be careful in the sketcher. A number of times I've had it tell me a sketch is fully constrained, but I was scratching my head because I didn't think it was fully constrained. A day later I'll go back into that sketch and it'll have realized its mistake and moved the sketch around (had one failed print because of that bug).
> Don't have any source code available?
I'm thinking of writing a blog post about the whole project at some point, with all the documentation and such. Bit exhausted right now...
Best of luck with your 3D printing!
A 'cat sms' would put humans into full servitude!
Here are two others, using different tech to automatically open the door for the pet.
Facial recognition: https://www.hackster.io/windowsiot/cat-door-with-pet-recogni...
Pattern recognition: https://hackaday.com/2010/05/14/cat-door-unlocks-via-facial-...
The OP is kinda swatting a fly with a sledgehammer, but blindfolded, because the system would probably break if the door changed or someone moved something into the detection window. Problem with CNNs is training them to know what is NOT a valid condition, and that is VERY VERY HARD.
This kind of "blind overdesign" makes me sad.
https://web.archive.org/web/20040401115046/http://www.quantu...
Nevertheless, this is a cool project, and the explanation in the YouTube video is even nicer, informative, and succinct.
One addition could be to have a motion sensor outside the door to turn on the light outside, so that this project can work even during late evenings/nights.
In this case it would be better to just have one detection box, and say 'pet is at door'
(One of the cameras is my old security camera but the two new ones are fish eye lense zeros close to the ground.)
Now what could be a great improvement is a cat flap identifying your cat(s) and letting them in based on computer vision, instead of relying on implants. I'd pay good money for it, provided that it worked in all weather conditions and all cat conditions (a wet and dirty cat needs to get in even more than a dry and clean one but I expect false negatives in these scenarios.)
That is why it needs to be inside the animal. And yes that is a true story. And yes he was also wearing a collar with a nameplate and address on him, the guy replaced it with a different collar.
1: https://en.wikipedia.org/wiki/Microchip_implant_(animal)#Use...
Your threshold for “barbaric” sounds pretty low, but I guess it’s all relative.
This is a good example of how titles dominate threads. Because of the title "Neural network knows when cat wants to go outside", we got cat quips. "Raspberry Pi Pet Detector Camera Using Python, TensorFlow, and Twilio" primes a different sort of discussion.
My cat definitely, however, is unaware of the idea that the environment around him can be changed, and isn't static. He can figure out how to open doors, and that if something is playing dead it will run when he knocks it from a shelf, but those are the limitations of his ability to interact with the environment.
He's smart enough to know his treats are kept in a small bin on a shelf in my desk, that weighs under a pound, and is covered by a thick sheet of paper. He could knock the whole thing to the ground and get all the treats he wants. But because it looks too big to be an eatable animal playing dead, it simply doesn't occur to him he can push it open to get the treats inside.
That, I think, explains a lot of their behavior. The cat will scratch at the door to go outside. But when I open the door, he needs to take a moment or three to re-situate himself in his new environment, for him, his entire environment just changed unexpectedly. If I then poke my head through the door, he'll realize that its open now, and run through. But if I don't, he needs to re-assess his entire locale, realize that the open door means its passable, and ignore his confusion for how his environment changed so rapidly.
This is true with a lot of things. He'll complain that his litterbox is too dirty. I'll clean it. He'll leave the litterbox, and go do something else. Later, he'll come back, find that its clean, and go to the bathroom. Its not that he was being an asshole, he just knows enough to have figured out that meowing next to a dirty litterbox results in it eventually being clean, but doesn't seem to recognize that the action of me scooping in there is what is actively changing the environment, he needs to rediscover his litterbox as clean 1-5-10-15 minutes later.
etc
You can use this to your advantage to play games with the cat, interestingly enough. I play with him with this thing: https://www.chewy.com/snugglycat-ripple-rug-cat-activity/dp/...
Some days, he gets bored with it. So I unvelcro it, change its shape, and start playing again, and suddenly, its an entirely new toy, and he gets excited again! lol
I honestly think the hardest part of explaining cat behavior is how chaotic they are as a species. You can explain A cat's behavior, but it's harder to explain all of them. My cats, for example, completely understand knocking over (even large) containers to get food, understand that turning door knobs will open doors (thankfully their lack of thumbs means they usually don't have the grip to pull it off), but fail to understand that sitting ON the closed food container means I can't use it to feed them.
Ive read that not only are cats more recently domesticated than dogs (like, by an order of magnitude of years, with dogs domesticated 50k-80k years ago) but that domestication didn't involve OUR deliberate breeding of them outside of recent centuries, so the traits selected for are more about compatibility (for their benefit) than for anything we explicitly want. My personal theory is that housecats are often from such small genepools (that haven't had a lot of recessives weeded out of them yet) that cats tend to be this mix of genius and idiot and weird, so it's very hard to extrapolate generalities from a few specimens. But that theory is likely worthless.
I applaud you for trying to explain this. You could be completely right, or wrong... We're talking about cats after all.
But when he is outside asking to come in, as soon as I open the door, he runs right inside. Perhaps it is because the inside environment is very stable for him with no threats ever so he trusts it.
He does this freezing behavior when guests enter the house. My housemate's cousin brought a huge dog for an afternoon visit. My cat froze entering the living room, detecting an unknown threat, and turned around again and went back to my room.
Gwern published a nice article about cats recently: https://www.gwern.net/Book-reviews#cat-sense-bradshaw-2013-a...