Page 1 of 1

Using USB Camera with Luckfox PICO RKMPI Example and H.265 Codec Support

Posted: 2025-01-13 10:37
by Hosa
Hi guys
I’ve been exploring the luckfox_pico_rkmpi_example repository, specifically the example for recording and streaming video with the SC3306 camera. The example can be found here: luckfox_pico_rkmpi_example.

I’m currently working with a USB camera and would like to know if it’s possible to adapt this repository to work with it. Additionally, I’m interested in utilizing the H.265 codec for video encoding and streaming.

Code: Select all

./luckfox_pico_rtsp_opencv_capture
opencv-mobile MIPI CSI camera with v4l2 rkaiq
Stop Application ...
killall: rkipc: no process killed
rkipc exit
ls: /oem/usr/etc/init.d/S??*: No such file or directory
   devpath = /dev/video13
   driver = rkisp_v7
   card = rkisp_mainpath
   bus_info = platform:rkisp-vir0
   version = 20000
   capabilities = 84201000
   device_caps = 4201000
   fmt = UYVY 4:2:2  59565955
   fmt = Y/CbCr 4:2:2  3631564e
   fmt = Y/CrCb 4:2:2  3136564e
   fmt = Y/CrCb 4:2:0  3132564e
       size = 32 x 16  ~  800 x 600  (+8 +8)
[/dev/video13 ioctl VIDIOC_ENUM_FRAMEINTERVALS  10 failed 19 No such device
1.836150] rkisp-vir0: rrockit log path (null), log_size = 0, can use export rt_log_path=, export rt_log_size= change
log_file = (nil)
RTVersion        10:34:10-196 {dump              :064} ---------------------------------------------------------
RTVersion        10:34:10-217 {dump              :065} rockit version: git-8cb4d25b8 Tue Feb 28 11:12:39 2023 +0800
RTVersion        10:34:10-228 {dump              :066} rockit building: built- 2023-02-28 15:23:19
RTVersion        10:34:10-236 {dump              :067} ---------------------------------------------------------
rockit default level 4, can use export rt_log_level=x, x=0,1,2,3,4,5,6 change
(null)           10:34:10-254 {read_log_level    :093} text is all=4
(null)           10:34:10-260 {read_log_level    :095} module is all, log_level is 4
kisp_enum_frameintervals (null)          No 10:34:10-270 {monitor_log_level :1t44} #Start monitor_log_leve al thread, arg:(nil)
ctive sensor
RTIsp3x          10:34:10-288 {ispInitDevice     :208} sensor name = Camera 1
RTIsp3x          10:34:10-291 {ispInitDevice     :211} sensor_index = 61
RTIsp3x          10:34:10-299 {getIspSubdevs     :100} rkisp_bypasspath entity name is NULL
RTIsp3x          10:34:10-308 {getIspSubdevs     :111} rkisp_mainpath_4x4sampling entity name is NULL
RTIsp3x          10:34:10-318 {getIspSubdevs     :122} rkisp_bypasspath_4x4sampling entity name is NULL
RTIsp3x          10:34:10-328 {getIspSubdevs     :133} isp_luma_path entity name is NULL
RTIsp3x          10:34:10-342 {ispInitDevice     :208} sensor name = Camera 1
RTIsp3x          10:34:10-345 {ispInitDevice     :211} sensor_index = 61
RTIsp3x          10:34:10-353 {getIspSubdevs     :100} rkisp_bypasspath entity name is NULL
RTIsp3x          10:34:10-362 {getIspSubdevs     :111} rkisp_mainpath_4x4sampling entity name is NULL
RTIsp3x          10:34:10-372 {getIspSubdevs     :122} rkisp_bypasspath_4x4sampling entity name is NULL
RTIsp3x          10:34:10-383 {getIspSubdevs     :133} isp_luma_path entity name is NULL
Create Pool success !
[INFO  rtsp_demo.c:280:rtsp_new_demo] rtsp server demo starting on port 554
[DEBUG rtsp_demo.c:480:rtsp_new_session] add session path: /live/0
rtsp streamq_alloc size is 1753484
venc_init
RKVencChannel    10:34:10-425 {configProfileLevel:2523} h265e unsupport profile 77. use default 0
MpiAdapterEncode 10:34:10-431 {ma_encode_create  :1653} ringbuf buf_size 3112960
[  101.931613] vsys dev open 26
[  102.087361] mpp_vcodec: 44: num_chan = 0
[  102.087504] mpp_vcodec: 368: attr->max_width = 1920, attr->max_height = 1080
[  102.092057]init success mpp_v
codec: 103: chan_entry->handle dbbceba9, enc dbbceba9
[  102.099000] 755: MPP_ENC_SET_CFG in
[  102.099033] 524: MPP_ENC_SET_RC_CFG bps 23328000 [21870000 : 24786000] fps [30:30] gop 60
[  102.099049] h265e_proc_prep_cfg:414: MPP_ENC_SET_PREP_CFG w:h [1920:1080] stride [5760:1080]
[  102.099071] 271: send header for set cfg change input/format
[  102.101080] 755: MPP_ENC_SET_CFG in
[  102.101105] 524: MPP_ENC_SET_RC_CFG bps 3072000 [2880000 : 3264000] fps [30:30] gop 1
[  102.101121] 271: send header for set cfg change rc_mode/fps/gop
[  102.101738] 755: MPP_ENC_SET_CFG in
[  102.101756] 524: MPP_ENC_SET_RC_CFG bps 3072000 [2880000 : 3264000] fps [30:30] gop 1
[  102.101768] 271: send header for set cfg change rc_mode/fps/gop
i use luckfox_pico_rtsp_opencv_capture example but as you can see it use /dev/video13 how can i change it so it use /dev/video0
i change usb mode to host and it can detect usb camera

Code: Select all

 v4l2-ctl --list-devices
[  191.086855] rockchip-csi2-dphy0: No link between dphy and sensor
[  191.087093] rkcif-mipi-lvds: rkcif_update_sensor_info: stream[0] get remote terminal sensor failed!
[  191.087123] stream_cif_mipi_id0: update serkisp-statistics (platform: rkisp):
        /dev/video21
        /dev/video22

rkcif-mipi-lvds (platform:rkcif):
        /dev/media1

rkisp_mainpath (platform:rkisp-vir0):
        /dev/video13
        /dev/video14
        /dev/video15
        /dev/video16
        /dev/video17
        /dev/video18
        /dev/video19
        /dev/video20
        /dev/media2

FHD Camera: FHD Camera (usb-xhci-hcd.0.auto-1):
        /dev/video0
        /dev/video1
        /dev/media0
but i have little knowledge about C code and can't find where should i change it so it use /dev/video0
Here are my main questions:
Can the current examples or any part of this repository be modified to support a USB camera?
How can I enable H.265 codec support for video encoding in this setup?
Any guidance, tips, or resources you could provide would be greatly appreciated. Looking forward to your insights!

Re: Using USB Camera with Luckfox PICO RKMPI Example and H.265 Codec Support

Posted: 2025-01-14 12:39
by Ryand
You need to make modifications by searching for the corresponding API functions of RKMPI,Here is the official documentation link for RKMPI.
https://github.com/Caesar-github/rockit ... er/mpi/doc