cvBoundingRect not working
cvBoundingRect not working
我正在传递cvFindContours即轮廓到cvBoundingRect的输出。但是它给出了这个错误:
OpenCV错误:cvBoundingRect中的坏参数(不支持的序列类型),文件/home/z/src/OpenCV-2.4.2/modules/imgproc/src/shapedescr.cpp, 950行抛出'cv::Exception'实例后调用终止什么():/home/z/src/opencv -2.4.2/modules/imgproc/src/shapedescr.cpp:950:错误:(-5)函数cvBoundingRect中不支持的序列类型
代码如下:
CvRect rect;
cvFindContours( imgB, g_storage, &contours,sizeof(CvContour),CV_RETR_LIST, CV_CHAIN_CODE,cvPoint(0,0));
if(contours)
{cvDrawContours(img_B,contours, CV_RGB(250,0,0), CV_RGB(0,0,250),1,2,8);
rect=cvBoundingRect(contours);
}
请告诉我这个错误的原因。解决方案是什么?由于
cvBoundingRect()取1个轮廓,您将把它们全部馈送到它
从berak离开的地方开始,CvSeq** first_contour是你提供的函数。
指针first_contour由函数填充。它将包含指向第一个最外层轮廓的指针,如果没有轮廓,则为NULL检测到(如果图像是完全黑的)。其他轮廓可能是通过h_next和v_next链接从first_contour到达。
所以你需要这样写:
CvSeq* contour = *contours;
while (contour != NULL)
{
//insert boundingbox and other code
contour = contour->h_next;
}
好了,我找到答案了。下面是正确的方法:
http://singhgaganpreet.com/tag/cvboundingrect-example/相关文章:
- GDB - strcmp not working: __strcmp_sse2_unaligned
- QT qScriptConnect is not working
- QDesktopServices::openUrl() not working Qt
- "Configure: Error: Could Not Find a Working Compiler, See config.log For Details"
- C++ std::set ordering not working with customer class*
- C++ SetWindowText not working
- visual studio 2012 c++ hello world - iostream not working
- getGravity not working?
- Opencv findcontours CV_RETR_EXTERNAL not working
- c++ srand() not working
- std::queue::empty() not working?
- BCB swprintf not working
- 将类型作为指向另一个类的对象的指针的泛型类-NOT WORKING
- LoadLibrary is not working
- gluUnProject not working
- C++ catch bad_alloc not working
- updatelayeredwindow not working
- OpenMP set_num_threads() is not working
- glOrtho not working
- Cuda atomicInc not working