Hi would you be so kind of pointing me to a simple working example? My references look like memory addresses but seem to point to nowhere.
Ingo On 3/3/2022 3:05 PM, Craig DeForest wrote: > When I had to do things like that, I would generally cast the pointer > to an IV and pass it around as an IV ref on the Perl side, then > manually unwrap it when needed on the C side. This is the approach > used by PDL itself. > > >> On Mar 3, 2022, at 7:55 AM, Ingo Schmid <ingo...@gmx.at> wrote: >> >> Hi, >> >> I'm working on PDL bindings (Inline:::Pdlpp) to the OpenCV (v4.5) >> tracking class. I have created a wrapper (see header below). >> >> I would now need to persistently store pointers to MatWrapper and >> TrackerWrapper - which are containers (structs) of the Mat and >> Tracker objects. >> >> At the moment, I have them declared in the auto_include code (struct >> TrackerWrapper * tw;). This would then prevent me from using multiple >> trackers. I therefore am looking of passing the pointer back and forth. >> >> I tried using >> >> OtherPars => 'TrackerWrapper * tw, MatWrapper * mw', .. >> >> this and a typemap file, it is referenced in the TYPEMAPS field. >> However, this results in unknown c type error TrackerWrapper when >> parsing the pd file. I think it is never used, following what is said >> here https://arxiv.org/pdf/1702.07753.pdf. Which subset of c-types >> are allowed? >> >> Is the approach reasonable and I am doing something wrong? What is >> the way to make a c struct persistent and accessible with perl/pp? >> >> There's Inline-C-Struct, does that work with pdl and if so, how? >> >> Any help is appreciated. I can share the full code (so far) upon >> request but it is work in progress. >> >> Ingo >> >> typemap: >> >> TYPEMAP >> >> TrackerWrapper T_PTR >> >> MatWrapper T_PTR >> >> >> tracker_wrapper.h: >> >> >> #ifdef __cplusplus >> extern "C" { >> #endif >> >> >> // >> struct cvType { >> int u8c3 ; >> int u8c1 ; >> int f32c3 ; >> int f32c1 ; >> } cvT; >> >> int tw_init(); >> //struct cvType cvT; >> typedef struct TrackerWrapper TrackerWrapper; >> struct TrackerWrapper * newTracker (int tracker_type); >> int deleteTracker (struct TrackerWrapper *); >> >> struct bBox{ >> int x; int y; int width; int height; >> }; >> >> typedef struct MatWrapper MatWrapper; >> struct MatWrapper * newMat (const int width, const int height, const >> int type, void * data); >> void * getData (struct MatWrapper * Mat); >> int setData (struct MatWrapper * Mat, const int type, void * data); >> >> int init_tracker(struct TrackerWrapper * Tr, struct MatWrapper * >> frame, const struct bBox * box ); >> int update_tracker(struct TrackerWrapper *, struct MatWrapper *, >> struct bBox * box); >> int show_tracker (struct MatWrapper * frame, struct bBox * roi) ; >> >> #ifdef __cplusplus >> } >> #endif >> >> >> >> >> _______________________________________________ >> pdl-general mailing list >> pdl-gene...@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/pdl-general >
_______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel