Skip to content

Commit

Permalink
Merge pull request #95 from taorye/main
Browse files Browse the repository at this point in the history
feat: example for uvc_server and uvc_stream
  • Loading branch information
Neutree authored Dec 19, 2024
2 parents d8e6919 + 9272856 commit 0d019e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 21 additions & 0 deletions examples/vision/streaming/uvc_server.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 2 additions & 4 deletions examples/vision/streaming/uvc_stream.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down

0 comments on commit 0d019e7

Please sign in to comment.