python - 尝试使用 opencv_createsamples 时出现 OpenCV 错误
问题描述
我正在尝试训练级联来检测人脸。我有 31 张带有面孔的图片,并且我使用opencv_annotation
了工具来生成-info
-file。该文件如下所示:
1 positiveImages/0.jpg 1 546 289 70 96
2 positiveImages/1.jpg 1 542 325 105 106
3 positiveImages/10.jpg 1 98 289 138 119
4 positiveImages/11.jpg 1 284 303 204 189
5 positiveImages/12.jpg 3 415 279 70 97 484 320 75 87 624 374 76 132
...
在此之后,我尝试使用该opencv_createsamples
工具生成.vec
用于训练级联的文件。这是我使用的命令:
opencv_createsamples -info file.txt -bg negatives.txt -vec cropped.vec -num 1920 -w 48 -h 48
这给了我以下带有错误的输出:
Info file name: file.txt
Img file name: (NULL)
Vec file name: cropped.vec
BG file name: negatives.txt
Num: 1920
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 48
Height: 48
Create training samples from images collection...
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp, line 3229
terminate called after throwing an instance of 'cv::Exception'
what(): /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp:3229: error: (-215) ssize.area() > 0 in function resize
Aborted (core dumped)
据我了解,这个错误是想告诉我没有图像,对吗?我想知道为什么会这样。file.txt
似乎没问题,它有正确的图像路径等。任何建议将不胜感激。
编辑。想知道是否有更好的方法来训练级联,例如用几千张人脸图片和几千张没有人脸的图片而不使用注释工具?如果正图像被裁剪成只包含人脸,我可以以某种方式只使用这两个文件夹进行训练吗?
编辑。我的文件夹结构是这样的:
/negativeImages
/positiveImages
file.txt
negatives.txt
我是opencv_createsamples
从根开始的。
解决方案
推荐阅读
- django - 404 - 在 Azure Web 服务中部署 Django 和 Vue js 集成项目时,静态文件找不到文件错误
- c - 在C中的链表中搜索值
- airflow - 如何在非气流运算符 python 函数中访问 Xcom 值
- r - 当轴标题中有上标时,如何调整绘图区域以使其与其他图形相等?
- netlogo - 连接一定半径内的海龟
- android - 通话时开启扬声器,Android 10及以上版本无法使用
- angular - 如何在角度 10 中使用异步管道检索数据后执行一些操作
- xamarin.forms - 如何在以 Xamarin 形式流式传输 rtsp 时拍摄快照
- ubuntu - 如何从 systemd 服务从同一台 Ubuntu 机器启动新的 XSession
- ruby - rspec:如何期望该页面具有所需的 html