Why am I getting opencv error with image size when expected?

I tried to run the opencv gender classification example from this site, http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html When I try to run the facerec_fisherfaces.cpp file it gives an error:

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)

      

Below is the csv file entry. I used this program:

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

I have 50 of these posts and images in these 200 * 200 locations. I used the same facerec_fisherfaces.cpp code as in the link I posted. Please, help.

+3


source to share


2 answers


This was because there was an empty string in the csv file and also the encoding had to be UTF-8



+2


source


There is an invalid image in the training. I solved this by putting an image from a list of images and labels.



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

      

0


source







All Articles