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 :

Problème avec des pointeurs


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 12
    Par défaut Problème avec des pointeurs
    Voila mon soucie est que sa compile parfaitement avec plusieurs avertissement

    conversion de pointeur suspecte.

    Donc je vous résume le code ici et je note ou sa plante:

    le main:
    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
    int main(int argc, char* argv[])
    {
    	unsigned char wnd_Decal;
    	short int xAbs,yAbs;
    	short int *px,*py;
    	unsigned char TabX[4][20],TabY[4][15];
    	px=&xAbs;
    	py=&yAbs;
     
     
     
    	Traitement(&TabX,&TabY,px,py,&wnd_Decal);
     
    	return 0;
    }

    la fonction traitement: qui marche impec au pas a pas:
    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
     
    void Traitement(unsigned char Tabx[4][20],unsigned char Taby[4][15], short int *px,short int *py,unsigned char *wnd_Decal)
     {
    	unsigned char Num_Fonct=0;
    	int i=0;
     
    	while (i==0)
    	{
    		switch (Num_Fonct)
    		{
    			case 0: *wnd_Decal=1;
    					Absolut(&Tabx,&Taby,px,py,&wnd_Decal);
     
    					if (*py>0 && !wnd_Decal)
    						Num_Fonct=2;
    					else if (*py>0 && wnd_Decal)
    						Num_Fonct=3;
    					else
    						Num_Fonct=0;
    					break;
     
    			case 1: *wnd_Decal=1;
    					Relatif(&Tabx,&Taby,px,py,&wnd_Decal);
    					if (!*py && !wnd_Decal)
    						Num_Fonct=0;
    					else Num_Fonct=3;
    					break;
     
    			case 2: *wnd_Decal=2;
    					Relatif(&Tabx,&Taby,px,py,&wnd_Decal);
    					if (!*py && !wnd_Decal)
    						Num_Fonct=0;
    					else Num_Fonct=3;
    					break;
     
    			case 3: *wnd_Decal=3;
    					Relatif(&Tabx,&Taby,px,py,&wnd_Decal);
    					if (!*py )
    						Num_Fonct=1;
    					else Num_Fonct=3;
    					break;
     
    			default: Num_Fonct=0;
     
    		}
     
    		//On récupère les valeur de X et Y qui sont xAbs et yAbs:test
                    printf(%i,*px);
                    printf(%i,*py);
                    //de toute facon sa arrive pas jusque la^^
    		i++;
    	}
     }

    Et l'endroit ou actuellement sa plante en boucle infini:
    le début de la fonction absolut:
    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
    void Absolut(unsigned char Tabx[4][20],unsigned char Taby[4][15],short int *px,short int *py,unsigned char *wnd_Decal)
     {
    	unsigned char i=0;
    
    	//APPEL A LA FONCTION DE CAPTURE DE LA ZONE IMAGE
    	FullCapture(&Tabx,&Taby);
    
    
    	//coordonnée du centre de la zone
    	while (*py==0 || i<4)
    		{
    			*wnd_Decal=1;
    			ProcProto(&Tabx,&Taby,px,py,&wnd_Decal,i);
    			i++;
    		}
    	if (!*py)
    	{
    		switch (i)
    		{
    		  case 1: Recadrage(px,&py,200,60,1);
    				  break;
    		  case 2: Recadrage(px,py,80,180,1);
    				  break;
    		  case 3: Recadrage(px,py,200,180,1);
    				  break;
    		}
    
    	}
     }
    Désolé ya d'autre fonction mais elle sont un peu longue donc ce n'est que ici que sa plante (joint le .c complet)
    l'endroit ou sa plante est le test sur *py et ensuite si on le suprimme sa replante quand on doit modifier un des 2 pointeurs.

    Donc sa fait pas mal de temps que j'ai plus fait de C et la je galere vraiment ....
    Merci de votre aide
    Fichiers attachés Fichiers attachés

  2. #2
    Expert confirmé
    Avatar de diogene
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Juin 2005
    Messages
    5 761
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 761
    Par défaut
    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
    	unsigned char wnd_Decal;
    ....
    	Traitement(&TabX,&TabY,px,py,&wnd_Decal);
    // Dans le code montré, les variables xAbs, yAbs et wnd_Decal ne sont pas initialisées.
    // Il n'y a aucune raison de mettre des & devant le nom des tableaux:
    // Traitement(TabX,TabY,px,py,&wnd_Decal);
    ....
    void Traitement(unsigned char Tabx[4][20],unsigned char Taby[4][15], short int *px,short int *py,unsigned char *wnd_Decal)
    {....
    			case 0: *wnd_Decal=1;
    					Absolut(&Tabx,&Taby,px,py,&wnd_Decal);
    // le dernier argument est du type unsigned char ** !!!!
    // Il n'y a aucune raison de mettre des & devant le nom des tableaux
    // Probablement :
    //          Absolut(Tabx,Taby,px,py,wnd_Decal);
    // Revoir aussi les autres case.
    ....
    }
    void Absolut(unsigned char Tabx[4][20],unsigned char Taby[4][15],short int *px,short int *py,unsigned char *wnd_Decal)
     { // le dernier paramètre est du type unsigned char * ,
       //  l'argument passé du type unsigned char ** !!!!
    ProcProto modifie t-il *py ?

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 12
    Par défaut
    en effet proproto modifie *py et *px car on fait une sorte de recherche de point dans une zone.Mais la fonction procproto doit également modifier le wnd_Decal

    jai tester a part procproto et il fonctionne parfaitement au passage.

    par contre justement ce que je comprend pas dans ta remarque c'est le coup des char** car je passe une adresse c'est tout et je demande a ce que l'on recupere une adresse dans la fonction (je me suis certainement planter dans la facon d'écrire... )

    donc en fait il faut que je passe des pointeur que je défini à l'avance en parametre et non les adresse? je pensais pourtant que sa marcherai...
    Sinon si tu as le temps de me détaillé un peu plus car j'ai pas tout saisi

  4. #4
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par Darick Voir le message
    Voila mon soucie est que sa compile parfaitement avec plusieurs avertissement
    Contradiction détectée...

    De toutes façons, ton code ne compile pas :
    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
     
    Project   : Forums
    Compiler  : GNU GCC Compiler (called directly)
    Directory : D:\dev\forums\
    --------------------------------------------------------------------------------
    Switching to target: default
    Compiling: main.c
    main.c:4: warning: ignoring #pragma hdrstop 
    main.c:8: warning: ignoring #pragma argsused 
    main.c:15: warning: unused parameter 'Tab'
    main.c:15: warning: unused parameter 'Tabx'
    main.c:15: warning: unused parameter 'Taby'
    main.c: In function `ProcProto':
    main.c:118: warning: suggest parentheses around && within ||
    main.c:152: warning: suggest parentheses around && within ||
    main.c:206: warning: suggest parentheses around && within ||
    main.c: In function `Absolut':
    main.c:248: warning: passing arg 1 of `FullCapture' from incompatible pointer type
    main.c:248: warning: passing arg 2 of `FullCapture' from incompatible pointer type
    main.c:255: warning: passing arg 1 of `ProcProto' from incompatible pointer type
    main.c:255: warning: passing arg 2 of `ProcProto' from incompatible pointer type
    main.c:255: warning: passing arg 3 of `ProcProto' from incompatible pointer type
    main.c:255: warning: passing arg 5 of `ProcProto' from incompatible pointer type
    main.c:262: warning: passing arg 2 of `Recadrage' from incompatible pointer type
    main.c: In function `Relatif':
    main.c:292: warning: suggest parentheses around + or - inside shift
    main.c:293: warning: comparison is always false due to limited range of data type
    main.c:299: warning: suggest parentheses around + or - inside shift
    main.c:300: warning: comparison is always false due to limited range of data type
    main.c:315: warning: passing arg 1 of `WndCapture' from incompatible pointer type
    main.c:315: warning: passing arg 2 of `WndCapture' from incompatible pointer type
    main.c:315: warning: passing arg 3 of `WndCapture' from incompatible pointer type
    main.c:320: warning: passing arg 1 of `WndCapture' from incompatible pointer type
    main.c:320: warning: passing arg 2 of `WndCapture' from incompatible pointer type
    main.c:320: warning: passing arg 3 of `WndCapture' from incompatible pointer type
    main.c:323: warning: passing arg 1 of `ProcProto' from incompatible pointer type
    main.c:323: warning: passing arg 2 of `ProcProto' from incompatible pointer type
    main.c:323: warning: passing arg 3 of `ProcProto' from incompatible pointer type
    main.c:323: warning: passing arg 4 of `ProcProto' from incompatible pointer type
    main.c:323: warning: passing arg 5 of `ProcProto' from incompatible pointer type
    main.c:324: warning: passing arg 1 of `Recadrage' from incompatible pointer type
    main.c:324: warning: passing arg 2 of `Recadrage' from incompatible pointer type
    main.c:294: warning: will never be executed
    main.c:301: warning: will never be executed
    main.c: In function `Traitement':
    main.c:338: warning: passing arg 1 of `Absolut' from incompatible pointer type
    main.c:338: warning: passing arg 2 of `Absolut' from incompatible pointer type
    main.c:338: warning: passing arg 5 of `Absolut' from incompatible pointer type
    main.c:349: warning: passing arg 1 of `Relatif' from incompatible pointer type
    main.c:349: warning: passing arg 2 of `Relatif' from incompatible pointer type
    main.c:349: warning: passing arg 5 of `Relatif' from incompatible pointer type
    main.c:356: warning: passing arg 1 of `Relatif' from incompatible pointer type
    main.c:356: warning: passing arg 2 of `Relatif' from incompatible pointer type
    main.c:356: warning: passing arg 5 of `Relatif' from incompatible pointer type
    main.c:363: warning: passing arg 1 of `Relatif' from incompatible pointer type
    main.c:363: warning: passing arg 2 of `Relatif' from incompatible pointer type
    main.c:363: warning: passing arg 5 of `Relatif' from incompatible pointer type
    main.c:374: error: syntax error before '%token
    main.c:375: error: syntax error before '%token
    main.c: In function `main':
    main.c:392: warning: passing arg 1 of `Traitement' from incompatible pointer type
    main.c:392: warning: passing arg 2 of `Traitement' from incompatible pointer type
    main.c: At top level:
    main.c:381: warning: unused parameter 'argc'
    main.c:381: warning: unused parameter 'argv'
    Process terminated with status 1 (0 minutes, 1 seconds)
    2 errors, 50 warnings
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
                    printf(%i,*px);
                    printf(%i,*py);
    Manque des "" (last minute changes ?)

    pragmas supprimés
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    				if ((!c.bit0 && c.bit1) || (i==((320>>*wnd_Decal)>>3)-1) && c.bit0)
    Ambigu... C'est
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
             if (((!c.bit0 && c.bit1) || (i == ((320 >> *wnd_Decal) >> 3) - 1))
                 && c.bit0)
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
             if ((!c.bit0 && c.bit1) || 
                ((i == ((320 >> *wnd_Decal) >> 3) - 1) && c.bit0))
    ?
    idem 2 autres fois un peu plus loin...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    void FullCapture (unsigned char Tabx[4][20], unsigned char Taby[4][15])
    <...>
     
       //APPEL A LA FONCTION DE CAPTURE DE LA ZONE IMAGE
       FullCapture (&Tabx, &Taby);
    Pourquoi ces & ? Le comportement est indéterminé (type erroné). S'agissant de pointeurs, l'effet est catastrophique...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
       //APPEL A LA FONCTION DE CAPTURE DE LA ZONE IMAGE
       FullCapture (Tabx, Taby);
    Idem avec ProcProto(), WndCapture(), Recadrage(), Absolut()[1], Relatif()... De plus, dans Absolut, px et py sont de type unsigned int *, or le prototype de ProcProto() est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    void ProcProto (unsigned char Tabx[4][20], 
                         unsigned char Taby[4][15],
                         unsigned char *wnd_Decal, 
                         short int *xAbs, 
                         short int *yAbs,
                         short int n)
    alors que l'appel est
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
          ProcProto (Tabx, Taby, px, py, &wnd_Decal, i);
    Je soupçonne une inversion dans les paramètres :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
          ProcProto (Tabx, Taby, &wnd_Decal, px, py, i);
    avec encore un & en trop (wnd_Decal est déjà un pointeur...)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
          ProcProto (Tabx, Taby, wnd_Decal, px, py, i);
    Il ne faut pas prendre les warnings du compilateur à la légère. Ils sont souvent là pour montrer les erreurs de codages ou au moins susciter la reflexion...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
       unsigned char iStart = 0, jStart = 0;
    <...>
       if (iStart < 0)
          iStart = 0;
    Absurde. Comment une valeur 'unsigned' pourrait-elle être < 0 ?

    Je ne commente plus, je corrige le 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
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
     
    //---------------------------------------------------------------------------
     
    #include <stdio.h>
     
    //---------------------------------------------------------------------------
     
    void FullCapture (unsigned char Tabx[4][20], unsigned char Taby[4][15])
    {
       Tabx[0][8] = 0xFE;
       Taby[0][10] = 0xFF;
    }
    void WndCapture (unsigned char Tab[2], unsigned char Tabx[4][20],
                     unsigned char Taby[4][15])
    {
     
       (void) Tab;
       (void) Tabx;
       (void) Taby;
    }
     
    //fonction de recadrage des coordonnées
    //x et y sont les coordonnée du centre de la zone, *D détermine la taille
    //de cette zone et Px et Py la position du marqueur dans cette zone
    void Recadrage (short int *Px, short int *Py, short int x, short int y,
                    unsigned char wnd_Decal)
    {
       if (x < ((320 >> wnd_Decal) >> 1))
       {
          *Px = *Px - ((320 >> wnd_Decal) >> 1) - x;
       }
       else
          *Px = x - ((320 >> wnd_Decal) >> 1) + *Px;
       if (y < (240 >> wnd_Decal) >> 1)
       {
          *Py = *Py - ((240 >> wnd_Decal) >> 1) - y;
       }
       else
          *Py = y - ((240 >> wnd_Decal) >> 1) + *Py;
    }
     
    //Fonction de traitement de reconnaissance du marqueur sur une zone de 320>>*D par
    //240>>*D, Px et Py détermine les valeurs du centre de la zone ou de la balle
    //que l'on veut retrouver.
    //*D détermine les dimensions de la zone.
    //Tabx et Taby donne les profils des zones étudiers de centre (*Px,*Py)
    //n permet de déterminer la ligne de lecture (0 pour tout les cas sauf le full)
    //A,b,c,d représente les limitesdu tableau.
    void ProcProto (unsigned char Tabx[4][20], unsigned char Taby[4][15],
                    unsigned char *wnd_Decal, short int *xAbs, short int *yAbs,
                    short int n)
    {
       //variable pour les boucles
       unsigned char i;             //TabX
       unsigned char j;             //parcours octet TabX
       unsigned char k;             //TabY
       unsigned char l;             //parcours octet TabY
     
       //variable de validation:
       unsigned char Valid = 0;
     
       //variable de comptage
       unsigned char NbPixX = 0;
       unsigned char NbPixY = 0;
     
       unsigned char ValX = 0;
       unsigned char ValY = 0;
     
       //variable zone:
       unsigned char NbPixZoneX = 0;
       unsigned char NbPixZoneY = 0;
     
       //Structure Champ de bite: compacte et rapide d'accès
       struct Test
       {
          unsigned char bit0:1;
          unsigned char bit1:1;
          unsigned char bit2:1;
          unsigned char bit3:1;
          unsigned char bit4:1;
          unsigned char bit5:1;
          unsigned char bit6:1;
          unsigned char bit7:1;
       }
       c;
     
       //Nouvelle version traitement image: Tableau de char (1 octet=8 pixels)
       unsigned short ConcatCharX, ConcatCharY;
       //Etude sur TabX donc sur la zone X du prototype Image
       for (i = 0; i < ((320 >> *wnd_Decal) >> 3); i++)
       {
          //concaténation dans une variable d'étude des 2 char nécéssaire au traitement
          ConcatCharX = 0x0000000000000000;
          ConcatCharX = ((Tabx[n][i - 1]) << 7) | Tabx[n][i];
     
          //parcours de l'octet:
          for (j = 0; j < 8; j++)
          {
             //remplissage conditions structure:
             c.bit0 = ConcatCharX >> (7 - j) & 0x0000000000000001; //bit 1 du pixel
             c.bit1 = ConcatCharX >> (8 - j) & 0x0000000000000001; //bit pixel-1
             c.bit2 = ConcatCharX >> (11 - j) & 0x0000000000000001; //bit pixel-4
     
             //Parcours Tabx
             if (c.bit0)
             {
                if (c.bit1)
                {
                   NbPixX += 1;
                }
                //mise en place des regroupements de pixels
                else if (!c.bit1 && c.bit2)
                {
                   NbPixX += 4;
                }
                else
                {
                   NbPixX = 1;
                }
             }
     
             /* -ed- ambigu, non corrige */
             if ((!c.bit0 && c.bit1) || (i == ((320 >> *wnd_Decal) >> 3) - 1)
                 && c.bit0)
             {
                //condition de validation pour parcourir tabY
                if (NbPixX >= 6 && NbPixX <= 15)
                {
                   ValX = (i * 8 + j) - (NbPixX >> 1);
                   //parcours de TabY
                   for (k = 0; k < ((240 >> *wnd_Decal) >> 3); k++)
                   {
                      ConcatCharY = 0x0000000000000000;
                      ConcatCharY = Taby[n][k - 1] << 8 | Taby[n][k];
                      //parcours de TabY octet
                      for (l = 0; l < 8; l++)
                      {
                         c.bit3 = ConcatCharY >> (7 - l) & 0x0000000000000001; //bit 1 du pixel
                         c.bit4 = ConcatCharY >> (8 - l) & 0x0000000000000001; //bit pixel-1
                         c.bit5 = ConcatCharY >> (11 - l) & 0x0000000000000001; //bit pixel-4
     
                         if (c.bit3)
                         {
                            if (c.bit4)
                            {
                               NbPixY += 1;
                            }
                            //mise en place des regroupements de pixels
                            else if (!c.bit3 && c.bit5)
                            {
                               NbPixY += 4;
                            }
                            else
                            {
                               NbPixY = 1;
                            }
                         }
     
                         /* -ed- ambigu, non corrige */
                         if ((!c.bit3 && c.bit4)
                             || (k == ((240 >> *wnd_Decal) >> 3) - 1) && c.bit3)
                         {
                            if (NbPixY >= 6 && NbPixY <= 15)
                            {
                               ValY = (k * 8 + l) - (NbPixY >> 1);
                               Valid = 1;
                               i = 20;
                               j = 8;
                               k = 15;
                               l = 8;
                            }
     
                            else if (NbPixY > 15 && NbPixY > NbPixZoneY)
                            {
                               //traitement zone en Y
                               NbPixZoneY = NbPixY;
                               ValY = (k * 8 + l) - (NbPixZoneY >> 1);
     
                            }
                         }
     
                      }
                   }
                }
                //zone en X
                if (NbPixX > 15 && NbPixX > NbPixZoneX)
                {
                   for (k = 1; k < ((240 >> *wnd_Decal) >> 3); k++)
                   {
                      ConcatCharY = Taby[n][k - 1] << 8 | Taby[n][k];
                      //parcours de TabY octet
                      for (l = 0; l < 8; l++)
                      {
                         c.bit3 = ConcatCharY >> (7 - l) & 0x0000000000000001; //bit 1 du pixel
                         c.bit4 = ConcatCharY >> (8 - l) & 0x0000000000000001; //bit pixel-1
                         c.bit5 = ConcatCharY >> (11 - l) & 0x0000000000000001; //bit pixel-4
     
                         if (c.bit3)
                         {
                            if (c.bit4)
                            {
                               NbPixY += 1;
                            }
                            //mise en place des regroupements de pixels
                            else if (!c.bit4 && c.bit5)
                            {
                               NbPixY += 4;
                            }
                            else
                            {
                               NbPixY = 1;
                            }
                         }
     
                         /* -ed- ambigu, non corrige */
                         if ((!c.bit3 && c.bit4)
                             || (k == ((240 >> *wnd_Decal) >> 3) - 1) && c.bit3)
                         {
                            if (NbPixY >= 6 && NbPixY <= 15)
                            {
                               ValY = (k * 8 + l) - (NbPixY >> 1);
                               ValX = (i * 8 + j) - (NbPixX >> 1);
                            }
                         }
                      }
     
                   }
     
                }
     
             }
          }
       }
     
       *xAbs = ValX;
       *yAbs = ValY;
       *wnd_Decal = Valid;
     
       //REMARQUE : Le test de validité de présence ou non se fait sur Y non sur X
       //en effet si Y possède une valeur alors X en possède une aussi et donc il y a présence
       //si Y est une zone X ne peu etre qu'un point et non nul
       //si Y est un point alors X est automatiquement non nul et soit une zone soit un point
       //si Y est nul alors X est une zone et un point Y n'a pu etre trouver
     
    }
     
    //Fonction principale de démarage de l'application ou en cas de perte de marqueur
    //on passe en paramêtre les 2 tableaux et les 2 coordonnées précédente du marqueur
    void Absolut (unsigned char Tabx[4][20], unsigned char Taby[4][15],
                  short int *px, short int *py, unsigned char *wnd_Decal)
    {
       unsigned char i = 0;
     
       //APPEL A LA FONCTION DE CAPTURE DE LA ZONE IMAGE
       FullCapture (Tabx, Taby);
     
       //coordonnée du centre de la zone
       while (*py == 0 || i < 4)
       {
          *wnd_Decal = 1;
          ProcProto (Tabx, Taby, wnd_Decal, px, py, i);
          i++;
       }
       if (!*py)
       {
          switch (i)
          {
          case 1:
             Recadrage (px, py, 200, 60, 1);
             break;
          case 2:
             Recadrage (px, py, 80, 180, 1);
             break;
          case 3:
             Recadrage (px, py, 200, 180, 1);
             break;
          }
     
       }
    }
     
     //Fonction principale de suivit du marqueur, 3 fonctions : fine,midel1 et midel2
    void Relatif (unsigned char Tabx[4][20], unsigned char Taby[4][15],
                  short int *xAbs, short int *yAbs, unsigned char *wnd_Decal)
    {
       //save du centre de la zone
       short int OldMarkX = *xAbs;
       short int OldMarkY = *yAbs;
       unsigned char DecalageOld = *wnd_Decal;
     
       //détermination des bords du tableau: istart et istop,jstart et jstop
       unsigned char iStart = 0, jStart = 0;
       unsigned char wnd_height;
     
       unsigned char TabWnd[2];
     
       wnd_height = 320 >> *wnd_Decal;
     
       /* -ed- ambigu */
       iStart = OldMarkX - (wnd_height) >> 1;
     
       /* -ed- inutile */
       if (iStart < 0)
          iStart = 0;
     
       if (iStart > (320 - ((wnd_height) >> 1)))
          iStart = 320 - ((wnd_height) >> 1);
     
       wnd_height = 240 >> *wnd_Decal;
     
       /* -ed- ambigu */
       jStart = OldMarkY - (wnd_height) >> 1;
     
       /* -ed- inutile */
       if (jStart < 0)
          jStart = 0;
     
       if (jStart > (240 - ((wnd_height) >> 1)))
          jStart = (240 - ((wnd_height) >> 1));
     
       TabWnd[1] = jStart;
       TabWnd[2] = *wnd_Decal;
     
       //APPEL A LA FONCTION DE CAPTURE DE LA ZONE IMAGE
       if ((iStart - ((iStart >> 3) << 3)) < 5)
       {
          TabWnd[0] = (iStart) >> 3;
          WndCapture (TabWnd, Tabx, Taby);
       }
       else
       {
          TabWnd[0] = ((iStart) >> 3) + 1;
          WndCapture (TabWnd, Tabx, Taby);
       }
     
       ProcProto (Tabx, Taby, wnd_Decal, xAbs, yAbs, 0);
       Recadrage (xAbs, yAbs, OldMarkX, OldMarkY, DecalageOld);
    }
     
    void Traitement (unsigned char Tabx[4][20], unsigned char Taby[4][15],
                     short int *px, short int *py, unsigned char *wnd_Decal)
    {
       unsigned char Num_Fonct = 0;
       int i = 0;
     
       while (i == 0)
       {
          switch (Num_Fonct)
          {
          case 0:
             *wnd_Decal = 1;
             Absolut (Tabx, Taby, px, py, wnd_Decal);
     
             if (*py > 0 && !wnd_Decal)
                Num_Fonct = 2;
             else if (*py > 0 && wnd_Decal)
                Num_Fonct = 3;
             else
                Num_Fonct = 0;
             break;
     
          case 1:
             *wnd_Decal = 1;
             Relatif (Tabx, Taby, px, py, wnd_Decal);
             if (!*py && !wnd_Decal)
                Num_Fonct = 0;
             else
                Num_Fonct = 3;
             break;
     
          case 2:
             *wnd_Decal = 2;
             Relatif (Tabx, Taby, px, py, wnd_Decal);
             if (!*py && !wnd_Decal)
                Num_Fonct = 0;
             else
                Num_Fonct = 3;
             break;
     
          case 3:
             *wnd_Decal = 3;
             Relatif (Tabx, Taby, px, py, wnd_Decal);
             if (!*py)
                Num_Fonct = 1;
             else
                Num_Fonct = 3;
             break;
     
          default:
             Num_Fonct = 0;
     
          }
     
          //On récupère les valeur de X et Y qui sont xAbs et yAbs:test
          printf ("%i", *px);
          printf ("%i", *py);
          //de toute facon sa arrive pas jusque la^^
          i++;
       }
    }
     
    int main (void)
    {
       unsigned char wnd_Decal;
       short int xAbs, yAbs;
       short int *px, *py;
       unsigned char TabX[4][20], TabY[4][15];
       px = &xAbs;
       py = &yAbs;
     
       Traitement (TabX, TabY, px, py, &wnd_Decal);
     
       return 0;
    }
     
    //---------------------------------------------------------------------------
    Il reste ceci :
    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
     
    Project   : Forums
    Compiler  : GNU GCC Compiler (called directly)
    Directory : D:\dev\forums\
    --------------------------------------------------------------------------------
    Switching to target: default
    Compiling: main.c
    main.c: In function `ProcProto':
    main.c:123: warning: suggest parentheses around && within ||
    main.c:160: warning: suggest parentheses around && within ||
    main.c:216: warning: suggest parentheses around && within ||
    main.c: In function `Relatif':
    main.c:299: warning: suggest parentheses around + or - inside shift
    main.c:302: warning: comparison is always false due to limited range of data type
    main.c:311: warning: suggest parentheses around + or - inside shift
    main.c:314: warning: comparison is always false due to limited range of data type
    main.c:303: warning: will never be executed
    main.c:315: warning: will never be executed
    Linking console executable: console.exe
    Process terminated with status 0 (0 minutes, 0 seconds)
    0 errors, 9 warnings
    Les expression ambigues et/ou inutiles sont marquées :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
       /* -ed- ambigu */
       /* -ed- inutile */
    Je ne sais pas si ça a un sens, mais ça donne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    5109
    Press ENTER to continue.
    --------------------
    [1] Pourquoi un t à Absolu ? Une référence à une certaine vodka finlandaise... ?

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 12
    Par défaut
    Manque des "" (last minute changes ?)
    oui C du last minute change ....


    if ((!c.bit0 && c.bit1) || (i==((320>>*wnd_Decal)>>3)-1) && c.bit0)
    faut pas se posé la question sur procproto car je l'ai tester a part et cette fonction marche parfaitement le souci est que ben on ma passer le reste et on me dit vas y integre...... ben vu comment sa fait je pige pas tout la.Par contre tu utilise GCC et certaine erreur ne sont pas afficher sur mon environnement de dev (Borland)

    FullCapture (&Tabx, &Taby);
    quel boulet je fais j'ai même pas vu sa .... merci.

    Je soupçonne une inversion dans les paramètres
    arf oui en effet j'ai passer le code ici alors que j'avais déjà entamer certaine modification
    désolé.

    Sinon merci pour la correction. Par contre pour le iStart oui j'ai pas fait attention en reparamétrant les case des variable mais on le met en char uniquement pas en unsigned.

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

Discussions similaires

  1. Probléme de pointeur avec des pointeurs de char *
    Par marime dans le forum Débuter
    Réponses: 4
    Dernier message: 30/09/2013, 13h14
  2. problème de fonction avec des pointeurs
    Par bl4cksky dans le forum Débuter
    Réponses: 16
    Dernier message: 09/09/2013, 12h28
  3. Réponses: 7
    Dernier message: 27/09/2012, 16h29
  4. problème char-actéristique avec des pointeurs
    Par Antigonos Ier Gonatas dans le forum C
    Réponses: 11
    Dernier message: 16/04/2007, 21h22
  5. Problèmes avec des vues
    Par dady dans le forum MFC
    Réponses: 22
    Dernier message: 09/01/2004, 16h26

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