Video window not loading frame
I know this question has been asked multiple times but none of the solutions have worked for my context plus my window is actually getting loaded.
When I run this program, the webcam lights up and the window actually appears but without the footage. The same thing happens when I try to load an image. I tried with and without the namedWindow()
method but still no luck. My frame
matrix consists of data and everything seems to run smoothly with exception to actually displaying the image/video.
I compiled OpenCV3.2.0 from source and running it on Mac OS Sierra.
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
VideoCapture cap(0);
void grabVideoFeed(Mat& frame)
{
if (!cap.isOpened()) cerr << "Issue grabbing camera";
cap.read(frame);
}
int main(int argc, const char * argv[])
{
Mat frame;
for(;;)
{
grabVideoFeed(frame);
if (frame.empty()) break;
namedWindow("Main", CV_WINDOW_AUTOSIZE);
imshow("Main", frame);
if (waitKey(30) >= 0) break;
}
cap.release();
destroyAllWindows();
return 0;
}
When I execute this program, the created window looks like this.
looks more like an apple gui problem to me, specifically this one
That's very weird because I was able to load video feeds through OpenCV with Python.
maybe try with different window flags, with or without namedWindow()
there seems to be a weird bug in opencv <--> cocoa present (my opinion)
did you build the python version locally ? might be helpful to check
cv2.printBuildInformation()
against your c++ oneA quick inspection into their build info reveals no significant difference actually. I might be wrong but have a peek and see. Python and C++
your python one was build by the conda guys, on 2017-03-30, your c++ one is from 2017-06-13
(it's a detective story, should you accept this mission. this note will self-destruct in 5 seconds)
I know that but looking at the Video/GUI and Media sections, they're both the same. Both of them use AVFoundation and Cocoa. The only reasonable explanation I can come up with is that this bug was introduced recently and wasn't there when the conda guys were compiling theirs. I found this suggested solution but yet to be added to master.