Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +15 -15
pages/Data Collection.py
CHANGED
|
@@ -542,8 +542,11 @@ elif st.session_state.current_page == "opencv_operations":
|
|
| 542 |
st.write("With OpenCV installed, let's learn basic image handling in OpenCV.")
|
| 543 |
st.write("## Basic Operations in OpenCV")
|
| 544 |
|
| 545 |
-
# Heading for Reading Images
|
| 546 |
-
st.
|
|
|
|
|
|
|
|
|
|
| 547 |
|
| 548 |
# About imread() function
|
| 549 |
st.write("""
|
|
@@ -564,7 +567,7 @@ elif st.session_state.current_page == "opencv_operations":
|
|
| 564 |
|
| 565 |
# Explanation for Grayscale Conversion
|
| 566 |
st.write("""
|
| 567 |
-
By default, the `imread()
|
| 568 |
To convert the image to grayscale, pass `0` as the second argument to the `imread()` function. This will return a 2D array where each pixel value represents intensity.
|
| 569 |
""")
|
| 570 |
|
|
@@ -579,8 +582,11 @@ elif st.session_state.current_page == "opencv_operations":
|
|
| 579 |
print(gray_image) # This will print the 2D array representing pixel intensity
|
| 580 |
""", language="python")
|
| 581 |
|
| 582 |
-
|
| 583 |
-
st.
|
|
|
|
|
|
|
|
|
|
| 584 |
|
| 585 |
# Explanation of the functions
|
| 586 |
st.write("""
|
|
@@ -607,30 +613,24 @@ elif st.session_state.current_page == "opencv_operations":
|
|
| 607 |
These three functions must work together to display and manage images effectively.
|
| 608 |
""")
|
| 609 |
|
| 610 |
-
# Syntax for imshow()
|
| 611 |
-
st.write("## imshow()")
|
| 612 |
st.code("""
|
|
|
|
| 613 |
cv2.imshow(window_name, image_array)
|
| 614 |
# window_name: The title of the pop-up window (string)
|
| 615 |
# image_array: The image data (usually a NumPy array)
|
| 616 |
-
""", language="python")
|
| 617 |
|
| 618 |
-
#
|
| 619 |
-
st.write("## waitKey()")
|
| 620 |
-
st.code("""
|
| 621 |
cv2.waitKey(delay_in_milliseconds)
|
| 622 |
# delay_in_milliseconds: Time in milliseconds to keep the window open
|
| 623 |
# Use 0 for infinite delay until a key is pressed
|
| 624 |
-
""", language="python")
|
| 625 |
|
| 626 |
-
#
|
| 627 |
-
st.write("## destroyAllWindows()")
|
| 628 |
-
st.code("""
|
| 629 |
cv2.destroyAllWindows()
|
| 630 |
# This ensures all windows opened by imshow() are cleared from RAM
|
| 631 |
""", language="python")
|
| 632 |
|
| 633 |
|
|
|
|
| 634 |
elif st.session_state.current_page == "explore_audio":
|
| 635 |
st.markdown("""
|
| 636 |
<h3 style="color: #e25822;">Exploring Audio</h3>
|
|
|
|
| 542 |
st.write("With OpenCV installed, let's learn basic image handling in OpenCV.")
|
| 543 |
st.write("## Basic Operations in OpenCV")
|
| 544 |
|
| 545 |
+
# Heading for Reading Images with Custom Color
|
| 546 |
+
st.markdown("""
|
| 547 |
+
<h3 style="color: #9400d3;">Reading an Image</h3>
|
| 548 |
+
""", unsafe_allow_html=True)
|
| 549 |
+
|
| 550 |
|
| 551 |
# About imread() function
|
| 552 |
st.write("""
|
|
|
|
| 567 |
|
| 568 |
# Explanation for Grayscale Conversion
|
| 569 |
st.write("""
|
| 570 |
+
By default, the `imread()' function reads an image as a 3D array in the RGB color space.
|
| 571 |
To convert the image to grayscale, pass `0` as the second argument to the `imread()` function. This will return a 2D array where each pixel value represents intensity.
|
| 572 |
""")
|
| 573 |
|
|
|
|
| 582 |
print(gray_image) # This will print the 2D array representing pixel intensity
|
| 583 |
""", language="python")
|
| 584 |
|
| 585 |
+
# Displaying Images with OpenCV in Custom Color
|
| 586 |
+
st.markdown("""
|
| 587 |
+
<h3 style="color: #9400d3;">Displaying Images with OpenCV</h3>
|
| 588 |
+
""", unsafe_allow_html=True)
|
| 589 |
+
|
| 590 |
|
| 591 |
# Explanation of the functions
|
| 592 |
st.write("""
|
|
|
|
| 613 |
These three functions must work together to display and manage images effectively.
|
| 614 |
""")
|
| 615 |
|
|
|
|
|
|
|
| 616 |
st.code("""
|
| 617 |
+
# imshow()
|
| 618 |
cv2.imshow(window_name, image_array)
|
| 619 |
# window_name: The title of the pop-up window (string)
|
| 620 |
# image_array: The image data (usually a NumPy array)
|
|
|
|
| 621 |
|
| 622 |
+
# waitKey()
|
|
|
|
|
|
|
| 623 |
cv2.waitKey(delay_in_milliseconds)
|
| 624 |
# delay_in_milliseconds: Time in milliseconds to keep the window open
|
| 625 |
# Use 0 for infinite delay until a key is pressed
|
|
|
|
| 626 |
|
| 627 |
+
# destroyAllWindows()
|
|
|
|
|
|
|
| 628 |
cv2.destroyAllWindows()
|
| 629 |
# This ensures all windows opened by imshow() are cleared from RAM
|
| 630 |
""", language="python")
|
| 631 |
|
| 632 |
|
| 633 |
+
|
| 634 |
elif st.session_state.current_page == "explore_audio":
|
| 635 |
st.markdown("""
|
| 636 |
<h3 style="color: #e25822;">Exploring Audio</h3>
|