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

OpenCV Discussion :

pb compilation /lib opencv 2.4.5


Sujet :

OpenCV

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    378
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 378
    Points : 94
    Points
    94
    Par défaut pb compilation /lib opencv 2.4.5
    Bonjour,

    je suis sous ubuntu et je tente d'installer opencv mais là je tombe sur un pb de lib.

    la compilation en ligne de commande d'opencv depuis les sources s'est bien passée mais dans /usr/local/lib j'ai ces lib
    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
     
    libopencv_core.so              libopencv_objdetect.so.2.4.5
    libopencv_core.so.2.4          libopencv_photo.so
    libopencv_core.so.2.4.5        libopencv_photo.so.2.4
    libopencv_features2d.so        libopencv_photo.so.2.4.5
    libopencv_features2d.so.2.4    libopencv_stitching.so
    libopencv_features2d.so.2.4.5  libopencv_stitching.so.2.4
    libopencv_flann.so             libopencv_stitching.so.2.4.5
    libopencv_flann.so.2.4         libopencv_superres.so
    libopencv_flann.so.2.4.5       libopencv_superres.so.2.4
    libopencv_gpu.so               libopencv_superres.so.2.4.5
    libopencv_gpu.so.2.4           libopencv_ts.so
    libopencv_gpu.so.2.4.5         libopencv_ts.so.2.4
    libopencv_highgui.so           libopencv_ts.so.2.4.5
    libopencv_highgui.so.2.4       libopencv_video.so
    libopencv_highgui.so.2.4.5     libopencv_video.so.2.4
    libopencv_imgproc.so           libopencv_video.so.2.4.5
    libopencv_imgproc.so.2.4       libopencv_videostab.so
    libopencv_imgproc.so.2.4.5     libopencv_videostab.so.2.4
    libopencv_legacy.so            libopencv_videostab.so.2.4.5
    libopencv_legacy.so.2.4        pkgconfig
    libopencv_legacy.so.2.4.5      python2.7
    libopencv_ml.so                python3.2
    libopencv_ml.so.2.4

    J'ai modifié /etc/ld.so.conf de cette manière
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    include /etc/ld.so.conf.d/*.conf
    /usr/local/lib
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    sudo gedit /etc/bash.bashrc
    pour ajouter

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    export PKG_CONFIG_PATH
    puis redémarrer le poste mais lorsque j'essaye de faire

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    /usr/bin/ld -limgproc ou
    /usr/bin/ld -llibopencv_imgproc
    cela ne fonctionne pas il dit qu'il ne peut pas trouver
    donc je suis coincé pour la compilation de mes programmes dans l'IDE

    où est l'erreur

    merci

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    378
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 378
    Points : 94
    Points
    94
    Par défaut
    additif

    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
     
    **** Build of configuration Debug for project test ****
     
    make all 
    Building target: test
    Invoking: GCC C++ Linker
    g++ -L/usr/local/lib/ -o"test"  ./src/test.o   -llibopencv_calib3d -llibopencv_contrib -llibopencv_core -llibopencv_features2d -llibopencv_flann -llibopencv_gpu -llibopencv_highgui -llibopencv_imgproc -llibopencv_legacy -llibopencv_ml -llibopencv_nonfree -llibopencv_objdetect -llibopencv_photo -llibopencv_stiching -llibopencv_superres -llibopencv_ts -llibopencv_video -llibopencv_videostab -llibopencv_
    /usr/bin/ld: ne peut trouver -llibopencv_calib3d
    /usr/bin/ld: ne peut trouver -llibopencv_contrib
    /usr/bin/ld: ne peut trouver -llibopencv_core
    /usr/bin/ld: ne peut trouver -llibopencv_features2d
    /usr/bin/ld: ne peut trouver -llibopencv_flann
    /usr/bin/ld: ne peut trouver -llibopencv_gpu
    /usr/bin/ld: ne peut trouver -llibopencv_highgui
    /usr/bin/ld: ne peut trouver -llibopencv_imgproc
    /usr/bin/ld: ne peut trouver -llibopencv_legacy
    /usr/bin/ld: ne peut trouver -llibopencv_ml
    /usr/bin/ld: ne peut trouver -llibopencv_nonfree
    /usr/bin/ld: ne peut trouver -llibopencv_objdetect
    /usr/bin/ld: ne peut trouver -llibopencv_photo
    /usr/bin/ld: ne peut trouver -llibopencv_stiching
    /usr/bin/ld: ne peut trouver -llibopencv_superres
    /usr/bin/ld: ne peut trouver -llibopencv_ts
    /usr/bin/ld: ne peut trouver -llibopencv_video
    /usr/bin/ld: ne peut trouver -llibopencv_videostab
    /usr/bin/ld: ne peut trouver -llibopencv_
    collect2: erreur: ld a retourné 1 code d'état d'exécution
    make: *** [test] Erreur 1

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

    Essaie d'enlever le "lib" devant les noms :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++ -L/usr/local/lib/ -o"test"  ./src/test.o   -llibopencv_calib3d -llibopencv_contrib  ...

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    378
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 378
    Points : 94
    Points
    94
    Par défaut
    merci cela fonctionne déjà un peu mieux mais bizarre

    voici ce que j'obtiens :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    **** Build of configuration Debug for project test ****
     
    make all 
    Building target: test
    Invoking: GCC C++ Linker
    g++ -L/usr/local/lib/ -o"test"  ./src/test.o   -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab
    /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: dans la fonction « _start »:
    (.text+0x20): référence indéfinie vers « main »
    collect2: erreur: ld a retourné 1 code d'état d'exécution
    make: *** [test] Erreur 1
    P.S : j'ai repris le code source que j'ai trouvé sur un post précédent

  5. #5
    Invité
    Invité(e)
    Par défaut
    Quel est le code que tu essaies de compiler ?
    Tu ne sembles pas avoir la fonction d'entrée main...

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    378
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 378
    Points : 94
    Points
    94
    Par défaut
    voici le code trouvé dans un post juste avant le mien et comme il touche à ce que je veux faire (SURF), je me suis dit de tenter de le compiler. J'ai suivi ta première instruction de remplacer les " par <

    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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    #include <stdio.h>
    #include <iostream>
     
    #include <opencv2/core/core.hpp>
    #include <opencv2/features2d/features2d.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/nonfree/nonfree.hpp>
    #include <opencv2/calib3d/calib3d.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
     
    using namespace cv;
     
    void readme();
     
    /** @function main */
    int main( int argc, char** argv )
    {
     if( argc != 3 )
     { readme(); return -1; }
     
    // Load the images
     Mat image1= imread( argv[2] );
     Mat image2= imread( argv[1] );
     Mat gray_image1;
     Mat gray_image2;
     // Convert to Grayscale
     cvtColor( image1, gray_image1, CV_RGB2GRAY );
     cvtColor( image2, gray_image2, CV_RGB2GRAY );
     
    imshow("first image",image2);
     imshow("second image",image1);
     
    if( !gray_image1.data || !gray_image2.data )
     { std::cout<< " --(!) Error reading images " << std::endl; return -1; }
     
    //-- Step 1: Detect the keypoints using SURF Detector
     int minHessian = 400;
     
    SurfFeatureDetector detector( minHessian );
     
    std::vector< KeyPoint > keypoints_object, keypoints_scene;
     
    detector.detect( gray_image1, keypoints_object );
     detector.detect( gray_image2, keypoints_scene );
     
    //-- Step 2: Calculate descriptors (feature vectors)
     SurfDescriptorExtractor extractor;
     
    Mat descriptors_object, descriptors_scene;
     
    extractor.compute( gray_image1, keypoints_object, descriptors_object );
     extractor.compute( gray_image2, keypoints_scene, descriptors_scene );
     
    //-- Step 3: Matching descriptor vectors using FLANN matcher
     FlannBasedMatcher matcher;
     std::vector< DMatch > matches;
     matcher.match( descriptors_object, descriptors_scene, matches );
     
    double max_dist = 0; double min_dist = 100;
     
    //-- Quick calculation of max and min distances between keypoints
     for( int i = 0; i < descriptors_object.rows; i++ )
     { double dist = matches[i].distance;
     if( dist < min_dist ) min_dist = dist;
     if( dist > max_dist ) max_dist = dist;
     }
     
    printf("-- Max dist : %f \n", max_dist );
     printf("-- Min dist : %f \n", min_dist );
     
    //-- Use only "good" matches (i.e. whose distance is less than 3*min_dist )
     std::vector< DMatch > good_matches;
     
    for( int i = 0; i < descriptors_object.rows; i++ )
     { if( matches[i].distance < 3*min_dist )
     { good_matches.push_back( matches[i]); }
     }
     std::vector< Point2f > obj;
     std::vector< Point2f > scene;
     
    for( int i = 0; i < good_matches.size(); i++ )
     {
     //-- Get the keypoints from the good matches
     obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
     scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
     }
     
    // Find the Homography Matrix
     Mat H = findHomography( obj, scene, CV_RANSAC );
     // Use the Homography Matrix to warp the images
     cv::Mat result;
     warpPerspective(image1,result,H,cv::Size(image1.cols+image2.cols,image1.rows));
     cv::Mat half(result,cv::Rect(0,0,image2.cols,image2.rows));
     image2.copyTo(half);
     imshow( "Result", result );
     
     waitKey(0);
     return 0;
     }
     
    /** @function readme */
     void readme()
     { std::cout << " Usage: Panorama < img1 > < img2 >" << std::endl; }

  7. #7
    Invité
    Invité(e)
    Par défaut
    RAS à première vue, mais ta ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    g++ -L/usr/local/lib/ -o"test"  ./src/test.o
    m'interpelle, et en particulier "test".
    Un problème dans le Makefile j'ai l'impression...

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    378
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 378
    Points : 94
    Points
    94
    Par défaut
    j'ai changé le code par un trouvé sur le site opencv
    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
    71
    72
    73
    /**
     * @function findContours_Demo.cpp
     * @brief Demo code to find contours in an image
     * @author OpenCV team
     */
     
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
     
    using namespace cv;
    using namespace std;
     
    Mat src; Mat src_gray;
    int thresh = 100;
    int max_thresh = 255;
    RNG rng(12345);
     
    /// Function header
    void thresh_callback(int, void* );
     
    /**
     * @function main
     */
    int main( int, char** argv )
    {
      /// Load source image and convert it to gray
      src = imread( argv[1], 1 );
     
      /// Convert image to gray and blur it
      cvtColor( src, src_gray, COLOR_BGR2GRAY );
      blur( src_gray, src_gray, Size(3,3) );
     
      /// Create Window
      const char* source_window = "Source";
      namedWindow( source_window, WINDOW_AUTOSIZE );
      imshow( source_window, src );
     
      createTrackbar( " Canny thresh:", "Source", &thresh, max_thresh, thresh_callback );
      thresh_callback( 0, 0 );
     
      waitKey(0);
      return(0);
    }
     
    /**
     * @function thresh_callback
     */
    void thresh_callback(int, void* )
    {
      Mat canny_output;
      vector<vector<Point> > contours;
      vector<Vec4i> hierarchy;
     
      /// Detect edges using canny
      Canny( src_gray, canny_output, thresh, thresh*2, 3 );
      /// Find contours
      findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
     
      /// Draw contours
      Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );
      for( size_t i = 0; i< contours.size(); i++ )
         {
           Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
           drawContours( drawing, contours, (int)i, color, 2, 8, hierarchy, 0, Point() );
         }
     
      /// Show in a window
      namedWindow( "Contours", WINDOW_AUTOSIZE );
      imshow( "Contours", drawing );
    }
    la compilation fonctionne maintenant, donc dans le source précédent il y avait 2 problèmes dont un que j'ai corrigé :
    dans la boucle for il y avait un int au lieu de size_t

    et le dernier message d'erreur donnait :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    init done 
    opengl support available 
    -- Max dist : 0,000000 
    -- Min dist : 0,000000 
    OpenCV Error: Assertion failed (npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type()) in findHomography, file /home/altair8080/Téléchargements/opencv-2.4.5/modules/calib3d/src/fundam.cpp, line 1074
    terminate called after throwing an instance of 'cv::Exception'
      what():  /home/altair8080/Téléchargements/opencv-2.4.5/modules/calib3d/src/fundam.cpp:1074: error: (-215) npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type() in function findHomography
    je suis intéressé par l'origine de cette dernière anomalie.

    Sinon j'espère que le code utilisé et qui fonctionne est bien dans le format opencv2.4.5 c++ sinon je vais me prendre la tête pour des anomalies inexistantes par la suite ;-) L'objectif étant de faire du SIFT, SURF

Discussions similaires

  1. Compiler .lib en Dll
    Par lemagicien dans le forum Visual C++
    Réponses: 1
    Dernier message: 23/03/2010, 10h36
  2. Bibliothèques compilées (.lib) : *-sgd-*.lib ?
    Par oodini dans le forum Boost
    Réponses: 1
    Dernier message: 12/08/2008, 16h41
  3. Compilation lib PWLib
    Par Dam06 dans le forum Windows
    Réponses: 1
    Dernier message: 26/03/2008, 16h14
  4. Compilation Lib + .h
    Par franck.automaticien dans le forum Réseau
    Réponses: 7
    Dernier message: 01/02/2007, 13h16
  5. compilation .lib .dll
    Par thierry31 dans le forum Autres éditeurs
    Réponses: 5
    Dernier message: 01/04/2005, 11h47

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