gnebehay/OpenTLD — pull request #11 by Stonelinks (2012-03-22 22:47:01+00:00)
Title: Manual Bounding Box Selection

Hello Georg,

This is a fix for a very minor bug that really had me confused for awhile. When manually selecting a bounding box, unless you draw it from top left to bottom right, the program was crashing with an error message similar to below:

ld@void:~/OpenTLD/build/bin$ ./tld
Starting at 21 473 -15 -15
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/ld/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 303

terminate called after throwing an instance of 'cv::Exception'
what(): /home/ld/OpenCV-2.3.1/modules/core/src/matrix.cpp:303: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat

Aborted

The fix for it is really simple, just testing for negative values in the bounding box and adjusting them as necessary.

OpenTLD is extremely impressive! Thanks for porting it to C++!