Running camera live on google colab

Viewed 24

How can I run this code on google colab to capture live fit with landmarks?

import cv2
import mediapipe as mp

mp_holistic = mp.solutions.holistic
cap = cv2.VideoCapture(0)
# Set mediapipe model 
with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
    while cap.isOpened():
    # Read feed
    ret, frame = cap.read()

    # Make detections
    image, results = mediapipe_detection(frame, holistic)
    print(results)
    
    # Draw landmarks
    draw_styled_landmarks(image, results)
    
    # Show to screen
    cv2.imshow('OpenCV Feed', image)

    # Break gracefully
    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
0 Answers
Related