vlsift 的运行时错误:输入图像包含格式错误的 PGM header

runtime error of vlsift: input image contains a malformed PGM header

我正在尝试通过 src 文件夹中的 运行ning sift.c 文件来测试 vlfeat 计算机视觉库的筛选检测器。我已经成功地编译了 运行 程序。但是,我收到错误:输入图像包含格式错误的 PGM header。 我确定这不是图像的问题文件输入。谁能解释一下。

这对应于VL_ERR_PGM_INV_HEAD error code which is issued by the PGM decoder if the file is less than 2 bytes or has a not supported or invalid magic number.

请注意,vlfeat 仅支持 P2 (ASCII) 和 P5(二进制)格式。所以你应该检查你的魔法来控制它是否符合这些要求,例如:

$ xxd -c 1 -l 2 foo.pgm
0000000: 50  P
0000001: 35  5

$ xxd -c 1 -l 2 bar.pbm
0000000: 50  P
0000001: 34  4

此处 foo.pgm 有效(二进制格式的灰度图),但 vlfeat(二进制格式的黑白位图)不支持 bar.pbm