2012-07-15 10 views
5

Ich habe gerade angefangen zu versuchen, mit OpenCV zu spielen, und ich schrieb ein kleines Programm aus einem Buch, das ziemlich einfach ist. Das Problem ist, wenn ich versuche, es zu kompilieren, bekomme ich diesen Fehler. Ich werde dir alle Informationen geben, die ich habe. Ich habe openCV mit Homebrew für Mac OS X 10.7 installiert.Fehler in OpenCV 2.4.2 "OpenCV Fehler: Schlechte Flagge"

#include <opencv2/core/core.hpp> 
#include <opencv2/highgui/highgui.hpp> 

int main(int argc, char *argv[]) 
{ 
cv::Mat image = cv::imread("usf.gif"); 
cv::namedWindow("My Image"); 
cv::imshow("My Image", image); 
cv::waitKey(5000); 

return 1; 
} 

ich diese kompiliert gefallen:

g++ -o test opencvtest.cc -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy 

Und das ist, was ich zurück bekam, wenn ich es zu laufen versucht.

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/homebrew-opencv-2.4.2-oQmu/OpenCV-2.4.2/modules/core/src/array.cpp, line 2482 
terminate called throwing an exceptionAbort trap: 6 

Danke nochmal.

+1

try Laden ein beliebiges anderes Bild wie jpg oder png unterstützt und prüfen, ob gleiche Fehler kommt. –

+0

Das hat perfekt funktioniert. Aber ich werde diese Frage aufgeben, hoffentlich kann jemand beantworten, warum es nicht mit Gifs funktioniert. Wissen ist Macht. – Red

+0

Sie können die Dokumentation der 'imread'-Funktion lesen, um die unterstützten Formate zu kennen. –

Antwort

9

Das ist, weil OpenCV nicht gif unterstützt:

The function imread loads an image from the specified file and returns it. If the image can not be read (because of missing file, improper permissions, unsupported or invalid format), the function returns empty matrix (Mat::data==NULL).Currently, the following file formats are supported:

Windows bitmaps - *.bmp, *.dib (always supported)

JPEG files - *.jpeg, *.jpg, *.jpe (see Note2)

JPEG 2000 files - *.jp2 (see Note2)

Portable Network Graphics - *.png (see Note2)

Portable image format - *.pbm, *.pgm, *.ppm (always supported)

Sun rasters - *.sr, *.ras (always supported)

TIFF files - *.tiff, *.tif (see Note2)

Siehe docs.

2

Ich denke, die „gifs“ nicht