From 9d221c19ca1c2d0756199e98fc85272ff5e5848d Mon Sep 17 00:00:00 2001 From: taorye Date: Thu, 12 Dec 2024 16:01:18 +0800 Subject: [PATCH 1/3] perf: enable parallel compression with `-T 0` for xz --- tools/os/gen_os.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/os/gen_os.sh b/tools/os/gen_os.sh index 10d04c54..5114c3d1 100755 --- a/tools/os/gen_os.sh +++ b/tools/os/gen_os.sh @@ -148,7 +148,7 @@ cp -r "tmp/sys_builtin_files/boot/boards" "tmp/sys_builtin_files/maixapp/" ./update_img.sh tmp/sys_builtin_files "tmp/$os_version_str.img" # 9. xz 压缩镜像 -xz -zv "tmp/$os_version_str.img" +xz -zv -T 0 "tmp/$os_version_str.img" echo "Complete: os file: tmp/$os_version_str.img.xz" From 3ab93643ea1b3e8e0497ce4a59bd6c989707df30 Mon Sep 17 00:00:00 2001 From: taorye Date: Thu, 12 Dec 2024 17:37:12 +0800 Subject: [PATCH 2/3] fix: use `set -o pipefail` to exit while has error in processing --- tools/os/update_img.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/os/update_img.sh b/tools/os/update_img.sh index 875f4798..26bd2dc6 100755 --- a/tools/os/update_img.sh +++ b/tools/os/update_img.sh @@ -1,6 +1,7 @@ #!/bin/sh set -e +set -o pipefail source_dir=$1 img_file=$2 @@ -34,7 +35,9 @@ $THISDIR/fuse2fs -o fakeroot -o offset=$PART_OFFSET $img_file $mount_root # copy root files echo "copy root files now" -find $source_dir -mindepth 1 -maxdepth 1 -type d ! -name "boot" -exec cp -r {} $mount_root \; +find $source_dir -mindepth 1 -maxdepth 1 -type d ! -name "boot" | while read -r dir; do + cp -r "$dir" "$mount_root" +done sync echo "copy root files done" From 08b450ad670e8c750e2f21b342a570ad31ee0af5 Mon Sep 17 00:00:00 2001 From: taorye Date: Mon, 16 Dec 2024 18:43:54 +0800 Subject: [PATCH 3/3] feat: add example for uvc streamer --- examples/vision/streaming/uvc_stream.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/vision/streaming/uvc_stream.py diff --git a/examples/vision/streaming/uvc_stream.py b/examples/vision/streaming/uvc_stream.py new file mode 100644 index 00000000..b0c1d42b --- /dev/null +++ b/examples/vision/streaming/uvc_stream.py @@ -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) +