Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Dec 20, 2024
2 parents 35d4510 + 0d019e7 commit a512f1a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 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()
24 changes: 24 additions & 0 deletions examples/vision/streaming/uvc_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from maix import camera, display, app, time, uvc

cam = camera.Camera(640, 360, fps=60) # Manually set resolution
# | 手动设置分辨率
# disp = display.Display() # MaixCAM default is 522x368
# | MaixCAM 默认是 522x368

uvcs = uvc.UvcStreamer()
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)

2 changes: 1 addition & 1 deletion tools/os/gen_os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 4 additions & 1 deletion tools/os/update_img.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

set -e
set -o pipefail

source_dir=$1
img_file=$2
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit a512f1a

Please sign in to comment.