Ask Your Question

Revision history [back]

when capturing image from webcam, if you grab only the first frame you will never get a quality image. you must let the camera to be warmed up.

let us test this stuation with the code below

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int argc, char** argv)
{
    VideoCapture cap;

    if(!cap.open(1))
        return 0;

    Mat frame[5];

    for(int i; i<5; i++ )
    {

        cap >> frame[i];
        imshow(format("Frame - %d",i), frame[i]);

    }
    waitKey();
    return 0;
}

difference between 1st and 5th frame is blurriness on my cam. i think on some cams the brightness difference can occur.

image description

image description

when capturing image from webcam, if you grab only the first frame you will never get a quality image. you must let the camera to be warmed up.

let us test this stuation with the code below

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int argc, char** argv)
{
    VideoCapture cap;

    if(!cap.open(1))
if(!cap.open(0))
        return 0;

    Mat frame[5];

    for(int i; i<5; i++ )
    {

        cap >> frame[i];
        imshow(format("Frame - %d",i), frame[i]);

    }
    waitKey();
    return 0;
}

difference between 1st and 5th frame is blurriness on my cam. i think on some cams the brightness difference can occur.

image description

image description

when capturing image from webcam, if you grab only the first frame you will never get a quality image. you must let the camera to be warmed up.

let us test this stuation with the code below

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int argc, char** argv)
{
    VideoCapture cap;

    if(!cap.open(0))
        return 0;

    Mat frame[5];

    for(int i; i=0; i<5; i++ )
    {

        cap >> frame[i];

        if( !frame[i].empty() )
        {
            imshow(format("Frame - %d",i), frame[i]);
             i++;
        }
    }

    waitKey();
    return 0;
}

difference between 1st and 5th frame is blurriness on my cam. i think on some cams the brightness difference can occur.

image description

image description