hari3485 commited on
Commit
b847e0d
·
verified ·
1 Parent(s): 85085be

Update pages/video.py

Browse files
Files changed (1) hide show
  1. pages/video.py +49 -19
pages/video.py CHANGED
@@ -3,27 +3,57 @@ import numpy as np
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
5
 
6
-
7
- # Title of the app
8
- st.title("Dynamic Grid Generator")
9
 
10
- # Add a slider to control grid size
11
- grid_size = st.slider("Select the grid size", min_value=2, max_value=50, value=10, step=1)
 
 
 
 
 
 
 
 
12
 
13
- # Create the grid
14
- fig, ax = plt.subplots(figsize=(5, 5))
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- # Draw the grid
17
- for x in np.linspace(0, 1, grid_size + 1):
18
- ax.axhline(x, color='black', linewidth=0.5)
19
- ax.axvline(x, color='black', linewidth=0.5)
 
 
 
 
 
20
 
21
- # Adjust plot settings
22
- ax.set_xticks([])
23
- ax.set_yticks([])
24
- ax.set_xlim(0, 1)
25
- ax.set_ylim(0, 1)
26
- ax.set_aspect('equal', adjustable='box')
27
 
28
- # Display the grid
29
- st.pyplot(fig)
 
 
 
 
 
 
 
 
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
5
 
6
+ # Title
7
+ st.title("Understanding Video Data and Processing with OpenCV")
 
8
 
9
+ # Subheader 1: What is Video Data?
10
+ st.markdown("### What is Video Data?")
11
+ st.markdown("""
12
+ - **Video** is a collection of images known as **frames**.
13
+ - Frames are visualized sequentially, creating the perception of motion.
14
+ - **Frame Rate (FPS)** determines smoothness:
15
+ - **30 FPS**: 30 frames per second.
16
+ - **60 FPS**: 60 frames per second.
17
+ - More FPS = smoother video.
18
+ """)
19
 
20
+ # Subheader 2: How to Play a Video Using OpenCV
21
+ st.markdown("### :blue[How to Play a Video Using OpenCV]")
22
+ st.markdown("""
23
+ 1. **Break the Video into Frames**:
24
+ - A video is essentially a sequence of images (frames).
25
+ - Use a `while` loop to iterate through frames, as the total frame count may not be known.
26
+ 2. **Key Functions**:
27
+ - `cv2.VideoCapture(path)`: Captures the video and extracts frames.
28
+ - `cv2.imshow()`: Displays a frame in a pop-up window.
29
+ - `cv2.waitKey(1)`: Waits for 1 millisecond before moving to the next frame.
30
+ 3. **Exit Condition**:
31
+ - Exit the loop when frames are exhausted or a specific key is pressed.
32
+ """)
33
 
34
+ # Subheader 3: Frame Handling Details
35
+ st.markdown("### Frame Handling Details")
36
+ st.markdown("""
37
+ - Each frame contains:
38
+ 1. **Images**: Represented as 3D arrays (height, width, and color channels).
39
+ 2. **Boolean Values**:
40
+ - `True`: Frame is present.
41
+ - `False`: No frame, signaling the loop to terminate.
42
+ """)
43
 
44
+ # Subheader 4: Converting Video to Tabular Data
45
+ st.markdown("### :green[Converting Video to Tabular Data]")
46
+ st.markdown("""
47
+ 1. Use `cv2.VideoCapture()` to capture frames.
48
+ 2. Convert the frames into tabular data, where each frame's pixel values are rows or columns.
49
+ """)
50
 
51
+ # Subheader 5: Color Space Conversion
52
+ st.markdown("### Color Space Conversion")
53
+ st.markdown("""
54
+ - OpenCV allows color space changes with `cv2.cvtColor()`.
55
+ - **Syntax**: `cv2.cvtColor(img, cv2.COLOR_<source>2<destination>)`
56
+ - Example:
57
+ ```python
58
+ img = cv2.imread("path/to/image")
59
+ gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)