Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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 3.6.4中的Opencv 3错误_Python_Opencv_Module - Fatal编程技术网

python 3.6.4中的Opencv 3错误

python 3.6.4中的Opencv 3错误,python,opencv,module,Python,Opencv,Module,我刚刚开始学习python上的opencv 我正在使用Win10、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

我刚刚开始学习python上的opencv 我正在使用Win10、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'
回溯(最近一次呼叫最后一次):
文件“C:\…\PyCharm 2018.1.2\helpers\pydev\pydev\u run\u in_console.py”,第行
52, 
在run_文件中
pydev_imports.execfile(文件、全局、局部)#执行脚本
文件“C:\…\PyCharm 2018.1.2\helpers\pydev\\u pydev\u imps\\u pydev\u execfile.py”,
第18行,在execfile中
exec(编译(内容+“\n”,文件,'exec'),全局,loc)
文件“C:/Projects/P03/Program.py”,第20行,在
main()
文件“C:/Projects/P03/Program.py”,第13行,主目录
img_translation=cv2.wrapAffine(图像,T,(宽度,高度))
AttributeError:模块“cv2.cv2”没有属性“wrapAffine”
但是当我在dir(cv2)中看到 我可以找到wrapAffine函数

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

您的代码有输入错误,或者可能对正确的术语有误解

该函数是,而不是
wrapAffine


您的代码中有一个输入错误,或者可能对正确的术语有误解

该函数是,而不是
wrapAffine

该函数是
warpAffine
。 此函数对图像应用仿射变换

该函数是
warpAffine

此函数对图像应用仿射变换

为什么被否决我不认为他们的答案有任何错误。这个答案是正确的,但有人否决了它。你什么时候会要求对否决票做出解释?@JeruLuke:我认为某人甚至不必有理由;我想这是被否决了,因为它基本上和我的答案没有什么不同,或者可能遗漏了其他东西。但是,先生,如果一个问题有两个相同的答案,那并不意味着我在复制你的答案。@Chandrapalsingjhala偶尔你会得到一些奇怪的否决票(就像有很多奇怪的赞成票发生一样)有人认为它没什么用处,这就是生活,对此争论不大。我不认为他们的答案有任何错误。这个答案是正确的,但是有人投了反对票。你什么时候会要求对否决票做出解释?@JeruLuke:我认为某人甚至不必有理由;我想这是被否决了,因为它基本上和我的答案没有什么不同,或者可能遗漏了其他东西。但是,先生,如果一个问题有两个相同的答案,那并不意味着我在复制你的答案。@Chandrapalsingjhala偶尔你会得到一些奇怪的否决票(就像有很多奇怪的赞成票发生一样)有人认为它没什么用处,这就是生活,对此争论不大。克服它,继续前进,从长远来看,这几点毫无意义。
  wrapAffine(image, T, (width, height))