namedWindow + imshow not showing on the screen

asked 2017-03-22 04:46:38 -0500

I can't get the window with the video to show on the screen. The light of the web camera flashes so it opens it and the program is in infinite loop when i run yet nothing shows on the screen.

#include <iostream>
#include <string>
#include <sstream>

#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>

using namespace cv;

int main(int argc, char **argv) {

    VideoCapture cap(0);
    namedWindow("video", WINDOW_NORMAL);
    while (1) {
        Mat frame;
        cap >> frame;
        imshow("video", frame);
        if (waitKey(30) >= 0) break;
    return 0;
edit retag flag offensive close merge delete



opencv version ? os ? which gui kit do you use ? did you build from src ?

it's not the code (which is fairly standard)

berak gravatar imageberak ( 2017-03-22 05:10:18 -0500 )edit

I have OpenCV 3.2.0 from github and i'am running ubuntu 16.04. Sorry for the noob question but how do i know with gui kit i use?

sep_vanmarcke gravatar imagesep_vanmarcke ( 2017-03-22 05:19:38 -0500 )edit

gtk2 / gtk3 / qt, which is it ?

berak gravatar imageberak ( 2017-03-22 05:21:39 -0500 )edit

I think it's gtk2. I did dpkg -s libgtk2.0-0 | grep '^Version' and i got Version: 2.24.30-1ubuntu1

sep_vanmarcke gravatar imagesep_vanmarcke ( 2017-03-22 05:29:01 -0500 )edit

If i do dpkg -s libgtk-3-0 | grep '^Version' i get Version: 3.18.9-1ubuntu3.2, so it seems like i have both gtk2 and gtk3? Is that good, bad? Should i install qt?

sep_vanmarcke gravatar imagesep_vanmarcke ( 2017-03-22 11:37:18 -0500 )edit

does application returns when you press any button after camera has been opened?

pi-null-mezon gravatar imagepi-null-mezon ( 2017-03-24 06:32:22 -0500 )edit