Ask Your Question

Revision history [back]

Capture frames becomes very slow when it's night

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);
}

}