Skip to content
Snippets Groups Projects
Commit 230f9132 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Added functions to get and set the gain and exposure parameters.

parent 16f723c8
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,10 @@ class CLICamera
#ifdef HAVE_OPENCV_H
bool get_image(cv::Mat &image);
#endif
void set_gain(unsigned short int gain);
unsigned short int get_gain(void);
void set_exposure(unsigned int exposure);
unsigned int get_exposure(void);
void close(void);
~CLICamera();
};
......
......@@ -15,6 +15,10 @@ int main(int argc, char *argv[])
cv::namedWindow("GlobalShutter",1);
camera.open(0x2a0b,0x00f8);
std::cout << "current gain: " << camera.get_gain() << std::endl;
camera.set_gain(32);
std::cout << "current exposure: " << camera.get_exposure() << std::endl;
camera.set_exposure(32);
for(i=0;i<100;i++)
{
if(camera.get_image(image))
......
......@@ -178,6 +178,64 @@ bool CLICamera::get_image(cv::Mat &image)
}
#endif
void CLICamera::set_gain(unsigned short int gain)
{
this->uvc_access.enter();
if(uvc_set_gain(this->device_handle,gain))
{
this->uvc_access.exit();
throw CLICameraException(_HERE_,"Impossible to set gain");
}
this->uvc_access.exit();
}
unsigned short int CLICamera::get_gain(void)
{
unsigned short int gain;
this->uvc_access.enter();
if(uvc_get_gain(this->device_handle,&gain,UVC_GET_CUR))
{
this->uvc_access.exit();
throw CLICameraException(_HERE_,"Impossible to get gain");
}
this->uvc_access.exit();
return gain;
}
void CLICamera::set_exposure(unsigned int exposure)
{
this->uvc_access.enter();
if(uvc_set_exposure_abs(this->device_handle,exposure))
{
this->uvc_access.exit();
throw CLICameraException(_HERE_,"Impossible to set gain");
}
this->uvc_access.exit();
}
unsigned int CLICamera::get_exposure(void)
{
unsigned int exposure;
this->uvc_access.enter();
if(uvc_get_exposure_abs(this->device_handle,&exposure,UVC_GET_CUR))
{
this->uvc_access.exit();
throw CLICameraException(_HERE_,"Impossible to get gain");
}
this->uvc_access.exit();
return exposure;
}
void CLICamera::close(void)
{
this->uvc_access.enter();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment