hillol7 commited on
Commit
61d7d6c
·
verified ·
1 Parent(s): 38e26ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import cv2
3
  import numpy as np
 
4
 
5
  def main():
6
  st.title("SIFT Object Tracking in Video")
@@ -11,8 +12,16 @@ def main():
11
 
12
  if uploaded_image and uploaded_video:
13
  st.sidebar.success("Files successfully uploaded!")
14
- image = cv2.imdecode(np.frombuffer(uploaded_image.read(), np.uint8), cv2.IMREAD_COLOR)
15
- video = cv2.VideoCapture(np.frombuffer(uploaded_video.read(), np.uint8))
 
 
 
 
 
 
 
 
16
 
17
  st.header("Uploaded Image")
18
  st.image(image, caption="Uploaded Image", use_column_width=True)
@@ -64,4 +73,4 @@ def main():
64
  st.sidebar.warning("Please upload both an image and a video.")
65
 
66
  if __name__ == "__main__":
67
- main()
 
1
  import streamlit as st
2
  import cv2
3
  import numpy as np
4
+ import tempfile
5
 
6
  def main():
7
  st.title("SIFT Object Tracking in Video")
 
12
 
13
  if uploaded_image and uploaded_video:
14
  st.sidebar.success("Files successfully uploaded!")
15
+
16
+ # Save the uploaded image to a temporary file
17
+ with tempfile.NamedTemporaryFile(suffix='.jpg') as tmp:
18
+ tmp.write(uploaded_image.read())
19
+ image = cv2.imread(tmp.name)
20
+
21
+ # Save the uploaded video to a temporary file
22
+ with tempfile.NamedTemporaryFile(suffix='.mp4') as tmp:
23
+ tmp.write(uploaded_video.read())
24
+ video = cv2.VideoCapture(tmp.name)
25
 
26
  st.header("Uploaded Image")
27
  st.image(image, caption="Uploaded Image", use_column_width=True)
 
73
  st.sidebar.warning("Please upload both an image and a video.")
74
 
75
  if __name__ == "__main__":
76
+ main()