HowTo use Raspberry Pi & OpenCV to track objects & turn servo
HTML-код
- Опубликовано: 27 авг 2024
- How I made my Halloween skeleton head turn to watch people as they walk by using a Raspberry Pi Zero, servo, camera, and OpenCV python library.
Parts:
Pi Zero W (with wireless): www.adafruit.c...
PWM Servo bonnet: www.adafruit.c...
Servo: www.adafruit.c...
USB to Barrel Jack cable: www.adafruit.c...
Pi NoIR Camera (camera without an IR filter that's better at night): www.adafruit.c...
camera cable that fits Pi Zero: www.adafruit.c...
USB Hub: www.adafruit.c...
mini HDMI to regular HDMI adapter: www.adafruit.c...
BYOS (bring your own skeleton)
Guides I followed:
circuitdigest....
learn.adafruit...
singleboardbyt...
www.instructab...
pysource.com/2...
running python programs at startup: www.dexterindu...
(note you have to turn off the camera view in the code!)
Sourcecode:
github.com/cur...
It is really neat to see your full process, Scott! I have a raspberry pi in the basement that has been waiting for me, and you are inspiring me to pull it out!
Ha! it's amazing how easy it was to get a servo working on it... just minutes. I need suggestions on an xmas project now... santa watching you?
@@CuriousInventor Love your stuff!! I would suggest attaching a nerf gun with drum and using another servo motor to engage the firing mechanism as well. I would like to take your idea and make something like this to ward off birds that are always pooping in my swimming pool.
I just subbed to your channel, it seams that you haven't been here in quite some time. But I find it very entertaining and informative.
Thank you for that!
Congrarts on getting featured on Hackaday
that's pretty fun. I've wanted to do ...this...forever. Strikes me that it wants to have the camera/pi in the head, and then 'always try to center the view on the object of desire' - but that can be problematic for motion.
I think the openCV function looks for things that move relative to a background, so I'm not sure it would work if the entire frame was changing. Moving the camera kind of breaks it, but putting in the head is what I thought I would do initially.
Awesome project
Hey CuriousInventor. Just wanted to say hi. Always loved your videos. Informative AND funny!
I hope you're doing well.
I REALLY appreciate this video....
Great video! I am using this code as inspiration for a color tracking project for school. I had a quick question about the remap function and how it works. I am currently having trouble utilizing the full frame to get an angle. It seems that it only registering an angle for a quarter of the frame.
I wonder if it's possible to make it track an object fast? I've been trying to find a guide but, no luck yet.
Which RPi OS are you running? Which OpenCV release did you get installed? I've been trying to get OpenCV loaded onto a RPi Zero W for 2 months now and I've have no luck. Could you post an image of your SD to Github? Any help or direction would be greatly appreciated.
very good project! I tried installing open cv on my RPi4 and did not have good luck I followed all the links. the issue is that when I got down to the 'make -j4' it failed each time stating 'No targets specified and no makefile found.'
Fyi, i never did any “make” to build from source, i just installed using aptget… you dont have to build from source at least for my application. I had to completely wipe my pi at one point and start over :(
@@CuriousInventor Thanks for the response. I tried that way also. When I got to the step 'import cv2' I got an error. I wiped the Pi for the 3rd time. I tried a Pi3 and now Pi4. I wiped again now and giving it another try.
Make sure youre doing pip3 also, i think things can get installed where only python2 can see them as opposed to python3
@@CuriousInventor Intreresting. Ok I will try that again. last time I had the issue of importing cv2. Importing numpy was not a problem. I'm giving it another try. Thanks
same problem. when I go to import cv2, it fails
what processor and code does the dog tracking use?
Where are you mate !?
Hey, very good project.I have rebuilt your project and it works fine. Only I noticed that the servos do not turn off. Can you include a routine in which the servos turn off when, for example, no movement is detected? Many greetings !
I think you'd need to use a mosfet to cut power to it, but that may have unintended consequences: forum.allaboutcircuits.com/threads/turning-off-servo-power-while-not-in-use.158019/
@@CuriousInventor Hello,
thanks for the answer but I meant if you can also solve this in software / program?
I dont believe so, unless a special servo is used.
Buddy which raspberry pi you used 3 or 4 1gb or 8gb
please help me as i show your videos you have great knowledge of things