News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Translating C header

Started by Farabi, April 21, 2009, 03:15:10 AM

Previous topic - Next topic

Farabi

Am I right translating it?
Quote
  typedef struct _IplImage
    {
        int  nSize;         /* sizeof(IplImage) */
        int  ID;            /* version (=0)*/
        int  nChannels;     /* Most of OpenCV functions support 1,2,3 or 4 channels */
        int  alphaChannel;  /* ignored by OpenCV */
        int  depth;         /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
                               IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
        char colorModel[4]; /* ignored by OpenCV */
        char channelSeq[4]; /* ditto */
        int  dataOrder;     /* 0 - interleaved color channels, 1 - separate color channels.
                               cvCreateImage can only create interleaved images */
        int  origin;        /* 0 - top-left origin,
                               1 - bottom-left origin (Windows bitmaps style) */
        int  align;         /* Alignment of image rows (4 or 8).
                               OpenCV ignores it and uses widthStep instead */
        int  width;         /* image width in pixels */
        int  height;        /* image height in pixels */
        struct _IplROI *roi;/* image ROI. when it is not NULL, this specifies image region to process */
        struct _IplImage *maskROI; /* must be NULL in OpenCV */
        void  *imageId;     /* ditto */
        struct _IplTileInfo *tileInfo; /* ditto */
        int  imageSize;     /* image data size in bytes
                               (=image->height*image->widthStep
                               in case of interleaved data)*/
        char *imageData;  /* pointer to aligned image data */
        int  widthStep;   /* size of aligned image row in bytes */
        int  BorderMode[4]; /* border completion mode, ignored by OpenCV */
        int  BorderConst[4]; /* ditto */
        char *imageDataOrigin; /* pointer to a very origin of image data
                                  (not necessarily aligned) -
                                  it is needed for correct image deallocation */
    }
    IplImage;

Quote


Quote
IplImage struct
nSize         dword 0;         /* sizeof(IplImage) */
ID            dword 0;            /* version (=0)*/
nChannels      dword 0;     /* Most of OpenCV functions support 1,2,3 or 4 channels */
alphaChannel   dword 0;  /* ignored by OpenCV */
depth         dword 0   ;         /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
                               IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
colorModel      dword 0; /* ignored by OpenCV */
channelSeq      dword 0; /* ditto */
dataOrder      dword 0;     /* 0 - interleaved color channels, 1 - separate color channels.
                               cvCreateImage can only create interleaved images */
origin         dword 0;        /* 0 - top-left origin,
                       ;        1 - bottom-left origin (Windows bitmaps style) */
_align         dword 0;         /* Alignment of image rows (4 or 8).
                               OpenCV ignores it and uses widthStep instead */
_width         dword 0;         /* image width in pixels */
height         dword 0;        /* image height in pixels */
roi            dword 0;/* image ROI. when it is not NULL, this specifies image region to process */
maskROI         dword 0; /* must be NULL in OpenCV */
imageId         dword 0;     /* ditto */
tileInfo      dword 0; /* ditto */
imageSize      dword 0;     /* image data size in bytes
                               (=image->height*image->widthStep
                               in case of interleaved data)*/
imageData      dword 0;  /* pointer to aligned image data */
widthStep      dword 0;   /* size of aligned image row in bytes */
BorderMode      dword 0; /* border completion mode, ignored by OpenCV */
BorderMode1      dword 0
BorderMode2      dword 0
BorderMode3      dword 0   
BorderConst      dword 0
BorderConst1   dword 0
BorderConst2   dword 0
BorderConst3   dword 0

imageDataOrigin   dword 0 ; /* pointer to a very origin of image data
IplImage ends
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Though the colorModel and channelSeq are 4 bytes that does not make them DWORDs, the byte order of a DWORD is reversed, the reason they have been defined as  BYTE 4 DUP (?) is so the order remains unchanged...

IplImage STRUCT
nSize DWORD ?
ID DWORD ?
nChannels DWORD ?
alphaChannel DWORD ?
depth DWORD ?
colorModel BYTE 4 DUP (?)
channelSeq BYTE 4 DUP (?)
dataOrder DWORD ?
origin DWORD ?
align DWORD ?
width DWORD ?
height DWORD ?
roi DWORD ?
maskROI DWORD ?
imageId DWORD ?
tileInfo DWORD ?
imageSize DWORD ?
imageData DWORD ?
widthStep DWORD ?
BorderMode  DWORD 4 DUP (?)
BorderConst  DWORD 4 DUP (?)
imageDataOrigin  DWORD ?
IplImage ENDS
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

What does this mean?

Quote
#ifndef MIN
#define MIN(a,b)  ((a) > (b) ? (b) : (a))
#endif
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

It is a macro, if a > b then return b, if a <= b then return a, it simply returns the smaller of the 2 parameters.

MACRO(Parameters) (Condition ? result TRUE : result FALSE)

In GoAsm the macro would be something like this:

MIN(%a,%b) MACRO
mov eax,%a
mov edx,%b
cmp edx,eax
jg >
xchg eax,edx
:
ENDM

MAX(%a,%b) MACRO
mov eax,%a
mov edx,%b
cmp edx,eax
jl >
xchg eax,edx
:
ENDM


Ofcourse it would overwrite EAX and EDX
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

 :U Thanks I got it.
I can simply use japhets H2INC tools but I need to understand that first.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote
   for(iTrain=0; iTrain<nTrainFaces; iTrain++)
   {
      double distSq=0;

      for(i=0; i<nEigens; i++)
      {
         float d_i =
            projectedTestFace -
            projectedTrainFaceMat->data.fl[iTrain*nEigens + i];
         //distSq += d_i*d_i / eigenValMat->data.fl;  // Mahalanobis
         distSq += d_i*d_i; // Euclidean
      }

      if(distSq < leastDistSq)
      {
         leastDistSq = distSq;
         iNearest = iTrain;
      }
   }

Is this code mean distSq reseted on every loop to 0?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

mitchi


Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

WHat does this do?
Quote
#define CV_CN_SHIFT   3
#define CV_8U   0
#define CV_8S   1
#define CV_16U  2
#define CV_16S  3
#define CV_32S  4
#define CV_32F  5
#define CV_64F  6
#define CV_USRTYPE1 7
#define CV_MAKETYPE(depth,cn) ((depth) + (((cn)-1) << CV_CN_SHIFT))

I need to know what value #define CV_32SC1 CV_MAKETYPE(CV_32S,1) is.

I simply put 4, but it seems does not work.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Nevermind, I understand it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

rags

Farabi here is a website that should help you understand C better.
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
God made Man, but the monkey applied the glue -DEVO

ToutEnMasm


Made by the translator, It is nort always like that (for macro)
Quote
CV_CN_SHIFT   equ   < 3>
CV_8U   equ   < 0>
CV_8S   equ   < 1>
CV_16U   equ   < 2>
CV_16S   equ   < 3>
CV_32S   equ   < 4>
CV_32F   equ   < 5>
CV_64F   equ   < 6>
CV_USRTYPE1   equ   < 7>
   CV_MAKETYPE MACRO depth,cn
      local Value
      Value equ   depth +((  cn - 1 ) SHL CV_CN_SHIFT )
      EXITM <Value>
      ENDM


Farabi

Quote from: rags on May 04, 2009, 10:25:18 AM
Farabi here is a website that should help you understand C better.
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/


Thanks, so thats where the header is. I dont have any C compiler here.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote from: ToutEnMasm on May 04, 2009, 12:18:37 PM

Made by the translator, It is nort always like that (for macro)
Quote
CV_CN_SHIFT   equ   < 3>
CV_8U   equ   < 0>
CV_8S   equ   < 1>
CV_16U   equ   < 2>
CV_16S   equ   < 3>
CV_32S   equ   < 4>
CV_32F   equ   < 5>
CV_64F   equ   < 6>
CV_USRTYPE1   equ   < 7>
   CV_MAKETYPE MACRO depth,cn
      local Value
      Value equ   depth +((  cn - 1 ) SHL CV_CN_SHIFT )
      EXITM <Value>
      ENDM


Thanks, I really need the translation.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"