gpt4 book ai didi

python - python 3.6.4 中的错误 Opencv 3

转载 作者:太空宇宙 更新时间:2023-11-03 21:59:30 24 4
gpt4 key购买 nike

我刚刚开始在 python 上学习 opencv我正在使用 win 10、python 3.6.4 和 opencv 3.4当我想运行这段代码时

image = cv2.imread("lena.jpg")

height, width = image.shape[:2]

quarter_height, quarter_width = height/4, width/4

T = np.float32([[1, 0, quarter_height], [0, 1, quarter_width]])
img_translation = cv2.wrapAffine(image, T, (width, height))
cv2.imshow("Translate", img_translation)
cv2.waitKey(0)
cv2.destroyAllWindows()

出现这个错误

Traceback (most recent call last):
File "C:\...\PyCharm 2018.1.2\helpers\pydev\pydev_run_in_console.py", line
52,
in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\...\PyCharm 2018.1.2\helpers\pydev\_pydev_imps\_pydev_execfile.py",
line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Projects/P03/Program.py", line 20, in <module>
main()
File "C:/Projects/P03/Program.py", line 13, in main
img_translation = cv2.wrapAffine(image, T, (width, height))
AttributeError: module 'cv2.cv2' has no attribute 'wrapAffine'

但是当我在 dir(cv2) 中看到我可以找到 wrapAffine 函数

我知道如何解决这个问题我尝试在几个 IDE 和 python 控制台上运行代码但什么也没发生。请帮忙

最佳答案

您的代码中有拼写错误,或者可能对正确的术语有误解。

The function is warpAffine, not wrapAffine.

关于python - python 3.6.4 中的错误 Opencv 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50128034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com