fix: camera change to camera_manager
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from maix import camera, image, time
|
from maix import image, time
|
||||||
|
from camera_manager import camera_manager
|
||||||
|
|
||||||
_USE_CV = False
|
_USE_CV = False
|
||||||
try:
|
try:
|
||||||
@@ -106,14 +107,8 @@ def find_brightest_bytes(frame, cx, cy, roi_r, th, ratio):
|
|||||||
return final_pos
|
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
|
own_cam = False
|
||||||
if cam is None:
|
|
||||||
try:
|
|
||||||
cam = camera.Camera(WIDTH, HEIGHT)
|
|
||||||
own_cam = True
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
try:
|
try:
|
||||||
last_pos = None
|
last_pos = None
|
||||||
stable = 0
|
stable = 0
|
||||||
@@ -122,7 +117,7 @@ def get_stable_laser_point(cam=None, timeout_ms=15000, stable_count=STABLE_COUNT
|
|||||||
while True:
|
while True:
|
||||||
if abs(time.ticks_diff(time.ticks_ms(), start)) > timeout_ms:
|
if abs(time.ticks_diff(time.ticks_ms(), start)) > timeout_ms:
|
||||||
return None
|
return None
|
||||||
frame = cam.read()
|
frame = camera_manager.read_frame()
|
||||||
if frame is None:
|
if frame is None:
|
||||||
time.sleep_ms(10)
|
time.sleep_ms(10)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user