Dll vc++

uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008 - 17 juin 2008 à 10:32
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008 - 18 juin 2008 à 21:04
Bonjour à tous

J'ai un projet dll en visual c++, quand j'exécute tout va bien mais le fichier .dll ne se génére pas.
Est ce que vous avez une idée.

Merci

bonne journée

13 réponses

Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 11:02
Salut

Est tu sur que ta dll ne s'est pas générée? As tu bien regardé dans tous les repertoires debug ou release de ton projet?

En fait, il est inutile d'exécuter ton projet mais il faut seulement le compiler (Build)

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 13:02
bonjour

merci pour la reponse
Quand j'utilise cette dll dans une application c#, une exception apparait
unable to load DLL (Exception HRESULT 0x8007007E)
est ce que vous avez une idee

merci beaucoup
0
Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 13:11
Et comment tu declares ta dll dans ton programme C#?

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 13:32
j'utilise la ligne de commande suivante

[DllImport(@"C:\Essai\Offline\bin\Debug\SIFTGPU.dll", EntryPoint="calculHist")]
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 13:40
Essaie queque chose comme ca:

[DllImport("C:\\Essai\\Offline\\bin\\Debug\\SIFTGPU.dll"]
private static extern type calculHist(avec les arguments la)

type etant le type de retour de ta fonction.

Dans ta dll, cette fonction doit etre precede de : extern

"C"
__declspec(
dllexport)

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 17:45
la même exception revient?
0
Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 17:54
C'est une question ou une affirmation?

Si c'est une affirmation, il faut verifier le chemin de ta dll, et surtout mettre une fonction vide dans ta dll pour etre sur que l'erreur ne provient pas de ta dll.

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 21:46
J'ai trouve' la meme exception. SVP, Y a-t-il d'autres suggestions ?
Et merci d'avance.
0
Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 23:00
Montre donc nous le code de ta dll ainsi que la manière dont tu la déclares en C# avec la ligne ou l'exception se produit.
Avec ça on y verra plus clair.

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 23:13
Voilà le code de ma dll

#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include <cvcam.h>
#include
#include <string>
#include <stdio.h >
#include <stdlib.h >
#include "stdafx.h"
using std::string;

extern "C"
__declspec(dllexport) double* calculHist(string path)

      

        {  

            double h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15,h16,h17,h18,h19,h20,h21,h22,h23,h24,h25,h26,h27,h28,h29,h30,h31,h32,h33,h34,h35,h36,h37,h38,h39,h40,h41,h42,h43,h44,h45,h46,h47,h48,h49,h50,h51,h52,h53,h54,h55,h56,h57,h58,h59,h60,h61,h62,h63,h64;        
            int r;
            int g;
            int b;
            int i,j;
        
            h1= 0;h2=0;h3=0;h4=0;h5=0;h6=0;h7=0;h8=0;h9=0;h10=0;h11=0;h12=0;h13=0;h14=0;h15=0;h16=0;h17=0;h18=0;h19=0;h20=0;h21=0;h22=0;h23=0;h24=0;h25=0;h26=0;h27=0;h28=0;h29=0;h30=0;h31=0;h32=0;h33=0;h34=0;h35=0;h36=0;h37=0;h38=0;h39=0;h40=0;h41=0;h42=0;h43=0;h44=0;h45=0;h46=0;h47=0;h48=0;h49=0;h50=0;h51=0;h52=0;h53=0;h54=0;h55=0;h56=0;h57=0;h58=0;h59=0;h60=0;h61=0;h62=0;h63=0;h64=0;
            double hist[64];
        int c1[3] = { 0, 0, 0 } ;
        int c2[3]= {1, 0, 0};
        int c3[3] = { 2, 0, 0};
        int c4[3] = { 3, 0, 0} ;
        int c5 [3]= { 1, 1, 0} ;
        int c6 [3]= { 1, 2, 0} ;
        int c7 [3]= { 1, 3, 0} ;
        int c8 [3]= { 1, 1, 1 } ;
        int c9 [3]= { 1, 1, 2 } ;
        int c10 [3]= { 1, 1, 3 } ;
        int c11 [3]= {  1, 2, 1 } ;
        int c12 [3]= { 1, 2, 2 } ;
        int c13 [3]= { 1, 2, 3 } ;
        int c14 [3]= { 1, 3, 1 } ;
        int c15 [3]= { 1, 3, 2 } ;
        int c16 [3]= { 1, 3, 3 } ;
        int c17 [3]= { 2, 1, 0 } ;
        int c18 [3]= { 2, 2, 0 } ;
        int c19 [3]= { 2, 3, 0 } ;
        int c20 [3]= { 2, 1, 1 } ;
        int c21 [3]= { 2, 1, 2 } ;
        int c22 [3]= { 2, 1, 3 } ;
        int c23 [3]= { 2, 2, 1 } ;
        int c24 [3]= { 2, 2, 2 } ;
        int c25 [3]= { 2, 2, 3 } ;
        int c26 [3]= { 2, 3, 1 } ;
        int c27 [3]= { 2, 3, 2 } ;
        int c28 [3]= { 2, 3, 3 } ;
        int c29 [3]= { 3, 1, 0 } ;
        int c30 [3]= { 3, 1, 1 } ;
        int c31 [3]= {  3, 1, 2 } ;
        int c32 [3]= { 3, 1, 3 } ;
        int c33 [3]= { 3, 2, 0 } ;
        int c34 [3]= { 3, 2, 1 } ;
        int c35 [3]= { 3, 2, 2 } ;
        int c36 [3]= {  3, 2, 3} ;
        int c37 [3]= { 3, 3, 0 } ;
        int c38 [3]= { 3, 3, 1 } ;
        int c39 [3]= { 3, 3, 2 } ;
        int c40 [3]= { 3, 3, 3 } ;
        int c41 [3]= { 0, 0, 1 };
        int c42 [3]={ 0, 0, 2 };
        int c43 [3]={ 0, 0, 3 };
        int c44 [3]={ 0, 1, 1 };
        int c45 [3]={ 0, 2, 1 };
        int c46 [3]= { 0, 3, 1 };
        int c47 [3]={ 0, 1, 2 };
        int c48 [3]={ 0, 2, 2 };
        int c49 [3]={ 0, 3, 2 };
        int c50 [3]={ 0, 1, 3 };
        int c51 [3]= { 0, 2, 3 };
        int c52 [3]={ 0, 3, 3 };
        int c53 [3]={ 0, 1, 0 };
        int c54 [3]={ 0, 2, 0 };
        int c55 [3]={ 0, 3, 0 };
        int c56 [3]= { 1, 0, 1} ;
        int c57 [3]= { 1, 0, 2 } ;
        int c58 [3]= { 1, 0, 3 } ;
        int c59 [3]= { 2, 0, 1 } ;
        int c60 [3]= { 2, 0, 2 } ;
        int c61 [3]= { 2, 0, 3 } ;
        int c62 [3]= { 3, 0, 1 } ;
        int c63 [3]= { 3, 0, 2 } ;
        int c64 [3]= { 3, 0, 3 } ;

      
        const char* p = path.data();
        IplImage* photo=cvLoadImage(p,3);
        int w=photo->width;
        int h=photo->height;
       
        uchar *data    = (uchar*) photo->imageData;
        CvMat *data1;
        cvLaplace(data,data1,3);
        CvMat *data2;
        cvMatMul(data1, data1, data2);
        for (i  ; i < w; i++)
            {
                for ( j  ; j < h; j++)
                {
                    r = 0 ;
                    g = 0;
                    b = 0;
                   
                    int pixelColorB =((uchar*)(photo->imageData + photo->widthStep*i))[j*3];
                    int pixelColorG =((uchar*)(photo->imageData + photo->widthStep*i))[j*3+1];
                    int pixelColorR =((uchar*)(photo->imageData + photo->widthStep*i))[j*3+2];
                    r = r + pixelColorR;
                    g = g + pixelColorG;
                    b = b + pixelColorB;

                    r = (r * 3) / 255;
                    g = (g * 3) / 255;
                    b = (b * 3) / 255;
                    double pond = cvmGet(data2,j,i);
                   if (c1[0]=r)
                          if (c1[1]=g)
                           if (c1[2]=b)
                           h1 = h1 + pond;
                   if (c2[0]=r)
                        if (c2[1]=g)
                            if (c2[2]=b)
                                h2 = h2 + pond;
                    if (c3[0]=r)
                        if (c3[1]=g)
                            if (c3[2]=b)
                                h3 = h3 + pond;
                    if (c4[0]=r)
                        if (c4[1]=g)
                            if (c4[2]=b)
                                h4 = h4 + pond;
                    if (c5[0]=r)
                        if (c5[1]=g)
                            if (c5[2]=b)
                                h5 = h5 + pond;
                    if (c6[0]=r)
                        if (c6[1]=g)
                            if (c6[2]=b)
                                h6 = h6 + pond;
                    if (c7[0]=r)
                        if (c7[1]=g)
                            if (c7[2]=b)
                                h7 = h7 + pond;
                    if (c8[0]=r)
                        if (c8[1]=g)
                            if (c8[2]=b)
                                h8 = h8 + pond;
                    if (c9[0]=r)
                        if (c9[1]=g)
                            if (c9[2]=b)
                                h9 = h9 + pond;
                    if (c10[0]=r)
                        if (c10[1]=g)
                            if (c10[2]=b)
                                h10 = h10 + pond;
                    if (c11[0]=r)
                        if (c11[1]=g)
                            if (c11[2]=b)
                                h11 = h11 + pond;
                    if (c12[0]=r)
                        if (c12[1]=g)
                            if (c12[2]=b)
                                h12 = h12 + pond;
                    if (c13[0]=r)
                        if (c13[1]=g)
                            if (c13[2]=b)
                                h13 = h13 + pond;
                    if (c14[0]=r)
                        if (c14[1]=g)
                            if (c14[2]=b)
                                h14 = h14 + pond;
                    if (c15[0]=r)
                        if (c15[1]=g)
                            if (c15[2]=b)
                                h15 = h15 + pond;
                    if (c16[0]=r)
                        if (c16[1]=g)
                            if (c16[2]=b)
                                h16 = h16 + pond;
                    if (c17[0]=r)
                        if (c17[1]=g)
                            if (c17[2]=b)
                                h17 = h17 + pond;
                    if (c18[0]=r)
                        if (c18[1]=g)
                            if (c18[2]=b)
                                h18 = h18 + pond;
                    if (c19[0]=r)
                        if (c19[1]=g)
                            if (c19[2]=b)
                                h19 = h19 + pond;
                    if (c20[0]=r)
                        if (c20[1]=g)
                            if (c20[2]=b)
                                h20 = h20 + pond;
                    if (c21[0]=r)
                        if (c21[1]=g)
                            if (c21[2]=b)
                                h21 = h21 + pond;
                    if (c22[0]=r)
                        if (c22[1]=g)
                            if (c22[2]=b)
                                h22 = h22 + pond;
                    if (c23[0]=r)
                        if (c23[1]=g)
                            if (c23[2]=b)
                                h23 = h23 + pond;
                    if (c24[0]=r)
                        if (c24[1]=g)
                            if (c24[2]=b)
                                h24 = h24 + pond;
                    if (c25[0]=r)
                        if (c25[1]=g)
                            if (c25[2]=b)
                                h25 = h25 + pond;
                    if (c26[0]=r)
                        if (c26[1]=g)
                            if (c26[2]=b)
                                h26 = h26 + pond;
                    if (c27[0]=r)
                        if (c27[1]=g)
                            if (c27[2]=b)
                                h27 = h27 + pond;
                    if (c28[0]=r)
                        if (c28[1]=g)
                            if (c28[2]=b)
                                h28 = h28 + pond;
                    if (c29[0]=r)
                        if (c29[1]=g)
                            if (c29[2]=b)
                                h29 = h29 + pond;
                    if (c30[0]=r)
                        if (c30[1]=g)
                            if (c30[2]=b)
                                h30 = h30 + pond;
                    if (c31[0]=r)
                        if (c31[1]=g)
                            if (c31[2]=b)
                                h31 = h31 + pond;
                    if (c32[0]=r)
                        if (c32[1]=g)
                            if (c32[2]=b)
                                h32 = h32 + pond;
                    if (c33[0]=r)
                        if (c33[1]=g)
                            if (c33[2]=b)
                                h33 = h33 + pond;
                    if (c34[0]=r)
                        if (c34[1]=g)
                            if (c34[2]=b)
                                h34 = h34 + pond;
                    if (c35[0]=r)
                        if (c35[1]=g)
                            if (c35[2]=b)
                                h35 = h35 + pond;
                    if (c36[0]=r)
                        if (c36[1]=g)
                            if (c36[2]=b)
                                h36 = h36 + pond;
                    if (c37[0]=r)
                        if (c37[1]=g)
                            if (c37[2]=b)
                                h37 = h37 + pond;
                    if (c38[0]=r)
                        if (c38[1]=g)
                            if (c38[2]=b)
                                h38 = h38 + pond;
                    if (c39[0]=r)
                        if (c39[1]=g)
                            if (c39[2]=b)
                                h39 = h39 + pond;
                    if (c40[0]=r)
                        if (c40[1]=g)
                            if (c40[2]=b)
                                h40 = h40 + pond;
                    if (c41[0]=r)
                        if (c41[1]=g)
                            if (c41[2]=b)
                                h41 = h41 + pond;
                    if (c42[0]=r)
                        if (c42[1]=g)
                            if (c42[2]=b)
                                h42 = h42 + pond;
                    if (c43[0]=r)
                        if (c43[1]=g)
                            if (c43[2]=b)
                                h43 = h43 + pond;
                    if (c44[0]=r)
                        if (c44[1]=g)
                            if (c44[2]=b)
                                h44 = h44 + pond;
                    if (c45[0]=r)
                        if (c45[1]=g)
                            if (c45[2]=b)
                                h45 = h45 + pond;
                    if (c46[0]=r)
                        if (c46[1]=g)
                            if (c46[2]=b)
                                h46 = h46 + pond;
                    if (c47[0]=r)
                        if (c47[1]=g)
                            if (c47[2]=b)
                                h47 = h47 + pond;
                    if (c48[0]=r)
                        if (c48[1]=g)
                            if (c48[2]=b)
                                h48 = h48 + pond;
                    if (c49[0]=r)
                        if (c49[1]=g)
                            if (c49[2]=b)
                                h49 = h49 + pond;
                    if (c50[0]=r)
                        if (c50[1]=g)
                            if (c50[2]=b)
                                h50 = h50 + pond;
                    if (c51[0]=r)
                        if (c51[1]=g)
                            if (c51[2]=b)
                                h51 = h51 + pond;
                    if (c52[0]=r)
                        if (c52[1]=g)
                            if (c52[2]=b)
                                h52 = h52 + pond;
                    if (c53[0]=r)
                        if (c53[1]=g)
                            if (c53[2]=b)
                                h53 = h53 + pond;
                    if (c54[0]=r)
                        if (c54[1]=g)
                            if (c54[2]=b)
                                h54 = h54 + pond;
                    if (c55[0]=r)
                        if (c55[1]=g)
                            if (c55[2]=b)
                                h55 = h55 + pond;
                    if (c56[0]=r)
                        if (c56[1]=g)
                            if (c56[2]=b)
                                h56 = h56 + pond;
                    if (c57[0]=r)
                        if (c57[1]=g)
                            if (c57[2]=b)
                                h57 = h57 + pond;
                    if (c58[0]=r)
                        if (c58[1]=g)
                            if (c58[2]=b)
                                h58 = h58 + pond;
                    if (c59[0]=r)
                        if (c59[1]=g)
                            if (c59[2]=b)
                                h59 = h59 + pond;
                    if (c60[0]=r)
                        if (c60[1]=g)
                            if (c60[2]=b)
                                h60 = h60 + pond;
                    if (c61[0]=r)
                        if (c61[1]=g)
                            if (c61[2]=b)
                                h61 = h61 + pond;
                    if (c62[0]=r)
                        if (c62[1]=g)
                            if (c62[2]=b)
                                h62 = h62 + pond;
                    if (c63[0]=r)
                        if (c63[1]=g)
                            if (c63[2]=b)
                                h63 = h63 + pond;
                    if (c64[0]=r)
                        if (c64[1]=g)
                            if (c64[2]=b)
                                h64 = h64 + pond;
           
   
   
};
};

 
//double hist[64]= {h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15,h16,h17,h18,h19,h20,h21,h22,h23,h24,h25,h26,h27,h28,h29,h30,h31,h32,h33,h34,h35,h36,h37,h38,h39,h40,h41,h42,h43,h44,h45,h46,h47,h48,h49,h50,h51,h52,h53,h54,h55,h56,h57,h58,h59,h60,h61,h62,h63,h64};
//return hist[64];

hist[0]=h1;hist[1]=h2;hist[2]=h3;hist[3]=h4;hist[4]=h5;hist[5]=h6;hist[6]=h7;hist[7]=h8;hist[8]=h9;hist[9]=h10;
hist[10]=h11;hist[11]=h12;hist[12]=h13;hist[13]=h14;hist[14]=h15;hist[15]=h16;hist[16]=h17;hist[17]=h18;hist[18]=h19;hist[19]=h20;
hist[20]=h21;hist[21]=h22;hist[22]=h23;hist[23]=h24;hist[24]=h25;hist[25]=h26;hist[26]=h27;hist[27]=h28;hist[28]=h29;hist[29]=h30;
hist[30]=h31;hist[31]=h32;hist[32]=h33;hist[33]=h34;hist[34]=h35;hist[35]=h36;hist[36]=h37;hist[37]=h38;hist[38]=h39;hist[39]=h40;
hist[40]=h41;hist[41]=h42;hist[42]=h43;hist[43]=h44;hist[44]=h45;hist[45]=h46;hist[46]=h47;hist[47]=h48;hist[48]=h49;hist[49]=h50;
hist[50]=h51;hist[51]=h52;hist[52]=h53;hist[53]=h54;hist[54]=h55;hist[55]=h56;hist[56]=h57;hist[7]=h58;hist[58]=h59;hist[59]=h60;
hist[60]=h61;hist[61]=h62;hist[62]=h63;hist[63]=h64;

return hist;
};
extern "C"
  __declspec(dllexport) int* calculLSH (float sift[])

{
         int* lsh;
         int D1[20]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
         int D2[20]={20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
         int D3[20]={40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59};
         int D4[20]={60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79};
         int D5[20]={80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99};
         int D6[20]={100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119};
         int D7[20]={120, 121, 122, 123, 124, 125, 126, 127, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
         int D8[20]={0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38};
         int D9[20]={40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78};
         int D10[20]={80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118};
         int D11[20]={120, 122, 124, 126, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30};
         int D12[20]={1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39};
         int D13[20]={41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79};
         int D14[20]={81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119};
         int D15[20]={121, 123, 125, 127, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31};
         int D16[20]={0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57};
         int D17[20]={60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117};
         int D18[20]={120, 123, 126, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49};
         int D19[20]={0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95};
         int D20[20]={100, 105, 110, 115, 120, 125, 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52};
         int D21[20]={56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 1, 5};
         int D22[20]={9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 83, 87, 91, 95};
         int D23[20]={0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 3};
         int T1[20]={60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79};
         int T2[20]={80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99};
         int T3[20]={100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119};
         int T4[20]={120,60,65,70,75,80,85,90,95,100,105,110,115,120,61,66,71,76,81,86};
         int T5[20]={91,96,101,106,111,116,62,67,72,77,82,87,92,97,102,107,112,117,63,68};
         int T6[20]={72,77,82,87,92,97,102,107,112,117,64,69,74,79,84,89,94,99,104,109};
         int T7[20]={114,119,66,71,76,81,86,91,96,101,106,111,116,67,72,77,82,87,92,97};
         int T8[20]={102,107,112,117,68,73,78,83,88,93,98,103,108,113,118,69,74,79,84,89};
         int T9[20]={94,99,104,109,114,119,70,75,80,85,90,95,100,105,110,115,120,71,76,81};
         int T10[20]={86,91,96,101,106,111,116,72,77,82,87,92,97,102,107,112,117,73,79,83};
         int T11[20]={89,93,99,103,109,113,119,74,80,86,94,100,106,112,118,75,81,85,91,105};
         int T12[20]={111,117,76,82,88,94,100,106,112,118,60,66,72,78,84,90,96,102,108,114};
         int T13[20]={60,70,80,90,100,110,120,71,81,91,101,111,72,62,82,92,102,112,61,63};
         int T14[20]={73,83,93,103,113,110,120,71,81,91,74,64,84,94,104,114,75,65,85,95};
         int T15[20]={105,115,66,76,86,96,106,116,67,77,87,97,107,117,68,78,88,98,108,118};
         int T16[20]={79,69,89,99,109,119,80,90,100,110,120,60,75,90,105,120,61,76,81,96};
         int T17[20]={62,82,93,113,120,111,72,71,81,91,64,64,84,94,74,114,75,65,105,95};
         int T18[20]={65,72,93,63,120,102,72,77,88,99,64,98,84,104,74,94,75,65,115,95};
         int T19[20]={105,72,103,63,72,102,92,97,98,79,64,88,84,104,74,94,105,85,65,95};
         int T20[20]={95,63,103,63,73,103,93,97,98,79,63,83,83,104,73,94,105,75,68,90};
         int T21[20]={96,76,106,61,77,112,93,94,67,79,98,88,84,65,71,72,105,85,65,65};
         int T22[20]={96,106,103,61,60,120,70,71,80,81,90,98,84,75,71,72,65,85,90,105};
         int T23[20]={83,89,103,101,100,98,70,91,80,101,90,108,64,65,71,82,95,65,80,90};
         int i;

         // Initialisation de vecteurs LSH
        
         string g1="00000000000000000000";
         string g2="00000000000000000000";
         string g3="00000000000000000000";
         string g4="00000000000000000000";
         string g5="00000000000000000000";
         string g6="00000000000000000000";
         string g7="00000000000000000000";
         string g8="00000000000000000000";
         string g9="00000000000000000000";
         string g10="00000000000000000000";
         string g11="00000000000000000000";
         string g12="00000000000000000000";
         string g13="00000000000000000000";
         string g14="00000000000000000000";
         string g15="00000000000000000000";
         string g16="00000000000000000000";
         string g17="00000000000000000000";
         string g18="00000000000000000000";
         string g19="00000000000000000000";
         string g20="00000000000000000000";
         string g21="00000000000000000000";
         string g22="00000000000000000000";
         string g23="00000000000000000000";
         

       
         for (i=0;i<20;i++)
         {
             if ( sift[D1[i]]>= T1[i])
               
                 g1[i]=1;

             if (sift[D2[i]]>= T2[i])
               
                 g2[i]=1;

             if (sift[D3[i]]>= T3[i])
           
                 g3[i]=1;

             if (sift[D4[i]]>= T4[i])
           
                 g4[i]=1;

             if (sift[D5[i]]>= T5[i])
             
                 g5[i]=1;

             if (sift[D6[i]]>= T6[i])
               
                 g6[i]=1;

             if (sift[D7[i]]>= T7[i])
               
                 g7[i]=1;

             if (sift[D8[i]]>= T8[i])
             
                 g8[i]=1;

             if (sift[D9[i]]>= T9[i])
           
                 g9[i]=1;

             if (sift[D10[i]]>= T10[i])
             
                 g10[i]=1;

             if (sift[D11[i]]>= T11[i])
               
                 g11[i]=1;

             if (sift[D12[i]]>= T12[i])
               
                 g12[i]=1;

             if (sift[D13[i]]>= T13[i])
               
                 g13[i]=1;

             if (sift[D14[i]]>= T14[i])
           
                 g14[i]=1;

             if (sift[D15[i]]>= T15[i])
             
                 g15[i]=1;

             if (sift[D16[i]]>= T16[i])
           
                 g16[i]=1;

             if (sift[D17[i]]>= T17[i])
           
                 g17[i]=1;

             if (sift[D18[i]]>= T18[i])
           
                 g18[i]=1;

             if (sift[D19[i]]>= T19[i])
           
                 g19[i]=1;

             if (sift[D20[i]]>= T20[i])
               
                 g20[i]=1;
            

             
             if (sift[D21[i]]>= T21[i])
           
                 g21[i]=1;

             
             if (sift[D22[i]]>= T22[i])
               
                 g22[i]=1;

             
             if (sift[D23[i]]>= T23[i])
               
                 g23[i]=1;

         }
       
         lsh[0]=atoi(g1.c_str());
             lsh[1]=atoi(g2.c_str());
             lsh[2]=atoi(g3.c_str());
             lsh[3]=atoi(g4.c_str());
             lsh[4]=atoi(g5.c_str());
             lsh[5]=atoi(g6.c_str());
             lsh[6]=atoi(g7.c_str());
             lsh[7]=atoi(g8.c_str());
             lsh[8]=atoi(g9.c_str());
             lsh[9]=atoi(g10.c_str());
             lsh[10]=atoi(g11.c_str());
             lsh[11]=atoi(g12.c_str());
             lsh[12]=atoi(g13.c_str());
             lsh[13]=atoi(g14.c_str());
             lsh[14]=atoi(g15.c_str());
             lsh[15]=atoi(g16.c_str());
             lsh[16]=atoi(g17.c_str());
             lsh[17]=atoi(g18.c_str());
             lsh[18]=atoi(g19.c_str());
             lsh[19]=atoi(g20.c_str());
             lsh[20]=atoi(g21.c_str());
             lsh[21]=atoi(g22.c_str());
             lsh[22]=atoi(g23.c_str());
       
         
         return lsh;
          }

dans le fichier .def de dll:

EXPORTS
   CreateNewSiftGPU @3
   calculLSH @2
   calculHist @1

Pour le code utilisé en c# pour appeler la dll

using System.Runtime.InteropServices;
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.ComponentModel;
using System.Drawing;
using MySql.Data.MySqlClient;

using System.Windows.Forms;

namespace Offline
{
    class Histogramme
    {

        [DllImport(@"C:\\Essai\\SiftGPU-0.5.302\\SiftGPU\\SiftGPU\\bin\\SIFTGPU.dll")]
         private static extern IntPtr calculHist(string path);
    

        public unsafe void calHist(string path)
        {

            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection();
            MySqlCommand MyCommand1 = new MySqlCommand();
            MySqlCommand MyCommand2 = new MySqlCommand();

            double[] hist = new double[64];

            try
            {

                String myConnectionString;
                myConnectionString = "server=" + "127.0.0.1" + ";" + "uid=" + "root" + ";" + "pwd=" + "151284" + ";" + "database=" + "base pfe" + ";";
                conn.ConnectionString = myConnectionString;
                conn.Open();

                IntPtr ptr = calculHist(path);
                Marshal.Copy(ptr, hist, 0, 64);
            

                MyCommand1.CommandText = "INSERT INTO histogramme(id_hist,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`h7`,`h8`,`h9`,`h10`,`h11`,`h12`,`h13`,`h14`,`h15`,`h16`,`h17`,`h18`,`h19`,`h20`,`h21`,`h22`,`h23`,`h24`,`h25`,`h26`,`h27`,`h28`,`h29`,`h30`,`h31`,`h32`,`h33`,`h34`,`h35`,`h36`,`h37`,`h38`,`h39`,`h40`,`h41`,`h42`,`h43`,`h44`,`h45`,`h46`,`h47`,`h48`,`h49`,`h50`,`h51`,`h52`,`h53`,`h54`,`h55`,`h56`,`h57`,`h58`,`h59`,`h60`,`h61`,`h62`,`h63`,`h64) VALUES(null,'" + hist[0] + "','" + hist[1] + "','" + hist[2] + "','" + hist[3] + "','" + hist[4] + "','" + hist[5] + "','" + hist[6] + "','" + hist[7] + "','" + hist[8] + "','" + hist[9] + "','" + hist[10] + "','" + hist[11] + "','" + hist[12] + "','" + hist[13] + "','" + hist[14] + "','" + hist[15] + "','" + hist[16] + "','" + hist[17] + "','" + hist[18] + "','" + hist[19] + "','" + hist[20] + "','" + hist[21] + "','" + hist[22] + "','" + hist[23] + "','" + hist[24] + "','" + hist[25] + "','" + hist[26] + "','" + hist[27] + "','" + hist[28] + "','" + hist[29] + "','" + hist[30] + "','" + hist[31] + "','" + hist[32] + "','" + hist[33] + "','" + hist[34] + "','" + hist[35] + "','" + hist[36] + "','" + hist[37] + "','" + hist[38] + "','" + hist[39] + "','" + hist[40] + "','" + hist[41] + "','" + hist[42] + "','" + hist[43] + "','" + hist[44] + "','" + hist[45] + "','" + hist[46] + "','" + hist[47] + "','" + hist[48] + "','" + hist[49] + "', '" + hist[50] + "','" + hist[51] + "','" + hist[52] + "','" + hist[53] + "','" + hist[54] + "','" + hist[55] + "','" + hist[56] + "','" + hist[57] + "','" + hist[58] + "','" + hist[59] + "','" + hist[60] + "','" + hist[61] + "','" + hist[62] + "','" + hist[63] + "')";
                MyCommand1.Connection = conn;
                MyCommand1.ExecuteNonQuery();

                conn.Close();
            }
            catch(System.Exception e){
           
                MessageBox.Show(e.Message);
            }
        }

    }
}

Merci beaucoup
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
17 juin 2008 à 23:15
l'exception apparait dans cette ligne

IntPtr ptr = calculHist(path);
0
Pistol_Pete Messages postés 1053 Date d'inscription samedi 2 octobre 2004 Statut Membre Dernière intervention 9 juillet 2013 7
17 juin 2008 à 23:53
Bon ta fonction dans ta dll retourne un pointeur sur un double
extern "C"
__declspec(dllexport) double* calculHist(string path)

Est tu sur que Intptr est un pointeur pour un double?

Enfin pour ta dll, je n'ai jamais vu un code aussi moche... Enfin ce n'ai que mon avis mais je suis sur que tu peux optimiser grandement cette fonction.
Tu veux faire quoi exactement, calculer l'histogramme de l'image?
Et fait attention, tous tes if sont des affectations:
if (c60[0]=r)
est equivalent à c60[0]=r;

Que ce passe t'il si tu commentes tout le code de cette fonction dans la dll, y a t'il toujours cette exception?

A+
0
uda2004 Messages postés 8 Date d'inscription vendredi 20 mars 2009 Statut Membre Dernière intervention 18 juin 2008
18 juin 2008 à 21:04
Bonsoir

la meme exception revient une autre fois.
Je suis entrain de calculer l'histogramme pondéré par le carré de laplacien d'une image.

Je sais pas où se trouve le probléme?

merci
0
Rejoignez-nous