2015-06-26 21 views
3

我试图从该站点上运行OpenCV的性别分类的例子, http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html 当我尝试运行它给出了一个错误说法facerec_fisherfaces.cpp,为什么在预期的图像大小时会出现opencv错误?

OpenCV Error: Unsupported format or combination of formats (In the Fisherfaces method all input samples (training images) must be of equal size! Expected 40000 pixels, but was 0 pixels.) in train, file /home/kavin/opencv/opencv-2.4.10/modules/contrib/src/facerec.cpp, line 564 
terminate called after throwing an instance of 'cv::Exception' 
what(): /home/kavin/opencv/opencv- 2.4.10/modules/contrib/src/facerec.cpp:564: error: (-210) In the Fisherfaces method all input samples (training images) must be of equal size! Expected 40000 pixels, but was 0 pixels. in function train 

Aborted (core dumped) 

下面是一个CSV文件条目我有使用冷杉此程序:

/home/kavin/Desktop/actors_cropped/female/an1_200_200.jpg;0

我有50个这样的表项,在大小为200 * 200的那些位置存在的图像。我已经使用了与我发布的教程链接相同的代码facerec_fisherfaces.cpp。请帮忙。

回答

2

这是因为有一个空行,CSV文件,并编码必须是UTF-8

0

还有是包括在训练一个无效的图像。我通过从图像和标签列表中弹出图像来解决此问题。

c = 0 
for i in images: 
    try: 
     height, width = i.shape[:2] 
    except: 
     images.pop(c) 
     labels.pop(c) 
     print("An invalid Image has been detected...continuing") 
    c += 1 
相关问题