-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from taorye/main
feat: add example for uvc streamer
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from maix import camera, display, app, time, uvc | ||
|
||
cam = camera.Camera(640, 360) # 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.use_mjpg(1) | ||
|
||
while not app.need_exit(): | ||
# time.fps_start() # Manually set fps calculation start point, comment here mean last time fps() call is start | ||
# | 动设置帧率(FPS)计算开始点,这里注释了表示上一次 fps 函数即是开始 | ||
img = cam.read() # Get one frame from camera, img is maix.image.Image type object | ||
# | 从摄像头获取一帧图像,img 是 maix.image.Image 类型的对象 | ||
# disp.show(img) # Show image to screen | ||
# | 将图像显示到屏幕 | ||
uvcs.show(img) | ||
|
||
fps = time.fps() # Calculate FPS between last time fps() call and this time call. | ||
# | 计算两次 fps 函数调用之间的帧率 | ||
print(f"time: {1000/fps:.02f}ms, fps: {fps:.02f}") # print FPS in console | ||
# | 在终端打印帧率(FPS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters