IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Imagerie Discussion :

integration d'opencv dans QT sous ubuntu.


Sujet :

Imagerie

  1. #1
    jean_pierr
    Invité(e)
    Par défaut integration d'opencv dans QT sous ubuntu.
    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:
    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);
    }
    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
    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
    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
    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

  2. #2
    jean_pierr
    Invité(e)
    Par défaut
    ok, j'ai trouve moi meme la solution. Je veux bien le publier.
    il faut ajouter dans le fichier .pro les lignes suivantes et verifier bien tous les packages sont bien installees.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    INCLUDEPATH += /usr/local/include/opencv
    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\
    -lavutil

  3. #3
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Le sujet date de quelques mois mais il m'a bien dépanné. Merci !

Discussions similaires

  1. [Lazarus] Assembleur dans Lazarus sous Ubuntu
    Par pedestre dans le forum Lazarus
    Réponses: 1
    Dernier message: 30/01/2014, 20h59
  2. [Ubuntu] Compilation d'OpenCV avec Qt
    Par jean_pierr dans le forum OpenCV
    Réponses: 0
    Dernier message: 22/08/2012, 05h14
  3. Réponses: 1
    Dernier message: 03/04/2012, 15h16
  4. Pb d'affichage du projet eclipse dans tomcat6 sous ubuntu
    Par tansym dans le forum Tomcat et TomEE
    Réponses: 5
    Dernier message: 26/01/2011, 08h48
  5. erreur integration via swfobject dans form sous ie7
    Par snopims_ dans le forum Flash
    Réponses: 1
    Dernier message: 16/01/2008, 06h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo