2014-02-26 59 views
0

我想要做面部检测,为此我创建了我自己的XML文件。我有两个文件夹 - 一个用于存储正片图像,另一个用于存储负片图像。我正在创建名为positive.txt和negative.txt的描述文件。 positive.txt文件共包含2676张图片,negative.txt共包含581张图片。现在我想使用以下命令创建positive.txt的vec文件:为什么积极的文本文件不会创建样本

opencv_createsamples -info positive.txt -vec vefile.vec -num 2676 -w 24 -h 24

但是,我收到一个错误。下面是输出:

Info file name: positive.txt 
Img file name: (NULL) 
Vec file name: vefile.vec 
BG file name: (NULL) 
Num: 2676 
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: 24 
Height: 24 
Create training samples from images collection... 

OpenCV Error: Assertion failed (rect.width >= 0 && rect.height >= 0 && rect.x <  image->width && rect.y < image->height && rect.x + rect.width >= (int)(rect.width > 0) && rect.y + rect.height >= (int)(rect.height > 0)) in cvSetImageROI, file /home/arya/stuff/opencv/opencv-2.4.7/modules/core/src/array.cpp, line 3006 
terminate called after throwing an instance of 'cv::Exception' 
    what(): /home/arya/stuff/opencv/opencv-2.4.7/modules/core/src/array.cpp:3006: error: (-215) rect.width >= 0 && rect.height >= 0 && rect.x < image->width && rect.y < image->height && rect.x + rect.width >= (int)(rect.width > 0) && rect.y + rect.height >= (int)(rect.height > 0) in function cvSetImageROI 

Aborted (core dumped) 

下面是其中positive.txt包含有关2676倍的图像信息的几个例子:

/home/arya/myown/Positive/Pictures1102.jpeg 2 414 271 40 51 547 289 37 52 
/home/arya/myown/Positive/images460.jpeg 1 108 21 93 127 
/home/arya/myown/Positive/Pictures1131.jpeg 3 298 418 62 81 443 316 42 52 656 346 50 52 
/home/arya/myown/Positive/face294.jpeg 1 189 84 45 57 
/home/arya/myown/Positive/images129.jpeg 1 115 22 84 112 
/home/arya/myown/Positive/images724.jpeg 1 128 19 89 106 
/home/arya/myown/Positive/Pictures489.jpeg 1 237 418 49 75 
/home/arya/myown/Positive/images90.jpeg 1 106 19 93 116 
/home/arya/myown/Positive/Pictures1246.jpeg 1 964 117 131 153 
/home/arya/myown/Positive/face922.jpeg 2 218 175 74 74 274 155 0 0 

这可能是导致上述错误?

回答

0

当设置图像的ROI时会发生此错误。创建示例实用程序从txt文件中获取对象位置,并按给定的位置矩形设置ROI。例如:

(414 271 40 51) 

是一个边界矩形,前两个整数是位置,后两个是矩形的宽度和高度。如果这个矩形不适合提供的图像,它会给出这个断言错误。所以有可能是错误的:

1.提供的矩形可能不会按照相应的顺序给出。

2.提供的矩形可能不属于给定的图片。

相关问题