简体   繁体   中英

OpenCV+Visual Studio 2008 - Program runs fine in debug but access violation in regular execution

I'm working on a computer vision program at the moment with OpenCV in C++. It seems to work 100% fine with a live feed from a webcam but when I tried to feed in a stream from an avi file it started crashing with an "Access Violation" error. I can't see why this would be the case because the only difference between the two is the initial frame-grabbing- the image processing is the same afterwards.

I'm developing in VS2008. The curious thing is that when I place a breakpoint in my main() and debug (F5) the program runs fine. However, when I Start Without Debugging (Ctrl+F5) I get the error.

Has anybody encountered a similar problem or would anyone know why my program would appear to work fine when debugging but not in normal execution?

Nothing specific about OpenCV, but the fact that it behaves differently with a different source stream, and in or out of the debugger, makes me think it is a timing issue. You could try attachng the debugger after the crash happens maybe.

I would suspect uninitialized variables. Many debuggers initialize all variables, including those that are not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM