opencv does not display a video in mac osx -


i installed opencv on mac osx 10.8.3, installed brew:

brew install opencv 

and version 2.4.3

>>> ls /usr/local/cellar/opencv 2.4.3 

i try display video. format .asf , codec mjpg (i can open vlc, see screenshot)

the number of frame (if printed out in opencv or seen in vlc) same.

but if run opencv program first frame showed. other not.. why??

this opencv code

#include <iostream>  #include <string>  #include <sstream>  #include <opencv2/core/core.hpp>  #include <opencv2/imgproc/imgproc.hpp>  #include <opencv2/highgui/highgui.hpp>   using namespace std; using namespace cv;   int main(int argc, char *argv[]) {      mat frame;     int numframe = 0;      if (argc != 2) {         cout << "not enough parameters" << endl;         return -1;     }      const string source = argv[1];     videocapture capture(source);     namedwindow("video", cv_window_autosize);      if (!capture.isopened()) {         cout  << "could not open " << source << endl;         return -1;     }      for(;;) {         capture >> frame;         numframe++;         if (frame.empty()) {             cout << "frame empty.." << endl;             break;         }         cout << numframe << endl;         imshow("video", frame);     }      return 0; } 

enter image description here

after:

imshow("video", frame); 

call:

waitkey(10); 

it's mandatory call cv::waitkey() display window. parameter number of milliseconds window remain opened. function return ascii code of key pressed during time.

ideally, replace 10 number makes display frames @ right fps. in other words: cv::waitkey(1000 / fps);


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -