Compare commits
3 Commits
3753f57041
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e68ffd9b8b | |||
| 49fd566457 | |||
| dd37465546 |
@@ -911,15 +911,15 @@ class EdamamAPI:
|
|||||||
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
url = "https://api.edamam.com/api/vision/v1/nutrients"
|
url = "https://api.edamam.com/api/vision/v1/nutrients?app_id=09cb5bd7&app_key=8b2730f3c7f4f075cc939da3fa0c49fb&beta=true&servings=1"
|
||||||
|
|
||||||
# Query parameters as specified by the YAML schema
|
# Query parameters as specified by the YAML schema
|
||||||
params = {
|
# params = {
|
||||||
"app_id": EDAMAM_APP_ID__FOOD,
|
# "app_id": EDAMAM_APP_ID__FOOD,
|
||||||
"app_key": EDAMAM_APP_KEY__FOOD,
|
# "app_key": EDAMAM_APP_KEY__FOOD,
|
||||||
"beta": "true" # Recommended since vision is in Beta
|
# "beta": "true" # Recommended since vision is in Beta
|
||||||
}
|
# }
|
||||||
print("params:", params)
|
# print("params:", params)
|
||||||
|
|
||||||
# Specify the media type in the header
|
# Specify the media type in the header
|
||||||
headers = {
|
headers = {
|
||||||
@@ -932,7 +932,7 @@ class EdamamAPI:
|
|||||||
|
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url,
|
url,
|
||||||
params=params,
|
# params=params,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=raw_image_bytes
|
data=raw_image_bytes
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
|
import sys
|
||||||
sys.path.insert(0, '..')
|
sys.path.insert(0, '..')
|
||||||
try:
|
try:
|
||||||
from shared import config
|
from shared import config
|
||||||
@@ -80,13 +81,13 @@ class MicrowaveDishAnalyzer:
|
|||||||
return 0.85 # Default factor for plated meals
|
return 0.85 # Default factor for plated meals
|
||||||
|
|
||||||
def estimate_volume(
|
def estimate_volume(
|
||||||
self, image_path: str, height_cm: float, food_label: str = "", config: Optional[Any] = None
|
self, image_path: str, height_cm: float, food_label: str = ""
|
||||||
) -> Dict[str, float]:
|
) -> Dict[str, float]:
|
||||||
"""
|
"""
|
||||||
Computes total physical volume in cm³ (mL).
|
Computes total physical volume in cm³ (mL).
|
||||||
Volume = Area (cm²) * Height (cm) * Shape Factor
|
Volume = Area (cm²) * Height (cm) * Shape Factor
|
||||||
"""
|
"""
|
||||||
area_cm2 = self.calculate_surface_area_cm2(image_path, config=config)
|
area_cm2 = self.calculate_surface_area_cm2(image_path)
|
||||||
k_shape = self._get_shape_factor(food_label)
|
k_shape = self._get_shape_factor(food_label)
|
||||||
volume_cm3 = area_cm2 * height_cm * k_shape
|
volume_cm3 = area_cm2 * height_cm * k_shape
|
||||||
|
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ async def on_new_alert(alert: Alert):
|
|||||||
# Send the alert to the lora device
|
# Send the alert to the lora device
|
||||||
payload = payloads.lora_new_alert(alert)
|
payload = payloads.lora_new_alert(alert)
|
||||||
print(f"[Alert Handling] Sending alert to LoRa device: {payload}")
|
print(f"[Alert Handling] Sending alert to LoRa device: {payload}")
|
||||||
if lora.send_reliable(payload):
|
if lora.send_reliable(payload, max_retries=7):
|
||||||
microwave_states["2"].set_cooking_state(CookingStates.ALERT)
|
microwave_states["2"].set_cooking_state(CookingStates.ALERT)
|
||||||
|
|
||||||
# --- HARDWARE CONTROLLERS ---
|
# --- HARDWARE CONTROLLERS ---
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class BaseLoraDevice:
|
|||||||
|
|
||||||
return packet
|
return packet
|
||||||
|
|
||||||
def send_reliable(self, payload, max_retries=4, ack_timeout=3.0):
|
def send_reliable(self, payload, max_retries=5, ack_timeout=3.0):
|
||||||
"""Sends a payload and listens in a single continuous RX window for the ACK."""
|
"""Sends a payload and listens in a single continuous RX window for the ACK."""
|
||||||
|
|
||||||
with self.tx_lock:
|
with self.tx_lock:
|
||||||
|
|||||||
Reference in New Issue
Block a user