Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当我在带掩码的python中使用cv2.goodFeaturesToTrack时,发生了以下错误_Python_Python 3.x_Image_Opencv3.0 - Fatal编程技术网

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

当我在带掩码的python中使用cv2.goodFeaturesToTrack时,发生了以下错误,python,python-3.x,image,opencv3.0,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, qu

这是我的代码:

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

OpenCV错误:断言失败(_-mask.empty()| |(_-mask.type()==((0)和((1)尝试使用np.uint8作为edge_-mask的类型。很好,很好!谢谢