OpenCV错误:断言失败(_img.rows * _img.cols == vecSize)

问题描述 投票:1回答:1

我一直收到这个错误

OpenCV Error: Assertion failed (_img.rows * _img.cols == vecSize) in get, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp, line 157 terminate called after throwing an instance of 'cv::Exception' what(): /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp:157: error: (-215) _img.rows * _img.cols == vecSize in function get Aborted (core dumped)

当运行opencv_traincascade时。我运行这些论点:opencv_traincascade -data data -vec positives.vec -bg bg.txt -numPos 1600 -numNeg 800 -numStages 10 -w 20 -h 20


我的项目构建如下: workspace |__bg.txt |__data/ # where I plan to put cascade |__info/ |__ # all samples |__info.lst |__jersey5050.jpg |__neg/ |__ # neg images |__opencv/ |__positives.vec


在我跑opencv_createsamples -img jersey5050.jpg -bg bg.txt -info info/info.lst -maxxangle 0.5 - maxyangle 0.5 -maxzangle 0.5 -num 1800之前


不太清楚为什么我收到这个错误。图像也都转换为灰度。 neg的大小为100x100,jersey5050.jpg的大小为50x50。我看到有人在OpenCV论坛上有同样的错误,有人建议删除在OpenCV创建的备份.xml文件,以防培训被“中断”。我删除了那些,没有。请帮忙!我在mac上使用python 3。我也在带有2GB内存的digitalocean的ubuntu服务器上运行这些命令,但我不认为这是问题的一部分。

编辑忘了提及,在opencv_createsamples命令后,我然后运行opencv_createsamples -info info/info.lst -num 1800 -w 20 -h20 -vec positives.vec

python-3.x opencv cascade assertion
1个回答
0
投票

我解决了哈哈。即使我在命令中指定宽度和高度为20x20,它也将其更改为20x24。所以opencv_traincascade命令抛出错误。一旦我在opencv_traincascade命令中更改了width和height参数,它就可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.