Ask Your Question

What are the default webcam settings?

asked 2014-03-28 14:32:12 -0500

Alexandru Onea gravatar image

I am trying to write a simple C program to get a frame from the webcam. Before that I used opencv. When using opencv the image from the webcam was just right. My program gets an image from the webcam but the webcam settings seem to be wrong (brightness, saturation, hue, contrast, etc.) I tried to play around and to adjust them but no result. I was wondering internally, how does opencv set these parameters?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2014-03-29 00:10:07 -0500

Haris gravatar image

updated 2014-03-31 21:49:27 -0500

You could use VideoCapture::get() to get camera property. Also don’t use out-dated C instead use new C++ interface.

See below C++ code, which will access default camera parameters, and also you can change it using track-bar. I have tested it with Logitech webcam and works fine.

float Brightness;
float Contrast ;
float Saturation;
float Gain;

int B;
int C;
int S;
int G;

char winName[20]="Live";
Mat frame;
VideoCapture cap(0);

void onTrackbar_changed(int, void*)
 Brightness =float(B)/100;
 Contrast   =float(C)/100;
 Saturation =float(S)/100;
 Gain       =float(G)/100;

cap.set(CV_CAP_PROP_CONTRAST, Contrast);
cap.set(CV_CAP_PROP_SATURATION, Saturation);
cap.set(CV_CAP_PROP_GAIN, Gain);


int main(int, char**)

    if(!cap.isOpened())  // check if we succeeded
        return -1;

    cout<<"Press 's' to save snapshot"<<endl;

 Brightness = cap.get(CV_CAP_PROP_BRIGHTNESS);
 Contrast   = cap.get(CV_CAP_PROP_CONTRAST );
 Saturation = cap.get(CV_CAP_PROP_SATURATION);
 Gain       = cap.get(CV_CAP_PROP_GAIN);

 cout<<"Default Brightness -------> "<<Brightness<<endl;
 cout<<"Default Contrast----------> "<<Contrast<<endl;
 cout<<"Default Saturation--------> "<<Saturation<<endl;
 cout<<"Default Gain--------------> "<<Gain<<endl<<endl;


createTrackbar( "Brightness",winName, &B, 100, onTrackbar_changed );
createTrackbar( "Contrast",winName, &C, 100,onTrackbar_changed );
createTrackbar( "Saturation",winName, &S, 100,onTrackbar_changed);
createTrackbar( "Gain",winName, &G, 100,onTrackbar_changed);

    int i=0;
    char name[10];

        cap >> frame; // get a new frame from camera
        imshow(winName, frame);
        char c=waitKey(30);

        if(c=='s') {
        if( c== 27) break;
return 0;


image description

edit flag offensive delete link more

Question Tools


Asked: 2014-03-28 14:32:12 -0500

Seen: 14,864 times

Last updated: Mar 31 '14