cedricve / raspicam

AVA RaspiCam: C++ API for using Raspberry camera with/without OpenCv
322 stars 138 forks source link

Raspicam + OpenCV = stripes and duplicates #37

Open jensJJ opened 7 years ago

jensJJ commented 7 years ago

Hello,

I was trying the OpenCV example on an raspberry Pi 3. The simple_test or raspistill gives me a clear image. If I use the OpenCV example and imshow(frame), I receive stripes and duplicates. See picture. Does anyone know why? I tried two brand new cameras and PIs + PSU. Thanks!

raspicam_opencv

aaron-hurst commented 7 years ago

Hi there,

You're image is a bit hard to see, but it looks like a problem I experienced a few months back. The cause seemed to be asynchronisation of the shutter speed with the mains frequency of the fluorescent lighing in the room I was working in. I solved this by adjusting the shutter speed so that it matched the frequency of the lights (2*50 Hz = 100 Hz where I am). In Raspicam language, that's a value of 3.03 for CV_CAP_PROP_EXPOSURE. Hence, my code was something like:

#define IMG_SHUTTER_SPEED 3.03
...
raspicam::RaspiCam_Cv Camera;
Camera.set ( CV_CAP_PROP_EXPOSURE, IMG_SHUTTER_SPEED);
...

Hope you find that helpful!

jensJJ commented 7 years ago

Thanks, I will test this!