bonjour
je débute sur opencv, et comme vous vous en doutez la première compilation ne se passe pas bien
Après le rituel d'installation
sudo apt-get install libopencv-dev
j'ai vérifié ce que cela donne
pour compiler
pkg-config opencv --cflags
-I/usr/include/opencv
pour linker
pkg-config opencv --libs
-lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_datasets -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_video -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_rgbd -lopencv_viz -lopencv_surface_matching -lopencv_text -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
l'affaire me semble bien engagée
voici un code d'essai pour voir ce que cela peut donner à partir des tutos officiels
#include <stdio.h>
#include <stdlib.h>
#include <cv.h> // contient les déclarations des structures et fonctions de manipulation d'images
#include <highgui.h> // contient déclarations des fonctions d'affichage des images
#define DEBUG
//#include <opencv/highgui.h>
//#include <highgui.h>
/* gcc opencv_ex02.o -o helloworld `pkg-config opencv --libs`
* * gcc -std=c11 -Wall -fmax-errors=10 -Wextra opencv_ex02.c -o opencv_ex02 `pkg-config --cflags --libs opencv `
*/
enum {
CV_LOAD_IMAGE_UNCHANGED =-1,
CV_LOAD_IMAGE_GRAYSCALE =0,
CV_LOAD_IMAGE_COLOR =1,
CV_LOAD_IMAGE_ANYDEPTH =2,
CV_LOAD_IMAGE_ANYCOLOR =4,
CV_LOAD_IMAGE_IGNORE_ORIENTATION =128
};
int main (int argc, char* argv[])
{
IplImage* img = NULL;
const char* window_title = "Hello, OpenCV!";
/* Vérification: au moins un argument doit être passé au programme.*/
if (argc < 2)
{
fprintf (stderr, "usage: %s IMAGE\n", argv[0]);
return EXIT_FAILURE;
}
CvArr * image;
cvShowImage("",image);
/* Chargement de l'image passée en argument */
img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
if (!img)
{
fprintf (stderr, "couldn't open image file: %s\n", argv[1]);
return EXIT_FAILURE;
}
/* Création d'une fenêtre intitulée "Hello, OpenCV!" */
cvNamedWindow (window_title, CV_WINDOW_AUTOSIZE);
/* Affichage de l'image */
cvShowImage (window_title, img);
/* Pause le temps que l'utilisateur appuie sur une touche */
cvWaitKey (0);
/* Destruction de la fenêtre */
cvDestroyAllWindows ();
/* Libération de la mémoire */
cvReleaseImage (&img);
return EXIT_SUCCESS;
}
compilation
gcc -std=c11 -Wall -fmax-errors=10 -Wextra opencv_ex02.c -o opencv_ex02 `pkg-config --cflags --libs opencv `
résultat de compilation
gcc -std=c11 -Wall -fmax-errors=10 -Wextra opencv_ex02.c -o opencv_ex02 `pkg-config --cflags --libs opencv `
opencv_ex02.c: In function ‘main’:
opencv_ex02.c:37:9: warning: implicit declaration of function ‘cvLoadImage’; did you mean ‘cvShowImage’? [-Wimplicit-function-declaration]
img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
^~~~~~~~~~~
cvShowImage
opencv_ex02.c:37:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
^
opencv_ex02.c:35:1: warning: ‘image’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cvShowImage("",image);
^~~~~~~~~~~~~~~~~~~~~
/tmp/ccB983qb.o : Dans la fonction « cvPointFrom32f » :
opencv_ex02.c:(.text+0x557) : référence indéfinie vers « cvRound »
opencv_ex02.c:(.text+0x56d) : référence indéfinie vers « cvRound »
/tmp/ccB983qb.o : Dans la fonction « cvReadInt » :
il y a des erreurs de compilation et de linkage...et un détail m'échappe...
Que se passe t-il d'après vous?