Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to set/get camera properties on Mac OS X

I am using OpenCV3 on Mac OS X. I want to get/set camera properties. Whatever value I tryout it has no effect. I wrote a simple code to see which properties are available and tried this with different webcams I own. But I could not get any values from any of the cams.

  • Is there something wrong in my code?
  • Does the Mac OS X backend not support to get/set camera properties?
  • Which webcams are fully controllable?

The code you can get as attachment.

Thx and regards Alexander

// The code I am using
#include "opencv2/opencv.hpp" 
using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
     // Start default camera
    VideoCapture video(0);

    //Alexander
    float Brightness = video.get(CV_CAP_PROP_BRIGHTNESS);
    float Contrast   = video.get(CV_CAP_PROP_CONTRAST );
    float Saturation = video.get(CV_CAP_PROP_SATURATION);
    float Gain       = video.get(CV_CAP_PROP_GAIN);

    float Position = video.get(CV_CAP_PROP_POS_MSEC);
    float Width = video.get(CV_CAP_PROP_FRAME_WIDTH);
    float Height = video.get(CV_CAP_PROP_FRAME_HEIGHT);
    float Format = video.get(CV_CAP_PROP_FORMAT);

    double Hue = video.get(CV_CAP_PROP_HUE);
    double Exposure = video.get(CV_CAP_PROP_EXPOSURE);
    double Mode = video.get(CV_CAP_PROP_MODE);
    double fps = video.get(CV_CAP_PROP_FPS);

    cout<<"Brightness -------> "<<Brightness<<endl;
    cout<<"Contrast----------> "<<Contrast<<endl;
    cout<<"Saturation--------> "<<Saturation<<endl;
    cout<<"Gain--------------> "<<Gain<<endl;
    cout<<"Hue---------------> "<<Hue<<endl;
    cout<<"Exposure----------> "<<Exposure<<endl;
    cout<<"Mode--------------> "<<Mode<<endl;

    cout<<"Position---------->"<<Position<<endl;
    cout<<"Width------------->"<<Width<<endl;
    cout<<"Height------------>"<<Height<<endl;
    cout<<"Format------------>"<<Format<<endl;
    cout<<"Frames---------->"<<fps<<endl<<endl;

    return 0;
}
click to hide/show revision 2
retagged

updated 2019-10-30 16:06:33 -0600

berak gravatar image

How to set/get camera properties on Mac OS X

I am using OpenCV3 on Mac OS X. I want to get/set camera properties. Whatever value I tryout it has no effect. I wrote a simple code to see which properties are available and tried this with different webcams I own. But I could not get any values from any of the cams.

  • Is there something wrong in my code?
  • Does the Mac OS X backend not support to get/set camera properties?
  • Which webcams are fully controllable?

The code you can get as attachment.

Thx and regards Alexander

// The code I am using
#include "opencv2/opencv.hpp" 
using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
     // Start default camera
    VideoCapture video(0);

    //Alexander
    float Brightness = video.get(CV_CAP_PROP_BRIGHTNESS);
    float Contrast   = video.get(CV_CAP_PROP_CONTRAST );
    float Saturation = video.get(CV_CAP_PROP_SATURATION);
    float Gain       = video.get(CV_CAP_PROP_GAIN);

    float Position = video.get(CV_CAP_PROP_POS_MSEC);
    float Width = video.get(CV_CAP_PROP_FRAME_WIDTH);
    float Height = video.get(CV_CAP_PROP_FRAME_HEIGHT);
    float Format = video.get(CV_CAP_PROP_FORMAT);

    double Hue = video.get(CV_CAP_PROP_HUE);
    double Exposure = video.get(CV_CAP_PROP_EXPOSURE);
    double Mode = video.get(CV_CAP_PROP_MODE);
    double fps = video.get(CV_CAP_PROP_FPS);

    cout<<"Brightness -------> "<<Brightness<<endl;
    cout<<"Contrast----------> "<<Contrast<<endl;
    cout<<"Saturation--------> "<<Saturation<<endl;
    cout<<"Gain--------------> "<<Gain<<endl;
    cout<<"Hue---------------> "<<Hue<<endl;
    cout<<"Exposure----------> "<<Exposure<<endl;
    cout<<"Mode--------------> "<<Mode<<endl;

    cout<<"Position---------->"<<Position<<endl;
    cout<<"Width------------->"<<Width<<endl;
    cout<<"Height------------>"<<Height<<endl;
    cout<<"Format------------>"<<Format<<endl;
    cout<<"Frames---------->"<<fps<<endl<<endl;

    return 0;
}