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:00]
nick
products:sbc:vim4:add-ons:vim4-mipi-camera [2024/09/24 03:46] (current)
nick [Preview video on ubuntu desktop]
Line 1: Line 1:
 +~~tag> VIM4 OpenCV V4l2 MIPI ISP ~~
  
-===== VIM4 MIPI Camera Usage =====+{{indexmenu_n>50}} 
 + 
 +====== VIM4 MIPI Camera Usage =====
 + 
 +===== Linux ===== 
 + 
 +==== Upgrade System ==== 
 + 
 +Please follow the [[products:sbc:vim4:configurations:upgrade-system|documentation ]]to upgrade your system to latest version.
  
 ==== Video Node ==== ==== Video Node ====
Line 9: Line 18:
  
  
-=== Install Gstreamer Encoder Plugin ===+Follow the steps below to install Gstreamer Encoder Plugin
 ```shell ```shell
 sudo apt update sudo apt update
Line 15: 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
 ``` ```
  
Line 23: Line 34:
 ==== Record Video with OpenCV ==== ==== Record Video with OpenCV ====
  
-=== Install OpenCV ===+Follow the steps below to install OpenCV:
  
 ```shell ```shell
Line 30: Line 41:
 ``` ```
  
-=== C++ === +Get Frame via V4l2:
- +
- +
-== Get Frame via V4l2 ==+
  
 ```c++ mipi-camera.cpp ```c++ mipi-camera.cpp
Line 54: 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 77: 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 133: Line 140:
 ``` ```
  
-===== New VIM4 MIPI Camera Usage =====+==== Preview video on ubuntu desktop ====
  
-==== Enable Overlays ====+<tabbox Ubuntu 24.04>
  
-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''.+You can use gstreamer ''waylandsink'' to preview the video on Ubuntu Wayland desktop:
  
 +```shell
 +gst-launch-1.0 v4l2src device=/dev/video50 io-mode=mmap  ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! videoconvert ! waylandsink
 ``` ```
-$ 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> 
  
 +You can use the command below to check display fps:
  
 ```shell ```shell
-$ git clone https://github.com/numbqq/v4l2_media_test +gst-launch-1.0 -v v4l2src device=/dev/video50 io-mode=mmap ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! fpsdisplaysink video-sink=waylandsink sync=false text-overlay=false
-$ 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>+<tabbox Ubuntu 22.04> 
 + 
 +You can use gstreamer ''clutterautovideosink'' to preview the video on Ubuntu Wayland desktop:
  
 ```shell ```shell
-$ git clone https://github.com/numbqq/v4l2_media_test +gst-launch-1.0 v4l2src device=/dev/video50 io-mode=mmap ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! clutterautovideosink
-$ 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> +You can use the command below to check display fps:
- +
-Test:+
  
 ```shell ```shell
-$ ./v4l2_test_raw -0 -n 10 -m /dev/media0+gst-launch-1.0 -v v4l2src device=/dev/video50 io-mode=mmap ! video/x-raw,format=NV12,width=3840,height=2160,framerate=30/1 ! fpsdisplaysink video-sink=clutterautovideosink sync=false text-overlay=true
 ``` ```
  
-It will capture 10 frames to file ''/tmp/dst_mif_0.yuv''.+You press ''Alt + F7'' and then move mouse to move the windown.
  
-Preview the file:+</tabbox>
  
-```shell +===== Android ===== 
-$ ffplay -f rawvideo -pixel_format nv21 -video_size 3840x2160 /tmp/dst_mif_0.yuv +WIP:
- +
-```+
  
  
Last modified: 2023/07/04 23:00 by nick