2

new user here and fairly new to programming using OpenCV.

I am using Visual Studio 2012, and have installed all OpenCV modules as per instructions have no problem running code to capture video stream and filter/ etc.

I am trying to reproduce code for optical flow example produced by stanford U here: http://robots.stanford.edu/cs223b05/notes/CS%20223-B%20T1%20stavens_opencv_optical_flow.pdf

but seem to be getting an access violation error with cvQueryFrame, so I've written a simple function to test the issue:

   int get_flow(){
    CvCapture *input_video = cvCaptureFromFile("C:\\test.avi");
    cvQueryFrame(input_video);

    while(1){
    if( cvWaitKey( 15 )==32 )  //wait until space key pressed
        {
            break;
        }
    }

    return 0;
}

I've checked the the test.avi is in the correct location, but am getting the following error whenever any code (this or the example code) runs the cvQueryFrame command as follows:

First-chance exception at 0x75E6A048 (msvcrt.dll) in Win32Project3.exe: 0xC0000005: Access violation reading location 0x011908C0.
Unhandled exception at 0x75E6A048 (msvcrt.dll) in Win32Project3.exe: 0xC0000005: Access violation reading location 0x011908C0.

which from my understanding means that msvcrt.dll is issuing an error regarding accessing certain memory point, but I can't figure out what the problem is.

I have used cvGrabFrame by itself without an issue, but using cvGrabFrame and cvRetrieveFrame together or just cvRetrieveFrame by itself also throws a msvcrt.dll access error.

I am not too sure where to look for the error, or the problem all together. I could not find any particular solutions to dealing with this. any ideas? (PS - I am running VS2012 in debug mode and have all the opencv libraries working in x86 on a x64 machine, and chrome is open also)

thanks!

evzdfx
  • 33
  • 3

1 Answers1

0

May be you are not able to open video file. And because of that query frame is failing You can try following code to check if you are really able to open video file and then you can call query frame on it.

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

    char *my_file = "C:\\test.avi";
    std::cout<<"Video File "<<my_file<<std::endl;
    cv::VideoCapture input_video;

    if(input_video.open(my_file))
    {
         std::cout<<"Video file open "<<std::endl;
    }
    else
    {
        std::cout<<"Not able to Video file open "<<std::endl;

    }
    namedWindow("My_Win",1);
    namedWindow("Segemented", 1);
    Mat cap_img;
    for(;;)
    {
         input_video >> cap_img;
         imshow("My_Win", cap_img);
          waitKey(0);
    }
   return 0;
 }
praks411
  • 1,972
  • 16
  • 23
  • 1
    Tried that, prints that video file is open, but getting the same error on " input_video >> cap_img;" with the call stack going through HighGui - > ffmpeg -> msvcrt.dll -> ntdll.dll with a call stack message saying "Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll". I fear that this problem may be a system install problem pertaining to various c++ components installed on the pc. Though grabbing frames using ">>" works for webcams, and test.avi plays fine by itself. – evzdfx May 01 '13 at 17:36
  • Yes it could be, you can also check your openCV version if it is the latest one. Also you can try installing Haali media splitter. I've it on my system. But I'm not sure if it is required or not. – praks411 May 01 '13 at 18:40
  • So i've tried again on a different computer, W7 with VS2012 Ultimate, and same error, maybe I installed the opencv incorrectly? I used the 'express' method by using pre-complied libraries, and then added them in VS2012, but other features and live camera image recovery works perfectly. – evzdfx May 01 '13 at 20:51
  • Are you using opencv from this link for windows. http://opencv.org/downloads.html. I'm using OpenCV2_4_3 on windows 7 32bits VS2012 and it is working perfectly from me. This is strange. I hope you are using correct version for both 32bits and 64bits. If nothing work then compile opencv on you machine and use those libs instead of precompiled ones. – praks411 May 01 '13 at 23:33
  • Ok So after hours of pain and a sliver of a thought to swap out the avi, I swapped it, and everything works! it was an error with the original avi fail, even though it passed the NULL check :@ stupid. stupid. oh well, Thank you for all the help! sorry to waste your time on such stupid things! – evzdfx May 02 '13 at 03:09
  • So just an update, everything seems to work, but I find the root error in the call stack comes from ntdll.dll, which fails whenever I pass an image or frame to be processed by external cv functions, for example, when I initialize NULL images and import a real image, and use cvGoodFeaturestoTrack, I get ntdll.dll error, maybe it can't access a 0 value? – evzdfx May 03 '13 at 15:30