I have been working with my Raspberry Pi 2B for a while now. Testing the Pi cam using raspistill
works great but trying to use OpenCV functions such as VideoCapture.open();
won't work. trying the same command with a USB camera works just fine. I tried different indexes as inputs but nothing works for the pi cam. What am I missing here?
2.1. To attach a camera module to a Pi Zero: Remove the existing camera module's cable by gently lifting the collar on the camera module and pulling the cable out. Next, insert the wider end of the adapter cable with the conductors facing in the same direction as the camera's lens.
Check the Connections to the Raspberry Pi Camera and Raspberry Pi Computer. then check the software settings and the hardware connections. then the camera module is working. Recheck the command you entered to take the picture, or you may have a bad sensor.
Connect Camera Board The camera board attaches to the Raspberry Pi via a ribbon cable. One end of the ribbon cable goes to the camera PCB and the other end attached to Raspberry Pi hardware itself. You need to get the ribbon cable connections the right way, or the camera will not work.
Run sudo raspi-config . Navigate to Interface Options and select Legacy camera to enable it. Reboot your Raspberry Pi again.
sudo modprobe bcm2835-v4l2
will "enable" the camera for opencv automatically.
make sure you have the camera enabled from the raspberry config, either gui or raspi-config. the above loads the necessary drivers to handle everything automatically, i.e. loads the appropriate interfaces (v4l2 drivers) for the raspberry camera.
works out of the box on raspbian jessie. other releases might include the drivers by default, but the link below contains info on compiling the drivers in your worst case. so you should be able to get this to work with pidora as well.
more info: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364
I assume your question is about the C++ API, not the python one? As far as I understand the raspberry pi camera is not a usb camera and as such should be approached differently. For python there is is picamera package which works like a charm (with opencv). I never used the C++ interface but a quick google leads to this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With