Opencv-python: Is it possible to add SIFT and SURF to opencv

Created on 12 Jan 2017  ·  24Comments  ·  Source: opencv/opencv-python

These two has been put into opencv_contrib

I see opencv_contrib from this article http://www.pyimagesearch.com/2015/07/16/where-did-sift-and-surf-go-in-opencv-3/

BTW: thanks for your great job.

enhancement

Most helpful comment

The builds are now up in PyPI: https://pypi.python.org/pypi/opencv-contrib-python

Release notes: https://github.com/skvark/opencv-python/releases/tag/7

Remember to uninstall opencv-python before installing opencv-contrib-python because the packages use same namespace. Same rule applies if you change from opencv-contrib-python to opencv-python.

All 24 comments

As far as I can understand, some of the opencv_contrib algorithms are non-free/patented and I'm not sure if I can redistribute OpenCV if I add them to the package. More information is needed about opencv_contrib licenses and redistribution rules before any decision can be made.

the opencv_contrib released with license BSD. looks well for now.

asked a question here. wait for answer https://github.com/opencv/opencv_contrib/issues/948 发自网易邮箱大师 On 2017-01-14 00:34 , Olli-Pekka Heinisuo Wrote: As far as I can understand, some of the opencv_contrib algorithms are non-free/patented and I'm not sure if I can redistribute OpenCV if I add them to the package. More information is needed about opencv_contrib licenses and redistribution rules before any decision can be made. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

looks like they do not like it published.

Seems have to use opencv2.4 if I want to use SIFT feature.

From reading that email exchange, it just seems you cannot use them commercially, but you should be able to redistribute them. Additionally, the validity of software patents at all very significantly from country to country so as long as you give the option of not having them included, it should be fine.

Thanks. This means that a new package entry has to be created to PyPI to keep the opencv_contrib separated from the plain opencv package. After this we will have two entries in PyPI:

  • opencv-python, which will remain the same
  • opencv-contrib-python, which will have the contrib modules and a note about the usage in commercial applications

How this will be done in practice is still open. There are few options:

  1. Make a separate repository for opencv_contrib

    • this would duplicate most of the code which is not very practical

  2. Run both builds via this repo, with and without opencv_contrib

    • needs some parameters to the build matrix to decide which build to run

Option 2 is probably the best. Opencv_contrib can be added as a submodule to this repo, and after that it should be pretty easy to parameterize the builds and add new entries to the build matrices. Build times will be of course very long 😃

Hi Skvark, is the new entry on Pypi "opencv-contrib-python" coming soon? :)

It's coming when I or someone else implements it. Probably later this month.

opencv-python is an excellent project, I am looking forward to the new branch "opencv-contrib-python" on pypi.

I have now made most of the changes to enable the contrib builds. Windows builds seem to be fine. However, there's at least one issue related to build times. Travis terminates OS X builds (don't know yet about the Linux builds, still compiling at the moment) at 50 min which is the limit for open source builds. So, builds times require some optimizations before I can make this happen.

Glad to know that. "opencv-contrib-python" is meaningful to many of us.

Some of the Linux builds have the same problem as above. I did run one of them with ninja-build but it took still over 50 minutes. All build speed optimization tips for Travis are welcome.

@skvark I have no experience with Travis, but have you considered trying to get Travis to parrallelize the build process? Just looking around, it appears that each TravisVM has 1.5 cores so you might be able to significantly increase the speed by setting the environment variables properly.

env:
  global:
    - MAKEFLAGS="-j 2"

Apparently, Ninja can use too much memory on Travis-CI causing the SWAP space to be used. Limiting the number of parrallel jobs Ninja can do it does apparently speed things up according to other repos.

Linux builds use -j5 and OS X -j4. I tested them with -j2 too but it had no effect. I will try how it goes when ninja is forced to -j2.

Is it possible to upload to pypi manualy at present?

Is any progress, @skvark

You can follow the progress in https://github.com/skvark/opencv-python/tree/opencv_contrib. Please don't spam to this thread, it will not have any effect to the development process.

@skvark have you considered caching intermediary build artifacts? It might help to speed up builds if used properly.

Do you mean like pip cache? I managed somehow to get a single macOS build to compile in 31 minutes by adding some OpenCV build flags and -j8, but I don't believe those changes alone made the build faster. Maybe there has been come changes in the Travis macOS environment... Still, some Linux builds take too long. I'll have to see if there are some OpenCV build flags which can be disabled to boost the compilation speed.

Good news. I had a better look into the build time issue and it turned out that there was a bug in build-wheels.sh file. The script looped through available Python installations and ended up compiling OpenCV multiple times in some cases (related to different unicode width's in Python 2.7). I'm going to do some cleaning and testing before merging the changes into master, but if everything goes as expected, the opencv-contrib-python package should be available pretty soon in PyPI.

Do you mean like pip cache?

No, I was more thinking of object files for example. You can cache an arbitrary directory in travis: https://docs.travis-ci.com/user/caching/#Arbitrary-directories

Yes, that would indeed make the build faster since the build changes only when the OpenCV version is updated. I'll have to see if that can be done easily for example by caching the whole cmake generated build directory.

The builds are now up in PyPI: https://pypi.python.org/pypi/opencv-contrib-python

Release notes: https://github.com/skvark/opencv-python/releases/tag/7

Remember to uninstall opencv-python before installing opencv-contrib-python because the packages use same namespace. Same rule applies if you change from opencv-contrib-python to opencv-python.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ES-Alexander picture ES-Alexander  ·  5Comments

Borda picture Borda  ·  4Comments

askerlee picture askerlee  ·  5Comments

demolpc picture demolpc  ·  3Comments

chtsngn picture chtsngn  ·  3Comments