簡體   English   中英

OpenCV從camshift算法輸出中繪制一個橢圓。

[英]OpenCV drawing an ellipse from the camshift algorithm output.

我使用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 );

在我看來,算法似乎無法跟蹤對象。 知道為什么會很棒,但是現在我將檢查旋轉矩形的尺寸。 這顯然是斷言所抱怨的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM