fix: camera change to camera_manager

This commit is contained in:
2026-06-02 09:55:36 +08:00
parent 801453fbdb
commit 2ad2836d77

View File

@@ -1,4 +1,5 @@
from maix import camera, image, time
from maix import image, time
from camera_manager import camera_manager
_USE_CV = False
try:
@@ -106,14 +107,8 @@ def find_brightest_bytes(frame, cx, cy, roi_r, th, ratio):
return final_pos
def get_stable_laser_point(cam=None, timeout_ms=15000, stable_count=STABLE_COUNT):
def get_stable_laser_point(timeout_ms=15000, stable_count=STABLE_COUNT):
own_cam = False
if cam is None:
try:
cam = camera.Camera(WIDTH, HEIGHT)
own_cam = True
except Exception:
return None
try:
last_pos = None
stable = 0
@@ -122,7 +117,7 @@ def get_stable_laser_point(cam=None, timeout_ms=15000, stable_count=STABLE_COUNT
while True:
if abs(time.ticks_diff(time.ticks_ms(), start)) > timeout_ms:
return None
frame = cam.read()
frame = camera_manager.read_frame()
if frame is None:
time.sleep_ms(10)
continue