简体   繁体   English

如何修复错误“模块'cv2.cv2'没有属性setMouseCallBack?”

[英]How to fix the error "module 'cv2.cv2' has no attribute setMouseCallBack?"

"I'm trying to implement setMouseCallBack function using which I want to get the co-ordinate value of the location of image on which the mouse is left-clicked. I wrote the code. But on running, it shows the error that "module 'cv2.cv2' does not have attribute setMouseCallBack". I already ran the command : pip install opencv-contrib-python as suggested in some other answers, but still it is not working. “我正在尝试实现 setMouseCallBack 函数,使用它我想获取鼠标左键单击的图像位置的坐标值。我编写了代码。但是在运行时,它显示了“模块”的错误'cv2.cv2' 没有属性 setMouseCallBack”。我已经按照其他一些答案中的建议运行了命令:pip install opencv-contrib-python,但它仍然无法正常工作。

The code is given below:代码如下:

import numpy as np
import cv2

def click_event(event,x,y,flags,param):
    if event==cv2.EVENT_LBUTTONDOWN:
        font=cv2.FONT_HERSHEY_SIMPLEX
        coordinate=str(x)+', '+str(y)
        cv2.putText(img,coordinate,(x,y),font,.5,(255,255,0),2)
        cv2.imshow('image',img)

img=np.zeros((512,512,3),dtype='uint8')
cv2.imshow('image',img)

cv2.setMouseCallBack('image',click_event)

cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.setMouseCallback('image', click_event)

B 不是资本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 模块 'cv2.cv2' 没有属性 'sift' - module 'cv2.cv2' has no attribute 'sift' 模块“cv2.cv2”没有属性“PutText” - module 'cv2.cv2' has no attribute 'PutText' 模块“cv2.cv2”没有属性“xfeatures2d”,模块“cv2.cv2”没有属性“SIFT” - module 'cv2.cv2' has no attribute 'xfeatures2d' and module 'cv2.cv2' has no attribute 'SIFT' AttributeError:模块'cv2.cv2'没有属性'rectange' - AttributeError: module 'cv2.cv2' has no attribute 'rectange' 模块“cv2.cv2”没有属性“dnn_superres” - module 'cv2.cv2' has no attribute 'dnn_superres' AttributeError: 模块 'cv2.cv2' 没有属性 'release' - AttributeError: module 'cv2.cv2' has no attribute 'release' 接收错误:AttributeError:尝试调用openCV方法时,模块'cv2.cv2'没有属性'CompareHist' - Receiving error: AttributeError: module 'cv2.cv2' has no attribute 'CompareHist' when trying to call a openCV method 模块“cv2.cv2”没有属性“xfeatures2d”(Opencv 3.4.2.17) - module 'cv2.cv2' has no attribute 'xfeatures2d'(Opencv 3.4.2.17) AttributeError: 模块 'cv2.cv2' 没有属性 'CAP_PROP_ORIENTATION_META' - AttributeError: module 'cv2.cv2' has no attribute 'CAP_PROP_ORIENTATION_META' OpenCV AttributeError 模块“cv2.cv2”没有属性“TrackerBoosting_create” - OpenCV AttributeError module 'cv2.cv2' has no attribute 'TrackerBoosting_create'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM