Ask Your Question
0

how can I set VideoCapture attributes with set?

asked 2017-01-25 01:43:52 -0500

j0h gravatar image

updated 2017-01-25 07:39:05 -0500

I am trying to adjust the gain in a simple camera function

void imgGet(){

    cv::VideoCapture cap(0);
    double k=0.99;
    cap.set(CAP_PROP_EXPOSURE,1); 
    Mat frame;
    cap >> frame;
    string fileName = getFName();
    imwrite(fileName, frame);
    }

Ive tried a variety of things, but the error I get is:

VIDIOC_S_CTRL: Invalid argument

I don't know what that means, how am I supposed to set the VideoCapture::set object? I have seen the videocapture documentation

but I didnt understand it in a useful way. I am on a Linux PC. despite the error, an image is still taken, but the image quality is unchanged.

edit retag flag offensive close merge delete

Comments

It should be

cap.set(CV_CAP_PROP_GAIN, k ); //value from 0 to 1
LBerger gravatar imageLBerger ( 2017-01-25 01:47:57 -0500 )edit
2

It is not an opencv message. May be CV_CAP_PROP_GAIN cannot be set on your camera...

LBerger gravatar imageLBerger ( 2017-01-25 03:05:58 -0500 )edit

I am guessing the second answer of @LBerger is right. Your camera has to support the programmatically setting of these parameters, and OpenCV must be using a camera interface that supports the set function. So please provide us your CMAKE output (to know which interfaces are enabled) and the type of your camera.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-01-25 03:37:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-25 03:35:44 -0500

pklab gravatar image

from 3.2 doc VideoCapture::set()

Even if it returns true this doesn't ensure that the property value has been accepted by the capture device

VideoCapture::get()

Reading / writing properties involves many layers. Some unexpected result might happens along this chain.

VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware

...Effective behaviour depends from device driver and API Backend

BRIGHTNESS, GAIN, EXPOSURE often doesn't works

in your case, you are working with Video4Linux backend using User Controls. Even if V4L2_CID_GAIN is integer, OpenCV normalizes/translates the accepted range to 0..1 as 0%..100% of accepted value by V4L thus @LBerger comment is right.

But maybe the camera doesn't accept the control, try if changing the GAIN using the v4l command line utils it works

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-01-25 01:43:52 -0500

Seen: 1,077 times

Last updated: Jan 25 '17