sawpawan / javacv

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

Access violation and like that #299

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Run...

What is the expected output? What do you see instead?
There are many versions that's why I put errors in attach...

What version of the product are you using? On what operating system?
opencv 2.4.4 and last javacv build. Windows 7 x64, Java x64, Eclipse x64, 
OpenCv x64 and x86 are enabled. I also try use x86 Java but the same...

Please provide any additional information below.
This analogue c++ code work fine. When it was simple piece of code in  one 
class it work. When I start complicate it, the errors are coming. In some cases 
when it work on debug and dont work in release and backward.

And code examples. 

I already match descriptions by BFMatcher (DMatch match), and when I try filter 
it and write it to 
DMatch good_matches = new DMatch();
like 
good_matches.put(match.position(i));   
I have an error in all cases except one times, when I start debugging it and 
wait some time. After I try repeat situation but can't.

Another code is 
global:
        FeatureDetector detector = null;
        DescriptorExtractor extractor = null;

are initialized in class constructor:
detector = new ORB().getFeatureDetector();
extractor = new ORB().getDescriptorExtractor();

and problematic function

public T getDescriptions(CvMat image) {
        KeyPoint keys = new KeyPoint();
        CvMat descr = new CvMat(null);
        detector.detect(image, keys, new CvMat(null));//there
        extractor.compute(image, keys, descr); //or there
        return new T...//T is my class
    }

I have error when I try use this function from other function of this class 
like getDescriptions(image). But when I call it like new 
ClassName().getDescriptions(image) it work. 
When I call it from another class it work but not always.

I also try use in my function new ORB().detectAndCompute(image, null, keys, 
descr, false);
It doesn't work when i try call it from another classes... 

Where is fail? in my program architecture or it JNI problem or something else?

P.S. sorry for my English!

Original issue reported on code.google.com by McBo...@gmail.com on 3 Apr 2013 at 3:59

Attachments:

GoogleCodeExporter commented 8 years ago
Would you have some code snippet that I can try and run? Thanks

Original comment by samuel.a...@gmail.com on 6 Apr 2013 at 11:57

GoogleCodeExporter commented 8 years ago
Let's see.. I think I understand what you are doing wrong from your unclear 
explanations.

You should allocate "good_matches" this way:
DMatch good_matches = new DMatch(total_number_of_matches);

And call detect() this way:
detector.detect(image, keys, null);

And make sure to keep Java references to all C++ objects you create. If you do 
not keep Java references, the underlying C++ objects may get garbage collected 
and it may causes crashes as you describe.

Does that fix everything?

And please ask such questions on the mailing list next time if possible! Thank 
you

Original comment by samuel.a...@gmail.com on 13 Apr 2013 at 2:33