当我在带遮罩的python中使用cv2.goodFeaturesToTrack时,发生以下错误

时间:2018-07-08 00:12:47

标签: python python-3.x image opencv3.0

这是我的代码:

frame_gray = cv2.cvtColor(cv2.imread('image.jpg'), cv2.COLOR_BGR2GRAY)
edge_mask = np.ones((457, 702))
cv2.rectangle(edge_mask, (15, 15), (687, 442), 0, cv2.FILLED)
p_add = cv2.goodFeaturesToTrack(frame_gray, mask=edge_mask, maxCorners=50, qualityLevel=0.3, minDistance=5, blockSize=7)

这是错误:

OpenCV Error: Assertion failed (_mask.empty() || (_mask.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && _mask.sameSize(_image))) in goodFeaturesToTrack, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/featureselect.cpp, line 366
Traceback (most recent call last):
File "test.py", line 59, in <module>
frame_gray, mask=edge_mask, maxCorners=50, qualityLevel=0.3, minDistance=5, blockSize=7)
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/featureselect.cpp:366: error: (-215) _mask.empty() || (_mask.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && _mask.sameSize(_image)) in function goodFeaturesToTrack

frame_gray和edge_mask都具有(457,702)的形状,因为我不理解“((((0)&((1 << 3)-1))+((((1)- 1)<< 3))“之类的东西,所以我不知道出了什么问题

0 个答案:

没有答案