Trueinfo commited on
Commit
101ca90
·
1 Parent(s): 74de0f9

Upload 2 files

Browse files
Files changed (2) hide show
  1. cvapp2.py +29 -0
  2. requirements.txt +83 -0
cvapp2.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ from PIL import Image
4
+
5
+ uploaded_video = st.file_uploader("Choose video", type=["mp4", "mov"])
6
+ frame_skip = 200 # display every 300 frames
7
+
8
+ if uploaded_video is not None: # run only when user uploads video
9
+ vid = uploaded_video.name
10
+ with open(vid, mode='wb') as f:
11
+ f.write(uploaded_video.read()) # save video to disk
12
+
13
+ st.markdown(f"""
14
+ ### Files
15
+ - {vid}
16
+ """,
17
+ unsafe_allow_html=True) # display file name
18
+
19
+ vidcap = cv2.VideoCapture(vid) # load video from disk
20
+ cur_frame = 0
21
+ success = True
22
+
23
+ while success:
24
+ success, frame = vidcap.read() # get next frame from video
25
+ if cur_frame % frame_skip == 0: # only analyze every n=300 frames
26
+ print('frame: {}'.format(cur_frame))
27
+ pil_img = Image.fromarray(frame) # convert opencv frame (with type()==numpy) into PIL Image
28
+ st.image(pil_img,channels='BGR')
29
+ cur_frame += 1
requirements.txt ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==5.0.1
2
+ appdirs==1.4.4
3
+ appnope==0.1.3
4
+ asttokens==2.4.1
5
+ attrs==23.1.0
6
+ beautifulsoup4==4.12.2
7
+ blinker==1.6.2
8
+ cachetools==5.3.1
9
+ certifi==2023.7.22
10
+ charset-normalizer==3.2.0
11
+ click==8.1.6
12
+ comm==0.2.0
13
+ debugpy==1.8.0
14
+ decorator==5.1.1
15
+ executing==2.0.1
16
+ ffmpeg-python==0.2.0
17
+ frozendict==2.3.8
18
+ future==0.18.3
19
+ gitdb==4.0.10
20
+ GitPython==3.1.32
21
+ html5lib==1.1
22
+ idna==3.4
23
+ importlib-metadata==6.8.0
24
+ ipykernel==6.26.0
25
+ ipython==8.17.2
26
+ jedi==0.19.1
27
+ Jinja2==3.1.2
28
+ jsonschema==4.19.0
29
+ jsonschema-specifications==2023.7.1
30
+ jupyter_client==8.6.0
31
+ jupyter_core==5.5.0
32
+ lxml==4.9.3
33
+ markdown-it-py==3.0.0
34
+ MarkupSafe==2.1.3
35
+ matplotlib-inline==0.1.6
36
+ mdurl==0.1.2
37
+ multitasking==0.0.11
38
+ nest-asyncio==1.5.8
39
+ numpy==1.25.2
40
+ opencv-python==4.8.1.78
41
+ packaging==23.1
42
+ pandas==2.0.3
43
+ parso==0.8.3
44
+ peewee==3.17.0
45
+ pexpect==4.8.0
46
+ Pillow==9.5.0
47
+ platformdirs==3.11.0
48
+ prompt-toolkit==3.0.39
49
+ protobuf==3.20.1
50
+ psutil==5.9.6
51
+ ptyprocess==0.7.0
52
+ pure-eval==0.2.2
53
+ pyarrow==12.0.1
54
+ pydeck==0.8.0
55
+ Pygments==2.16.1
56
+ Pympler==1.0.1
57
+ python-dateutil==2.8.2
58
+ pytz==2023.3
59
+ pytz-deprecation-shim==0.1.0.post0
60
+ pyzmq==25.1.1
61
+ referencing==0.30.2
62
+ requests==2.31.0
63
+ rich==13.5.2
64
+ rpds-py==0.9.2
65
+ six==1.16.0
66
+ smmap==5.0.0
67
+ soupsieve==2.5
68
+ stack-data==0.6.3
69
+ streamlit==1.25.0
70
+ tenacity==8.2.2
71
+ toml==0.10.2
72
+ toolz==0.12.0
73
+ tornado==6.3.3
74
+ traitlets==5.13.0
75
+ typing_extensions==4.7.1
76
+ tzdata==2023.3
77
+ tzlocal==4.3.1
78
+ urllib3==2.0.4
79
+ validators==0.21.2
80
+ wcwidth==0.2.9
81
+ webencodings==0.5.1
82
+ yfinance==0.2.31
83
+ zipp==3.16.2