Capture frames becomes very slow when it's night

asked 2016-11-25 07:20:41 -0500

Hi everybody, I have a problem with my webcam, has every faith it makes night it becomes slower my code and the following:

    #include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
void main(void)

{

VideoCapture cap;

cap.open(0);

cap.set(CV_CAP_PROP_FRAME_WIDTH, 160*2);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 120*2);
cap.set(CAP_PROP_FPS,60);
cap.set(CV_CAP_PROP_POS_MSEC, 100);
cap.set(CV_CAP_PROP_BRIGHTNESS, 100);
cap.set(CV_CAP_PROP_CONTRAST, 100);
cap.set(CV_CAP_PROP_SATURATION, 200);
cap.set(CV_CAP_PROP_HUE, 1);
cap.set(CV_CAP_PROP_GAIN, 100);
cap.set(CAP_PROP_AUTOFOCUS, 0);

//cap.set(CV_CAP_PROP_EXPOSURE, CAP_PROP_ISO_SPEED);
while (1)
{
    Mat frame;
    int64 t = getTickCount();
    cap.grab();
    cap.retrieve(frame);
    t = getTickCount() - t;
    printf("Time elapsed: %fms\n", t * 1000 / getTickFrequency());
    cout << cap.get(CAP_PROP_FPS) << endl;
    imshow("frame", frame);

waitKey(timing);
}

}
edit retag flag offensive close merge delete

Comments

Your camera adjust time exposure.. When you use set VdeoVapture method you should use get after to check if parameter is set

LBerger gravatar imageLBerger ( 2016-11-25 08:50:28 -0500 )edit

I tried to put that

cap.set(CV_CAP_PROP_FRAME_WIDTH, 160);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 120);
cap.set(CV_CAP_PROP_FORMAT, CV_8UC1);
cap.set(CV_CAP_PROP_GAIN, 50); // values range from 0 to 100
cap.set(CV_CAP_PROP_EXPOSURE, 50); //-1 is auto, values range from 0 to 100
cap.set(CV_CAP_PROP_WHITE_BALANCE_RED_V, 50); //values range from 0 to 100, -1 auto whitebalance
cap.set(CV_CAP_PROP_WHITE_BALANCE_BLUE_U, 50); //values range from 0 to 100,  -1 auto whitebalance
cap.set(CV_CAP_PROP_BRIGHTNESS, 85);

But it is always the same problem, when I put my finger in the camera the number of capture begins to slow

Laminos gravatar imageLaminos ( 2016-11-26 09:37:44 -0500 )edit

You cannot change the world : when there is not enough photon you have to increase time exposure and hope that read noise is low. You should buy somethin like this good quantum efficiency

LBerger gravatar imageLBerger ( 2016-11-26 09:54:03 -0500 )edit

You mean there is no possibility to set this with a change in max temp wait

Laminos gravatar imageLaminos ( 2016-11-26 10:06:33 -0500 )edit

It depends of your driver and your camera. When you write cap.set(CV_CAP_PROP_EXPOSURE, 50); have you check value set using get(CV_CAP_PROP_EXPOSURE) ? Even if you manage to set a low time exposure may be you will have a black image :not enough photon convert in charge in a pixel

LBerger gravatar imageLBerger ( 2016-11-26 10:14:10 -0500 )edit

I just want to have a static acquisition temp and equal to 60fps

Laminos gravatar imageLaminos ( 2016-11-26 10:14:49 -0500 )edit

my camera it's logitech c170

Laminos gravatar imageLaminos ( 2016-11-26 10:15:45 -0500 )edit

That's not possible with a logitech c170. in doc it is written up to 30 fps. Your value is wrong it is ranging from 0 to -11 (may be -14) read this

LBerger gravatar imageLBerger ( 2016-11-26 10:26:55 -0500 )edit

Ok but it is not static how to make it static

Laminos gravatar imageLaminos ( 2016-11-26 10:44:07 -0500 )edit

I just changed CV_CAP_PROP AUTO EXPOSURE thank you very much

Laminos gravatar imageLaminos ( 2016-11-26 11:19:37 -0500 )edit