简体   繁体   中英

OpenCV Python can't use SIFT

I'm trying a simple thing like

sift = cv2.SIFT()

and get this bad error

raceback (most recent call last): File "C:\\image processing\\featurematching2.py", line 9, in sift = cv2.SIFT() AttributeError: 'module' object has no attribute 'SIFT'

I do not understand that because cv2 is installed.

cv2.version is '3.1.0'

my system is windows8.1 64bit my python program 2.7.12 and opencv 3.1.0

maybe someone has got the same problem and could help me

thanks a lot

In OpenCV 3 a more strict separation has been done to distinguish between proprietary and non-proprietary features (also royalty free and not free). Both SIFT and SURF are proprietary algorithms (and not royalty free) and as such are not distributed with a default installation of OpenCV 3 (the one you find in a distro's repository unless it doesn't have a problem with distributing proprietary stuff).

In order to access such proprietary features you need to build them from source by compiling the contrib module. I've never stumbled across this issue because I always build OpenCV from source (at least starting from version 3.0) so I was always selecting which features I think I will use and building these accordingly.

Detailed instructions are provided here . The contrib module is all you need. Personally I would advise to compile OpenCV at least once so that you can get a better overview of what's where.

Note the following though - as mentioned SIFT is proprietary and not royalty free. See this discussion for more details. Basically if you are doing projects for fun at home or at school you are good to go. But the moment you start working on these as a part of a company project or in general for commercial use, you have to cash in.

Last but not least the opencv_contrib module also contains features that are not stable enough to be included in the main packages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM