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

 C++ Discussion :

Expected primary-expression before 'void'


Sujet :

C++

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut Expected primary-expression before 'void'
    Bonjour,

    je suis entrent de programmer un Tracking avec Eclipse et Opencv, et arrivant à une certeine instruction j'ai eu une erreur "expected primary-expression before 'void' " voici l'instruction :

    cvSetMouseCallback("CamShiftDemo",on_mouse,void*);

    et voici mon psuedo 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
    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
    void on_mouse( int event, int x, int y, int flags )
    {
        if( !image )
            return;
     
        if( image->origin )
            y = image->height - y;
     
        if( select_object )
        {
            selection.x = MIN(x,origin.x);
            selection.y = MIN(y,origin.y);
            selection.width = selection.x + CV_IABS(x - origin.x);
            selection.height = selection.y + CV_IABS(y - origin.y);
     
            selection.x = MAX( selection.x, 0 );
            selection.y = MAX( selection.y, 0 );
            selection.width = MIN( selection.width, image->width );
            selection.height = MIN( selection.height, image->height );
            selection.width -= selection.x;
            selection.height -= selection.y;
     
        }
     
        switch( event )
        {
        case CV_EVENT_LBUTTONDOWN:
            origin = cvPoint(x,y);
            selection = cvRect(x,y,0,0);
            select_object = 1;
            break;
        case CV_EVENT_LBUTTONUP:
            select_object = 0;
            if( selection.width > 0 && selection.height > 0 )
                track_object = -1;
    #ifdef _DEBUG
        printf("\n # تَ±êµؤر،شٌاّسٍ£؛");
        printf("\n   X = %d, Y = %d, Width = %d, Height = %d",
            selection.x, selection.y, selection.width, selection.height);
    #endif
            break;
        }
    }
     
     
    CvScalar hsv2rgb( float hue )
    {
        int rgb[3], p, sector;
        static const int sector_data[][3]=
            {{0,2,1}, {1,2,0}, {1,0,2}, {2,0,1}, {2,1,0}, {0,1,2}};
        hue *= 0.033333333333333333333333333333333f;
        sector = cvFloor(hue);
        p = cvRound(255*(hue - sector));
        p ^= sector & 1 ? 255 : 0;
     
        rgb[sector_data[sector][0]] = 255;
        rgb[sector_data[sector][1]] = 0;
        rgb[sector_data[sector][2]] = p;
     
    #ifdef _DEBUG
        printf("\n # Convert HSV to RGB£؛");
        printf("\n   HUE = %f", hue);
        printf("\n   R = %d, G = %d, B = %d", rgb[0],rgb[1],rgb[2]);
    #endif
     
        return cvScalar(rgb[2], rgb[1], rgb[0],0);
    }
     
    int main( int argc, char** argv )
    {
        CvCapture* capture = 0;
        IplImage* frame = 0;
     
       if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
            capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0);
        else if( argc == 2 )
           capture = cvCaptureFromAVI( argv[1] );
     
        if( !capture )
        {
            fprintf(stderr,"Could not initialize capturing...\n");
            return -1;
        }
     
        printf( "Hot keys: \n"
            "\tESC - quit the program\n"
            "\tc - stop the tracking\n"
            "\tb - switch to/from backprojection view\n"
            "\th - show/hide object histogram\n"
            "To initialize tracking, select the object with mouse\n" );
     
        //cvNamedWindow( "Histogram", 1 );
        cvNamedWindow( "CamShiftDemo", 1 );
     
        cvSetMouseCallback("CamShiftDemo",on_mouse,void*); // on_mouse 
     
        cvCreateTrackbar( "Vmin", "CamShiftDemo", &vmin, 256, 0 );
        cvCreateTrackbar( "Vmax", "CamShiftDemo", &vmax, 256, 0 );
        cvCreateTrackbar( "Smin", "CamShiftDemo", &smin, 256, 0 );
    en exécutant ce programme tout en mettant cette instruction comme commentaire j'aurai une fenêtre noir comme quoi il n'a pas reconnu ma cam integrer alors que je peux l'utiliser sur Skype ou MSN, j'aimerai bien que vous m'aidiez à trouver ou est le problème avec la CAM ( j'ai un HP DV5 PAVILLON).

    Merci d'avance.

  2. #2
    Membre éprouvé
    Homme Profil pro
    Ingénieur 3D
    Inscrit en
    Avril 2008
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Ingénieur 3D

    Informations forums :
    Inscription : Avril 2008
    Messages : 400
    Points : 968
    Points
    968
    Par défaut
    Le void* est une déclaration de pointeur sur void, pas une variable ou valeur. Change le par un NULL et ca compilera.
    Ensuite pour ton problème de webcam, si tu as une version récente d'OpenCV, il faut que tu copies la dll ffmpeg fournie avec opencv dans ton dossier d’exécutable.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Bonjour,
    Merci pour votre réponse.

    enfait même en changeant void* avec NULL j'aurai un autre erreur :

    initializing argument 2 of 'void cvSetMouseCallback(const char*,void(*)(int, int, int, int, void*),void*)
    Invalide arguments


    Et pour Opencv j'utilise Opencv1.0, je trouve pas le fichier dll ffmpeg, j'ai trouvé cvcap_ffmpeg.cpp et je l'ai ajouté dans mon projet, sachant que j'ai ajouter le fichier dll "cvcam.dll" aussi mais toujours rien, j'aurai une fenêtre noir dans l'execution. ce n'est pas une question de compatibilité de la cam avec Opencv ou peut-être il faut que je met à jour mon driver de la cam ?

    Merci.

  4. #4
    Membre éprouvé
    Homme Profil pro
    Ingénieur 3D
    Inscrit en
    Avril 2008
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Ingénieur 3D

    Informations forums :
    Inscription : Avril 2008
    Messages : 400
    Points : 968
    Points
    968
    Par défaut
    Pourquoi utiliser OpenCV 1? Cette version n'est plus supportée depuis des années et est probablement bourrée de bugs et autres. Sinon, pour ton problème de mouse callback, je te conseille de regarder la documentation ou les tutos pour voir comment tu es censé appeler la fonction.

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Enfait je viens d'integrer Opencv2.0 sur mon projet et ajouter le fichier dll libOpencv_ffmpeg200.dll sur le répértoir de mon projet mais toujours rien fenêtre noir ... Si vous pouvez essayez le code chez vous ça serait bien de me dir si le problème est dans ma CAM ou peut-être le problème est dans Opencv2.0 aussi.

    Merci

Discussions similaires

  1. expected primary-expression before '->' token
    Par namecha dans le forum Débuter
    Réponses: 2
    Dernier message: 14/04/2012, 15h50
  2. Réponses: 2
    Dernier message: 16/11/2011, 11h25
  3. Réponses: 2
    Dernier message: 08/02/2010, 10h00
  4. Réponses: 3
    Dernier message: 15/05/2009, 16h18
  5. expected primary-expression before '=' token
    Par steph_p dans le forum Débuter
    Réponses: 4
    Dernier message: 02/02/2009, 16h03

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