Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori
Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori
Il primo headset open-back della linea INZONE arriva a 200 euro con driver derivati dalle cuffie da studio MDR-MV1 e un peso record di soli 199 grammi
Nutanix cambia pelle: dall’iperconvergenza alla piattaforma full stack per cloud ibrido e IA
Nutanix cambia pelle: dall’iperconvergenza alla piattaforma full stack per cloud ibrido e IA
Al .NEXT 2026 di Chicago, Nutanix ha mostrato quanto sia cambiata: una piattaforma software che gestisce VM, container e carichi di lavoro IA ovunque, dall’on-premise al cloud pubblico. Con un’esecuzione rapidissima sulle partnership e sulla migrazione da VMware
Recensione Xiaomi Pad 8 Pro: potenza bruta e HyperOS 3 per sfidare la fascia alta
Recensione Xiaomi Pad 8 Pro: potenza bruta e HyperOS 3 per sfidare la fascia alta
Xiaomi Pad 8 Pro adotta il potente Snapdragon 8 Elite all'interno di un corpo con spessore di soli 5,75 mm e pannello LCD a 144Hz flicker-free, per un tablet che può essere utilizzato con accessori dedicati di altissima qualità. Fra le caratteristiche esclusive, soprattutto per chi intende usarlo con la tastiera ufficiale, c'è la modalità Workstation di HyperOS 3, che trasforma Android in un sistema operativo con interfaccia a finestre
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 20-11-2007, 14:04   #1
pa_co
Member
 
L'Avatar di pa_co
 
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
Errore di compilazione in visual c++

Avrei bisogno di utilizzare il filtro di Gabor per disegnare delle impronte, ed ho trovato girando su internet due file che sembrano fare ciò(i file sono cvgabor.cpp e cvgabor.h) Tali file richiedono l'installazione delle OpenCv. Installo e configuro le openCv, ma appena aggiungo i file cvgabor.cpp e cvgabor.h e clicco su rebuild all mi compare l'errore: "fatal error C1010 - unexpected end of file while looking for precompiled header directive"... dove sbaglio?

Grazie
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein)
pa_co è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 14:31   #2
tomminno
Senior Member
 
Iscritto dal: Oct 2005
Messaggi: 3306
Quote:
Originariamente inviato da pa_co Guarda i messaggi
Avrei bisogno di utilizzare il filtro di Gabor per disegnare delle impronte, ed ho trovato girando su internet due file che sembrano fare ciò(i file sono cvgabor.cpp e cvgabor.h) Tali file richiedono l'installazione delle OpenCv. Installo e configuro le openCv, ma appena aggiungo i file cvgabor.cpp e cvgabor.h e clicco su rebuild all mi compare l'errore: "fatal error C1010 - unexpected end of file while looking for precompiled header directive"... dove sbaglio?

Grazie
Nelle proprietà del progetto devi deselezionare l'utilizzo degli header precompilati.
tomminno è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 15:05   #3
pa_co
Member
 
L'Avatar di pa_co
 
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
Deselezionando gli header precompilati al posto del primo errore me ne da circa 8... possibile che la strada seguita non sia quella giusta?
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein)
pa_co è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 17:08   #4
tomminno
Senior Member
 
Iscritto dal: Oct 2005
Messaggi: 3306
Quote:
Originariamente inviato da pa_co Guarda i messaggi
Deselezionando gli header precompilati al posto del primo errore me ne da circa 8... possibile che la strada seguita non sia quella giusta?
Sempre lo stesso errore o altri?
tomminno è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 17:38   #5
pa_co
Member
 
L'Avatar di pa_co
 
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
Quote:
Originariamente inviato da tomminno Guarda i messaggi
Sempre lo stesso errore o altri?
Mi da i seguenti errori alla classe cvgabor.cpp...io non sono molto competente...programma in c++ da non molto tempo...però suppongo che il problema dipenda dalla configurazione delle openCV...

warning C4305: '=' : truncation from 'const double' to 'float'
warning C4305: '=' : truncation from 'const double' to 'float'
error C2065: 'round' : undeclared identifier
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2374: 'i' : redefinition; multiple initialization
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
warning C4305: '=' : truncation from 'const double' to 'float'
warning C4305: '=' : truncation from 'const double' to 'float'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'

Error executing cl.exe.

Identity.exe - 8 error(s), 4 warning(s)


Grazie.
Pasquale.
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein)
pa_co è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 18:31   #6
tomminno
Senior Member
 
Iscritto dal: Oct 2005
Messaggi: 3306
Quote:
Originariamente inviato da pa_co Guarda i messaggi
Mi da i seguenti errori alla classe cvgabor.cpp...io non sono molto competente...programma in c++ da non molto tempo...però suppongo che il problema dipenda dalla configurazione delle openCV...

warning C4305: '=' : truncation from 'const double' to 'float'
warning C4305: '=' : truncation from 'const double' to 'float'
error C2065: 'round' : undeclared identifier
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2374: 'i' : redefinition; multiple initialization
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'
warning C4305: '=' : truncation from 'const double' to 'float'
warning C4305: '=' : truncation from 'const double' to 'float'
error C2360: initialization of 'i' is skipped by 'case' label
see declaration of 'i'

Error executing cl.exe.

Identity.exe - 8 error(s), 4 warning(s)


Grazie.
Pasquale.
No il problema dipende dal codice di cvgabor che non è parte delle OpenCV.
Per quanto riguarda round si dovrebbe risolvere con un #include <math.h>
Per quanto riguarda la "i", che pare essere dichiarata dentro uno switch, prova ad usare le parentesi graffe.
tomminno è offline   Rispondi citando il messaggio o parte di esso
Old 20-11-2007, 18:54   #7
pa_co
Member
 
L'Avatar di pa_co
 
Iscritto dal: Jul 2006
Città: Milano
Messaggi: 131
Per quanto riguarda la libreria <math.h> l'avevo inclusa, ma l'errore sul round me lo dava lo stesso. Ti allego il file su cui mi da gli errori...

cvgabor.cpp
Codice:
/***************************************************************************
 *   Copyright (C) 2006 by Mian Zhou   *
 *   [email protected]   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "cvgabor.h"
#include <math.h> 


CvGabor::CvGabor()
{
}


CvGabor::~CvGabor()
{
cvReleaseMat( &Real );
cvReleaseMat( &Imag );
}


/*!
    \fn CvGabor::CvGabor(int iMu, int iNu)
Construct a gabor

Parameters:
    	iMu		The orientation iMu*PI/8,
    	iNu 		The scale,

Returns:
	None,

Create a gabor with a orientation iMu*PI/8, and with a scale iNu. The sigma (Sigma) and the spatial frequence (F) are set to 2*PI and sqrt(2) defaultly. It calls Init() to generate parameters and kernels.
 */
 CvGabor::CvGabor(int iMu, int iNu)
{
    //Initilise the parameters 
    
    Sigma = 2*PI;
    F = sqrt(2.0);
    Init(iMu, iNu, Sigma, F);
    
}

/*!
    \fn CvGabor::CvGabor(int iMu, int iNu, double dSigma)
Construct a gabor

Parameters:
    	iMu		The orientation iMu*PI/8,
    	iNu 		The scale,
	dSigma 		The sigma value of Gabor,

Returns:
	None

Create a gabor with a orientation iMu*PI/8, a scale iNu, and a sigma value dSigma. The spatial frequence (F) is set to sqrt(2) defaultly. It calls Init() to generate parameters and kernels.
 */
CvGabor::CvGabor(int iMu, int iNu, float dSigma)
{ 
    F = sqrt(2.0);
    Init(iMu, iNu, dSigma, F);
}


/*!
    \fn CvGabor::CvGabor(int iMu, int iNu, double dSigma, double dF)
Construct a gabor

Parameters:
    	iMu		The orientation iMu*PI/8
    	iNu 		The scale
	dSigma 		The sigma value of Gabor
	dF		The spatial frequency 

Returns:
	None

Create a gabor with a orientation iMu*PI/8, a scale iNu, a sigma value dSigma, and a spatial frequence dF. It calls Init() to generate parameters and kernels.
 */
 CvGabor::CvGabor(int iMu, int iNu, float dSigma, float dF)
{

    Init(iMu, iNu, dSigma, dF);
    
}


/*!
    \fn CvGabor::CvGabor(double dPhi, int iNu)
Construct a gabor

Parameters:
    	dPhi		The orientation in arc
    	iNu 		The scale

Returns:
	None

Create a gabor with a orientation dPhi, and with a scale iNu. The sigma (Sigma) and the spatial frequence (F) are set to 2*PI and sqrt(2) defaultly. It calls Init() to generate parameters and kernels.
 */
 CvGabor::CvGabor(float dPhi, int iNu)
{

    Sigma = 2*PI;
    F = sqrt(2.0);
    Init(dPhi, iNu, Sigma, F);
}


/*!
    \fn CvGabor::CvGabor(double dPhi, int iNu, double dSigma)
Construct a gabor

Parameters:
    	dPhi		The orientation in arc
    	iNu 		The scale
	dSigma		The sigma value of Gabor

Returns:
	None
    
Create a gabor with a orientation dPhi, a scale iNu, and a sigma value dSigma. The spatial frequence (F) is set to sqrt(2) defaultly. It calls Init() to generate parameters and kernels.
 */
 CvGabor::CvGabor(float dPhi, int iNu, float dSigma)
{

    F = sqrt(2);
    Init(dPhi, iNu, dSigma, F);
}


/*!
    \fn CvGabor::CvGabor(double dPhi, int iNu, double dSigma, double dF)
Construct a gabor

Parameters:
    	dPhi		The orientation in arc
    	iNu 		The scale
	dSigma 		The sigma value of Gabor
	dF		The spatial frequency 

Returns:
	None

Create a gabor with a orientation dPhi, a scale iNu, a sigma value dSigma, and a spatial frequence dF. It calls Init() to generate parameters and kernels.
 */
 CvGabor::CvGabor(float dPhi, int iNu, float dSigma, float dF)
{

   Init(dPhi, iNu, dSigma,dF);
}

/*!
    \fn CvGabor::IsInit()
Determine the gabor is initilised or not

Parameters:
	None

Returns:
	a boolean value, TRUE is initilised or FALSE is non-initilised.

Determine whether the gabor has been initlized - variables F, K, Kmax, Phi, Sigma are filled.
 */
bool CvGabor::IsInit()
{

    return bInitialised;
}

/*!
    \fn CvGabor::mask_width()
Give out the width of the mask

Parameters:
	None

Returns:
	The long type show the width.

Return the width of mask (should be NxN) by the value of Sigma and iNu.
 */
long CvGabor::mask_width()
{

    long lWidth;
    if (IsInit() == FALSE)  {
       perror ("Error: The Object has not been initilised in mask_width()!\n");
       return 0;
    }
    else {
       //determine the width of Mask
      float dModSigma = Sigma/K;
      float dWidth = round(dModSigma*6 + 1);
      //test whether dWidth is an odd.
      if (fmod(dWidth, 2.0)==0.0) dWidth++;
      lWidth = (long)dWidth;

      return lWidth;
    }
}


/*!
    \fn CvGabor::creat_kernel()
Create gabor kernel

Parameters:
	None

Returns:
	None

Create 2 gabor kernels - REAL and IMAG, with an orientation and a scale 
 */
void CvGabor::creat_kernel()
{
    
    if (IsInit() == FALSE) {perror("Error: The Object has not been initilised in creat_kernel()!\n");}
    else {
      CvMat *mReal, *mImag;
      mReal = cvCreateMat( Width, Width, CV_32FC1);
      mImag = cvCreateMat( Width, Width, CV_32FC1);
      
      /**************************** Gabor Function ****************************/ 
      int x, y;
      float dReal;
      float dImag;
      float dTemp1, dTemp2, dTemp3;

      for (int i = 0; i < Width; i++)
      {
          for (int j = 0; j < Width; j++)
          {
              x = i-(Width-1)/2;
              y = j-(Width-1)/2;
              dTemp1 = (pow(K,2)/pow(Sigma,2))*exp(-(pow((float)x,2)+pow((float)y,2))*pow(K,2)/(2*pow(Sigma,2)));
              dTemp2 = cos(K*cos(Phi)*x + K*sin(Phi)*y) - exp(-(pow(Sigma,2)/2));
              dTemp3 = sin(K*cos(Phi)*x + K*sin(Phi)*y);
              dReal = dTemp1*dTemp2;
              dImag = dTemp1*dTemp3; 
              //gan_mat_set_el(pmReal, i, j, dReal);
	      cvmSet( (CvMat*)mReal, i, j, dReal );
              //gan_mat_set_el(pmImag, i, j, dImag);
              cvmSet( (CvMat*)mImag, i, j, dImag );

          } 
       }
       /**************************** Gabor Function ****************************/
       bKernel = TRUE;
       cvCopy(mReal, Real, NULL);
       cvCopy(mImag, Imag, NULL);
       printf("A %d x %d Gabor kernel with %f PI in arc is created.\n", Width, Width, Phi/PI);
       cvReleaseMat( &mReal );
       cvReleaseMat( &mImag );
     }
}


/*!
    \fn CvGabor::get_image(int Type)
Get the speific type of image of Gabor

Parameters:
	Type		The Type of gabor kernel, e.g. REAL, IMAG, MAG, PHASE   

Returns:
	Pointer to image structure, or NULL on failure	

Return an Image (gandalf image class) with a specific Type   "REAL"	"IMAG" "MAG" "PHASE"  
 */
IplImage* CvGabor::get_image(int Type)
{

    if(IsKernelCreate() == FALSE)
    { 
      perror("Error: the Gabor kernel has not been created in get_image()!\n");
      return NULL;
    }
    else
    {  
    IplImage* pImage;
    IplImage *newimage;
    newimage = cvCreateImage(cvSize(Width,Width), IPL_DEPTH_8U, 1 );
    //printf("Width is %d.\n",(int)Width);
    //printf("Sigma is %f.\n", Sigma);
    //printf("F is %f.\n", F);
    //printf("Phi is %f.\n", Phi);
    
    //pImage = gan_image_alloc_gl_d(Width, Width);
    pImage = cvCreateImage( cvSize(Width,Width), IPL_DEPTH_32F, 1 );
    
    
    CvMat* kernel = cvCreateMat(Width, Width, CV_32FC1);
    double ve;
    CvScalar S;
    switch(Type)
    {
        case 1:  //Real

           cvCopy( (CvMat*)Real, (CvMat*)kernel, NULL );
            //pImage = cvGetImage( (CvMat*)kernel, pImageGL );
           for (int i = 0; i < kernel->rows; i++)
    	   {
              for (int j = 0; j < kernel->cols; j++)
              {
                   ve = cvGetReal2D((CvMat*)kernel, i, j);
                   cvSetReal2D( (IplImage*)pImage, j, i, ve );
              }
           }
           break;
        case 2:  //Imag
           cvCopy( (CvMat*)Imag, (CvMat*)kernel, NULL );
           //pImage = cvGetImage( (CvMat*)kernel, pImageGL );
           for (int i = 0; i < kernel->rows; i++)
    	   {
              for (int j = 0; j < kernel->cols; j++)
              {
                   ve = cvGetReal2D((CvMat*)kernel, i, j);
                   cvSetReal2D( (IplImage*)pImage, j, i, ve );
              }
           }
           break; 
        case 3:  //Magnitude
           ///@todo  
           break;
        case 4:  //Phase
          ///@todo
           break;
    }
   
    cvNormalize((IplImage*)pImage, (IplImage*)pImage, 0, 255, CV_MINMAX, NULL );


    cvConvertScaleAbs( (IplImage*)pImage, (IplImage*)newimage, 1, 0 );

    cvReleaseMat(&kernel);

    cvReleaseImage(&pImage);

    return newimage;
    }
}


/*!
    \fn CvGabor::IsKernelCreate()
Determine the gabor kernel is created or not

Parameters:
	None

Returns:
	a boolean value, TRUE is created or FALSE is non-created.

Determine whether a gabor kernel is created.
 */
bool CvGabor::IsKernelCreate()
{

    return bKernel;
}


/*!
    \fn CvGabor::get_mask_width()
Reads the width of Mask

Parameters:
    None

Returns:
    Pointer to long type width of mask.
 */
long CvGabor::get_mask_width()
{
  return Width;
}


/*!
    \fn CvGabor::Init(int iMu, int iNu, double dSigma, double dF)
Initilize the.gabor

Parameters:
    	iMu 	The orientations which is iMu*PI.8
    	iNu 	The scale can be from -5 to infinit
    	dSigma 	The Sigma value of gabor, Normally set to 2*PI
    	dF 	The spatial frequence , normally is sqrt(2)

Returns:

Initilize the.gabor with the orientation iMu, the scale iNu, the sigma dSigma, the frequency dF, it will call the function creat_kernel(); So a gabor is created.
 */
void CvGabor::Init(int iMu, int iNu, double dSigma, double dF)
{
  //Initilise the parameters 
    bInitialised = FALSE;
    bKernel = FALSE;

    Sigma = dSigma;
    F = dF;
    
    Kmax = PI/2;
    
    // Absolute value of K
    K = Kmax / pow(F, (float)iNu);
    Phi = PI*iMu/8;
    bInitialised = TRUE;
    Width = mask_width();
    Real = cvCreateMat( Width, Width, CV_32FC1);
    Imag = cvCreateMat( Width, Width, CV_32FC1);
    creat_kernel();
}


/*!
    \fn CvGabor::Init(double dPhi, int iNu, double dSigma, double dF)
Initilize the.gabor

Parameters:
    	dPhi 	The orientations 
    	iNu 	The scale can be from -5 to infinit
    	dSigma 	The Sigma value of gabor, Normally set to 2*PI
    	dF 	The spatial frequence , normally is sqrt(2)

Returns:
	None

Initilize the.gabor with the orientation dPhi, the scale iNu, the sigma dSigma, the frequency dF, it will call the function creat_kernel(); So a gabor is created.filename 	The name of the image file
    	file_format 	The format of the file, e.g. GAN_PNG_FORMAT
    	image 	The image structure to be written to the file
    	octrlstr 	Format-dependent control structure

 */
void CvGabor::Init(double dPhi, int iNu, double dSigma, double dF)
{

    bInitialised = FALSE;
    bKernel = FALSE;
    Sigma = dSigma;
    F = dF;
    
    Kmax = PI/2;
    
    // Absolute value of K
    K = Kmax / pow(F, (float)iNu);
    Phi = dPhi;
    bInitialised = TRUE;
    Width = mask_width();
    Real = cvCreateMat( Width, Width, CV_32FC1);
    Imag = cvCreateMat( Width, Width, CV_32FC1);
    creat_kernel();
}



/*!
    \fn CvGabor::get_matrix(int Type)
Get a matrix by the type of kernel

Parameters:
    	Type		The type of kernel, e.g. REAL, IMAG, MAG, PHASE

Returns:
    	Pointer to matrix structure, or NULL on failure.

Return the gabor kernel.
 */
CvMat* CvGabor::get_matrix(int Type)
{
    if (!IsKernelCreate()) {perror("Error: the gabor kernel has not been created!\n"); return NULL;}
    switch (Type)
    {
      case CV_GABOR_REAL:
        return Real;
        break;
      case CV_GABOR_IMAG:
        return Imag;
        break;
      case CV_GABOR_MAG:
        return NULL;
        break;
      case CV_GABOR_PHASE:
        return NULL;
        break;
    }
}




/*!
    \fn CvGabor::output_file(const char *filename, Gan_ImageFileFormat file_format, int Type)
Writes a gabor kernel as an image file.

Parameters:
    	filename 	The name of the image file
    	file_format 	The format of the file, e.g. GAN_PNG_FORMAT
    	Type		The Type of gabor kernel, e.g. REAL, IMAG, MAG, PHASE   
Returns:
	None

Writes an image from the provided image structure into the given file and the type of gabor kernel.
 */
void CvGabor::output_file(const char *filename, int Type)
{
  IplImage *pImage;
  pImage = get_image(Type);
  if(pImage != NULL)
  {
    if( cvSaveImage(filename, pImage )) printf("%s has been written successfully!\n", filename);
    else printf("Error: writting %s has failed!\n", filename);
  }
  else 
    perror("Error: the image is empty in output_file()!\n"); 

  cvReleaseImage(&pImage);
}






/*!
    \fn CvGabor::show(int Type)
 */
void CvGabor::show(int Type)
{
    if(!IsInit()) {
        perror("Error: the gabor kernel has not been created!\n");
    }
    else {
    IplImage *pImage;
    pImage = get_image(Type);
    cvNamedWindow("Testing",1);
    cvShowImage("Testing",pImage);
    cvWaitKey(0);
    cvDestroyWindow("Testing");
    cvReleaseImage(&pImage);
    }

}




/*!
    \fn CvGabor::conv_img(IplImage *src, IplImage *dst, int Type)
 */
void CvGabor::conv_img(IplImage *src, IplImage *dst, int Type)
{
    double ve, re,im;

    CvMat *mat = cvCreateMat(src->width, src->height, CV_32FC1);
    for (int i = 0; i < src->width; i++)
    {
       for (int j = 0; j < src->height; j++)
       {
              ve = cvGetReal2D((IplImage*)src, j, i);
              cvSetReal2D( (CvMat*)mat, i, j, ve );
       }
    }

    CvMat *rmat = cvCreateMat(src->width, src->height, CV_32FC1);
    CvMat *imat = cvCreateMat(src->width, src->height, CV_32FC1);

    CvMat *kernel = cvCreateMat( Width, Width, CV_32FC1 );

    switch (Type)
    {
      case CV_GABOR_REAL:
        cvCopy( (CvMat*)Real, (CvMat*)kernel, NULL );
        cvFilter2D( (CvMat*)mat, (CvMat*)mat, (CvMat*)kernel, cvPoint( (Width-1)/2, (Width-1)/2));
        break;
      case CV_GABOR_IMAG:
        cvCopy( (CvMat*)Imag, (CvMat*)kernel, NULL );
        cvFilter2D( (CvMat*)mat, (CvMat*)mat, (CvMat*)kernel, cvPoint( (Width-1)/2, (Width-1)/2));
        break;
      case CV_GABOR_MAG:
        /* Real Response */
        cvCopy( (CvMat*)Real, (CvMat*)kernel, NULL );
        cvFilter2D( (CvMat*)mat, (CvMat*)rmat, (CvMat*)kernel, cvPoint( (Width-1)/2, (Width-1)/2));
        /* Imag Response */
        cvCopy( (CvMat*)Imag, (CvMat*)kernel, NULL );
        cvFilter2D( (CvMat*)mat, (CvMat*)imat, (CvMat*)kernel, cvPoint( (Width-1)/2, (Width-1)/2));
        /* Magnitude response is the square root of the sum of the square of real response and imaginary response */
        for (int i = 0; i < mat->rows; i++)
        {
           for (int j = 0; j < mat->cols; j++)
           {
               re = cvGetReal2D((CvMat*)rmat, i, j);
               im = cvGetReal2D((CvMat*)imat, i, j);
               ve = sqrt(re*re + im*im);
               cvSetReal2D( (CvMat*)mat, i, j, ve );
           }
        }       
        break;
      case CV_GABOR_PHASE:
        break;
    }
    
    if (dst->depth == IPL_DEPTH_8U)
    {
    	cvNormalize((CvMat*)mat, (CvMat*)mat, 0, 255, CV_MINMAX);
    	for (int i = 0; i < mat->rows; i++)
    	{
            for (int j = 0; j < mat->cols; j++)
            {
                ve = cvGetReal2D((CvMat*)mat, i, j);
                ve = cvRound(ve);
                cvSetReal2D( (IplImage*)dst, j, i, ve );
            }
        }
     }

     if (dst->depth == IPL_DEPTH_32F)
     {
         for (int i = 0; i < mat->rows; i++)
    	 {
            for (int j = 0; j < mat->cols; j++)
            {
                ve = cvGetReal2D((CvMat*)mat, i, j);
                cvSetReal2D( (IplImage*)dst, j, i, ve );
            }
         }
     }       

    cvReleaseMat(&kernel);
    cvReleaseMat(&imat);   
    cvReleaseMat(&rmat);
    cvReleaseMat(&mat);
}
cvgabor.h
Codice:
/***************************************************************************
 *   Copyright (C) 2006 by Mian Zhou   *
 *   [email protected]   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef CVGABOR_H
#define CVGABOR_H

#include <iostream>


#include <cv.h>
#include <highgui.h>

#define PI 3.14159265
#define FALSE 0
#define TRUE 1
#define CV_GABOR_REAL 1
#define CV_GABOR_IMAG 2
#define CV_GABOR_MAG  3
#define CV_GABOR_PHASE 4

/**
@author Mian Zhou
*/
class CvGabor{
public:
    CvGabor();

    ~CvGabor();

     CvGabor(int iMu, int iNu);
     CvGabor(int iMu, int iNu, float dSigma);
     CvGabor(int iMu, int iNu, float dSigma, float dF);
     CvGabor(float dPhi, int iNu);
     CvGabor(float dPhi, int iNu, float dSigma);
     CvGabor(float dPhi, int iNu, float dSigma, float dF);
    bool IsInit();
    long mask_width();
    IplImage* get_image(int Type);
    bool IsKernelCreate();
    long get_mask_width();
    void Init(int iMu, int iNu, double dSigma, double dF);
    void Init(double dPhi, int iNu, double dSigma, double dF);
    void output_file(const char *filename, int Type);
    CvMat* get_matrix(int Type);
    void show(int Type);
    void conv_img(IplImage *src, IplImage *dst, int Type);

protected:
    float Sigma;
    float F;
    float Kmax;
    float K;
    float Phi;
    bool bInitialised;
    bool bKernel;
    long Width;
    CvMat *Imag;
    CvMat *Real;
private:
    void creat_kernel();

};

#endif
__________________
"Due cose sono infinite: l'universo e la stupidità umana ma sull'universo nutro ancora dubbi..."(A. Einstein)
pa_co è offline   Rispondi citando il messaggio o parte di esso
Old 21-11-2007, 10:24   #8
tomminno
Senior Member
 
Iscritto dal: Oct 2005
Messaggi: 3306
Scopro adesso che Microsoft non ha implementato la funzione round (che è stata introdotta con il C99) quindi devi scrivere una funzione un'alternativa tipo:
Codice:
double round(double x) { return (x-floor(x))>0.5 ? ceil(x) : floor(x); }
Nel codice postato VS2005 non segnala altri errori.
tomminno è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori Sony INZONE H6 Air: il primo headset open-back d...
Nutanix cambia pelle: dall’iperconvergenza alla piattaforma full stack per cloud ibrido e IA Nutanix cambia pelle: dall’iperconvergenza alla ...
Recensione Xiaomi Pad 8 Pro: potenza bruta e HyperOS 3 per sfidare la fascia alta Recensione Xiaomi Pad 8 Pro: potenza bruta e Hyp...
NZXT H9 Flow RGB+, Kraken Elite 420 e F140X: abbiamo provato il tris d'assi di NZXT NZXT H9 Flow RGB+, Kraken Elite 420 e F140X: abb...
ASUS ROG Swift OLED PG34WCDN recensione: il primo QD-OLED RGB da 360 Hz ASUS ROG Swift OLED PG34WCDN recensione: il prim...
Ecovacs presenta la gamma 2026: paviment...
Efficienza energetica fino a 2.000 volte...
Lenovo 360: il programma di canale dell'...
Appena 10.000 qubit per rompere la critt...
Analisi dei transistor durante il funzio...
Attacco informatico a Booking.com: espos...
A quattro mesi dal divieto dei social ne...
NVIDIA GeForce RTX 5060 e 5060 Ti: in ar...
Rebellions, Arm e SK Telecom, nuova alle...
Modernizzazione delle app: Red Hat OpenS...
Nel mirino di Google c'è il back ...
PRAGMATA in bundle con GeForce RTX 5000:...
Le novità MOVA per il 2026: robot e impi...
Windows, stop all'attivazione telefonica...
ASUS porta la serie TUF nel formato Mini...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 04:04.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v