dhanrajc / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

cvMinMaxLoc #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
cvMinMaxLoc in C use as parameter 4 pointers, but converting the C code:

CvPoint    minloc, maxloc;
double    minval, maxval;
cvMinMaxLoc(res, &minval, &maxval, &minloc, &maxloc, 0);

into java:
CvPoint minloc = new CvPoint();
CvPoint maxloc = new CvPoint();
double[] minval = {};
double[] maxval = {};
cvMinMaxLoc(res, minval, maxval, minloc, maxloc, null);

throws a untraceable fatal error, im doing something bad in this function call?

after calling cvMinMaxLoc i use
cvMatchTemplate(img, tpl, res, CV_TM_SQDIFF);
without error.

Original issue reported on code.google.com by graficag...@gmail.com on 5 Mar 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Yes, your minval and maxval have length 0. If you want to get something in 
return, they need to be at least of length 1, if not, pass null. I guess I 
should pass a NULL pointer there when the user provides something like that..

Original comment by samuel.a...@gmail.com on 5 Mar 2011 at 1:31

GoogleCodeExporter commented 9 years ago
thanks for the answer, but i can´t make cvMatchTemplate + cvMinMaxLoc work, 
"translating" from C examples doesnt seem to work, someone has run these OpenCV 
functions and has an example for me to try?

Original comment by graficag...@gmail.com on 10 Mar 2011 at 4:02

GoogleCodeExporter commented 9 years ago
Can you post the code you "translated" that "doesn't seem to work"?

Original comment by samuel.a...@gmail.com on 10 Mar 2011 at 6:29

GoogleCodeExporter commented 9 years ago
Sorry Samuel, i had deleted the previous code, so I started from scratch and 
now it works perfectly.

this issue is resolved

Original comment by graficag...@gmail.com on 12 Mar 2011 at 8:48

GoogleCodeExporter commented 9 years ago
Apparently, some versions of C/C++ do support pointers of size zero:

The pointer returned points to the start (lowest byte address) of the allocated 
space. If the space cannot be allocated, a null pointer is returned. If the 
size of the space requested is zero, the behavior is implementation defined: 
either a null pointer is returned, or the behavior is as if the size were some 
nonzero value, except that the returned pointer shall not be used to access an 
object.
- http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf

So this is not a bug of JavaCPP or JavaCV after all :) Marking as invalid

Original comment by samuel.a...@gmail.com on 6 Apr 2011 at 1:16