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

Images Discussion :

Compiler un fichier .cc


Sujet :

Images

  1. #1
    Membre du Club
    Femme Profil pro
    Inscrit en
    Avril 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Avril 2011
    Messages : 128
    Points : 56
    Points
    56
    Par défaut Compiler un fichier .cc
    Salut, j'ai trouvé un programme matlab sur l'internet (HOG-based Template Matching) que je dois compiler tout d'abord une liste de fichier .cc tout en exécutant le script suivant :
    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
    mex -O resize.cc
    mex -O dt.cc
    mex -O features.cc
    mex -O getdetections.cc
     
    % use one of the following depending on your setup
    % 0 is fastest, 3 is slowest 
     
    % 0) multithreaded convolution using SSE
    mex -O fconvsse.cc -o fconv
     
    % 1) multithreaded convolution using blas
    %    WARNING: the blas version does not work with matlab >= 2010b 
    %    and Intel CPUs
    % mex -O fconvblasMT.cc -lmwblas -o fconv
     
    % 2) mulththreaded convolution without blas
    % mex -O fconvMT.cc -o fconv
     
    % 3) convolution using blas
    % mex -O fconvblas.cc -lmwblas -o fconv
     
    % 4) basic convolution, very compatible
    % mex -O fconv.cc -o fconv
    Mais matlab m'affiche l'erreur suivant:
    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
    Error resize.cc: 36  undeclared identifier `alphainfo' 
    Warning resize.cc: 36  Statement has no effect 
    Error resize.cc: 36  syntax error; found `ofs' expecting `;' 
    Error resize.cc: 36  undeclared identifier `ofs' 
    Error resize.cc: 36  type error: pointer expected 
    Warning resize.cc: 36  Statement has no effect 
    Error resize.cc: 37  illegal statement termination 
    Error resize.cc: 37  skipping `int' 
    Error resize.cc: 37  undeclared identifier `k' 
    Error resize.cc: 38  syntax error; found `int' expecting `;' 
    Error resize.cc: 38  syntax error; found `int' expecting `;' 
    Error resize.cc: 38  syntax error; found `int' expecting `)' 
    Error resize.cc: 38  skipping `int' 
    Error resize.cc: 38  undeclared identifier `dy' 
    Warning resize.cc: 38  Statement has no effect 
    Warning resize.cc: 38  unreachable code 
    Error resize.cc: 38  syntax error; found `)' expecting `;' 
    Error resize.cc: 38  illegal statement termination 
    Error resize.cc: 38  skipping `)' 
    Error resize.cc: 47  type error: pointer expected 
    Error resize.cc: 47  left operand of . has incompatible type `int' 
    Error resize.cc: 48  type error: pointer expected 
    Error resize.cc: 48  left operand of . has incompatible type `int' 
    Error resize.cc: 49  type error: pointer expected 
    Error resize.cc: 49  too many errors 
     
      C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Compile of 'resize.cc' failed. 
     
    Error using mex (line 206)
    Unable to complete successfully.
     
    Error in compile (line 1)
    mex -O resize.cc
    quel est le problème? Merci.

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Les fichiers .cc contiennent des programmes en C++ et non MATLAB
    Pourrait-on avoir un aperçu de ce fichier resize.cc qui semble poser problème ?

  3. #3
    Membre du Club
    Femme Profil pro
    Inscrit en
    Avril 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Avril 2011
    Messages : 128
    Points : 56
    Points
    56
    Par défaut
    Voici ce que contient le fichier resize.cc :
    Code c++ : 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 <math.h>
    #include <assert.h>
    #include <string.h>
    #include "mex.h"
     
    /*
     * Fast image subsampling.
     * This is used to construct the feature pyramid.
     */
     
    // struct used for caching interpolation values
    struct alphainfo {
      int si, di;
      double alpha;
    };
     
    // copy src into dst using pre-computed interpolation values
    void alphacopy(double *src, double *dst, struct alphainfo *ofs, int n) {
      struct alphainfo *end = ofs + n;
      while (ofs != end) {
        dst[ofs->di] += ofs->alpha * src[ofs->si];
        ofs++;
      }
    }
     
    // resize along each column
    // result is transposed, so we can apply it twice for a complete resize
    void resize1dtran(double *src, int sheight, double *dst, int dheight, 
    		  int width, int chan) {
      double scale = (double)dheight/(double)sheight;
      double invscale = (double)sheight/(double)dheight;
     
      // we cache the interpolation values since they can be 
      // shared among different columns
      int len = (int)ceil(dheight*invscale) + 2*dheight;
      alphainfo ofs[len];
      int k = 0;
      for (int dy = 0; dy < dheight; dy++) {
        double fsy1 = dy * invscale;
        double fsy2 = fsy1 + invscale;
        int sy1 = (int)ceil(fsy1);
        int sy2 = (int)floor(fsy2);       
     
        if (sy1 - fsy1 > 1e-3) {
          assert(k < len);
          assert(sy-1 >= 0);
          ofs[k].di = dy*width;
          ofs[k].si = sy1-1;
          ofs[k++].alpha = (sy1 - fsy1) * scale;
        }
     
        for (int sy = sy1; sy < sy2; sy++) {
          assert(k < len);
          assert(sy < sheight);
          ofs[k].di = dy*width;
          ofs[k].si = sy;
          ofs[k++].alpha = scale;
        }
     
        if (fsy2 - sy2 > 1e-3) {
          assert(k < len);
          assert(sy2 < sheight);
          ofs[k].di = dy*width;
          ofs[k].si = sy2;
          ofs[k++].alpha = (fsy2 - sy2) * scale;
        }
      }
     
      // resize each column of each color channel
      bzero(dst, chan*width*dheight*sizeof(double));
      for (int c = 0; c < chan; c++) {
        for (int x = 0; x < width; x++) {
          double *s = src + c*width*sheight + x*sheight;
          double *d = dst + c*width*dheight + x;
          alphacopy(s, d, ofs, k);
        }
      }
    }
     
    // main function
    // takes a double color image and a scaling factor
    // returns resized image
    mxArray *resize(const mxArray *mxsrc, const mxArray *mxscale) {
      double *src = (double *)mxGetPr(mxsrc);
      const int *sdims = mxGetDimensions(mxsrc);
      if (mxGetNumberOfDimensions(mxsrc) != 3 || 
          mxGetClassID(mxsrc) != mxDOUBLE_CLASS)
        mexErrMsgTxt("Invalid input");  
     
      double scale = mxGetScalar(mxscale);
      if (scale > 1)
        mexErrMsgTxt("Invalid scaling factor");   
     
      int ddims[3];
      ddims[0] = (int)round(sdims[0]*scale);
      ddims[1] = (int)round(sdims[1]*scale);
      ddims[2] = sdims[2];
      mxArray *mxdst = mxCreateNumericArray(3, ddims, mxDOUBLE_CLASS, mxREAL);
      double *dst = (double *)mxGetPr(mxdst);
     
      double *tmp = (double *)mxCalloc(ddims[0]*sdims[1]*sdims[2], sizeof(double));
      resize1dtran(src, sdims[0], tmp, ddims[0], sdims[1], sdims[2]);
      resize1dtran(tmp, sdims[1], dst, ddims[1], ddims[0], sdims[2]);
      mxFree(tmp);
     
      return mxdst;
    }
     
    // matlab entry point
    // dst = resize(src, scale)
    // image should be color with double values
    void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 
      if (nrhs != 2)
        mexErrMsgTxt("Wrong number of inputs"); 
      if (nlhs != 1)
        mexErrMsgTxt("Wrong number of outputs");
      plhs[0] = resize(prhs[0], prhs[1]);
    }

  4. #4
    Invité
    Invité(e)
    Par défaut
    Avec quel compilateur travailles-tu ? LCC d'après ce que je vois...

    Ce code, malgré l'extension, est plutôt un code C, ligne 36, il manquerait alors un struct devant, et cela utilise un VLA qui requiert C99, qui n'est pas disponible sous LCC : il te faudrait alors allouer ta mémoire manuellement avec malloc() puis la libérer avec free() une fois fini.
    De même la déclaration de la variable dans le for(...) ou en "milieu de code" : c'est du C99, sinon il te faut déclarer toutes tes variables en début de bloc { }.

    Ligne 46 assert(sy-1 >= 0); sy n'est pas défini, je présume que c'est sy1.

  5. #5
    Membre du Club
    Femme Profil pro
    Inscrit en
    Avril 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Avril 2011
    Messages : 128
    Points : 56
    Points
    56
    Par défaut
    Oui, je compile avec Lcc-win32. Avec quel compilateur vous me conseillez de travailler avec?

  6. #6
    Invité
    Invité(e)
    Par défaut
    Si tu souhaites pouvoir utiliser les features du C99, soit GCC soit Clang.

  7. #7
    Membre du Club
    Femme Profil pro
    Inscrit en
    Avril 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Avril 2011
    Messages : 128
    Points : 56
    Points
    56
    Par défaut
    J'ai téléchargé le GCC et j'ai l'ajouté dans les variables du système, mais maintenant lorsque je tape le commande :
    il m'affiche
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Welcome to mex -setup.  This utility will help you set up  
    a default compiler.  For a list of supported compilers, see  
    http://www.mathworks.com/support/compilers/R2013a/win32.html 
     
    Please choose your compiler for building MEX-files: 
     
    Would you like mex to locate installed compilers [y]/n?  mex -setup
     
    Select a compiler: 
    [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2013a\sys\lcc 
     
    [0] None 
     
    Compiler:
    Comment je peux spécifier le GCC pour matlab?

  8. #8
    Invité
    Invité(e)
    Par défaut
    Un minimum de recherches t'aurais vite mené à gnumex

Discussions similaires

  1. [MASM] Compiler un fichier .sys ?
    Par - Robby - dans le forum x86 16-bits
    Réponses: 12
    Dernier message: 08/01/2008, 12h28
  2. [Info]Comment compiler un fichier sans le lancer ?
    Par blan dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 10/10/2005, 18h03
  3. [SOAP]Compilation du fichier stdsoap2.cpp (gSoap)
    Par Neo41 dans le forum C++Builder
    Réponses: 2
    Dernier message: 11/02/2005, 15h55
  4. Réponses: 1
    Dernier message: 18/06/2004, 02h12
  5. Réponses: 2
    Dernier message: 25/10/2002, 23h19

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