rcrespocano / opencv-python Goto Github PK
View Code? Open in Web Editor NEWCurso introducción a OpenCV y Python
License: GNU General Public License v3.0
Curso introducción a OpenCV y Python
License: GNU General Public License v3.0
Again, some errors due to a series of refactoring operations made in the latest versions:
Ejemplo 22, line 25,26 and 27 crash:
knn = cv2.KNearest() # error
knn.train(trainData, responses) # error
ret, results, neighbours, dist = knn.find_nearest(newcomer, k) # error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-cfe065aacd5a> in <module>()
23 # Classification
24 k = 5
---> 25 knn = cv2.KNearest()
26 knn.train(trainData, responses)
27 ret, results, neighbours, dist = knn.find_nearest(newcomer, k)
AttributeError: module 'cv2' has no attribute 'KNearest'
This version works:
knn = cv2.ml.KNearest_create()
knn.train(trainData,cv2.ml.ROW_SAMPLE,responses)
ret, results, neighbours, dist = knn.findNearest(newcomer, k)
+info:
http://stackoverflow.com/a/30950853
http://stackoverflow.com/a/32990528
http://stackoverflow.com/a/34247966
Ejemplo 16 and 17 return errors:
flags=cv2.cv.CV_HAAR_SCALE_IMAGE
# AttributeError: 'module' object has no attribute 'cv.CV_HAAR_SCALE_IMAGE'
For OpenCV 3.1 use this instead:
flags=cv2.CASCADE_SCALE_IMAGE
info: http://stackoverflow.com/questions/30013009/opencv-3-0-0-dev-python-bindings-not-working-properly
Website with documentation is wrong.
kmeans requires 6 arguments and not 5:
print(cv2.kmeans.__doc__)
# kmeans(data, K, bestLabels, criteria, attempts, flags[, centers]) -> retval, bestLabels, centers
Thus, ejemplo 23, line 22:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-af223fb327d3> in <module>()
20
21 # Apply kmeans
---> 22 ret, label, center = cv2.kmeans(Z, K, criteria, attempts, cv2.KMEANS_RANDOM_CENTERS)
23
24 # Now separate the data, Note the flatten()
TypeError: Required argument 'flags' (pos 6) not found
This will work:
ret, label, center = cv2.kmeans(Z, K, None, criteria, attempts, cv2.KMEANS_RANDOM_CENTERS)
Ejemplo 21, line 83:
# Initiate ORB detector
orb = cv2.ORB()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-63fa69861ef0> in <module>()
81
82 # Initiate ORB detector
---> 83 orb = cv2.ORB()
84
85 # Find the keypoints and descriptors with ORB
AttributeError: module 'cv2' has no attribute 'ORB'
In OpenCV 3.x, this method has been renamed to:
orb = cv2.ORB_create()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.