diff --git a/examples/vision/streaming/uvc_server.py b/examples/vision/streaming/uvc_server.py new file mode 100644 index 00000000..42e24f55 --- /dev/null +++ b/examples/vision/streaming/uvc_server.py @@ -0,0 +1,21 @@ +from maix import camera, display, app, time, uvc +import time +import atexit + +cam = camera.Camera(640, 360, fps=60) # Manually set resolution + # | 手动设置分辨率 +# disp = display.Display() # MaixCAM default is 522x368 + # | MaixCAM 默认是 522x368 +def fill_mjpg_img_cb(buf, size): + img = cam.read() + return uvc.helper_fill_mjpg_image(buf, size, img) + +uvcs = uvc.UvcServer(fill_mjpg_img_cb) + +uvcs.run() + +while not app.need_exit(): + time.sleep(1) + +# fixme: actually can't reach here, :( +# uvcs.stop() diff --git a/examples/vision/streaming/uvc_stream.py b/examples/vision/streaming/uvc_stream.py index b0c1d42b..16b6e0ca 100644 --- a/examples/vision/streaming/uvc_stream.py +++ b/examples/vision/streaming/uvc_stream.py @@ -1,13 +1,11 @@ from maix import camera, display, app, time, uvc -cam = camera.Camera(640, 360) # Manually set resolution +cam = camera.Camera(640, 360, fps=60) # Manually set resolution # | 手动设置分辨率 # disp = display.Display() # MaixCAM default is 522x368 # | MaixCAM 默认是 522x368 -uvcs = uvc.UvcStreamer(0) -# uvcs.use_mjpg(1) for mjpg or yuyv default without it -# uvcs.use_mjpg(1) 是为了刷 mjpg 通道,不添加这一行默认是 yuyv 通道 +uvcs = uvc.UvcStreamer() uvcs.use_mjpg(1) while not app.need_exit():