Ask Your Question
0

Can't open any avi, opencv2.4.9 on OSX10.9 with Eclipse Luna

asked 2014-09-26 07:38:07 -0600

sls2 gravatar image

I would really appreciate some help as I have spent 2.5 days getting nowhere despite reading everything I can find via Google search etc. I have installed using make, macports and brew (and uninstalled between), and tried installing every dependency I've seen mentioned. Yet still I cannot open a simple video. I can see the .avi file as I can return the width/height/frame rate etc, but just cannot open a frame. Code is at the end of this post, its just the basic tutorial with extra lines in to print out what is happening at each stage for debugging purposes.

I am using OSX 10.9.5, OpenCV 2.4.9, Eclipse Luna.

I have configured Eclipse with the Includes (opencv_core, opencv_highgui etc), include path (usr/local/include/opencv and ...opencv2) and Library search path (/usr/local/lib).

I have checked that I am building using release rather than debug.

It gets to the point of cap.read(frame) in the while loop and fails with the error below which seems to suggest it is looking for files in a temporary directory. Can anyone advise if there is another setting somewhere that needs to be changed to stop this happening? Or give any advice that may get this working?

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /tmp/opencv-Dx3QJT/opencv-2.4.9/modules/highgui/src/window.cpp, line 261 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-Dx3QJT/opencv-2.4.9/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow

============================

#include <iostream> #include "opencv2/core/core.hpp" #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp"

using namespace cv; using namespace std;

int main(int argc, char *argv[]) { // Container for each frame cv::Mat frame; std::cout << "Empty frame created" << endl;

// Open video file
//cv::VideoCapture cap(argv[1]);
cv::VideoCapture cap;
cap.open("vid/Megamind.avi");
std::cout << "Video found" << endl;

cv::waitKey(1000);

// Check whether the file was opened
if (!cap.isOpened())
{
    std::cout << "Cannot open the video file" << endl;
    return -1;
}

//Counts the frames per second
int fps = (int)cap.get(CV_CAP_PROP_FPS);
std::cout << "Frame per seconds : " << fps << endl;

//count total number of frames
int fno = (int)cap.get(CV_CAP_PROP_FRAME_COUNT);
std::cout << "Total no. frames : " << fno << endl;

int fwid = (int)cap.get(CV_CAP_PROP_FRAME_WIDTH);
std::cout << "Width : " << fwid << endl;

int fhei = (int)cap.get(CV_CAP_PROP_FRAME_HEIGHT);
std::cout << "Height : " << fhei << endl;

cv::waitKey(1000);

// Creates a window
cv::namedWindow("Video1",WINDOW_AUTOSIZE);


while (1) {

    //cap.set(CV_CAP_PROP_FRAME_WIDTH, fwid);
    //cap.set(CV_CAP_PROP_FRAME_HEIGHT, fhei);

    cap.read(frame);

    /**
    if (!cap.read(frame)) // Check end of the video file
        cerr << "Can't read frame";
        break; **/

    // Show current frame on window
    cv::imshow("Video1", frame);

    waitKey(1000/fps);

}

return 0;

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-09-29 04:54:58 -0600

sls2 gravatar image

This was resolved by removing all components and re-installing again. Sadly I don't know what was different between this final install that worked and the previous ones that didn't so can't provide any useful update here.

edit flag offensive delete link more

Comments

Good too see you got it solved. Too bad you don't know how. Keep up the good work. Do accept your own answer as a solution so it shows solved in search results.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-29 05:58:28 -0600 )edit

Question Tools

Stats

Asked: 2014-09-26 07:38:07 -0600

Seen: 356 times

Last updated: Sep 29 '14