Underexposed/dark images on raspicam_cv_still
As exposure cannot be set, pictures are often under-exposed.
case CV_CAP_PROP_EXPOSURE :
// if ( value>0 && value<=100 ) { // _impl->setShutterSpeed ( Scaler::scale ( 0,100,0,330000, value ) ); // } else { // _impl->setExposure ( RASPICAM_EXPOSURE_AUTO ); // _impl->setShutterSpeed ( 0 ); // }
Is there a reason why this section is commented out?
Shutterspeed is currently set to automatic. The setter is never used, nor can be used. This implicates that the getter will always return -1
There are situations where shutterspeed has to be fixed, not automatic, such as to avoid flicker in time lapses.
Will this setter be added to the library?
On Friday, June 5, 2015, Cédric Verstraeten [email protected] wrote:
Shutterspeed is currently set to automatic. The setter is never used, nor can be used. This implicates that the getter wil always return -1
— Reply to this email directly or view it on GitHub https://github.com/cedricve/raspicam/issues/2#issuecomment-109173380.
Bogdan Bocse Tel: +(40) 724-714-234 www.bogdanbocse.com
Ok, I've never needed this feature in the Kerberos.io project, however I do unstand your request. We will integrate this in the library.
Hello Cedricve, same issue here. i tried , but the image are too dark than with raspistill command with the same parameters values, its the exposure value? any news about this issue? and about the others parameters that are not implemented, like awb?
Also having dark images.
All pictures I try to take using the opencv modules are black as well.
The frame rate is at a constant 30 fps, as can be seen in the highlighted line of code below:
https://github.com/cedricve/raspicam/blob/master/src/private/private_impl.cpp#L71
30 fps is the reason why manual exposure is only mapped on the interval [0,33] ms, because each frame can have an exposure (be it manual, or automatic) of 1/30 s, that is 33ms.
Solution for better exposure: change in the line of code from the link above, the fps:
from
State.framerate = 30;
to
State.framerate = 10;
Next, recompile the library, by going to the build directory, and inserting the commands from the tutorial
https://github.com/cedricve/raspicam#compiling
You will have a frame rate of 10 fps, but can obtain an exposure as low as 100ms (in the case of 10 fps)
below is the code I've used for having a preview on the raspberry of the exposure range
#include <raspicam/raspicam.h>
#include <raspicam/raspicam_cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
raspicam::RaspiCam_Cv Camera; // Camera Object
Camera.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
Camera.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cv::Mat frame;
// Set camera params
Camera.set(CV_CAP_PROP_FORMAT, CV_8UC3); // For color
// Open camera
cout << "Opening camera..." << endl;
if (!Camera.open())
{
cerr << "Error opening camera!" << endl; return -1;
} else
cout << "OPEN~!!\n";
//Start capturing
cv::namedWindow("Display Window", cv::WINDOW_AUTOSIZE);
int i=0;
for (;;)
{
Camera.set(CV_CAP_PROP_EXPOSURE, 1+i%30);
Camera.grab();
Camera.retrieve(frame);
cv::imshow("Display Window", frame);
printf("i==%d\n", i);
if (cv::waitKey(1) > 0)
{
break;
}
i++;
if(i<=30)
{
cv::imwrite ("image"+std::to_string(i)+".jpg",frame );
}
}
cout << "Stopping camera.." << endl;
Camera.release();
return 0;
}
By keeping the mapping from 0 to 330000, I just stopped setting the value in
Camera.set(CV_CAP_PROP_EXPOSURE, 1+i%30);
at 30, therefore I only use range [1, 30] out of [1, 100]. By using values greater than 30, obviously no change in exposure can take place, given the 10 fps.
Below you can see the maximum possible manual exposure with the library compiled having 30 fps vs 10 fps. Camera not moved, light conditions unchanged.
Camera.set(CV_CAP_PROP_EXPOSURE, 100); // as high as possible shutter speed

Images are still too dark, need a way to get brighter images. Any thoughts on this @6by9 ?