Reputation: 41
I'm just getting started to learning opencv on python I'm using win 10, python 3.6.4 and opencv 3.4 when i want to run this code
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()
this error raised
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'
but when i see in dir(cv2) i can find wrapAffine function
i do know how to solve this problem i tried to run the code on several IDEs and python console but nothing happened. please help
Upvotes: 1
Views: 887
Reputation: 291
wrapAffine(image, T, (width, height))
The function is warpAffine
.
This function apply a affine transformation to the image
Upvotes: 2
Reputation: 47292
You have a typo in your code, or maybe a misunderstanding of the correct term.
The function is
warpAffine
, notwrapAffine
.
Upvotes: 3