From 10d74a434134d649f11e47cbbcfcfcabfc443163 Mon Sep 17 00:00:00 2001
From: "michael.divia" <michael.divia@etu.hesge.ch>
Date: Wed, 9 Apr 2025 21:22:30 +0200
Subject: [PATCH] I need some sleep

---
 python/pokedex_rpi.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/python/pokedex_rpi.py b/python/pokedex_rpi.py
index 9102019..a14d342 100644
--- a/python/pokedex_rpi.py
+++ b/python/pokedex_rpi.py
@@ -25,21 +25,23 @@ else:
 with open(json_path, "r") as f:
     class_names = json.load(f)
 
-# --- Run inference ---
+# --- Inference ---
 with Hailo(hef_path) as hailo:
-    # Get model input shape (e.g., 224x224x3 or 256x256x3)
     model_h, model_w, _ = hailo.get_input_shape()
 
-    # Setup and start the camera
+    # Initialize camera and configure MAIN output only (no preview)
     picam2 = Picamera2()
-    main = {'size': (model_w, model_h), 'format': 'RGB888'}
-    config = picam2.create_preview_configuration(main)
-    picam2.start(config)
+    config = picam2.create_still_configuration(
+        main={"size": (model_w, model_h), "format": "RGB888"},
+        display=None  # Disable preview stream to avoid tiny resolution
+    )
+    picam2.configure(config)
+    picam2.start()
 
     print("-- Capturing image...")
     frame = picam2.capture_array()
 
-    # Optionally display the captured image
+    # Optional: Show the captured image
     try:
         cv2.imshow("Captured Image", frame)
         print("-- Press any key to continue...")
@@ -51,11 +53,9 @@ with Hailo(hef_path) as hailo:
         cv2.imwrite(output_path, frame)
         os.system(f"feh --fullscreen {output_path}")
 
-    # Run inference
     print("-- Running inference...")
     inference_results = hailo.run(frame)
 
-    # Postprocess: find predicted class
     predicted_idx = int(np.argmax(inference_results))
     predicted_name = class_names[predicted_idx]
-    print(f"-- Predicted Pokémon: {predicted_name}")
+    print(f"-- Predicted Pokémon: {predicted_name}")
\ No newline at end of file
-- 
GitLab