Better camera settings + better rpompt
This commit is contained in:
@@ -16,13 +16,13 @@ class DishSafetyResult(BaseModel):
|
||||
|
||||
def check_dish_safety(image_path: str) -> dict:
|
||||
prompt = (
|
||||
"You are a microwave safety vision inspector.\n\n"
|
||||
"TASK: Check if this dish contains any REAL METAL CUTLERY (metal spoons, forks, knives) or ALUMINUM FOIL.\n\n"
|
||||
"You are a strict microwave safety vision inspector.\n\n"
|
||||
"TASK: Inspect the dish for ANY metal or plastic utensils (spoons, forks, knives, metal handles) or aluminum foil.\n\n"
|
||||
"CRITICAL RULES:\n"
|
||||
"1. Rice, curry, stew, potatoes, herbs, dark sauce, and ceramic/plastic/glass bowls are SAFE food items.\n"
|
||||
"2. Camera image noise, shadows, and food textures are NOT metal objects.\n"
|
||||
"3. Unless a shiny, metallic silver/gold utensil or foil sheet is clearly visible, mark is_safe = True and detected_hazards = [].\n"
|
||||
"4. Do NOT invent or guess utensils if none are clearly visible."
|
||||
"1. Look closely at the edges and interior of the bowl for utensil handles sticking out, even if they appear dark or shadowed.\n"
|
||||
"2. If you see ANY spoon handle, fork, knife, or utensil body—whether shiny silver, grey, or dark metal—mark is_safe = False.\n"
|
||||
"3. ONLY mark is_safe = True if the bowl contains 100% food and rice with NO protruding utensils or foreign objects.\n"
|
||||
"4. If a spoon or utensil is detected, set detected_hazards = ['metal spoon'] and warning_message = 'Please remove the metal utensil before microwaving.'"
|
||||
)
|
||||
|
||||
response_raw = generate(
|
||||
|
||||
@@ -6,7 +6,25 @@ import time
|
||||
|
||||
picam2 = Picamera2()
|
||||
|
||||
camera_config = picam2.create_still_configuration()
|
||||
# Get maximum full-sensor dimensions
|
||||
sensor_format = picam2.sensor_modes[0]
|
||||
max_width = sensor_format['size'][0]
|
||||
max_height = sensor_format['size'][1]
|
||||
|
||||
camera_config = picam2.create_still_configuration(
|
||||
raw={"size": (1640, 1232)},
|
||||
main={"size": (1640, 1232)}
|
||||
)
|
||||
picam2.set_controls({
|
||||
"AeEnable": False, # Disable Auto Exposure to lock settings
|
||||
"ExposureTime": 60000, # 40 ms shutter time (brightens without grain)
|
||||
"AnalogueGain": 2.0, # Keep gain low to eliminate sensor noise
|
||||
"AwbEnable": False, # Disable Auto White Balance fluctuation
|
||||
"ColourGains": (1.4, 1.2), # Balanced RGB gains for indoor warm LED
|
||||
"Brightness": 0.2, # Slight boost to shadow detail
|
||||
"Contrast": 1.1, # Crisp edges around metallic surfaces
|
||||
"ScalerCrop": [0, 0, max_width, max_height] # Uncrop the image
|
||||
})
|
||||
picam2.configure(camera_config)
|
||||
|
||||
picam2.start()
|
||||
|
||||
Reference in New Issue
Block a user