hari3485 commited on
Commit
21e094d
·
verified ·
1 Parent(s): ad0c3b0

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. pages/Data Collection.py +56 -36
pages/Data Collection.py CHANGED
@@ -555,67 +555,87 @@ def image_details_page():
555
  # Basic Operations Section
556
  elif page =="Basic Operations":
557
 
 
 
 
 
 
 
 
 
 
 
558
  st.code("""
559
  import cv2
560
  import numpy as np
561
  """)
562
 
563
- st.title("OpenCV Basics: Image Handling")
564
-
565
- # Theory Section
566
- st.header("1. `cv2.imread` - Reading an Image")
567
  st.markdown("""
568
- - **Purpose**: Converts an image file into a numerical array that represents its pixel data.
569
- - **Default Behavior**: Reads the image in the **BGR color space**.
570
- - **Parameters**:
571
- - `path`: Specifies the location of the image file.
572
- - `flags`:
573
- - `1`: Reads the image as a color image (default).
574
- - `0`: Reads the image as a grayscale image (2D array).
575
- - **Output**: A numerical array where each element corresponds to a pixel's intensity or color.
576
- """)
577
- st.code("""
578
- # Code to read an image
579
- img = cv2.imread('path/to/your/image.jpg', 1) # Read as color image
580
- st.image(img, channels="BGR") # Display image in Streamlit
581
  """)
582
 
583
  # Theory Section
584
- st.header("2. `cv2.imshow` - Displaying an Image")
585
  st.markdown("""
586
- - **Purpose**: Opens a pop-up window to show an image.
587
- - **Parameters**:
588
- - `Window Name`: Title of the display window.
589
- - `Image`: Array data representing the image.
590
  """)
591
  st.code("""
592
- # Code to display an image
593
- cv2.imshow("Sample Image", img)
 
 
 
 
 
 
594
  """)
595
 
 
596
  # Theory Section
597
- st.header("3. `cv2.waitKey` - Waiting for a Key Input")
598
  st.markdown("""
599
- - **Purpose**: Waits for the specified time (in milliseconds) for a key press to proceed or close the window.
 
 
600
  - **Parameters**:
601
- - `Delay`:
602
- - If `0`: Waits indefinitely until a key is pressed.
603
- - If a positive value: Waits for that duration in milliseconds.
604
- - **Usage**: Prevents the program from closing the window immediately.
605
  """)
606
- st.code("""
607
- # Code to wait for a key press
608
- cv2.waitKey(0) # Wait indefinitely until key press
 
 
 
 
609
  """)
610
 
611
  # Theory Section
612
- st.header("4. `cv2.destroyAllWindows` - Closing OpenCV Windows")
613
  st.markdown("""
614
  - **Purpose**: Closes all OpenCV-created windows.
615
- - **Usage**: Ensures proper memory cleanup and avoids crashes by freeing up resources after the display is no longer needed.
616
- - **Best Practice**: Always use this after displaying images to clean up the resources.
617
  """)
 
 
 
 
618
  st.code("""
 
 
 
 
 
 
 
 
619
  # Code to close all windows
620
  cv2.destroyAllWindows() # Close all OpenCV windows
621
  """)
 
555
  # Basic Operations Section
556
  elif page =="Basic Operations":
557
 
558
+
559
+ st.title("What is OpenCV?")
560
+ st.header("Understanding Open Source Computer Vision")
561
+
562
+ # Introduction
563
+ st.write("""
564
+ OpenCV (Open Source Computer Vision) is a free and open-source library designed for real-time computer vision tasks.
565
+ It is widely used in industries like healthcare, security, robotics, and AI to process images and videos effectively.
566
+ """)
567
+
568
  st.code("""
569
  import cv2
570
  import numpy as np
571
  """)
572
 
573
+ # Features Section
574
+ st.subheader("Key Features of OpenCV:")
 
 
575
  st.markdown("""
576
+ - **Image Processing**: Resize, crop, filter, and manipulate images easily.
577
+ - **Object Detection**: Detect faces, objects, and track their movements in real-time.
578
+ - **Video Analysis**: Perform video stabilization, motion detection, and frame-by-frame analysis.
579
+ - **Machine Learning Integration**: Combine with AI frameworks for advanced tasks like face recognition and augmented reality.
 
 
 
 
 
 
 
 
 
580
  """)
581
 
582
  # Theory Section
583
+ st.header("Reading an Image")
584
  st.markdown("""
585
+ - It converts an 2D image into Machine representation value array.
586
+ - **cv2.imread("path)** this method going to convert image to 3D aray as it used default colour space **RGB**.
587
+ - The data type of image should be **uint8**.
 
588
  """)
589
  st.code("""
590
+ # Code to read an image
591
+ img = cv2.imread('BGR_image', 1) # by default it considers this as coloured image
592
+ print(img)
593
+ """)
594
+
595
+ st.code("""
596
+ img = cv2.imread("gray_scale_image",0) # when we want it in 2D array use parametre `flags=0` it considers as grayscale image
597
+ print(img)
598
  """)
599
 
600
+
601
  # Theory Section
602
+ st.header("`cv2.imshow`")
603
  st.markdown("""
604
+ - After creating or reading an image, we can display it using OpenCV. Here’s how the key functions work together:
605
+ - The `imshow()` function creates a pop-up window to display the image.
606
+ - Internally, it converts the numerical array into a visual image.
607
  - **Parameters**:
608
+ Window Name: Title of the pop-up window (string).
609
+ Image Array: The array representing the image.
 
 
610
  """)
611
+
612
+ # Theory Section
613
+ st.header("`cv2.waitKey`")
614
+ st.markdown("""
615
+ - The main purpose Waits for a key press and adds a delay before closing the pop-up window.
616
+ - `waitKey(0)` or `waitKey()` Keeps the window open indefinitely until a key is pressed.
617
+ - `waitkey(10) After 10 milli seconds the pop up window will be closed when we use `waitkey(n)` after n milliseconds window closes.
618
  """)
619
 
620
  # Theory Section
621
+ st.header("`cv2.destroyAllWindows`")
622
  st.markdown("""
623
  - **Purpose**: Closes all OpenCV-created windows.
624
+ - **Usage**:This makes sure that memory is cleared and helps avoid crashes by getting rid of resources when the image is no longer needed.
 
625
  """)
626
+
627
+ st.markdown("<h5 style='color: green;'>These three functions must work together to display and manage images effectively./h5>", unsafe_allow_html=True)
628
+
629
+
630
  st.code("""
631
+ img = cv2.imshow("Window name",image)
632
+
633
+ # Window name : Name of the window
634
+ # image : The image we created
635
+
636
+ # Code to wait for a key press
637
+ cv2.waitKey() # Wait indefinitely until key press
638
+
639
  # Code to close all windows
640
  cv2.destroyAllWindows() # Close all OpenCV windows
641
  """)