bnj,
j'ai compiler mon programme pour l'acquisition d'un video a partir de webcam en utilisant opencv sous QT sous Ubuntu 12.04 voila mon code:
et voila les lignes de fichier .pro
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 #include <opencv/cv.h> #include <opencv/highgui.h> using namespace std; using namespace cv; // initialize global variables int g_slider_position = 0; // trackbar position CvCapture* g_capture = NULL; // structure to create a video input // routine to be called when user moves a trackbar slider void onTrackbarSlide(int pos) { cvSetCaptureProperty( g_capture, CV_CAP_PROP_POS_FRAMES, pos ); } int main( int argc, char** argv ) { // create a window with appropriate size. Windows name is determined by file name // supplied as an argument cvNamedWindow( argv[1], CV_WINDOW_AUTOSIZE ); // open video g_capture = cvCreateFileCapture( argv[1] ); // set read position in units of frames and retrieve total number of frames int frames = (int) cvGetCaptureProperty( g_capture, CV_CAP_PROP_FRAME_COUNT ); // do not create treackbar if video does not include an information // about number of frames if( frames!=0 ) { cvCreateTrackbar( "Position", argv[1], &g_slider_position, frames, onTrackbarSlide ); } // display video frame by frame IplImage* frame; while(1) { frame = cvQueryFrame( g_capture ); if( !frame ) break; cvShowImage( argv[1], frame ); // set trackbar to a current frame position cvSetTrackbarPos("Position", argv[1], g_slider_position); g_slider_position++; char c = cvWaitKey(33); // quit if ESC is pressed if( c == 27 ) break; } // free memory cvReleaseCapture( &g_capture ); cvDestroyWindow( argv[1] ); return(0); }
lorsque je compile, je trouve 22 erreurs . voila:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 TEMPLATE = app CONFIG += console CONFIG -= qt SOURCES += \webcam.cpp INCLUDEPATH += /usr/local/include/ LIBS += -L/usr/local/lib\ -lopencv_core \ -lopencv_imgproc \ -lopencv_highgui \ -lopencv_ml \ -lopencv_video \ -lopencv_features2d \ -lopencv_calib3d \ -lopencv_objdetect \ -lopencv_contrib \ -lopencv_legacy \ -lopencv_flann
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 16:48:12: Exécution des étapes de compilation pour le projet exemple1... 16:48:12: Configuration inchangée, étape QMake sautée. 16:48:12: Débute : "/usr/bin/make" -w make: Entering directory `/home/rafik/traitement_image_opencv/exemple1' /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -o Makefile exemple1.pro WARNING: /home/rafik/traitement_image_opencv/exemple1/exemple1.pro:5: Unescaped backslashes are deprecated. WARNING: Failure to find: \webcam.cpp make: Leaving directory `/home/rafik/traitement_image_opencv/exemple1' make: Entering directory `/home/rafik/traitement_image_opencv/exemple1' g++ -Wl,-O1 -o exemple1 webcam.o -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_finalize@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_make_smpte_tc_string@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_make_string@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_realloc_f@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_get_smpte_from_framenum@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_timecode_init@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_samples_set_silence@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_calloc@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_get_media_type_string@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_dynarray_add@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_init@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_asprintf@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_make_mpeg_tc_string@LIBAVUTIL_51' /usr/local/lib/libavformat.so.54: undefined reference to `av_rescale_q_rnd@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprintf@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_samples_copy@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_get_default_channel_layout@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_init_from_string@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_bprint_chars@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_timecode_adjust_ntsc_framenum@LIBAVUTIL_51' /usr/local/lib/libavcodec.so.54: undefined reference to `av_tempfile@LIBAVUTIL_51' make: Leaving directory `/home/rafik/traitement_image_opencv/exemple1' collect2: ld returned 1 exit status make: *** [exemple1] Error 1 16:48:12: Le processus "/usr/bin/make" s'est terminé avec le code 2. Erreur à la compilation du projet exemple1 (cible : Desktop) Lors de l'exécution de l'étape "Make"
merci de m'aider c'est la premiere fois que j'utilse opencv.
Note: j'ai installer opencv sous /usr/local
Partager