嗨,我正在用Python做OpenCV。我确实旋转了图像。我实际上想做的是旋转框架而不是图像。这是我的下面的代码
import cv2
import time
cv2.namedWindow("Example")
frame = cv2.imread('logo.JPG')
#frame = cv2.flip(frame,90)
while True:
cv2.imshow("Example", frame)
k = chr(cv2.waitKey())
if k == 'a':
cap = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
runTime = time.time() + 2.5
while time.time() < runTime:
ret, frame = cap.read()
if not ret:
break
info = 'Place your face in the center.'
cv2.rectangle(frame, (0, 0), (1000, 24), (0, 0, 0), cv2.FILLED)
cv2.putText(frame, info, (200, 15), font, 0.5, (255, 255, 255), 1)
cv2.line(frame, (150, 100), (220, 100), (0, 0, 0), 3)
cv2.line(frame, (150, 100), (150, 170), (0, 0, 0), 3)
cv2.line(frame, (150, 400), (220, 400), (0, 0, 0), 3)
cv2.line(frame, (150, 400), (150, 330), (0, 0, 0), 3)
cv2.line(frame, (430, 100), (500, 100), (0, 0, 0), 3)
cv2.line(frame, (500, 100), (500, 170), (0, 0, 0), 3)
cv2.line(frame, (430, 400), (500, 400), (0, 0, 0), 3)
cv2.line(frame, (500, 400), (500, 330), (0, 0, 0), 3)
cv2.line(frame, (0, 260), (800, 260), (0, 0, 255), 1)
cv2.line(frame, (325, 25), (325, 800), (0, 0, 255), 1)
cv2.imshow("Example", frame)
cv2.imwrite('newTestImg.jpg', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
frame = cv2.imread('logo.JPG')
cv2.imshow("Example", frame)
cv2.destroyAllWindows()
如果我运行此代码,结果将如下所示。
我实际上想做的就是旋转下图所示的框架。
所以我不仅可以旋转图片,还可以旋转框架。
如果您知道,请帮助我。