我正在使用 camshift 来跟踪网球,并在找到网球后在网球周围画一个椭圆。但是,我经常收到此错误
OpenCV Error: Assertion failed (box.size.width >= 0 && box.size.height >= 0 && thickness <= 255) in ellipse, file /home/eanders/src/OpenCV-2.4.2/modules/core/src/drawing.cpp, line 1678 terminate called after throwing an instance of 'cv::Exception'
what(): /home/eanders/src/OpenCV-2.4.2/modules/core/src/drawing.cpp:1678: error: (-215) box.size.width >= 0 && box.size.height >= 0 && thickness <= 255 in function ellipse
我假设 camshift 方法正在返回一个 RotatedRect 对象,该对象在某种程度上不是要在其中绘制的椭圆的正确尺寸。任何想法如何纠正这个问题?代码如下。提前谢谢各位。
Rect trackWindow = Rect(p1, box);
///employ camshift algorithm
RotatedRect trackBox = CamShift(backproj, trackWindow, TermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ));
ellipse( image, trackBox, Scalar(255,255,255), 3, CV_AA );
ellipse( backproj, trackBox, Scalar(255,255,255), 3, CV_AA );