Update pages/2_📷_Webcamera.py
Browse files- pages/2_📷_Webcamera.py +29 -26
pages/2_📷_Webcamera.py
CHANGED
|
@@ -1,33 +1,33 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
# st.title("Webcamera")
|
| 14 |
# st.write("Steps to use: \n1. Click on Start button.\n2. To stop the video when done, press Stop. \n\n The output will be displayed in about 40 secs.")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
# time.sleep(10)
|
| 33 |
# st.write(len(ctx.video_processor.my_list))
|
|
@@ -66,8 +66,11 @@
|
|
| 66 |
# output_df.rename(columns = {0:'Index'}, inplace = True)
|
| 67 |
# st.write(output_df)
|
| 68 |
import streamlit as st
|
|
|
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
if picture:
|
| 73 |
-
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from streamlit_webrtc import webrtc_streamer
|
| 3 |
+
import av
|
| 4 |
+
import cv2
|
| 5 |
+
import time
|
| 6 |
+
import mediapipe as mp
|
| 7 |
+
import numpy as np
|
| 8 |
+
import pandas as pd
|
| 9 |
+
from mediapipe_functions import *
|
| 10 |
+
from utils import *
|
| 11 |
+
import tensorflow as tf
|
| 12 |
|
| 13 |
# st.title("Webcamera")
|
| 14 |
# st.write("Steps to use: \n1. Click on Start button.\n2. To stop the video when done, press Stop. \n\n The output will be displayed in about 40 secs.")
|
| 15 |
|
| 16 |
+
class VideoProcessor:
|
| 17 |
+
def __init__(self) -> None:
|
| 18 |
+
self.threshold1 = 100
|
| 19 |
+
self.threshold2 = 200
|
| 20 |
+
self.my_list = []
|
| 21 |
|
| 22 |
+
def recv(self, frame):
|
| 23 |
+
img = frame.to_ndarray(format="bgr24")
|
| 24 |
+
self.my_list.append(img)
|
| 25 |
+
return av.VideoFrame.from_ndarray(img, format="bgr24")
|
| 26 |
|
| 27 |
+
# Create the video processor instance
|
| 28 |
+
video_processor = VideoProcessor()
|
| 29 |
|
| 30 |
+
ctx = webrtc_streamer(key="sample", video_processor_factory=lambda: video_processor)
|
| 31 |
|
| 32 |
# time.sleep(10)
|
| 33 |
# st.write(len(ctx.video_processor.my_list))
|
|
|
|
| 66 |
# output_df.rename(columns = {0:'Index'}, inplace = True)
|
| 67 |
# st.write(output_df)
|
| 68 |
import streamlit as st
|
| 69 |
+
import time
|
| 70 |
|
| 71 |
+
# start = time.time()
|
| 72 |
+
# while(time.)
|
| 73 |
+
# picture = st.camera_input("Take a picture")
|
| 74 |
|
| 75 |
+
# if picture:
|
| 76 |
+
# st.image(picture)
|