2012-07-15 13 views
5

Empecé a intentar jugar con OpenCV y escribí un pequeño programa de un libro que es bastante simple. El problema es cuando intento compilarlo, obtengo este error. Te daré toda la información que tengo. Instalé openCV usando homebrew para Mac OS X 10.7.Error en OpenCV 2.4.2 "Error de OpenCV: indicador incorrecto"

#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; 
} 

Me gustó mucho este compilado:

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 

y esto es lo que me dieron la espalda cuando trataba de ejecutarlo.

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 

Gracias de nuevo.

+1

intente cargar cualquier otra imagen como jpg o png y compruebe si se produce el mismo error. –

+0

Eso funcionó perfectamente. Pero dejaré esta pregunta con suerte para que alguien pueda responder por qué no funciona con los gifs. El conocimiento es poder. – Red

+0

Puede leer los documentos de la función 'imread' para conocer los formatos admitidos. –

Respuesta

9

Eso es porque OpenCV no soporta gif:

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)

Ver docs.

2

Creo que los "gifs" no son compatibles

Cuestiones relacionadas