Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change the contrast and brightness of the camera?

Hi, I am using opencv and microsoft visual studio 2010 express edition. I have made a windows form application for camera (uEye camera) control. I tried to change the contrast and brightness of my camera using this code:

cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value); cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);

There are no errors but the brightness and the contrast are the same as previous without a change.

Could you please give me an advise.

Here is my code:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

             capture = cvCaptureFromCAM(0);

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 40.00) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value);
             cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);   

             timer1->Start();
         }

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {

             IplImage* frame = cvQueryFrame(capture);


             pictureBox2->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(frame->width,frame->height,frame->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) frame->imageData);

             pictureBox2->Refresh();

                     gray = cvQueryFrame(capture);

             cvThreshold(frame, gray, 100,255,CV_THRESH_BINARY_INV);
             pictureBox1->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(gray->width,gray->height,gray->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) gray->imageData);

            pictureBox1->Refresh();

         }

How to change the contrast and brightness of the camera?

Hi, I am using opencv and microsoft visual studio 2010 express edition. I have made a windows form application for camera (uEye camera) control. I tried to change the contrast and brightness of my camera using this code:

cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value); cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value);
cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);

There are no errors but the brightness and the contrast are the same as previous without a change.

Could you please give me an advise.

Here is my code:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

             capture = cvCaptureFromCAM(0);

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 40.00) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value);
             cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);   

             timer1->Start();
         }

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {

             IplImage* frame = cvQueryFrame(capture);


             pictureBox2->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(frame->width,frame->height,frame->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) frame->imageData);

             pictureBox2->Refresh();

                     gray = cvQueryFrame(capture);

             cvThreshold(frame, gray, 100,255,CV_THRESH_BINARY_INV);
             pictureBox1->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(gray->width,gray->height,gray->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) gray->imageData);

            pictureBox1->Refresh();

         }
click to hide/show revision 3
retagged

updated 2014-03-06 04:16:25 -0600

berak gravatar image

How to change the contrast and brightness of the camera?

Hi, I am using opencv and microsoft visual studio 2010 express edition. I have made a windows form application for camera (uEye camera) control. I tried to change the contrast and brightness of my camera using this code:

cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value);
cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);

There are no errors but the brightness and the contrast are the same as previous without a change.

Could you please give me an advise.

Here is my code:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

             capture = cvCaptureFromCAM(0);

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 40.00) ;

             cvSetCaptureProperty(capture,CV_CAP_PROP_BRIGHTNESS,trackBar1->Value);
             cvSetCaptureProperty(capture,CV_CAP_PROP_CONTRAST,trackBar2->Value);   

             timer1->Start();
         }

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {

             IplImage* frame = cvQueryFrame(capture);


             pictureBox2->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(frame->width,frame->height,frame->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) frame->imageData);

             pictureBox2->Refresh();

                     gray = cvQueryFrame(capture);

             cvThreshold(frame, gray, 100,255,CV_THRESH_BINARY_INV);
             pictureBox1->Image  = gcnew    //replacement of cvShowImage
                 System::Drawing::Bitmap(gray->width,gray->height,gray->widthStep,
                 System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) gray->imageData);

            pictureBox1->Refresh();

         }