Ask Your Question

timpattinson's profile - activity

2014-01-16 20:09:43 -0600 asked a question Mat::operator() throwing exception

I have this code, to take a quadrant of the image. In the documentation for cv::Rect it says that rect.x and rect.y refer to the upper left corner, however that seems not to be the case. I'm using VS2012 and opencv version 2.4.6

_declspec(dllexport) video::video_error_t video::subsectionFilter::ProcessFrame(Mat &frame)
{
    Mat subsct;
    if(bQuadrant){
        switch(iQuadrant)
        {
            case topright:
                roi.x = frame.cols/2;
                roi.y =frame.rows;
                break;
            case topleft:
                roi.x = 0;
                roi.y = frame.rows;
                break;
            case bottomleft:
                roi.x = 0;
                roi.y = frame.rows/2;
                break;
            case bottomright:
                roi.x = frame.cols/2;
                roi.y = frame.rows/2;
                break;
        }
        roi.width=frame.cols/2;
        roi.height=frame.rows/2;
    }
    subsct = frame(roi);
    frame = subsct;
    return success;
}
2014-01-15 22:38:10 -0600 received badge  Editor (source)
2014-01-15 22:29:35 -0600 asked a question VideoCapture from file not opening.

I've written this in C++ (VS2012) using OpenCV 2.4.6

#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>    
int main(){
    Mat image;
    VideoCapture cap;
    cap.open("test.avi");
    if(!cap.isOpened()){
        cout<< "Capture not open \n";
        cin.get();
    }
    cvNamedWindow("Video Output");
    while(1){
        cap >> image;
        imshow("Video Output",image);
        waitKey(30);
    }
}

Running it, the video capture fails to open (isOpened() returns false) test.avi is located in the same directory as the exectuable, and running it in Debug/Release/outside the IDE makes no difference. I've also tested it using the video files provided here: http://docs.opencv.org/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.html#videoinputpsnrmssim I'm using VS2012 on Windows 8.1 x64 and compiling for Release x64

What could I be doing wrong?

EDIT: As seen in other questions, I've copied the opencv_ffmpeg DLL to the folder with my executable. Now it only works outside the IDE (VS2012)