OpenCV Error : Incorrect size of input array ( Non - positive width or height ) in cvCreateMatHeader , file / build / buildd / opencv - 2.1 . 0 / src / cxcore / cxarray . cpp , line 113terminate called after throwing an instance of 'cv::Exception'what (): / build / buildd / opencv - 2.1 . 0 / src / cxcore / cxarray . cpp : 113 : error : (- 201 ) Non - positive width or height in function cvCreateMatHeader
Looks like someone has already created a bug report and found some fixes for this:源出处:http://opencv-users.1802565.n2.nabble.com/cvExtractSurf-fails-with-Non-positive-width-or-height-exception-opencv-2-1-0-td4963615.html
Hello,
I use opencv 2.1.0-1 on archlinux (i386). I'm not sure if I don't
correctly use the API, if it is an archlinux package problem of if it
is a opencv bug. Thank you for your help
This is the output of my program:
./a.out
Filesize: 13x29
OpenCV Error: Incorrect size of input array (Non-positive width or
height) in cvCreateMatHeader, file
/build/src/OpenCV-2.1.0/src/cxcore/cxarray.cpp, line 113
terminate called after throwing an instance of 'cv::Exception'
what(): /build/src/OpenCV-2.1.0/src/cxcore/cxarray.cpp:113: error:
(-201) Non-positive width or height in function cvCreateMatHeader
Aborted
And here is the source code:
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
int main(int argc, char** argv)
{
IplImage* image = cvLoadImage( "image.png", CV_LOAD_IMAGE_GRAYSCALE );
if( !image )
{
fprintf( stderr, "Can not load image.png ");
exit(-1);
}
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
CvSURFParams params = cvSURFParams(500, 1);
CvSize s = cvGetSize(image);
printf("Filesize: %dx%d\n", s.width, s.height);
cvExtractSURF( image, 0, &imageKeypoints, &imageDescriptors,
storage, params );
printf("Object Descriptors: %d\n", imageDescriptors->total);
return 0;
}
I am having the same problem with both OpenCV 2.0.0 and 2.1.0 in Visual Studio 2008. Debug/release libraries were built from source. I compiled the sample code found in opencv/sample/c/find_obj.cpp and it works great with the images provided, but when I supply my own images I get mixed results. When I input a white image (i.e. no features can be extracted) it produces this error. When I input an image composed of noise it works great. I ran the VS debugger and the call stack shows:
cxcore200.dll!cv::error(const cv::Exception & exc={...}) Line 194 +
cxcore200.dll!cv::flann::Index::knnSearch(const cv::Mat & queries={...}, cv::Mat & indices={...}, cv::Mat & dists={...}, int knn=2, const cv::flann::SearchParams & searchParams={...}) Line 135 +
Project.exe!flannFindPairs(const CvSeq * __formal=0x00401b1a, const CvSeq * objectDescriptors=0x00cf57d0, const CvSeq * __formal=0x00401b1a, const CvSeq * imageDescriptors=0x00cfb2e8, std::vector<int,std::allocator<int> > & ptpairs=[...]())
Project.exe!locatePlanarObject(const CvSeq * objectKeypoints=, const CvSeq * objectDescriptors=, const CvSeq * imageKeypoints=, const CvSeq * imageDescriptors=, const CvPoint * src_corners=, CvPoint * dst_corners=) Line 170
So I'm guessing it's something in cv::flann::Index::knnSearch(...)
As an alternative OpenSURF seems to work (it works well with a webcam image source). http://www.chrisevansdev.com/computer-vision-opensurf.html
-Paul Filitchkin
Looks like someone has already created a bug report and found some fixes for this :
https://code.ros.org/trac/opencv/ticket/68
- Paul Filitchkin
在使用OpenCV 2.1.0版本时,遇到cvExtractSurf函数抛出'Non-positive width or height'异常。详细探讨了该异常产生的原因及可能的解决方案,帮助开发者解决图像处理过程中的问题。
5850

被折叠的 条评论
为什么被折叠?



