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 :

OpenCV Error: Assertion failed


Sujet :

OpenCV

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2011
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2011
    Messages : 10
    Points : 5
    Points
    5
    Par défaut OpenCV Error: Assertion failed
    Alors voila je galère sur ce programme depuis 2 semaines rien à faire pourtant le programme se compile sans erreur et se génère, et à mon avis c'est bien codé.
    Par contre j'ai une erreur à l’exécution du programme du type :
    OpenCV Error: Assertion failed (elemSize() == (((((DataType<_Tp>::type) & ((512- 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> ((DataType<_Tp>::type) & ((1 << 3) - 1))*2) & 3))) in unknown function, file c:\opencv2.2\include\opencv2\core\mat.hpp, line 563
    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
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
     
    using namespace cv;
    using namespace std;
     
    /// Global variables
    Mat src, src_gray;
    Mat myHarris_dst, myHarris_copy, Mc;
    Mat myShiTomasi_dst; Mat myShiTomasi_copy;
     
    int myShiTomasi_qualityLevel = 5;
    int myHarris_qualityLevel = 50;
    int max_qualityLevel = 150;
     
    double myHarris_minVal; double myHarris_maxVal;
    double myShiTomasi_minVal; double myShiTomasi_maxVal;
     
    RNG rng(12345);
     
    char* myHarris_window = "My Harris corner detector";
    char* myShiTomasi_window = "My Shi Tomasi corner detector";
     
     
    void myShiTomasi_function( int, void* );
    void myHarris_function( int, void* );
     
     
    int main( int argc, char** argv )
    {
     
      src = imread( "V1.jpg", 1 );
      cvtColor( src, src_gray, CV_BGR2GRAY );
     
     
      int blockSize = 3; int apertureSize = 3;
     
      /// My Harris matrix -- Using cornerEigenValsAndVecs
      myHarris_dst = Mat::zeros( src_gray.size(), CV_32FC(6) );
      Mc = Mat::zeros( src_gray.size(), CV_32FC1 );
     
     
      cornerEigenValsAndVecs( src_gray, myHarris_dst, blockSize, apertureSize, BORDER_DEFAULT );
     
        /* calculate Mc */
      for( int j = 0; j < src_gray.rows; j++ )
         { for( int i = 0; i < src_gray.cols; i++ )
              {
                float lambda_1 = myHarris_dst.at<float>( j, i, 0 );
                float lambda_2 = myHarris_dst.at<float>( j, i, 1 );
                Mc.at<float>(j,i) = lambda_1*lambda_2 - 0.04*pow( ( lambda_1 + lambda_2 ), 2 );
              }
         }
     
    minMaxLoc( Mc, &myHarris_minVal, &myHarris_maxVal, 0, 0, Mat() );
     
      /* Create Window and Trackbar */
      namedWindow( myHarris_window, CV_WINDOW_AUTOSIZE );
      createTrackbar( " Quality Level:", myHarris_window, &myHarris_qualityLevel, max_qualityLevel,
                        myHarris_function );
      myHarris_function( 0, 0 );
     
      /// My Shi-Tomasi -- Using cornerMinEigenVal
      myShiTomasi_dst = Mat::zeros( src_gray.size(), CV_32FC1 );
      cornerMinEigenVal( src_gray, myShiTomasi_dst, blockSize, apertureSize, BORDER_DEFAULT );
     
      minMaxLoc( myShiTomasi_dst, &myShiTomasi_minVal, &myShiTomasi_maxVal, 0, 0, Mat() );
     
      /* Create Window and Trackbar */
      namedWindow( myShiTomasi_window, CV_WINDOW_AUTOSIZE );
      createTrackbar( " Quality Level:", myShiTomasi_window, &myShiTomasi_qualityLevel, max_qualityLevel,
                         myShiTomasi_function );
      myShiTomasi_function( 0, 0 );
     
      waitKey(0);
      return(0);
    }
     
    /** function myShiTomasi_function  */
    void myShiTomasi_function( int, void* )
    {
      myShiTomasi_copy = src.clone();
     
      if( myShiTomasi_qualityLevel < 1 ) { myShiTomasi_qualityLevel = 1; }
     
      for( int j = 0; j < src_gray.rows; j++ )
         { for( int i = 0; i < src_gray.cols; i++ )
              {
                if( myShiTomasi_dst.at<float>(j,i) > myShiTomasi_minVal + ( myShiTomasi_maxVal -
                         myShiTomasi_minVal )*myShiTomasi_qualityLevel/max_qualityLevel )
                  { circle( myShiTomasi_copy, Point(i,j), 4, Scalar( rng.uniform(0,255),
                             rng.uniform(0,255), rng.uniform(0,255) ), -1, 8, 0 ); }
              }
         }
      imshow( myShiTomasi_window, myShiTomasi_copy );
    }
     
    /** function myHarris_function */
    void myHarris_function( int, void* )
    {
      myHarris_copy = src.clone();
     
      if( myHarris_qualityLevel < 1 ) { myHarris_qualityLevel = 1; }
     
      for( int j = 0; j < src_gray.rows; j++ )
         { for( int i = 0; i < src_gray.cols; i++ )
              {
                if( Mc.at<float>(j,i) > myHarris_minVal + ( myHarris_maxVal - myHarris_minVal )
                                                             *myHarris_qualityLevel/max_qualityLevel )
                  { circle( myHarris_copy, Point(i,j), 4, Scalar( rng.uniform(0,255), rng.uniform(0,255),
                            rng.uniform(0,255) ), -1, 8, 0 ); }
              }
         }
      imshow( myHarris_window, myHarris_copy );
    }
    Est ce que on peut m'aider sur ce sujet svp

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2011
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2011
    Messages : 10
    Points : 5
    Points
    5
    Par défaut
    J'avais oublier de spécifier que l'erreur surgit à la 1 instruction de la boucle :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    for( int j = 0; j < src_gray.rows; j++ )
         { for( int i = 0; i < src_gray.cols; i++ )
              {
                float lambda_1 = myHarris_dst.at<float>( j, i, 0 );
                float lambda_2 = myHarris_dst.at<float>( j, i, 1 );
                Mc.at<float>(j,i) = lambda_1*lambda_2 - 0.04*pow( ( lambda_1 + lambda_2 ), 2 );
              }
         }

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Août 2011
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2011
    Messages : 10
    Points : 5
    Points
    5
    Par défaut
    Finalement j'ai pu trouver une solution je l'a publie si ça peut aider.
    alors pour faire bref j'ai utilsé une autre méthode pour l’accès aux données de mon image

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    for( int i = 0; i < src_gray.rows; i++ )
    		{
    			float* pt = (float*)(myHarris_dst.data+myHarris_dst.step*i);
    			float* dst = (float*)( Mc.data +  Mc.step*i);
    			for(int j = 0; j < src_gray.cols; j++ )
    			{
    				float lambda_1 = pt[j*6];
    				float lambda_2 = pt[j*6+1];
     
    				dst[j] = (float)(lambda_1*lambda_2 - 0.04*pow( ( lambda_1 + lambda_2 ), 2 ));	
    			}
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Debug Assertion Failed ! File: dbgheap.c
    Par jacques_henry dans le forum MFC
    Réponses: 9
    Dernier message: 15/04/2015, 11h29
  2. Réponses: 1
    Dernier message: 12/04/2011, 10h07
  3. Réponses: 4
    Dernier message: 22/11/2005, 17h55
  4. Réponses: 3
    Dernier message: 07/12/2004, 22h09

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