I wrote a program in C++, using wiring pi for the LED, trigger, ad openCV3.2 for the camera. It works, taking a photo, when the button is pressed, but the photo quality is low, even in a well lit room. I think this is because the exposure time is too short.

How can I increase the exposure time, to produce higher quality images?

here is my source, from the function that needs help:

void imgGet(){

    cv::VideoCapture cap(0);
    Mat frame;
    cap >> frame;
    string fileName = getFName(); //returns a string for file naming
    imwrite(fileName, frame);

The VideoCapture documentation is here: but the program returns

VIDIOC_S_CTRL: Invalid argument

it takes the photo, but the exposure time never changes.

Here is an example of what I'm experiencing (both are taken without flash): This is the image quality after running my program: enter image description here

This image is from another OpenCV program, that streams Video. The image becomes saturated as I expect, because the camera is on for a longer period of time. This is a side effect of the video streaming continuously. What I want to do is control it.

enter image description here

  • In what aspect is the image quality low? What is the purpose of the led, is it used as a flash?
    – jogco
    Jan 25 '17 at 8:23
  • 1
    The exposure is low. The camera needs to be active for a longer period, before saving the data from the camera.
    – j0h
    Jan 25 '17 at 13:11
  • Go and look at the OpenCV documentation on how to control exposure time.
    – jogco
    Jan 25 '17 at 13:13
  • What camera are you using? Not all cameras support all openCV options.
    – Jacobm001
    Jan 25 '17 at 16:35
  • one camera is a Suyin Corp. Acer CrystalEye Webcam the other is a Lenovo Integrated Webcam [R5U877]
    – j0h
    Jan 25 '17 at 17:29

You can also configure some captures parameters through v4l2-ctl. My camera don't have exposure setting, but the one you use may have it.

Run in the console :

v4l2-ctl -l

to retrieve the parameters you can change, then run

v4l2-ctl --set-ctrl=contrast=36

to define new values.

I use this approach to correct a too dark camera, successfully :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.