Mk1443 commited on
Commit
39bc6ad
·
verified ·
1 Parent(s): cf2680c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -65,7 +65,8 @@ def play_countdown_audio():
65
  while pygame.mixer.music.get_busy():
66
  time.sleep(0.1)
67
 
68
- def capture_image(label, camera, person_height_cm, pixels_per_cm):
 
69
  print(f"Please position yourself for the {label} pose.")
70
  instruction_text = f"Please stand straight in the box for the {label} pose."
71
  audio_file = f"input1/instruction_{label}.mp3"
@@ -125,16 +126,14 @@ def process_images(front_img, side_img, real_height_cm):
125
  return measurements_df
126
 
127
  def gradio_interface(person_height_cm):
128
- cap = cv2.VideoCapture(0)
129
- if not cap.isOpened():
130
- return "Error: Unable to access the camera."
131
 
132
  pixels_per_cm = 5
133
- front_frame = capture_image("front", cap, person_height_cm, pixels_per_cm)
134
- side_frame = capture_image("side", cap, person_height_cm, pixels_per_cm)
135
 
136
- cap.release()
137
- cv2.destroyAllWindows()
138
 
139
  # Load the captured images to process for body measurement
140
  front_img = cv2.imread(os.path.join(output_dir, "output/front_image.jpg"))
@@ -148,7 +147,6 @@ def main():
148
  # Updated Gradio interface with separate button trigger
149
  with gr.Blocks() as demo:
150
  height_input = gr.Number(label="Enter your height (in cm)")
151
- capture_button = gr.Button("Capture Images")
152
  output_df = gr.DataFrame()
153
 
154
  capture_button.click(fn=gradio_interface, inputs=height_input, outputs=output_df)
 
65
  while pygame.mixer.music.get_busy():
66
  time.sleep(0.1)
67
 
68
+ def capture_image(label, person_height_cm, pixels_per_cm):
69
+ camera = gr.Button("Capture Images")
70
  print(f"Please position yourself for the {label} pose.")
71
  instruction_text = f"Please stand straight in the box for the {label} pose."
72
  audio_file = f"input1/instruction_{label}.mp3"
 
126
  return measurements_df
127
 
128
  def gradio_interface(person_height_cm):
129
+
130
+ # if not cap.isOpened():
131
+ # return "Error: Unable to access the camera."
132
 
133
  pixels_per_cm = 5
134
+ front_frame = capture_image("front", person_height_cm, pixels_per_cm)
135
+ side_frame = capture_image("side", person_height_cm, pixels_per_cm)
136
 
 
 
137
 
138
  # Load the captured images to process for body measurement
139
  front_img = cv2.imread(os.path.join(output_dir, "output/front_image.jpg"))
 
147
  # Updated Gradio interface with separate button trigger
148
  with gr.Blocks() as demo:
149
  height_input = gr.Number(label="Enter your height (in cm)")
 
150
  output_df = gr.DataFrame()
151
 
152
  capture_button.click(fn=gradio_interface, inputs=height_input, outputs=output_df)