Phaneendrabayi commited on
Commit
92ea980
·
verified ·
1 Parent(s): 2f4663c

Update pages/Life_cycle_of_ML.py

Browse files
Files changed (1) hide show
  1. pages/Life_cycle_of_ML.py +2 -61
pages/Life_cycle_of_ML.py CHANGED
@@ -875,7 +875,7 @@ def video_handling_dashboard():
875
  # **Title and Introduction**
876
  st.title("OpenCV Video Handling Explanation and Examples")
877
  # 1. What is a Video
878
- st.header("What is a Video?")
879
  st.write("""
880
  A video is essentially a sequence of images (called frames) displayed in rapid succession to create the illusion of motion.
881
  OpenCV allows us to process these frames sequentially for tasks like display, modification, or saving to a file.
@@ -905,7 +905,7 @@ cap.release()
905
  cv2.destroyAllWindows()
906
  """, language='python')
907
 
908
- st.header("Extracting Frames from Video:")
909
  st.code("""import cv2
910
  # Extracting a specific frame
911
  cap = cv2.VideoCapture('your_video_file.mp4')
@@ -1008,65 +1008,6 @@ cap.release()
1008
  cv2.destroyAllWindows() # Close all OpenCV windows
1009
  """, language="python")
1010
 
1011
- # A Simple Demo using Streamlit
1012
- st.subheader("Demo: Process Frames in Real-Time")
1013
- st.write("""
1014
- This example captures video from your webcam, processes frames in real-time, and displays them:
1015
- """)
1016
- # Title of the app
1017
- st.title("Webcam Stream on Button Click")
1018
-
1019
- # Button to start the webcam
1020
- if st.button("Start Webcam"):
1021
- # Get video from webcam
1022
- cap = cv2.VideoCapture(0)
1023
-
1024
- # Check if camera opened successfully
1025
- if not cap.isOpened():
1026
- st.error("Cannot open camera")
1027
-
1028
- while True:
1029
- # Capture frame-by-frame
1030
- ret, frame = cap.read()
1031
-
1032
- # If frame is not read correctly
1033
- if not ret:
1034
- st.error("Can't receive frame (stream end?). Exiting ...")
1035
- break
1036
-
1037
- # Our operations on the frame here
1038
- gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
1039
-
1040
- # Display the resulting frame
1041
- st.image(gray, channels="L")
1042
-
1043
- # When everything done, release the capture
1044
- cap.release()
1045
-
1046
- st.code("""
1047
- import cv2
1048
- import streamlit as st
1049
-
1050
- vid = cv2.VideoCapture(0)
1051
- stframe = st.empty()
1052
-
1053
- while True:
1054
- success, frame = vid.read()
1055
- if not success:
1056
- st.warning("Webcam not accessible")
1057
- break
1058
-
1059
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # Convert BGR to RGB for Streamlit
1060
- stframe.image(frame, use_column_width=True)
1061
-
1062
- if cv2.waitKey(1) & 0xFF == ord('q'): # Exit on pressing 'q'
1063
- break
1064
-
1065
- vid.release()
1066
- cv2.destroyAllWindows()
1067
- """, language="python")
1068
-
1069
- st.write("Use the code above to see the webcam in real time using Streamlit!")
1070
 
1071
 
1072
 
 
875
  # **Title and Introduction**
876
  st.title("OpenCV Video Handling Explanation and Examples")
877
  # 1. What is a Video
878
+ st.subheader("What is a Video?")
879
  st.write("""
880
  A video is essentially a sequence of images (called frames) displayed in rapid succession to create the illusion of motion.
881
  OpenCV allows us to process these frames sequentially for tasks like display, modification, or saving to a file.
 
905
  cv2.destroyAllWindows()
906
  """, language='python')
907
 
908
+ st.subheader("Extracting Frames from Video:")
909
  st.code("""import cv2
910
  # Extracting a specific frame
911
  cap = cv2.VideoCapture('your_video_file.mp4')
 
1008
  cv2.destroyAllWindows() # Close all OpenCV windows
1009
  """, language="python")
1010
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1011
 
1012
 
1013