Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VideoCapture.open(0) won't recognize pi cam

Tags:

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?

like image 746
DMEM Avatar asked Apr 11 '15 21:04

DMEM


People also ask

How do I connect my PI zero camera?

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.

Why is my camera is not working on Raspberry Pi?

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.

How do I get my PI camera to work?

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.

How do I enable my Raspberry Pi camera in terminal?

Run sudo raspi-config . Navigate to Interface Options and select Legacy camera to enable it. Reboot your Raspberry Pi again.


2 Answers

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

like image 156
ats Avatar answered Oct 06 '22 00:10

ats


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

like image 24
Claude Avatar answered Oct 06 '22 00:10

Claude