system windows 10 msvc 2017 python 3.6.6
Hi,
It seems that some users have got some problem with drawKeypoints (http://answers.opencv.org/question/206950/function-drawkeypoints-do-not-work-in-opencv-401/ and http://answers.opencv.org/question/207758/drawkeypoints-bug/) using this code
import cv2
import numpy as np
def draw_keypoints(vis, keypoints, color = (0, 255, 255)):
for kp in keypoints:
x, y = kp.pt
cv2.circle(vis, (int(x), int(y), 2, color))
input_image = cv2.imread('lena.jpg')
if input_image is None:
print("check file path")
exit()
gray_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
orb = cv2.ORB_create()
keypoints = orb.detect(gray_image, None)
keypoints, descriptor = orb.compute(gray_image, keypoints)
t= cv2.drawKeypoints(input_image, keypoints, outImage=input_image, color=(0,255,0),
flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow('ORB keypoints', input_image)
cv2.waitKey()
Error is AttributeError: module 'cv2.cv2' has no attribute 'drawKeypoints'
If i use my own version opencv-python there is no problem. Something is wrong but what ?
This seems to be a bug in the binding generators in the upstream? You will have to wait that I have time to make a release for version 4.0.1 as it seems that the bug was fixed between 4.0.0 and 4.0.1 releases.
Yes it is fixed now. Some users wait the new release. As moderator on answers.opencv.org I can give an explanation.
Thanks
Thanks for your work on opencv-python.
I encounter the same issue.
In the meantime, I have worked around the issue by editing my code: I have replaced each call to drawKeypoints() with several calls to drawMarker().
For instance, in the tutorial:
img2 = cv.drawKeypoints(img, kp, None, color=(0,255,0), flags=0)
plt.imshow(img2), plt.show()
with:
img2 = img.copy()
for marker in kp:
img2 = cv.drawMarker(img2, tuple(int(i) for i in marker.pt), color=(0, 255, 0))
plt.imshow(img2), plt.show()
This issue should be fixed in 4.0.1 but unfortunately I cannot release 4.0.1 before macOS build issues have been solved.
Do you know when 4.0.1 might be released? Thanks
Hello ,
I had a question about the version available : when I run pip install opencv-python on my Rpi 3B+ : it installs opencv 3.4 .. but here it's said the current version is 4.0 ( " opencv-python 4.0.0.21 " // https://pypi.org/project/opencv-python/ ) .
(In fact I first tried for 3 days to compil myself a 4.0.0 build, following several tutorials webpage, but without any success .. each time after installing the build/make it says " no module named cv2 found .. " So the only working solution for me is using this ' pip install opencv-python ' )
Could you let me know how to reach this version '4.0.0.21' please ?
Thanks for your work Skvark !
@wipix sorry, that's my fault - I built the opencv-python packages on the RPi but I've been too swamped to finish 4.x recently. I'll try and get the builders working on this next week but if you can't wait that long you'll just have to build it from source for now.
Hi Waveform80 , thank your for your response. Ok no problem , happy to hear that it's coming soon ! I'll wait ;) . Thanks for your hard work !
Hi,
Is there any rough ETA on releasing 4.01 with the fix to this drawKeypoints issue?
Like a week, a month, six months?
Thanks for any guidance.
Just in case someone who needs v4.0.1 on Windows stumbles here and cannot wait for the fix, you can download a .whl file from this repository and install it locally with pip. It is less handy than a PyPI install, but that might help in the meantime.
You can build OpenCV yourself if you need 4.0.1 right now or downgrade opencv-python to 3.4.5. I have been busy lately, but I'll have a look at the macOS Travis environments again during this week. I cannot give any estimates about the release date.
Still the error. Is the 4.0.1 being release, or we still need to build it from source ?
As you can see from the releases page or from PyPI there is no new release. I have very little free time to debug the macOS build issue. Any help is appreciated, especially since I do not own any macOS devices.
Well, not sure if it's for the same reason or it's just me, but I have the issue on Ubuntu 18.XX, so a non-macOS device. :-)
EDIT : Compilation eventually ended, and same problem from source. So my issue may be a false positive.
I mean that the compilation fails in this repository (due to homebrew issues on Travis) on macOS. This drawKeypoints issue should be fixed if you compile OpenCV 4.0.1 manually. I have to release all the builds (Windows, macOS, Linux) simultaneosly to PyPi to avoid breaking millions of installations. There are no build issues currently with Windows or Linux builds.
Below code worked for me after modifying drawKeypoints as suggested by @woctezuma
Thanks :+1:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('/Images/object3.jpg',0)
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector_create(threshold=25)
# find and draw the keypoints
kp = fast.detect(img, None)
# Print all default params
print ("Threshold: ", fast.getThreshold())
print ("NonmaxSuppression: ", fast.getNonmaxSuppression())
print ("Neighborhood: ", fast.getType())
print ("Total Keypoints with NonmaxSuppression: ", len(kp))
img2 = img.copy()
for marker in kp:
img2 = cv2.drawMarker(img2, tuple(int(i) for i in marker.pt), color=(0, 255, 0))
cv2.imshow("FAST TRUE", img2)
cv2.imwrite('/Output/fast_true.png',img2)
# Disable nonmaxSuppression
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)
print ("Total Keypoints without NonmaxSuppression: ", len(kp))
img3 = img.copy()
for marker in kp:
img3 = cv2.drawMarker(img3, tuple(int(i) for i in marker.pt), color=(0, 255, 0))
cv2.imshow("FAST False", img3)
if cv2.waitKey(0) & 0xFF == ord('q'):
cv2.imwrite('/Output/fast_false.png',img3)
cv2.destroyAllWindows()
@joshlynsathish
Traceback (most recent call last):
File "C:\Users\home\Desktop\iiitb-intern\indoor-outdoor\sampleorb.py", line 13, in
img3 = img1.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
I am getting this error.
Help!!!
I'm using 4.1.0 and having this problem.
how to compare check image similarity with fast algorithm because which is giving key points only not descriptors .in sift and orb returning descriptors also
Most helpful comment
Thanks for your work on
opencv-python.I encounter the same issue.
In the meantime, I have worked around the issue by editing my code: I have replaced each call to
drawKeypoints()with several calls todrawMarker().For instance, in the tutorial:
with: