Hi,
I would like to update the pointer to piddle data. I've got a C function
void * getData(MatWrapper * mw);
that returns the pointer to opencv Mat data. I declare the piddle $m
with the right size and data type in PMCode. Now, I can successfully say
void * data = getData($COMP(mw));
$P(m)=data;
and print the right numbers in C.
printf("m (48,48) %f\n",$m(k=>48,l=>48)); # 50.842896 - correct.
However, after returning to perl, $m(48,48) is 0 and get_dataref shows
the wrong datdress. What's the trick to make this permanent?
Ingo
==
pp_def ('get_data',
Pars=>'[o] m(k,l);',
OtherPars=>'MatWrapper * mw',
Code=>pp_line_numbers(__LINE__,
'
PDL_Indx ks = $SIZE(k);
PDL_Indx ls = $SIZE(l);
int x = cols($COMP(mw),-1);
int y = rows($COMP(mw),-1);
printf ("x %d : ks %d / y %d : ls %d ",x,ks,y,ls);
if ((x == ks) && (y == ls))
{
void * dat;
dat = getData($COMP(mw));
$P(m)=dat;
} else {
$CROAK("Matrix size does not match!\n");
}
printf("m (48,48) %f\n",$m(k=>48,l=>48));
'),
PMCode=>pp_line_numbers(__LINE__,
'
sub get_data {
my ($mw,$p) = @_;
unless (ref ($p) =~ "PDL") {
say "rows $mw->rows";
$p=zeroes(float,$mw->cols,$mw->rows);
}
_get_data_int($p,$$mw);
say "(get_data) 48,48: ",$p->slice("48","48");
$p->upd_data;
say "(get_data) 48,48: ",$p->slice("48","48");
$p->transpose;
}
',),
Doc=><<"EOD",
=head2 set_data - update data of a Mat object. Size and type should match.
EOD
);
_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general