I'm new to Python.
I wanted to rotate the image from the center and tried it while watching the internet, but I don't know what the error message was giving an error.
In the code below, the error spit out was the eleventh line, undefined name 'identity'.
import cv2
import matplotlib.pyplot as plt
def rotate_center (image, angle):
h, w = image.shape [: 2]
affine = cv2.getRotationMatrix2D ((w/2.0, h/2.0), angle, 1.0)
return cv2.warpAffine (image, affine, (w, h))
ifname== "main":
image = cv2.imread ("mizu.jpg") [:,:, ::-1]
converted = identity (image)
plt.imshow (converted)
plt.title ("Identity")
plt.show ()
When I looked into it, it came out that there was a variable error, not being defined, etc., but if I don't check how to define a variable in Python, is it defined without permission? I do not understand because it is written.
I tried to rewrite the characters for strange spaces, but the error did not change.
And even if you look at the site described at the end, it is not described because it is not described where the rotation angle of the image is decided, so I am very sorry, but I would appreciate it if someone could tell me.
-
Answer # 1
Related articles
- how to save the image ocr result file in python
- python image display error beginner, thank you
- about image output of python
- python - error in image binarization using cv2adaptivethreshold function
- python - i want to convert a black and white image to an arbitrary color image
- python - i want to display an image with pysimplegui, but an error occurs
- python - i want to create a contour image
- python - i want to divide the read image into pixels and label them
- python - i want to read an image and display it
- python - image recognition using cnn keras multiple inputs
- python - tkinter photo image question
- python - about image deletion in django
- python - image is not saved even though there is no opencv error
- python - image recognition with keras
- python - (tensorflow) please tell me how to save and output image data mnist
- python - when i tried to inflate the image, i couldn't read the image
- python - i want to load graph data created with pyplot as image data without saving it
- python - i want to find the height information of each pixel in the image
- python - confusion matrix display in image recognition on cnn
- python - out of range of predict function used in image recognition (?)
Even if you sayidentity (image)
is a function that performs "1. Identity transformation" in the reference site.The error is that "
identity
is not defined", but when you look at the code in the question, the function is not defined (copy and paste)., you don't need to actually define (copy and paste), and what you want to do is "12. Rotate from the center of the image" in the reference site code>must be called from
__ main __
.I haven't checked the actual operation, but I think it will work.