Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim4:add-ons:vim4-mipi-camera

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:vim4:add-ons:vim4-mipi-camera [2023/07/04 23:13]
nick
products:sbc:vim4:add-ons:vim4-mipi-camera [2024/05/18 03:12] (current)
nick [Record Video via Gstreamer]
Line 1: Line 1:
 +~~tag> VIM4 OpenCV V4l2 MIPI ISP ~~
 +
 {{indexmenu_n>50}} {{indexmenu_n>50}}
  
 +====== VIM4 MIPI Camera Usage ======
  
-===== VIM4 MIPI Camera Usage =====+===== Linux =====
  
-==== Linux ====+==== Upgrade System ====
  
-=== Video Node ===+Please follow the [[products:sbc:vim4:configurations:upgrade-system|documentation ]]to upgrade your system to latest version. 
 + 
 +==== Video Node ====
  
 The video node for MIPI camera is ''/dev/video50''. The video node for MIPI camera is ''/dev/video50''.
  
-=== Record Video via Gstreamer ===+==== Record Video via Gstreamer ===
  
 +Follow the steps below to install Gstreamer Encoder Plugin:
  
-== Install Gstreamer Encoder Plugin == 
 ```shell ```shell
 sudo apt update sudo apt update
Line 19: Line 25:
 ``` ```
  
-== Record Video ==+Record Video
 ```shell ```shell
-gst-launch-1.0 v4l2src device=/dev/video50 io-mode=mmap num-buffers=300 ! video/x-raw,format=NV12 ! amlvenc bitrate=8000 ! h264parse ! qtmux ! filesink location=test_50.mp4+gst-launch-1.0 -e v4l2src device=/dev/video50 io-mode=mmap num-buffers=300 ! video/x-raw,format=NV21,width=3840,height=2160,framerate=30/! amlvenc bitrate=8000 ! h264parse ! qtmux ! filesink location=test_50.mp4
 ``` ```
  
  
-=== Record Video with OpenCV ===+==== Record Video with OpenCV ====
  
-== Install OpenCV ==+Follow the steps below to install OpenCV:
  
 ```shell ```shell
Line 34: Line 41:
 ``` ```
  
-== Get Frame via V4l2 ==+Get Frame via V4l2:
  
 ```c++ mipi-camera.cpp ```c++ mipi-camera.cpp
Line 55: Line 62:
     VideoCapture capture(stoi(res), CAP_V4L2);     VideoCapture capture(stoi(res), CAP_V4L2);
     capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('U','Y','V','Y'));     capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('U','Y','V','Y'));
-    capture.set(CAP_PROP_FRAME_WIDTH, 1920); +    capture.set(CAP_PROP_FRAME_WIDTH, 3840); 
-    capture.set(CAP_PROP_FRAME_HEIGHT, 1080);+    capture.set(CAP_PROP_FRAME_HEIGHT, 2160);
     while (count)     while (count)
     {     {
Line 78: Line 85:
 ``` ```
  
-== Get Frame via Gstreamer ==+Get Frame via Gstreamer:
  
 ```c++ mipi-camera.cpp ```c++ mipi-camera.cpp
Line 97: Line 104:
     string str = argv[1];     string str = argv[1];
     string gstformat = "NV12";     string gstformat = "NV12";
-    string gstfile = "v4l2src device=" + str + " ! video/x-raw,format=" + gstformat + ",width=1920,height=1080,framerate=30/1 ! videoconvert ! appsink";+    string gstfile = "v4l2src device=" + str + " ! video/x-raw,format=" + gstformat + ",width=3840,height=2160,framerate=30/1 ! videoconvert ! appsink";
     VideoCapture capture(gstfile);     VideoCapture capture(gstfile);
  
Line 132: Line 139:
 ./mipi /dev/video50 ./mipi /dev/video50
 ``` ```
-==== Android ====+===== Android =====
 WIP: WIP:
  
-===== New VIM4 MIPI Camera Usage ===== 
- 
-==== Linux ==== 
- 
-=== Enable Overlays === 
- 
-If you want to use the OS08A10 MIPI camera, you need to enable it in [[products:sbc:vim4:configurations:device-tree-overlay|overlays]], you need to add ''vim4n-os08a10'' to ''fdt_overlays'' in ''/boot/dtb/amlogic/kvim4.dtb.overlay.env''. 
- 
-``` 
-$ cat /boot/dtb/amlogic/kvim4.dtb.overlay.env  
-fdt_overlays=vim4n-os08a10 
-``` 
- 
-And then reboot to take effect. 
- 
-=== Video Node === 
- 
-The video node is ''/dev/media0''. 
- 
-=== Get Frames via Mediactl API === 
- 
-You can get the test source code here: https://github.com/numbqq/v4l2_media_test 
- 
-Download and build the test source code: 
- 
-<tabbox 5.4 kernel> 
- 
- 
-```shell 
-$ git clone https://github.com/numbqq/v4l2_media_test 
-$ cd v4l2_media_test 
-$ git checkout e0482794337c01935593a91b621f9c42123cf175 
-$ g++ v4l2_test_raw.cpp -o v4l2_test_raw  -Wall -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -pthread -fPIE -lispaml -ldl -lmediaAPI -ltuning -lm -fPIC -D_FORTIFY_SOURCE=2 -O3 
-$ ls v4l2_test_raw 
-v4l2_test_raw 
-``` 
- 
-<tabbox 5.15 kernel> 
- 
-```shell 
-$ git clone https://github.com/numbqq/v4l2_media_test 
-$ cd v4l2_media_test 
-$ g++ v4l2_test_raw.cpp -o v4l2_test_raw  -Wall -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -pthread -fPIE -lispaml -ldl -lmediaAPI -ltuning -llens -lm -fPIC -D_FORTIFY_SOURCE=2 -O3 
-$ ls v4l2_test_raw 
-v4l2_test_raw 
-``` 
- 
-</tabbox> 
- 
-Test: 
- 
-```shell 
-$ ./v4l2_test_raw -p 0 -n 10 -m /dev/media0 
-``` 
- 
-It will capture 10 frames to file ''/tmp/dst_mif_0.yuv''. 
- 
-Preview the file: 
- 
-```shell 
-$ ffplay -f rawvideo -pixel_format nv21 -video_size 3840x2160 /tmp/dst_mif_0.yuv 
- 
-``` 
- 
-==== Android ==== 
-WIP: 
  
Last modified: 2023/07/04 23:13 by nick