为什么当图像符合预期时,我会收到关于图像大小的 opencv 错误?

Why am I getting an opencv error with size of images when they are as expected?

我正在尝试 运行 来自该站点的 opencv 性别分类示例, http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html 当我尝试 运行 时 facerec_fisherfaces.cpp 它给出了一个错误提示,

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 的位置。我使用了与我发布的教程 link 中相同的代码 facerec_fisherfaces.cpp。请帮忙

这是因为 csv 文件中有一个空行,而且编码必须是 UTF-8

训练中包含无效图像。我通过从图像和标签列表中弹出图像来解决这个问题。

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