Saeed Masoomi
Saeed Masoomi

Reputation: 1834

How can set exposure time for DMM 27UJ003-ML camera using opencv

I'm using a camera which is called DMM 27UJ003-MLand the documents are available via this link. This camera has some features such as Brightness which can be set in OpenCV, see the following code for instance

//Header 
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
   VideoCapture cap(0);   //Access to camera with ID = 0
   double brightness = cap.get(CV_CAP_PROP_BRIGHTNESS); // get value of brightness
   cout<<brightness<<endl;   //print brightness value in console
}

result is 0.5 and it's OK,I can set Brightness as well, but if i want to change Exposure time the problem will be appear!!(Exposure time is another camera property that can be variable)

int main()
{
    VideoCapture cap(0);
    cap.set(CV_CAP_PROP_EXPOSURE,0.1);
}

ButExposure time can't be set in appropriate way and if want to use get method to knowing what set as Exposure time value,result is strange

VideoCapture cap(0);
double Exposure = cap.get(CV_CAP_PROP_EXPOSURE);
cout<<Exposure<<endl;

result of Exposure is inf and camera doesn't response to outside environment(it seems that Exposure time is inf actually) so the only way to reset Exposure timeis software that company gave to me and i don't know how i can set this feature in opencv

thanks for your help.

Upvotes: 1

Views: 448

Answers (2)

John
John

Reputation: 11

Add the following code at the beginning:

cap.set(CV_CAP_PROP_AUTO_EXPOSURE,0.25);

0.25 means 'manual mode'.

Upvotes: 1

Saeed Masoomi
Saeed Masoomi

Reputation: 1834

If you use Linux based machine you can install a package that will help you about that, which it's name is v4l2ucp,this package can be install by below command in ubuntu

sudo apt install v4l2ucp

this is a package that give you graphical control on camera with using great v4l2 package (by installing v4l2ucp there is no need to install v4l2 again). if you can change exposure time in the v4l2ucp then you can use v4l2 inside of your program.

you can get whole information about your camera by below command in ubuntu terminal.

v4l2-ctl --all

after knowing which parameters are available for you by using above command you can change value of that parameter. for example of my output is like below

 brightness (int)    : min=-10 max=10 step=1 default=0 value=0

you can see there is a variable of camera,which it's name is brightness and defalut value of that is 0 and there is boundary for value (min=-10, and max =10) so how can I set this value to 10 for instance? I can do this by below command(please test it by open camera)

v4l2-ctl --set-ctrl brightness=10

after doing that in terminal you can see brightness changes in camera.

So how we could use v4l2 command inside Qt programming? by using QProcess class, this command let you to run terminal commands inside of Qt program. I write a simple example

 #include <QProcess>
 int main()
 {
     QProcess process;
     process.start("v4l2-ctl --set-ctrl brightness=10");
     pro.waitForFinished(-1);
 }

Upvotes: 0

Related Questions