Closed GoogleCodeExporter closed 8 years ago
The cause of this problem is most likely the same as the one for issue #10
http://code.google.com/p/javacv/issues/detail?id=10 .. will keep you posted for
something to try
Original comment by samuel.a...@gmail.com
on 7 Aug 2010 at 4:14
Hi Samuel,
Thanks for your response. I tried adding setAutoSynch(false) to all CvSeq
constructors, but that didn't actually fix the issue. To be certain, the error
no longer appears, but the contours found, if at all, are 1-2 pixel radius
circles randomly. Using your test2.java example, none of the contours found
with the non-modified javacv.jar are found.
I'm mildly stumped, but would like to show you the exact error, on the off
chance I didn't explain myself correctly:
Exception in thread "main" java.lang.StackOverflowError
at com.sun.jna.Native.getNativeSize(Native.java:951)
at com.sun.jna.Native.getNativeSize(Native.java:937)
at com.sun.jna.Structure.getNativeAlignment(Structure.java:890)
at com.sun.jna.Structure.calculateSize(Structure.java:823)
at com.sun.jna.Structure.allocateMemory(Structure.java:282)
at com.sun.jna.Structure.<init>(Structure.java:177)
at com.sun.jna.Structure.<init>(Structure.java:167)
at com.sun.jna.Structure.<init>(Structure.java:163)
at com.sun.jna.Structure.<init>(Structure.java:154)
at name.audet.samuel.javacv.jna.cxcore$CvArr.<init>(cxcore.java:2379)
at name.audet.samuel.javacv.jna.cxcore$CvSeq.<init>(cxcore.java:3060)
at name.audet.samuel.javacv.jna.cxcore$CvSeq$ByReference.<init>(cxcore.java:3092)
at sun.reflect.GeneratedConstructorAccessor3.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.jna.Structure.newInstance(Structure.java:1159)
at com.sun.jna.Structure.updateStructureByReference(Structure.java:486)
at com.sun.jna.Pointer.getValue(Pointer.java:400)
at com.sun.jna.Structure.readField(Structure.java:517)
at com.sun.jna.Structure.read(Structure.java:419)
at com.sun.jna.Structure.autoRead(Structure.java:1368)
loops the following infinitely:
at com.sun.jna.Structure.updateStructureByReference(Structure.java:490)
at com.sun.jna.Pointer.getValue(Pointer.java:400)
at com.sun.jna.Structure.readField(Structure.java:517)
at com.sun.jna.Structure.read(Structure.java:419)
at com.sun.jna.Structure.autoRead(Structure.java:1368)
Thank you,
Nick
Original comment by nsul...@gmail.com
on 11 Aug 2010 at 12:52
Once "auto-synch" is disabled, you need to use the readField() method to read
the native values of the fields in the Structure. The values of the Java fields
will not be correct.. Did you use readField() in your Java code?
BTW, I modified CvSeq slightly in this test package to include a static
autoSynch flag:
http://www.ok.ctrl.titech.ac.jp/~saudet/javacv.jar
With that, something like the following should disable the default auto-synch
behavior of any newly constructed CvSeq objects:
CvSeq.autoSynch = false;
If that works, I plan to add the flag to all Structure in the next release...
thanks
Original comment by samuel.a...@gmail.com
on 12 Aug 2010 at 3:04
Hi Samuel,
Thanks for the advice. I'm not very familiar with JNA. Is there any way you
could clarify on readField(). Am I to just replace read() with readField() in
the cvSeq constructors?
Thank you,
Nick
Original comment by easul...@gmail.com
on 12 Aug 2010 at 3:58
For each individual field, yes.. if you have a field "int number", then instead
of something like
int n = someStructure.number
you replace that with
int n = (Integer)someStructure.readField("number")
Original comment by samuel.a...@gmail.com
on 12 Aug 2010 at 4:02
Marking this long-standing issue as fixed, since it should work. If you still
get stack overflows after setting CvSeq.autoSynch = false, please reopen the
issue. Otherwise please mark it as /verified/, thank you.
Original comment by samuel.a...@gmail.com
on 4 Nov 2010 at 10:40
Original issue reported on code.google.com by
nsul...@gmail.com
on 7 Aug 2010 at 12:23