Приложение на отслеживания людей на видео
To upload files, please first save the app
import streamlit as st
import cv2
import numpy as np
st.title("People Tracking in Video")
# Upload video file
video_file = st.file_uploader("Upload a video file", type=["mp4", "avi", "mov"])
if video_file is not None:
# Read video file
cap = cv2.VideoCapture(video_file)
# Create a tracker
tracker = cv2.TrackerCSRT_create() if cv2.__version__.split('.')[0] == '4' else cv2.TrackerKCF_create()
# Read first frame and select ROI for tracking
ret, frame = cap.read()
x, y, width, height = st.selectbox("Select ROI for tracking:", [1, 2, 3, 4, 5, 6])
bbox = (x, y, width, height)
tracker.init(frame, bbox)
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
success, bbox = tracker.update(frame)
# Draw bounding box
if success:
(x, y, w, h) = [int(v) for v in bbox]
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
else:
cv2.putText(frame, "Tracking failure", (100, 200), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)
# Display the result
st.image(frame, channels='BGR')
cap.release()
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?