cli to control zed camera start and stop. 2. measure now use every svo2 file for 1 fish, give intermideate result and final result with confidecne level(*).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Header, Query
|
||||
from starlette.responses import JSONResponse
|
||||
@@ -16,10 +16,27 @@ router = APIRouter(prefix="/api/v1/biomass", tags=["biomass"])
|
||||
HEADER_BIOMASS_NEW = "X-Fish-Biomass-New"
|
||||
|
||||
|
||||
def _new_headers(has_new: bool) -> dict[str, str]:
|
||||
def _new_headers(has_new: bool) -> Dict[str, str]:
|
||||
return {HEADER_BIOMASS_NEW: "1" if has_new else "0"}
|
||||
|
||||
|
||||
# GET /real/camera/ 的 data.result[] 仅含:id, type, length, weight, date(与客户端约定一致)
|
||||
_BIOMASS_CAMERA_RESULT_KEYS = ("id", "type", "length", "weight", "date")
|
||||
|
||||
|
||||
def _biomass_camera_result_rows(result: Any) -> List[Dict[str, Any]]:
|
||||
if not isinstance(result, list):
|
||||
return []
|
||||
out: List[Dict[str, Any]] = []
|
||||
for it in result:
|
||||
if not isinstance(it, dict):
|
||||
continue
|
||||
row = {k: it[k] for k in _BIOMASS_CAMERA_RESULT_KEYS if k in it}
|
||||
if row:
|
||||
out.append(row)
|
||||
return out
|
||||
|
||||
|
||||
def _resolve_client_id(
|
||||
x_fish_client_id: Optional[str] = Header(None, alias="X-Fish-Client-Id"),
|
||||
client_id: Optional[str] = Query(
|
||||
@@ -69,7 +86,7 @@ async def get_real_camera(
|
||||
)
|
||||
|
||||
payload: dict = {
|
||||
"result": m.result,
|
||||
"result": _biomass_camera_result_rows(m.result),
|
||||
"video_left": m.video_left,
|
||||
"video_right": m.video_right,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user