Ask Your Question
0

No error line number in OpenCV?

asked 2014-09-05 12:52:18 -0500

vc++ gravatar image

I am a starter for OpenCV. I installed my OpenCV on mac and it succeed. However, whenever I run the program and the program failed, it cannot give which line I am wrong but only output wrong information in OpenCV. For example, I wrote a long program and when running it, it gives the following result but I don't know which line it is(suppose my file is main.cpp)

OpenCV Error: Assertion failed (s >= 0) in setSize, 
file /Users/home/Documents/tools/opencv-2.4.9/modules/core/src/matrix.cpp, line 116
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: 
/Users/home/Documents/tools/opencv-2.4.9/modules/core/src/matrix.cpp:116: error: (-215) s >= 0 in    
function setSize

so I really don't know where is the problem. I compiled my files using following commands:

g++ -Wall -std=c++11 -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_imgproc -o main main.cpp
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-05 14:43:23 -0500

Guanta gravatar image

Add the option -g to the g++ command (g++ -g -Wall ...), it will add the debug-information.

edit flag offensive delete link more

Comments

Hi, I did as you told, but it seems it didn't work. The only error information it gives are errors within OpenCV source file. It still didn't give me which line goes wrong in my main function. It could be really difficult since I either guess which line wrong or by printing each line. This is not convenient at all. Is it a bug of OpenCV?

vc++ gravatar imagevc++ ( 2014-09-11 14:56:22 -0500 )edit

No, definitely not a bug from OpenCV! Maybe the stack is just noch long enough, try to use valgrind or gdb for easier debugging, i.e. compile your code with -g than run gdb, in gdb you call run main , then this will run until the assertion comes, then you call bt (which stands for backtrace) and you probably find the position in your main.

Guanta gravatar imageGuanta ( 2014-09-22 04:46:05 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-09-05 12:52:18 -0500

Seen: 379 times

Last updated: Sep 05 '14