Jump to content
Sign in to follow this  
frank10

DllstructGetData doesn't match the struct definition names

Recommended Posts

frank10

I have this C++ struct:

;~ typedef struct _IplImage {
;~ 00132     int  nSize;         /*< sizeof(IplImage) */
;~ 00133     int  ID;           /*< version (=0)*/
;~ 00134     int  nChannels;     /*< Most of OpenCV functions support 1,2,3 or 4 channels */
;~ 00135     int  alphaChannel;  /*< ignored by OpenCV */
;~ 00136     int  depth;         /*< pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,
;~ 00137                           IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
;~ 00138     char colorModel[4]; /*< ignored by OpenCV */
;~ 00139     char channelSeq[4]; /*< ignored by OpenCV */
;~ 00140     int  dataOrder;     /*< 0 - interleaved color channels, 1 - separate color channels.
;~ 00141                           cvCreateImage can only create interleaved images */
;~ 00142     int  origin;       /*< 0 - top-left origin,
;~ 00143                           1 - bottom-left origin (Windows bitmaps style) */
;~ 00144     int  align;         /*< Alignment of image rows (4 or 8).
;~ 00145                           OpenCV ignores it and uses widthStep instead */
;~ 00146     int  width;         /*< image width in pixels */
;~ 00147     int  height;       /*< image height in pixels */
;~ 00148     struct _IplROI *roi;/*< image ROI. if NULL, the whole image is selected */
;~ 00149     struct _IplImage *maskROI; /*< must be NULL */
;~ 00150     void  *imageId;     /*< must be NULL */
;~ 00151     struct _IplTileInfo *tileInfo; /*< must be null */
;~ 00152     int  imageSize;     /*< image data size in bytes
;~ 00153                           (==image->height*image->widthStep
;~ 00154                           in case of interleaved data)*/
;~ 00155     char *imageData;  /*< pointer to aligned image data */
;~ 00156     int  widthStep;   /*< size of aligned image row in bytes */
;~ 00157     int  BorderMode[4]; /*< ignored by OpenCV */
;~ 00158     int  BorderConst[4]; /* ignored by OpenCV */
;~ 00159     char *imageDataOrigin; /*< pointer to very origin of image data
;~ 00160                              (not necessarily aligned) -
;~ 00161                              needed for correct deallocation */

with ImageData defined as:
;~ public:
;~ ImageData(
;~  array<unsigned char>^ bytes
;~ )
and roi:
typedef struct _IplROI
{
    int  coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/
    int  xOffset;
    int  yOffset;
    int  width;
    int  height;
}

I tried to translate this to Autoit:

global $_roi = 'LONG xOffset;' & _
    'LONG yOffset;' & _
    'LONG width;' & _
    'LONG height;'

global $_IplImage = 'int  nSize;' & _
    'int  ID;' & _
    'int  nChannels;' & _
    'int  alphaChannel;' & _
    'int  depth;' & _
    'char colorModel[4];' & _
    'char channelSeq[4];' & _
    'int  dataOrder;' & _
    'int  origin;' & _
    'int align;' & _
    'int  width;' & _
    'int  height;' & _
    $_roi & _
    'int  imageSize;' & _
    'ptr imageData;' & _
    'int  widthStep;' & _
    'int BorderMode[4];' & _
    'int  BorderConst[4];' & _
    'ptr imageDataOrigin;'

Global $tIplImage = DllStructCreate($_IplImage, $returnedPointer)

I had to eliminate some voices in the original struct (such as align, maskROI, tileInfo) to get a correct corrispondence value in calling

DllStructGetData($tIplImage, 'someNamedItem')

Besides I had to delete one line from roi struct (I deleted the first 'coi') even if it's defined with coi...

If I leave all as the definition, I get wrong values from DllStructGetData.

All of this, with trial & error, but is there a precise rule to make the correct translation to an autoit struct in a case like this? Or the only one is to print values from a C++ prog and then try at guess to match it in autoit?

Furthermore, if I want to get the height value, it gives me the root-struct one, but if I would like to get the roi->height one (they have the same name)?

Share this post


Link to post
Share on other sites
ProgAndy

Hi,

roi and maskROI are pointers to structures and no inline structures.

...
int  height;
ptr roi;
ptr maskROI;
ptr imageId;
ptr tileInfo;
int  imageSize;  
...

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
frank10

Thank you ProgAndy, you're right, they are pointers.

It works now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×