Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenCV从camshift算法输出绘制椭圆。_C++_Opencv - Fatal编程技术网

C++ OpenCV从camshift算法输出绘制椭圆。

C++ OpenCV从camshift算法输出绘制椭圆。,c++,opencv,C++,Opencv,我正在使用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/dra

我正在使用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

在我看来,算法似乎无法跟踪目标。 知道原因会很好,但现在我要检查旋转矩形的尺寸。
这显然是断言所抱怨的。

是的,这是可能的。我决定最简单的方法就是把椭圆倒出来,在旋转体的中心坐标上画一个小圆,因为我对这个中心点最感兴趣。谢谢你的回答。旋转电极的位置有用吗?我猜,该算法无法跟踪对象,因此返回一个默认的Rect(维数为0x0,位置可能为0,0)。因此,您可能会在错误的位置绘制这些点……是的,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 );