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

Add support for xfeatures2d module of OpenCV 3 #54

Closed
jpsacha opened this issue Jun 15, 2015 · 21 comments
Closed

Add support for xfeatures2d module of OpenCV 3 #54

jpsacha opened this issue Jun 15, 2015 · 21 comments

Comments

@jpsacha
Copy link
Member

jpsacha commented Jun 15, 2015

Some of the algorithms previously available in javacpp-presets moved in OpenCV 3 to xfeatures2d module. Those include SIFT, SURF, and related.There are also some other interesting algorithms in xfeatures2d module, like DAISY.

@saudet
Copy link
Member

saudet commented Jun 15, 2015

The problem with opencv_contrib is that they don't provide binaries for Windows. Would you be able to adjust the cppbuild.sh file to build OpenCV with opencv_contrib from source for Windows as well? In addition, it would be a good idea to build it with MinGW-w64. This way, we can build under Linux as well, and consequently on Travis CI for free.

BTW, if the only thing that you are worried about are descriptors, AKAZE usually provides better results than SIFT, SURF, DAISY or anything else, and doesn't have any of their legal issues either.

@jpsacha
Copy link
Member Author

jpsacha commented Jun 16, 2015

I was looking at updating the cookbook examples, I have most under control (as far I can tell so far), except examples that use SURF (1) and SIFT (6). Some of the most interesting/elaborated examples use SIFT.

I can compile OpenCV on Window with Visual Studio. I was not able to do that with MinGW, getting syntax errors, not clear how to it should really be setup on Windows. I tried using MinGW tool chain under Cygwin using cmake:

cmake -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/i686-w64-mingw32-g++ -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/i686-w64-mingw32-gcc -DWITH_OPENEXR=NO ../opencv.git

that can create cmake setup. It compiles part but eventually ends in errors like:

usr/i686-w64-mingw32/sys-root/mingw/include/float.h:278:57: error: expected ‘,’ or ‘...’ before numeric constant

If this is not possible to add xfeatures2d, I will probably drop I will drop SURF and SIFT from the cookbook examples.

@saudet
Copy link
Member

saudet commented Jun 16, 2015

Well, if you get it working with MSVC, that'll be alright for now too. Please send your modifications to cppbuild.sh!

As for SURF or SIFT in the cookbook examples, those could be converted to AKAZE. Check the changes to https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/ObjectFinder.java for an example.

@jpsacha
Copy link
Member Author

jpsacha commented Jun 17, 2015

OK. I will try to setup presets to build with VS2012/VS2013 and xfeatures2d.

Though I have trouble building current javacpp-presets (no modifications yet). I am getting error while building jniopencv_objdetect.dll:

   Creating library jniopencv_objdetect.lib and object jniopencv_objdetect.exp niopencv_objdetect.obj : error LNK2001: unresolved external symbol "public: __cdecl cv::DetectionBasedTracker::Parameters::Parameters(void)" (??0Parameters@DetectionBasedTracker@cv@@QEAA@XZ)
X:\javacpp-presets\opencv\target\classes\org\bytedeco\javacpp\windows-x86_64\jniopencv_objdetect.dll : fatal error LNK1120: 1 unresolved externals

Any ideas?

@saudet
Copy link
Member

saudet commented Jun 17, 2015

It's a bug in OpenCV. We need to patch this (see issue #56). One more reason to use MinGW-w64: whatever works on Linux or Mac OS X would also work on Windows. C++ isn't as portable as Java...

@saudet
Copy link
Member

saudet commented Jun 17, 2015

@jpsacha
Copy link
Member Author

jpsacha commented Jun 17, 2015

There is something missing in the Wiki Instructions. When I try to build either from Windows SDK or MinWG command prompt using maven install ... it invokes Visual Studio compiler cl.
When I tried to force different compiler using

mvn -Dplatform.compiler=/mingw64/bin/c++ install --projects .,opencv

it will complain about incorrect options, like:

c++: error: /IX:\javacpp-presets\opencv/cppbuild/windows-x86_64/include/: Invalid argument

Notice some slashes going in two different directions. Are the compiler options generated by javacpp? Any way to control them?

Can you actually currently build javacpp-presets on Windows using MinGW?

@saudet
Copy link
Member

saudet commented Jun 18, 2015

I haven't tried for OpenCV, but you're right, we also need to modify the pom.xml file. Check Tesseract, for example. And also need to change the reference to the C++ runtime library in presets/opencv_core.java for redistribution.

@saudet
Copy link
Member

saudet commented Jun 19, 2015

In any case, since SURF and SIFT are no longer part of the core of OpenCV, it makes sense to move to something like AKAZE. Do you have any good reasons for not switching to AKAZE?

@jpsacha
Copy link
Member Author

jpsacha commented Jun 19, 2015

The idea for the Cookbook Examples if that people reading the book that has C++ examples can simply go to the Cookbook Examples and see how it works on JVM. I was thinking to have a set of some interesting algorithms, say AKAZE or LATCH in a separate set, independent of the Cookbook, may not have time for that for a couple of weeks. Beside that ther is a lot other interesting stuff in contrib beside xfeatures2d.

I have the xfeatures2d wrappings working on Linux, including SURF and SIFT. Also ported most of the Cookbook code now to OpenCV 3. Most of the SURF and SIFT examples are working, one I did not have time to finish yet, though the issue is mostly with different use of vectors in OpenCV 3 (e,g., get instead of position and size instead of capacity).

I also tested on Mac. OpenCV wrappers (without xfeatures2d) did not build complaining about missing headers in contrib/trackblob.hpp (if I remember correctly). Did not have time yet to look where the error is coming from.

OpenCV and contrib can be build with Visiual Studio 2013 that is free, so technically there is a way to have Windows, Linux, and Mac covered.

@jpsacha
Copy link
Member Author

jpsacha commented Jun 20, 2015

Correction to previous: javacpp-presets build fine on Mac, also with xfeatures2d. Cookbook examples also work now with xfeatures2d (once that were already ported). I will be pushing changes to javacpp-presets and Cookbook examples on GitHub after I do some cleanups.

Windows hopefully going to work too after issue #56 is resolved.

@saudet
Copy link
Member

saudet commented Jun 20, 2015

Ok, good, but BTW it's not just about xfeatures2d. opencv_contrib comes with a whole lot of stuff I'm not sure I want to deal with right now. If you can resolve everything on Windows, either with MSVC 2013 or MinGW-w64, that'd be great, but we'll see how things go...

@jpsacha
Copy link
Member Author

jpsacha commented Jun 20, 2015

Other things in opencv_contrib can be disabled, though currently everything builds fine (though anything except xfeatures2d needlessly).

Wrapping for xfeatures2d are now published on my fork's branch xfeatures2d. Tested on Ubuntu 64 and Mac.

Cookbook Examples ported so far for OpenCV 3 are on branch WIP/opencv3. Work fine (except video in Chapter 10) on Ubuntu 64 and Mac.

I will wait till Issue #56 is fixed before working on Windows version of opencv presets. At that time we can also disable opencv_contrib modules that are not needed, to reduce compilation time and size of binaries.

@saudet
Copy link
Member

saudet commented Jun 20, 2015

Like I said, please do try to fix the Windows build. I can't do everything by myself, I'm just one guy, and this is something that anyone can do, so it's kind of low priority on my list. Besides, this is a bug in OpenCV, so we could also send them a bug report and maybe they'll fix it, eventually. :)

@jpsacha
Copy link
Member Author

jpsacha commented Jun 21, 2015

I understand time constants. I am in the same boat.

I do not understand why it is a bug in OpenCV, though that discussion should really move to Issue #56.

@jpsacha
Copy link
Member Author

jpsacha commented Jul 24, 2015

@saudet Can you bump library versions (javacpp, etc.) from released "1.0" to next, say to "1.0.1-SNAPSHOT"?
That helps testing new code.
I have support for xfeatures2d implemented, just need to test it and create PR.

@saudet
Copy link
Member

saudet commented Jul 24, 2015

Does it really help? If I change the version, everyone has to rebuild all the native libraries. That seems inconvenient to me, so I tend to avoid changing the version until I make breaking changes. Is this alright for you though? In any case, thanks for the work on this module!

@jpsacha
Copy link
Member Author

jpsacha commented Jul 25, 2015

Having a newer build with version the same as released one is confusing SBT (that I use for testing). I have to make up a different version number, test, then revert the version number before committing. Anyway I will create PR soon.

jpsacha added a commit to jpsacha/javacpp-presets that referenced this issue Jul 25, 2015
@jpsacha
Copy link
Member Author

jpsacha commented Jul 25, 2015

Implemented in PR #75,

@saudet
Copy link
Member

saudet commented Jul 25, 2015

I see, SBT doesn't like it. Thanks for the explanation and the PR!

jpsacha added a commit to jpsacha/javacpp-presets that referenced this issue Jul 25, 2015
saudet added a commit that referenced this issue Jul 25, 2015
Add presets for the `xfeatures2d` module of OpenCV 3.0 (issue #54)
@saudet
Copy link
Member

saudet commented Oct 30, 2015

Included in version 1.1. Thanks for your time on this!!

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

No branches or pull requests

2 participants