不是手册里的那款,我又重刷了3.4.1系统,不 upgrade,在旧示例上跑,只出了几帧就崩了:
sunrise@ubuntu:/app/pydev_demo/03_mipi_camera_sample$ sudo systemctl stop lightdm
sunrise@ubuntu:/app/pydev_demo/03_mipi_camera_sample$ python mipi_camera.py
Opened DRM device: /dev/dri/card0
1920x1080
1680x1050
1280x1024
1280x960
1280x800
1280x720
1024x768
800x600
720x576
720x480
720x400
640x480
Resolution 3840x2160 does not exist in the list.
Resolution 1920x1080.
[BPU_PLAT]BPU Platform Version(1.3.6)! soc info(x5)
[HBRT] set log level as 0. version = 3.15.55.0
[DNN] Runtime version = 1.24.5_(3.15.55 HBRT)
[A][DNN][packed_model.cpp:247][Model](2026-07-16,11:53:15.609.429) [HorizonRT] The model builder version = 1.23.5
[W][DNN]bpu_model_info.cpp:491][Version](2026-07-16,11:53:15.682.225) Model: fcos_efficientnetb0_512x512_nv12. Inconsistency between the hbrt library version 3.15.55.0 and the model build version 3.15.47.0 detected, in order to ensure correct model results, it is recommended to use compilation tools and the BPU SDK from the same OpenExplorer package.
--- model input properties ---
tensor type: NV12
data type: uint8
layout: NCHW
shape: (1, 3, 512, 512)
--- model output properties ---
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 64, 64, 80)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 32, 32, 80)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 16, 16, 80)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 8, 8, 80)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 4, 4, 80)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 64, 64, 4)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 32, 32, 4)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 16, 16, 4)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 8, 8, 4)
tensor type: int32
data type: int32
layout: NHWC
shape: (1, 4, 4, 4)
tensor type: int32
data type: int32
layout: NCHW
shape: (1, 64, 64, 1)
tensor type: int32
data type: int32
layout: NCHW
shape: (1, 32, 32, 1)
tensor type: int32
data type: int32
layout: NCHW
shape: (1, 16, 16, 1)
tensor type: int32
data type: int32
layout: NCHW
shape: (1, 8, 8, 1)
tensor type: int32
data type: int32
layout: NCHW
shape: (1, 4, 4, 1)
2026/07/16 11:53:15.690 !INFO [OpenCamera][0447]hbn module
set camera fps: -1,width: 3840,height: 2160
Camera 0:
mipi_host: 0
Camera 1:
mipi_host: 2
Camera 2:
mipi_host: 0
Camera 3:
mipi_host: 0
mipi mclk is not configed.
Searching camera sensor on device: /proc/device-tree/soc/cam/vcon@0 i2c bus: 6 mipi rx phy: 0
WARN: Sensor Name: sc1330t, Expected Chip ID: 0xCA18, Actual Chip ID Read: 0x00
WARN: Sensor Name: irs2875-tof, Expected Chip ID: 0x2875, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-10fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-10fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-10fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc230ai-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-1280p, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-1280p, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-1280p, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-hdr-2lane, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-hdr-2lane, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-hdr-2lane, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc132gs-hdr-2lane, Expected Chip ID: 0x132, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc035hgs, Expected Chip ID: 0x31, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc035hgs_mono, Expected Chip ID: 0x31, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc035hgs_mono, Expected Chip ID: 0x31, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov5640, Expected Chip ID: 0x5640, Actual Chip ID Read: 0x00
WARN: Sensor Name: f37, Expected Chip ID: 0xF37, Actual Chip ID Read: 0x00
[0] INFO: Found sensor name:imx415-30fps-2lane on mipi rx csi 0, i2c addr 0x1a, config_file:linear_3840x2160_raw10_30fps_2lane.c
[1] INFO: Found sensor name:imx415-30fps-4lane on mipi rx csi 0, i2c addr 0x1a, config_file:linear_3840x2160_raw10_30fps_4lane.c
WARN: Sensor Name: sc202cs-1600x1200, Expected Chip ID: 0xEB52, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc202cs-1600x1200, Expected Chip ID: 0xEB52, Actual Chip ID Read: 0x00
WARN: Sensor Name: irs2381c-tof, Expected Chip ID: 0x2381, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc035hgs-vc0, Expected Chip ID: 0x35, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc035hgs-vc1, Expected Chip ID: 0x35, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc231ai-30fps, Expected Chip ID: 0xCB6A, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc231ai-30fps, Expected Chip ID: 0xCB6A, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc231ai-30fps, Expected Chip ID: 0xCB6A, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx586-30fps-4lane, Expected Chip ID: 0x586, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx586-30fps-4lane, Expected Chip ID: 0x586, Actual Chip ID Read: 0x00
WARN: Sensor Name: os08c10-30fps-2lane, Expected Chip ID: 0x53, Actual Chip ID Read: 0x00
WARN: Sensor Name: os08c10-30fps-2lane, Expected Chip ID: 0x53, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0820std-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0820std-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc1336, Expected Chip ID: 0xCA3F, Actual Chip ID Read: 0x00
WARN: Sensor Name: dummy, Expected Chip ID: 0x00, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xA55A, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xA55A, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xA55A, Actual Chip ID Read: 0x00
WARN: Sensor Name: ar0233-30fps, Expected Chip ID: 0xA55A, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov9782-200fps-2lane, Expected Chip ID: 0x9281, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov9782-200fps-2lane, Expected Chip ID: 0x9281, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov9782-120fps-2lane, Expected Chip ID: 0x9281, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov9782-120fps-2lane, Expected Chip ID: 0x9281, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-640x480-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-640x480-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-1632x1232-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-1632x1232-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-1920x1080-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-1920x1080-30fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-3264x2464-15fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-3264x2464-15fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-3264x2464-21fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx219-3264x2464-21fps, Expected Chip ID: 0x219, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov5647-640x480-60fps, Expected Chip ID: 0x5647, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov5647-1280x960-30fps, Expected Chip ID: 0x5647, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov5647-1920x1080-30fps, Expected Chip ID: 0x5647, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov5647-2592x1944-15fps, Expected Chip ID: 0x5647, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-1280x960-120fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-1280x960-120fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-1920x1080-50fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-1920x1080-50fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-2016x1520-21fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-2016x1520-21fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-4000x3000-10fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: imx477-4000x3000-10fps, Expected Chip ID: 0x477, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov50h40-30fps-4lane, Expected Chip ID: 0x6C, Actual Chip ID Read: 0x00
WARN: Sensor Name: ov50h40-30fps-4lane, Expected Chip ID: 0x6C, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s_2lane, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
WARN: Sensor Name: ox05b1s_2lane, Expected Chip ID: 0x58, Actual Chip ID Read: 0x00
[2] INFO: Found sensor name:imx415-60fps-4lane on mipi rx csi 0, i2c addr 0x1a, config_file:linear_3840x2160_raw10_60fps_4lane.c
WARN: Sensor Name: sc850sl-30fps, Expected Chip ID: 0x9D1E, Actual Chip ID Read: 0x00
WARN: Sensor Name: sc850sl-30fps, Expected Chip ID: 0x9D1E, Actual Chip ID Read: 0x00
WARN: Sensor Name: shw3g-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
WARN: Sensor Name: shw3g-30fps, Expected Chip ID: 0xCB34, Actual Chip ID Read: 0x00
Auto-selected sensor: imx415-60fps-4lane (Resolution: 3840x2160@60fps)
2026/07/16 11:53:16.037 !INFO [CamInitParam][0326]Setting VSE channel-0: input_width:3840, input_height:2160, dst_w:512, dst_h:512
2026/07/16 11:53:16.037 !INFO [CamInitParam][0326]Setting VSE channel-1: input_width:3840, input_height:2160, dst_w:1920, dst_h:1080
2026/07/16 11:53:16.037 !INFO [CamInitParam][0326]Setting VSE channel-5: input_width:3840, input_height:2160, dst_w:3840, dst_h:2160
2026/07/16 11:53:16.037 !INFO [vp_vin_init][0055]csi0 ignore mclk ex attr, because mclk is not configed at device tree.
================= VP Modules Status ====================
======================== VFLOW =========================
(active)[S0] vin0_C0*(dma)-m2m-isp0_C0-m2m-vse0_C0
========================= SIF ==========================
------------------- flow0 info -------------------
rx_index:0
vc_index:0
ipi_channels:1
width:3840
height:2160
format:0x2b
online_isp:0
ddr_en:0
bufnum:0
emb_en:0
embeded_dependence:0
embeded_width:0
embeded_height:0
size_err_cnt:0
========================= ISP ==========================
------------------- flow0 info -------------------
input_mode:2
sched_mode:0
tile_mode:0
af_mode:0
sensor_mode:0
input_width:3840
input_height:2160
input_format:1
input_bit_width:10
input_crop_x:0
input_crop_y:0
input_crop_w:3840
input_crop_h:2160
ddr_en:1
output_format:2
output_bit_width:8
========================= VSE ==========================
------------------- flow0 info -------------------
input_fps:0/0
input_width:3840
input_height:2160
input_format:2
input_bitwidth:8
dns0 channel: roi [0][0][3840][2160], target [512][512], fps [30/30]
dns1 channel: roi [0][0][3840][2160], target [1920][1080], fps [30/30]
ups channel: roi [0][0][0][0], target [0][0], fps [0/30]
========================= VENC =========================
Cannot open file /sys/kernel/debug/vpu/venc.========================= VDEC =========================
Cannot open file /sys/kernel/debug/vpu/vdec.========================= JENC =========================
Cannot open file /sys/kernel/debug/jpu/jenc.======================= Buffer =========================
----------------------------------------------
flowid module cid chn FREE REQ PRO COM USED
----------------------------------------------
0 vin0 0 0 16 0 0 0 0
0 vin0 0 8 0 2 1 0 0
0 isp0 0 0 16 0 0 0 0
0 isp0 0 8 0 3 0 0 0
0 vse0 0 0 16 0 0 0 0
0 vse0 0 8 0 3 0 0 0
0 vse0 0 9 0 3 0 0 0
0 vse0 0 13 0 3 0 0 0
----------------------------------------------
flowid module cid chn FREE REQ PRO COM USED
----------------------------------------------
0 vin0 0 0 16 0 0 0 0
0 vin0 0 8 0 2 1 0 0
0 isp0 0 0 16 0 0 0 0
0 isp0 0 8 0 3 0 0 0
0 vse0 0 0 16 0 0 0 0
0 vse0 0 8 0 3 0 0 0
0 vse0 0 9 0 3 0 0 0
0 vse0 0 13 0 3 0 0 0
========================= END ===========================
Opened DRM device: /dev/dri/card0
DRM is available, using libdrm for rendering.
------------------------------------------------------
Plane 0:
Plane ID: 41
Src W: 1920
Src H: 1080
CRTC X: 0
CRTC Y: 0
CRTC W: 1920
CRTC H: 1080
Format: NV12
Z Pos: 0
Alpha: 65535
Pixel Blend Mode: 1
Rotation: -1
Color Encoding: -1
Color Range: -1
------------------------------------------------------
Setting DRM client capabilities...
Setting up KMS...
CRTC ID: 31
CRTC ID: 63
Number of connectors: 1
Connector ID: 74
Type: 11
Type Name: HDMI-A
Connection: Connected
Modes: 41
Subpixel: 1
Mode 0: 1280x720 @ 60Hz
Mode 1: 1920x1080 @ 60Hz
Mode 2: 1920x1080 @ 60Hz
Mode 3: 1920x1080 @ 60Hz
Mode 4: 1920x1080i @ 60Hz
Mode 5: 1920x1080i @ 60Hz
Mode 6: 1920x1080 @ 50Hz
Mode 7: 1920x1080i @ 50Hz
Mode 8: 1920x1080i @ 50Hz
Mode 9: 1920x1080 @ 24Hz
Mode 10: 1920x1080 @ 24Hz
Mode 11: 1680x1050 @ 60Hz
Mode 12: 1280x1024 @ 60Hz
Mode 13: 1280x960 @ 60Hz
Mode 14: 1280x800 @ 60Hz
Mode 15: 1280x720 @ 60Hz
Mode 16: 1280x720 @ 60Hz
Mode 17: 1280x720 @ 60Hz
Mode 18: 1280x720 @ 50Hz
Mode 19: 1280x720 @ 50Hz
Mode 20: 1024x768 @ 60Hz
Mode 21: 800x600 @ 60Hz
Mode 22: 800x600 @ 56Hz
Mode 23: 720x576 @ 50Hz
Mode 24: 720x576 @ 50Hz
Mode 25: 720x576 @ 50Hz
Mode 26: 720x576i @ 50Hz
Mode 27: 720x576i @ 50Hz
Mode 28: 720x480 @ 60Hz
Mode 29: 720x480 @ 60Hz
Mode 30: 720x480 @ 60Hz
Mode 31: 720x480 @ 60Hz
Mode 32: 720x480 @ 60Hz
Mode 33: 720x480i @ 60Hz
Mode 34: 720x480i @ 60Hz
Mode 35: 720x480i @ 60Hz
Mode 36: 720x480i @ 60Hz
Mode 37: 640x480 @ 60Hz
Mode 38: 640x480 @ 60Hz
Mode 39: 640x480 @ 60Hz
Mode 40: 720x400 @ 70Hz
2026/07/16 11:53:17.088 !INFO [BindTo][0088]BindTo_CHN:-1
2026/07/16 11:53:17.088 !INFO [BindTo][0093]m_prev_module_chn:1
2026/07/16 11:53:17.101 !INFO [SetImageFrame][0493]N2D init done!
Created new framebuffer: fb_id=78 for dma_buf_fd=90
add mapping dma_buf_fd:90 fb_id:78, mapping_count: 1
Created new framebuffer: fb_id=79 for dma_buf_fd=91
add mapping dma_buf_fd:91 fb_id:79, mapping_count: 2
tv is in the picture with confidence:0.6016, bbox:[754, 262, 906, 382]
tv is in the picture with confidence:0.5725, bbox:[754, 262, 905, 381]
tv is in the picture with confidence:0.5539, bbox:[430, 406, 545, 458]
chair is in the picture with confidence:0.5257, bbox:[407, 443, 568, 593]
chair is in the picture with confidence:0.5373, bbox:[401, 443, 566, 592]
tv is in the picture with confidence:0.5339, bbox:[706, 381, 796, 449]
person is in the picture with confidence:0.5142, bbox:[1630, 343, 1761, 491]
tv is in the picture with confidence:0.5051, bbox:[430, 405, 546, 456]
chair is in the picture with confidence:0.5691, bbox:[401, 441, 572, 593]
tv is in the picture with confidence:0.5613, bbox:[752, 262, 905, 382]
person is in the picture with confidence:0.5449, bbox:[1633, 342, 1762, 493]
chair is in the picture with confidence:0.5030, bbox:[645, 425, 876, 681]
chair is in the picture with confidence:0.5744, bbox:[402, 442, 571, 591]
person is in the picture with confidence:0.5683, bbox:[1631, 344, 1762, 492]
tv is in the picture with confidence:0.5398, bbox:[749, 264, 905, 383]
chair is in the picture with confidence:0.5179, bbox:[645, 425, 879, 683]
tv is in the picture with confidence:0.5669, bbox:[748, 263, 906, 383]
chair is in the picture with confidence:0.5591, bbox:[401, 443, 572, 594]
person is in the picture with confidence:0.5337, bbox:[1628, 343, 1759, 490]
tv is in the picture with confidence:0.5406, bbox:[752, 264, 905, 385]
person is in the picture with confidence:0.5330, bbox:[1631, 340, 1760, 494]
chair is in the picture with confidence:0.5300, bbox:[408, 441, 568, 593]
chair is in the picture with confidence:0.5749, bbox:[402, 443, 566, 594]
tv is in the picture with confidence:0.5676, bbox:[751, 263, 906, 385]
person is in the picture with confidence:0.5359, bbox:[1634, 342, 1761, 489]
person is in the picture with confidence:0.5119, bbox:[1289, 117, 1914, 662]
chair is in the picture with confidence:0.5623, bbox:[403, 443, 568, 594]
tv is in the picture with confidence:0.5411, bbox:[751, 264, 905, 382]
person is in the picture with confidence:0.5312, bbox:[1633, 344, 1758, 486]
person is in the picture with confidence:0.5203, bbox:[1295, 116, 1914, 665]
person is in the picture with confidence:0.5014, bbox:[1156, 115, 1917, 887]
tv is in the picture with confidence:0.5759, bbox:[752, 262, 907, 381]
chair is in the picture with confidence:0.5645, bbox:[403, 443, 572, 594]
person is in the picture with confidence:0.5486, bbox:[1633, 344, 1759, 485]
chair is in the picture with confidence:0.5966, bbox:[403, 443, 567, 594]
tv is in the picture with confidence:0.5645, bbox:[750, 263, 907, 384]
person is in the picture with confidence:0.5279, bbox:[1631, 341, 1758, 484]
chair is in the picture with confidence:0.5165, bbox:[643, 423, 888, 726]
tv is in the picture with confidence:0.5776, bbox:[752, 264, 904, 382]
chair is in the picture with confidence:0.5751, bbox:[403, 441, 569, 593]
person is in the picture with confidence:0.5281, bbox:[1629, 343, 1759, 488]
chair is in the picture with confidence:0.5186, bbox:[644, 427, 877, 682]
person is in the picture with confidence:0.5176, bbox:[1195, 117, 1913, 686]
chair is in the picture with confidence:0.5551, bbox:[402, 438, 567, 593]
tv is in the picture with confidence:0.5444, bbox:[752, 265, 906, 383]
person is in the picture with confidence:0.5188, bbox:[1635, 342, 1758, 485]
chair is in the picture with confidence:0.5033, bbox:[649, 425, 875, 678]
chair is in the picture with confidence:0.5719, bbox:[401, 443, 570, 593]
person is in the picture with confidence:0.5322, bbox:[1637, 341, 1758, 486]
person is in the picture with confidence:0.5041, bbox:[1048, 111, 1920, 799]
chair is in the picture with confidence:0.5764, bbox:[399, 443, 569, 593]
tv is in the picture with confidence:0.5585, bbox:[752, 263, 904, 382]
person is in the picture with confidence:0.5413, bbox:[1632, 341, 1761, 487]
chair is in the picture with confidence:0.6027, bbox:[401, 442, 567, 593]
person is in the picture with confidence:0.5738, bbox:[1633, 342, 1762, 488]
chair is in the picture with confidence:0.5345, bbox:[643, 421, 878, 713]
tv is in the picture with confidence:0.5220, bbox:[752, 264, 905, 377]
chair is in the picture with confidence:0.5748, bbox:[405, 442, 565, 592]
person is in the picture with confidence:0.5497, bbox:[1637, 345, 1762, 483]
tv is in the picture with confidence:0.5348, bbox:[753, 265, 905, 381]
chair is in the picture with confidence:0.5326, bbox:[644, 423, 878, 756]
chair is in the picture with confidence:0.5662, bbox:[400, 442, 571, 591]
tv is in the picture with confidence:0.5418, bbox:[750, 263, 905, 385]
person is in the picture with confidence:0.5142, bbox:[1639, 343, 1752, 491]
chair is in the picture with confidence:0.5765, bbox:[403, 443, 568, 594]
tv is in the picture with confidence:0.5357, bbox:[748, 264, 904, 383]
person is in the picture with confidence:0.5175, bbox:[1637, 342, 1756, 487]
chair is in the picture with confidence:0.5136, bbox:[644, 421, 878, 760]
tv is in the picture with confidence:0.5781, bbox:[751, 263, 906, 385]
chair is in the picture with confidence:0.5493, bbox:[403, 443, 567, 594]
chair is in the picture with confidence:0.5345, bbox:[644, 436, 875, 682]
person is in the picture with confidence:0.5259, bbox:[1638, 343, 1756, 492]
chair is in the picture with confidence:0.5429, bbox:[403, 441, 570, 594]
person is in the picture with confidence:0.5408, bbox:[1636, 344, 1760, 492]
tv is in the picture with confidence:0.5323, bbox:[751, 264, 905, 380]
chair is in the picture with confidence:0.5028, bbox:[644, 426, 878, 699]
tv is in the picture with confidence:0.5840, bbox:[751, 263, 905, 384]
chair is in the picture with confidence:0.5450, bbox:[401, 443, 567, 594]
person is in the picture with confidence:0.5212, bbox:[1637, 342, 1757, 496]
tv is in the picture with confidence:0.5872, bbox:[750, 264, 905, 386]
chair is in the picture with confidence:0.5633, bbox:[404, 440, 568, 594]
person is in the picture with confidence:0.5139, bbox:[1637, 345, 1750, 495]
tv is in the picture with confidence:0.5691, bbox:[753, 264, 904, 384]
chair is in the picture with confidence:0.5573, bbox:[401, 442, 568, 594]
chair is in the picture with confidence:0.5296, bbox:[649, 433, 878, 682]
laptop is in the picture with confidence:0.5193, bbox:[933, 634, 1743, 823]
person is in the picture with confidence:0.5028, bbox:[1640, 342, 1747, 494]
tv is in the picture with confidence:0.5638, bbox:[751, 262, 905, 383]
chair is in the picture with confidence:0.5510, bbox:[402, 440, 567, 594]
chair is in the picture with confidence:0.5507, bbox:[644, 422, 876, 682]
person is in the picture with confidence:0.5121, bbox:[1640, 341, 1756, 496]
chair is in the picture with confidence:0.5536, bbox:[401, 444, 565, 594]
tv is in the picture with confidence:0.5323, bbox:[748, 264, 902, 382]
person is in the picture with confidence:0.5215, bbox:[1643, 343, 1756, 494]
chair is in the picture with confidence:0.5152, bbox:[644, 422, 877, 684]
chair is in the picture with confidence:0.6036, bbox:[403, 442, 568, 593]
chair is in the picture with confidence:0.5720, bbox:[403, 443, 569, 593]
tv is in the picture with confidence:0.5266, bbox:[753, 264, 905, 378]
tv is in the picture with confidence:0.5941, bbox:[750, 263, 903, 386]
person is in the picture with confidence:0.5052, bbox:[1297, 115, 1911, 663]
person is in the picture with confidence:0.5198, bbox:[1643, 343, 1756, 496]
tv is in the picture with confidence:0.5821, bbox:[749, 262, 905, 382]
chair is in the picture with confidence:0.5522, bbox:[402, 443, 566, 591]
chair is in the picture with confidence:0.5247, bbox:[408, 441, 567, 592]
chair is in the picture with confidence:0.5144, bbox:[649, 422, 877, 677]
person is in the picture with confidence:0.5066, bbox:[1646, 342, 1754, 494]
person is in the picture with confidence:0.5015, bbox:[1013, 105, 1912, 792]
tv is in the picture with confidence:0.5309, bbox:[750, 263, 904, 385]
chair is in the picture with confidence:0.5246, bbox:[649, 415, 878, 680]
person is in the picture with confidence:0.5026, bbox:[1643, 341, 1755, 496]
chair is in the picture with confidence:0.5999, bbox:[402, 442, 567, 592]
tv is in the picture with confidence:0.5276, bbox:[752, 264, 906, 384]
person is in the picture with confidence:0.5146, bbox:[1061, 108, 1919, 759]
person is in the picture with confidence:0.5099, bbox:[1295, 117, 1909, 656]
chair is in the picture with confidence:0.5503, bbox:[406, 443, 564, 594]
tv is in the picture with confidence:0.5259, bbox:[752, 264, 905, 381]
person is in the picture with confidence:0.5051, bbox:[1643, 343, 1753, 495]
laptop is in the picture with confidence:0.5018, bbox:[929, 632, 1720, 819]
chair is in the picture with confidence:0.5405, bbox:[402, 439, 574, 594]
chair is in the picture with confidence:0.5278, bbox:[645, 422, 878, 697]
person is in the picture with confidence:0.5047, bbox:[1643, 343, 1756, 495]
chair is in the picture with confidence:0.5795, bbox:[401, 442, 573, 593]
tv is in the picture with confidence:0.5256, bbox:[748, 263, 907, 386]
chair is in the picture with confidence:0.5906, bbox:[398, 443, 567, 593]
tv is in the picture with confidence:0.5451, bbox:[751, 263, 904, 384]
person is in the picture with confidence:0.5242, bbox:[1642, 342, 1758, 496]
chair is in the picture with confidence:0.5149, bbox:[632, 823, 944, 948]
tv is in the picture with confidence:0.5949, bbox:[749, 263, 906, 384]
chair is in the picture with confidence:0.5682, bbox:[404, 439, 567, 594]
person is in the picture with confidence:0.5147, bbox:[1643, 343, 1755, 493]
chair is in the picture with confidence:0.5741, bbox:[402, 443, 569, 593]
tv is in the picture with confidence:0.5294, bbox:[750, 263, 905, 382]
person is in the picture with confidence:0.5201, bbox:[1640, 342, 1758, 493]
chair is in the picture with confidence:0.5034, bbox:[644, 424, 881, 760]
chair is in the picture with confidence:0.5911, bbox:[401, 443, 569, 594]
tv is in the picture with confidence:0.5451, bbox:[747, 263, 901, 384]
chair is in the picture with confidence:0.5169, bbox:[644, 414, 879, 685]
person is in the picture with confidence:0.5048, bbox:[1642, 340, 1756, 493]
tv is in the picture with confidence:0.5634, bbox:[750, 263, 906, 385]
chair is in the picture with confidence:0.5510, bbox:[407, 444, 567, 594]
person is in the picture with confidence:0.5327, bbox:[1640, 344, 1755, 492]
chair is in the picture with confidence:0.5772, bbox:[402, 443, 567, 594]
tv is in the picture with confidence:0.5366, bbox:[751, 264, 905, 382]
person is in the picture with confidence:0.5333, bbox:[1640, 343, 1760, 495]
chair is in the picture with confidence:0.5029, bbox:[644, 422, 882, 680]
tv is in the picture with confidence:0.5441, bbox:[751, 264, 904, 382]
chair is in the picture with confidence:0.5431, bbox:[404, 441, 572, 591]
chair is in the picture with confidence:0.5292, bbox:[627, 820, 944, 953]
person is in the picture with confidence:0.5234, bbox:[1637, 342, 1753, 489]
chair is in the picture with confidence:0.5213, bbox:[649, 421, 872, 679]
chair is in the picture with confidence:0.5606, bbox:[402, 441, 569, 594]
chair is in the picture with confidence:0.5669, bbox:[407, 443, 565, 594]
person is in the picture with confidence:0.5117, bbox:[1638, 345, 1749, 494]
tv is in the picture with confidence:0.5039, bbox:[753, 262, 901, 384]
chair is in the picture with confidence:0.5610, bbox:[402, 441, 567, 593]
tv is in the picture with confidence:0.5305, bbox:[752, 264, 904, 381]
person is in the picture with confidence:0.5214, bbox:[1638, 345, 1756, 492]
chair is in the picture with confidence:0.5084, bbox:[645, 422, 877, 676]
chair is in the picture with confidence:0.5717, bbox:[402, 442, 567, 593]
chair is in the picture with confidence:0.5301, bbox:[648, 424, 876, 677]
person is in the picture with confidence:0.5117, bbox:[1638, 343, 1755, 489]
tv is in the picture with confidence:0.5019, bbox:[748, 264, 903, 384]
chair is in the picture with confidence:0.5518, bbox:[402, 443, 568, 594]
person is in the picture with confidence:0.5102, bbox:[1127, 108, 1908, 733]
tv is in the picture with confidence:0.5092, bbox:[749, 263, 905, 382]
person is in the picture with confidence:0.5043, bbox:[1636, 343, 1754, 494]
tv is in the picture with confidence:0.5562, bbox:[749, 262, 904, 383]
chair is in the picture with confidence:0.5494, bbox:[402, 442, 567, 594]
person is in the picture with confidence:0.5327, bbox:[1637, 343, 1754, 483]
chair is in the picture with confidence:0.5016, bbox:[650, 423, 875, 679]
chair is in the picture with confidence:0.5447, bbox:[405, 441, 567, 594]
chair is in the picture with confidence:0.5465, bbox:[401, 443, 571, 594]
tv is in the picture with confidence:0.5447, bbox:[752, 264, 904, 380]
person is in the picture with confidence:0.5396, bbox:[1635, 345, 1758, 490]
chair is in the picture with confidence:0.5032, bbox:[649, 424, 880, 679]
person is in the picture with confidence:0.5437, bbox:[1634, 345, 1761, 490]
chair is in the picture with confidence:0.5202, bbox:[633, 827, 932, 949]
tv is in the picture with confidence:0.5079, bbox:[753, 263, 906, 387]
person is in the picture with confidence:0.5395, bbox:[1628, 349, 1758, 495]
chair is in the picture with confidence:0.5350, bbox:[407, 443, 568, 594]
person is in the picture with confidence:0.5604, bbox:[1626, 344, 1760, 492]
tv is in the picture with confidence:0.5451, bbox:[749, 267, 904, 383]
chair is in the picture with confidence:0.5361, bbox:[402, 443, 569, 595]
chair is in the picture with confidence:0.5248, bbox:[649, 420, 877, 682]
person is in the picture with confidence:0.5511, bbox:[1624, 346, 1764, 490]
chair is in the picture with confidence:0.5388, bbox:[401, 440, 569, 593]
tv is in the picture with confidence:0.5376, bbox:[753, 264, 905, 380]
chair is in the picture with confidence:0.5342, bbox:[649, 424, 877, 681]
Traceback (most recent call last):
File "/app/pydev_demo/03_mipi_camera_sample/mipi_camera.py", line 406, in <module>
img = np.frombuffer(img, dtype=np.uint8)
TypeError: a bytes-like object is required, not 'NoneType'
sunrise@ubuntu:/app/pydev_demo/03_mipi_camera_sample$
旧示例代码:
sunrise@ubuntu:/app/pydev_demo/03_mipi_camera_sample$ cat mipi_camera.py
#!/usr/bin/env python3
################################################################################
# Copyright (c) 2024,D-Robotics.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
import sys
import signal
import os
import numpy as np
import cv2
import colorsys
from time import time,sleep
import multiprocessing
from threading import BoundedSemaphore
import ctypes
import json
# Camera API libs
try:
from hobot_vio import libsrcampy as srcampy
except ImportError:
from hobot_vio_rdkx5 import libsrcampy as srcampy
try:
from hobot_dnn import pyeasy_dnn as dnn
except ImportError:
from hobot_dnn_rdkx5 import pyeasy_dnn as dnn
import threading
# sensor
sensor_width = 3840
sensor_height = 2160
image_counter = None
is_stop=False
output_tensors = None
fcos_postprocess_info = None
# def signal_handler(signal, frame):
# sys.exit(0)
# global is_stop
# print("Stopping!\n")
# is_stop=True
class hbSysMem_t(ctypes.Structure):
_fields_ = [
("phyAddr",ctypes.c_double),
("virAddr",ctypes.c_void_p),
("memSize",ctypes.c_int)
]
class hbDNNQuantiShift_yt(ctypes.Structure):
_fields_ = [
("shiftLen",ctypes.c_int),
("shiftData",ctypes.c_char_p)
]
class hbDNNQuantiScale_t(ctypes.Structure):
_fields_ = [
("scaleLen",ctypes.c_int),
("scaleData",ctypes.POINTER(ctypes.c_float)),
("zeroPointLen",ctypes.c_int),
("zeroPointData",ctypes.c_char_p)
]
class hbDNNTensorShape_t(ctypes.Structure):
_fields_ = [
("dimensionSize",ctypes.c_int * 8),
("numDimensions",ctypes.c_int)
]
class hbDNNTensorProperties_t(ctypes.Structure):
_fields_ = [
("validShape",hbDNNTensorShape_t),
("alignedShape",hbDNNTensorShape_t),
("tensorLayout",ctypes.c_int),
("tensorType",ctypes.c_int),
("shift",hbDNNQuantiShift_yt),
("scale",hbDNNQuantiScale_t),
("quantiType",ctypes.c_int),
("quantizeAxis", ctypes.c_int),
("alignedByteSize",ctypes.c_int),
("stride",ctypes.c_int * 8)
]
class hbDNNTensor_t(ctypes.Structure):
_fields_ = [
("sysMem",hbSysMem_t * 4),
("properties",hbDNNTensorProperties_t)
]
class FcosPostProcessInfo_t(ctypes.Structure):
_fields_ = [
("height",ctypes.c_int),
("width",ctypes.c_int),
("ori_height",ctypes.c_int),
("ori_width",ctypes.c_int),
("score_threshold",ctypes.c_float),
("nms_threshold",ctypes.c_float),
("nms_top_k",ctypes.c_int),
("is_pad_resize",ctypes.c_int)
]
libpostprocess = ctypes.CDLL('/usr/lib/libpostprocess.so')
get_Postprocess_result = libpostprocess.FcosPostProcess
get_Postprocess_result.argtypes = [ctypes.POINTER(FcosPostProcessInfo_t)]
get_Postprocess_result.restype = ctypes.c_char_p
def get_TensorLayout(Layout):
if Layout == "NCHW":
return int(2)
else:
return int(0)
is_stop=False
def signal_handler(signal, frame):
global is_stop
print("Stopping!\n")
is_stop=True
sys.exit(0)
def get_display_res():
disp_w_small=1920
disp_h_small=1080
disp = srcampy.Display()
resolution_list = disp.get_display_res()
if (sensor_width, sensor_height) in resolution_list:
print(f"Resolution {sensor_width}x{sensor_height} exists in the list.")
return int(sensor_width), int(sensor_height)
else:
print(f"Resolution {sensor_width}x{sensor_height} does not exist in the list.")
for res in resolution_list:
# Exclude 0 resolution first.
if res[0] == 0 and res[1] == 0:
break
else:
disp_w_small=res[0]
disp_h_small=res[1]
# If the disp_w、disp_h is not set or not in the list, default to iterating to the smallest resolution for use.
if res[0] <= sensor_width and res[1] <= sensor_height:
print(f"Resolution {res[0]}x{res[1]}.")
return int(res[0]), int(res[1])
disp.close()
return disp_w_small, disp_h_small
disp_w, disp_h = get_display_res()
# detection model class names
def get_classes():
return np.array([
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train",
"truck", "boat", "traffic light", "fire hydrant", "stop sign",
"parking meter", "bench", "bird", "cat", "dog", "horse", "sheep",
"cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella",
"handbag", "tie", "suitcase", "frisbee", "skis", "snowboard",
"sports ball", "kite", "baseball bat", "baseball glove", "skateboard",
"surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork",
"knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
"broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair",
"couch", "potted plant", "bed", "dining table", "toilet", "tv",
"laptop", "mouse", "remote", "keyboard", "cell phone", "microwave",
"oven", "toaster", "sink", "refrigerator", "book", "clock", "vase",
"scissors", "teddy bear", "hair drier", "toothbrush"
])
def get_hw(pro):
if pro.layout == "NCHW":
return pro.shape[2], pro.shape[3]
else:
return pro.shape[1], pro.shape[2]
def print_properties(pro):
print("tensor type:", pro.tensor_type)
print("data type:", pro.dtype)
print("layout:", pro.layout)
print("shape:", pro.shape)
class ParallelExector(object):
def __init__(self, counter, parallel_num=4):
global image_counter
image_counter = counter
self.parallel_num = parallel_num
if parallel_num != 1:
self._pool = multiprocessing.Pool(processes=self.parallel_num,
maxtasksperchild=5)
self.workers = BoundedSemaphore(self.parallel_num)
def infer(self, output):
if self.parallel_num == 1:
run(output)
else:
self.workers.acquire()
self._pool.apply_async(func=run,
args=(output, ),
callback=self.task_done,
error_callback=print)
def task_done(self, *args, **kwargs):
"""Called once task is done, releases the queue is blocked."""
self.workers.release()
def close(self):
if hasattr(self, "_pool"):
self._pool.close()
self._pool.join()
def limit_display_cord(coor):
coor[0] = max(min(disp_w, coor[0]), 0)
# min coor is set to 2 not 0, leaving room for string display
coor[1] = max(min(disp_h, coor[1]), 2)
coor[2] = max(min(disp_w, coor[2]), 0)
coor[3] = max(min(disp_h, coor[3]), 0)
return coor
def scale_bbox(bbox, input_w, input_h, output_w, output_h):
scale_x = output_w / input_w
scale_y = output_h / input_h
x1 = int(bbox[0] * scale_x)
y1 = int(bbox[1] * scale_y)
x2 = int(bbox[2] * scale_x)
y2 = int(bbox[3] * scale_y)
return [x1, y1, x2, y2]
def run(outputs):
global image_counter
strides = [8, 16, 32, 64, 128]
for i in range(len(strides)):
if (output_tensors[i].properties.quantiType == 0):
output_tensors[i].sysMem[0].virAddr = ctypes.cast(outputs[i].ctypes.data_as(ctypes.POINTER(ctypes.c_float)), ctypes.c_void_p)
output_tensors[i + 5].sysMem[0].virAddr = ctypes.cast(outputs[i + 5].ctypes.data_as(ctypes.POINTER(ctypes.c_float)), ctypes.c_void_p)
output_tensors[i + 10].sysMem[0].virAddr = ctypes.cast(outputs[i + 10].ctypes.data_as(ctypes.POINTER(ctypes.c_float)), ctypes.c_void_p)
else:
output_tensors[i].sysMem[0].virAddr = ctypes.cast(outputs[i].ctypes.data_as(ctypes.POINTER(ctypes.c_int32)), ctypes.c_void_p)
output_tensors[i + 5].sysMem[0].virAddr = ctypes.cast(outputs[i + 5].ctypes.data_as(ctypes.POINTER(ctypes.c_int32)), ctypes.c_void_p)
output_tensors[i + 10].sysMem[0].virAddr = ctypes.cast(outputs[i + 10].ctypes.data_as(ctypes.POINTER(ctypes.c_int32)), ctypes.c_void_p)
libpostprocess.FcosdoProcess(output_tensors[i], output_tensors[i + 5], output_tensors[i + 10], ctypes.pointer(fcos_postprocess_info), i)
result_str = get_Postprocess_result(ctypes.pointer(fcos_postprocess_info))
result_str = result_str.decode('utf-8')
# print(result_str)
# draw result
# 解析JSON字符串
data = json.loads(result_str[14:])
# 遍历每一个结果
for index, result in enumerate(data):
bbox = result['bbox'] # 矩形框位置信息
score = result['score'] # 得分
id = int(result['id']) # id
name = result['name'] # 类别名称
bbox = scale_bbox(bbox, 512, 512, disp_w, disp_h)
coor = limit_display_cord(bbox)
coor = [round(i) for i in coor]
# get bbox score
score = float(score)
# concat bbox string
bbox_string = '%s: %.2f' % (name, score)
bbox_string = bbox_string.encode('gb2312')
# concat bbox color
box_color = colors[id]
color_base = 0xFF000000
box_color_ARGB = color_base | (box_color[0]) << 16 | (
box_color[1]) << 8 | (box_color[2])
print("{} is in the picture with confidence:{:.4f}, bbox:{}".format(name, score, coor))
# if new frame come in, need to flush the display buffer.
# For the meaning of parameters, please refer to the relevant documents of display api
if index == 0:
disp.set_graph_rect(coor[0], coor[1], coor[2], coor[3], 3, 1,
box_color_ARGB)
disp.set_graph_word(coor[0], coor[1] - 2, bbox_string, 3, 1,
box_color_ARGB)
else:
disp.set_graph_rect(coor[0], coor[1], coor[2], coor[3], 3, 0,
box_color_ARGB)
disp.set_graph_word(coor[0], coor[1] - 2, bbox_string, 3, 0,
box_color_ARGB)
# fps timer and counter
with image_counter.get_lock():
image_counter.value += 1
if image_counter.value == 100:
finish_time = time()
print(
f"Total time cost for 100 frames: {finish_time - start_time}, fps: {100/(finish_time - start_time)}"
)
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler)
models = dnn.load('../models/fcos_512x512_nv12.bin')
print("--- model input properties ---")
# 打印输入 tensor 的属性
print_properties(models[0].inputs[0].properties)
print("--- model output properties ---")
# 打印输出 tensor 的属性
for output in models[0].outputs:
print_properties(output.properties)
# 获取结构体信息
fcos_postprocess_info = FcosPostProcessInfo_t()
fcos_postprocess_info.height = 512
fcos_postprocess_info.width = 512
fcos_postprocess_info.ori_height = disp_h
fcos_postprocess_info.ori_width = disp_w
fcos_postprocess_info.score_threshold = 0.5
fcos_postprocess_info.nms_threshold = 0.6
fcos_postprocess_info.nms_top_k = 5
fcos_postprocess_info.is_pad_resize = 0
output_tensors = (hbDNNTensor_t * len(models[0].outputs))()
for i in range(len(models[0].outputs)):
output_tensors[i].properties.tensorLayout = get_TensorLayout(models[0].outputs[i].properties.layout)
#print(output_tensors[i].properties.tensorLayout)
if (len(models[0].outputs[i].properties.scale_data) == 0):
output_tensors[i].properties.quantiType = 0
else:
output_tensors[i].properties.quantiType = 2
scale_data_tmp = models[0].outputs[i].properties.scale_data.reshape(1, 1, 1, models[0].outputs[i].properties.shape[3])
output_tensors[i].properties.scale.scaleData = scale_data_tmp.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
for j in range(len(models[0].outputs[i].properties.shape)):
output_tensors[i].properties.validShape.dimensionSize[j] = models[0].outputs[i].properties.shape[j]
output_tensors[i].properties.alignedShape.dimensionSize[j] = models[0].outputs[i].properties.shape[j]
# Camera API, get camera object
cam = srcampy.Camera()
# get model info
h, w = get_hw(models[0].inputs[0].properties)
input_shape = (h, w)
# Open f37 camera
# For the meaning of parameters, please refer to the relevant documents of camera
cam.open_cam(0, -1, -1, [w, disp_w], [h, disp_h],sensor_height,sensor_width)
# Get HDMI display object
disp = srcampy.Display()
# For the meaning of parameters, please refer to the relevant documents of HDMI display
disp.display(0, disp_w, disp_h)
# bind camera directly to display
srcampy.bind(cam, disp)
# change disp for bbox display
disp.display(3, disp_w, disp_h)
# setup for box color and box string
classes = get_classes()
num_classes = len(classes)
hsv_tuples = [(1.0 * x / num_classes, 1., 1.) for x in range(num_classes)]
colors = list(map(lambda x: colorsys.hsv_to_rgb(*x), hsv_tuples))
colors = list(
map(lambda x: (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)),
colors))
# fps timer and counter
start_time = time()
image_counter = multiprocessing.Value("i", 0)
# post process parallel executor
parallel_exe = ParallelExector(image_counter)
while not is_stop:
# image_counter += 1
# Get image data with shape of 512x512 nv12 data from camera
cam_start_time = time()
img = cam.get_img(2, 512, 512)
cam_finish_time = time()
# Convert to numpy
buffer_start_time = time()
img = np.frombuffer(img, dtype=np.uint8)
buffer_finish_time = time()
# Forward
infer_start_time = time()
outputs = models[0].forward(img)
infer_finish_time = time()
output_array = []
for item in outputs:
output_array.append(item.buffer)
parallel_exe.infer(output_array)
cam.close_cam()
disp.close()