尝试使用OpenCV_createsamples时发生OpenCV错误

2024-06-01 00:20:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着训练一个级联来检测人脸。我有31张带有人脸的图片,我使用opencv_annotation工具生成了-info-文件。该文件如下所示:

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


Tags: 文件工具nametxt图片opencvcondamax