2015-06-26 20 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 
相關問題