Access violation when opening OpenCV VideoCapture (release only)

asked 2015-10-04 12:41:37 -0600

TyN101 gravatar image

I have an application written in visual studio, utilizing OpenCV 2.4.10. The program executes flawlessly in debug mode, but in release mode it crashes on the first command following a VideoCapture::open() call, regardless of whether the call was completed in the constructor or with the method call. I recognize that this is a pretty common occurrence, and that a dll linkage may be the issue, but have been unable to fully identify the problem. Any assistance is greatly appreciated.

Here is the error message:

Unhandled exception at 0x03DE7D43 (opencv_ffmpeg2410.dll) in OpenCVLaserDot.exe: 0xC0000005: Access violation reading location 0x00000000.

Here is the segment of code surrounding the VideoCapture instantiation:

const string DEFAULT_INPUT_FILE = "C:/Users/Tyler/Documents/Visual Studio 2013/Projects/OpenCVLaserDot/Release/a.avi";

VideoCapture cap; 
if (inputFile == "1" || inputFile == ""){
    cap.open(DEFAULT_INPUT_FILE);
} else {
    cap.open(inputFile);
}
if (!cap.isOpened()){ 
    printf("Failed to open video\n");
    return -1; 
}
edit retag flag offensive close merge delete

Comments

1

Isn't it because you have not linked the relesed dlls (opencv_ffmpeg2410.dll release and opencv_ffmpeg2410d.dll debug)?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-10-05 03:00:34 -0600 )edit
1

I know it is probably not the case but

  • OpenCV 2.4.10 imho, drop it, its deprecated and there is a newer stable version 2.4.11. This ensures that you do not get stuck at old problems.
  • Like said above, make sure you link the released dlls/so files when building in release.
  • However the error is suggesting that it doesn't succeed in opening the camera. Is the printf reached or not?
StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-05 06:11:57 -0600 )edit