File size: 630 Bytes
488c004 b4cba66 488c004 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from streamlit_webrtc import webrtc_streamer, RTCConfiguration
import av
import cv2
cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
class VideoProcessor:
def recv(self, frame):
frm = frame.to_ndarray(format="bgr24")
faces = cascade.detectMultiScale(cv2.cvtColor(frm, cv2.COLOR_BGR2GRAY), 1.1, 3)
for x,y,w,h in faces:
cv2.rectangle(frm, (x,y), (x+w, y+h), (0,255,0), 3)
return av.VideoFrame.from_ndarray(frm, format='bgr24')
webrtc_streamer(key="key", video_processor_factory=VideoProcessor,rtc_configuration= RTCConfiguration{"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}) ) |