imshow is returning lots of static like an old tv. Has anyone else seen this? [closed]

asked 2018-12-21 00:49:28 -0600

jackosmacko gravatar image

updated 2018-12-21 01:37:08 -0600

LBerger gravatar image

//this shows my webcam stream with lots of noise. like an old tv set on the wrong channel. Please help.

#include "pch.h"


#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
    VideoCapture cap;
    cap.open(0);
    if (!cap.isOpened())
    {
        printf("--(!)Error opening video capture\n");
        return -3;
    }


    Mat image;
    namedWindow("Image", WINDOW_AUTOSIZE);
    while (1)
    {
        cap.read(image);

        imshow("Image", image);
        waitKey(30);
    }


    return 0;
}
/////

image description

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-11-09 10:22:46.136354

Comments

opencv version / os ?

berak gravatar imageberak ( 2018-12-21 00:50:46 -0600 )edit

blind guess: it's a problem with the MSMF webcam backend, can you try:

cap.open(0, CAP_DSHOW);

? (use directshow, not msmf)

berak gravatar imageberak ( 2018-12-21 01:53:55 -0600 )edit

Basic troubleshooting: Is it just imshow or do you see it with imwrite too?

Meaning, is the problem in imshow or in the image reading?

Tetragramm gravatar imageTetragramm ( 2018-12-21 23:08:52 -0600 )edit