Python Forum

Full Version: Rotation Effect on live Webcam Feed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Halo, i´m studient to highschool. Big Grin

I need to do a code that make rotation Effect on live Webcam Feed for and against the hands of the clock but just does only to for the hand of the clock, can u help me? this is the code that i have.

import cv2
import time


def main():
    windowName = "Live Video Feed"
    cv2.namedWindow(windowName)
    cap = cv2.VideoCapture(0)

    if cap.isOpened():
        ret, frame = cap.read()

    rows, columns, channels = frame.shape
    angle = 0
    scale = 0.5
#   scale = 1

    while True:

        ret, frame = cap.read()

        if angle == 180:
            angle = 0

        print(scale)

        R = cv2.getRotationMatrix2D((columns / 2, rows / 2), angle, scale)

        print(R)

        output = cv2.warpAffine(frame, R, (columns, rows))

        cv2.imshow(windowName, output)
        angle = angle - 1
        time.sleep(0.01)
        if cv2.waitKey(1) == 27:
            break


    cv2.destroyWindow(windowName)

    cv2.destroyAllWindows()

    cap.release()


if __name__ == "__main__":
    main()