Phaneendrabayi commited on
Commit
bc2eb82
·
verified ·
1 Parent(s): 8163b0d

Update pages/Life_cycle_of_ML.py

Browse files
Files changed (1) hide show
  1. pages/Life_cycle_of_ML.py +8 -2
pages/Life_cycle_of_ML.py CHANGED
@@ -812,6 +812,7 @@ def affine_transformation_demo():
812
 
813
 
814
 
 
815
  # Function to handle mouse events and shape drawing
816
  def draw_shapes_on_canvas():
817
  # Global variables for drawing state
@@ -833,6 +834,10 @@ def draw_shapes_on_canvas():
833
  # Create canvas
834
  canvas = np.ones((height, width, 3), dtype=np.uint8) * 255 # White canvas
835
 
 
 
 
 
836
  # Mouse callback function
837
  def mouse_callback(event, x, y, flags, param):
838
  nonlocal drawing, start_point, end_point, current_shape, polygon_points, canvas
@@ -887,9 +892,10 @@ def draw_shapes_on_canvas():
887
 
888
  st.write("Click on the canvas to draw shapes. Left-click for the start, Right-click for the end.")
889
 
890
- # Keep drawing until the user stops
891
  while True:
892
- cv2.imshow(window_name, canvas)
 
893
 
894
  # Break the loop if the user presses 'q' or closes the window
895
  if cv2.waitKey(1) & 0xFF == ord('q'):
 
812
 
813
 
814
 
815
+
816
  # Function to handle mouse events and shape drawing
817
  def draw_shapes_on_canvas():
818
  # Global variables for drawing state
 
834
  # Create canvas
835
  canvas = np.ones((height, width, 3), dtype=np.uint8) * 255 # White canvas
836
 
837
+ # Store the current image as a session state so it can be updated
838
+ if 'canvas_image' not in st.session_state:
839
+ st.session_state.canvas_image = canvas
840
+
841
  # Mouse callback function
842
  def mouse_callback(event, x, y, flags, param):
843
  nonlocal drawing, start_point, end_point, current_shape, polygon_points, canvas
 
892
 
893
  st.write("Click on the canvas to draw shapes. Left-click for the start, Right-click for the end.")
894
 
895
+ # Display the current canvas in Streamlit
896
  while True:
897
+ # Show the current canvas
898
+ st.image(canvas, channels="BGR", use_column_width=True)
899
 
900
  # Break the loop if the user presses 'q' or closes the window
901
  if cv2.waitKey(1) & 0xFF == ord('q'):