Précédent   Forum du club des développeurs et IT Pro > C et C++ > C++ > Débuter
Débuter Forum d'entraide pour débuter en langage de programmation C++. Avant de poster : cours d'initiation au C++
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 10/12/2012, 20h28   #1
aybayb
Invité de passage
 
Homme
Inscription : 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 : 0
Points : 0
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 :
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.
aybayb est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2012, 12h34   #2
math_lab
Membre chevronné
 
Homme
Chercheur en informatique
Inscription : avril 2008
Messages : 329
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Royaume-Uni

Informations professionnelles :
Activité : Chercheur en informatique

Informations forums :
Inscription : avril 2008
Messages : 329
Points : 627
Points : 627
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.
math_lab est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2012, 13h31   #3
aybayb
Invité de passage
 
Homme
Inscription : 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 : 0
Points : 0
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.
aybayb est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2012, 15h18   #4
math_lab
Membre chevronné
 
Homme
Chercheur en informatique
Inscription : avril 2008
Messages : 329
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Royaume-Uni

Informations professionnelles :
Activité : Chercheur en informatique

Informations forums :
Inscription : avril 2008
Messages : 329
Points : 627
Points : 627
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.
math_lab est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/12/2012, 16h06   #5
aybayb
Invité de passage
 
Homme
Inscription : 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 : 0
Points : 0
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
aybayb est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 06h59.


 
 
 
 
Partenaires

Hébergement Web