agrobot_base/Python/OAK/datasets/oak-fcc-3/tests/test.py

37 lines
1.1 KiB
Python

from core.oak_fcc3_service import OakFcc3Service
svc = OakFcc3Service(
fps=15,
width=640,
height=400,
frame_type="MULTISPEC",
capture_mode="TRIPLE",
raw_policy="require_triple",
sync_mode="best",
sync_tolerance_ms=25.0,
)
svc.connect()
svc.begin(frame_type="RAW_BRUTO", output_dtype="uint8", capture_mode="TRIPLE")
frame, meta = svc.capture_frame(timeout=2.0)
print(meta["camera_info"])
for cam_id, arr in frame.items():
print(cam_id, arr.shape, arr.dtype, arr.size)
from core.raw_processor_core import RawProcessorCore
from core.raw_processor_preview import RawProcessorPreview
import cv2
core = RawProcessorCore(sensor_width=1280, sensor_height=800, bayer_pattern="GBRG")
preview = RawProcessorPreview(sensor_width=1280, sensor_height=800, bayer_pattern="GBRG")
raw16 = core.unpack_raw10_packed(frame["cam0"], sensor_width=1280, sensor_height=800)
img = preview.raw16_to_preview_bgr(raw16, bit_depth=10)
cv2.imwrite("calibration/cam0_raw_preview.png", img)
print(raw16.shape, raw16.dtype, raw16.min(), raw16.max())
svc.stop()
svc.disconnect()