Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing KeyPointVector bug #1012

Closed
mijoypad opened this issue Jun 4, 2018 · 12 comments
Closed

Writing KeyPointVector bug #1012

mijoypad opened this issue Jun 4, 2018 · 12 comments
Labels

Comments

@mijoypad
Copy link

mijoypad commented Jun 4, 2018

Hello, I think I've found bug which is stopping my further work as I cannot proceed with my project without completing this step.

So, based on this sample:
https://github.com/bytedeco/javacv/blob/72d9fd9d55e86a32942afb5edd983cd4bb3647bc/samples/OpenCVFeatures2dSerialization.java

and particaularly this piece of code:

    private static void serializeFile(Mat matrix, String fileName) throws UnsupportedEncodingException {
        try (KeyPointVector keyPointVectorSerialize = new KeyPointVector(); Mat objectDescriptorsSerialize = new Mat(); AKAZE akaze = AKAZE.create();
             FileStorage fileStorage = new FileStorage(fileName, FileStorage.WRITE, StandardCharsets.UTF_8.name())
        ) {
            akaze.detectAndCompute(matrix, new Mat(), keyPointVectorSerialize, objectDescriptorsSerialize, false);
            System.out.println("Vector size: " + keyPointVectorSerialize.size());
            System.out.println("Descriptor size: " + objectDescriptorsSerialize.cols());
            
            ///////////////HERE/////////////
            write(fileStorage, "keyPoints", keyPointVectorSerialize);
            //////////////////////////////////

            write(fileStorage, "descriptors", objectDescriptorsSerialize);
            fileStorage.release();
        }
}

it should all work. However, in my case the write method does not take KeyPointVector as an argument but just the single KeyPoint. I'm going to try with previous versions of javacv, but I would be very grateful if someone could take a look and give me a solution or fix the bug ASAP.

@mijoypad
Copy link
Author

mijoypad commented Jun 4, 2018

Ok, I checked it with javacv-1.3 and it works. At first I tried just changing the javacpp.jar and javacv.jar to those from version 1.3 and at this point method argument was correct (KeyPointVector) - not uderlining, however the program still wasn't compiling because of it. Only after using complete set of files from javacv-1.3 it started running. At this point I'll try to use older version (howver I don't know if it won't cause any other trouble) but I'm hoping that this issue will be fixed shortly. Anyways I'm very grateful for your work, as the official OpenCV for java lacks a lot of features (this one is one of them actually).

@mijoypad
Copy link
Author

mijoypad commented Jun 4, 2018

Ok, something more FYI, maybe it will help you to examine the issue.
The last working version is 1.3.3 as in 1.4.0 the problem already exists.
When using the newest version and changing the opencv.jar only from 1.3.3, the argument is taken properly, however the program does not compile showing error:

C:\Users*user*l.javacpp\cache\opencv-windows-x86_64.jar\org\bytedeco\javacpp\windows-x86_64\jniopencv_core.dll: Can't find dependent libraries

After changing the opencv-windows-x86_64.jar file to the one from 1.3.3 everything seems to be working fine. So I don't know if the problem regards javacv itself or the OpenCV core maybe, but this is what I found out.

@saudet saudet added the bug label Jun 5, 2018
@saudet
Copy link
Member

saudet commented Jun 5, 2018

If looks like these functions are deprecated. I'll enable them by defining CV__LEGACY_PERSISTENCE, but you should find another way to serialize your KeyPointVector as they might not be available in the next release of OpenCV.

@saudet
Copy link
Member

saudet commented Jun 5, 2018

@Maurice-Betzel If you have some time, could you take a look and update the sample? Thanks for your time on this!

@mijoypad
Copy link
Author

mijoypad commented Jun 5, 2018

Ok, thank you very much for you reply. It's just weird that the function works for single KeyPoint and does not work for vector of them - why would anyone would like to change it that way ;)

saudet added a commit to bytedeco/javacpp-presets that referenced this issue Jun 5, 2018
@saudet
Copy link
Member

saudet commented Jun 5, 2018

I see, they want us to use the function templates. We'll do that when the legacy functions disappear, so we shouldn't need to change anything else once we do that:

// This code is not needed anymore, but it is preserved here to keep source compatibility
// Implementation is similar to templates instantiations

bytedeco/javacpp-presets@12b0576#diff-098f93602679a6676e7669064dd1a9ebR22839

@mijoypad
Copy link
Author

mijoypad commented Jun 6, 2018

Ok, cool, thank you :)

@mijoypad
Copy link
Author

mijoypad commented Jun 8, 2018

Any chance you could upload these few modified compiled *.jar files? I've spent a few hours trying to compile latest commits, but still getting some errors and I'm exhausted, I need the newest version as it contains push_back for KeyPointsVector container :|

@saudet
Copy link
Member

saudet commented Jun 8, 2018

The CI servers automatically upload snapshots to the repository: http://bytedeco.org/builds/

For convenience, we can browse and download JAR files manually as well from the snapshot repository:

@mijoypad
Copy link
Author

mijoypad commented Jun 8, 2018

O! I'm laughing through tears. I've spent so much time for nothing, but on the other hand I've got it working :) Thank you so much for such a quick answer solving my problem ;)

@saudet
Copy link
Member

saudet commented Jun 8, 2018

Sorry about that :(

@saudet
Copy link
Member

saudet commented Jul 18, 2018

Fix is included in version 1.4.2. Thanks again for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants