Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


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

Differences

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

Link to this comparison view

Next revision
Previous revision
products:sbc:vim-5:add-ons:vim4-mipi-camera [2026/09/15 02:13]
127.0.0.1 external edit
— (current)
Line 1: Line 1:
-~~tag> VIM4 OpenCV V4l2 MIPI ISP ~~ 
- 
-{{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 ==== 
- 
-The video node for MIPI camera is ''/dev/video50''. 
- 
-==== Record Video via Gstreamer ==== 
- 
- 
-Follow the steps below to install Gstreamer Encoder Plugin: 
- 
-```shell 
-sudo apt update 
-sudo apt install gstreamer-aml 
-``` 
- 
-Record Video: 
- 
-```shell 
-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/1 ! amlvenc bitrate=8000 ! h264parse ! qtmux ! filesink location=test_50.mp4 
-``` 
- 
- 
-==== Record Video with OpenCV ==== 
- 
-Follow the steps below to install OpenCV: 
- 
-```shell 
-sudo apt update 
-sudo apt install libopencv-dev python3-opencv 
-``` 
- 
-Get Frame via V4l2: 
- 
-```c++ mipi-camera.cpp 
-#include <opencv2/highgui/highgui.hpp> 
-#include <opencv2/imgproc/imgproc.hpp> 
-#include <opencv2/core/core.hpp> 
-#include <iostream> 
-#include <string> 
-using 
-namespace  cv; 
- 
-using 
-namespace  std; 
- 
-int main(int argc, char** argv) 
-{ 
-    int count=100; 
-    string str = argv[1]; 
-    string res=str.substr(10); 
-    VideoCapture capture(stoi(res), CAP_V4L2); 
-    capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('U','Y','V','Y')); 
-    capture.set(CAP_PROP_FRAME_WIDTH, 3840); 
-    capture.set(CAP_PROP_FRAME_HEIGHT, 2160); 
-    while (count) 
-    { 
-        Mat frame; 
-        capture >> frame; 
- 
-        if (frame.empty()) { 
-            break; 
-        } 
-        int h = frame.rows; 
-        int w = frame.cols; 
-        const char *name = "video"; 
-        namedWindow(name, 0); 
-        imshow(name, frame); 
-        waitKey(30); 
-        count--; 
-    } 
-    return 0; 
-} 
- 
-``` 
- 
-Get Frame via Gstreamer: 
- 
-```c++ mipi-camera.cpp 
-#include <opencv2/highgui/highgui.hpp> 
-#include <opencv2/imgproc/imgproc.hpp> 
-#include <opencv2/core/core.hpp> 
-#include <iostream> 
-#include <string> 
-using 
-namespace  cv; 
- 
-using 
-namespace  std; 
- 
-int main(int argc, char** argv) 
-{ 
-    int count=100; 
-    string str = argv[1]; 
-    string gstformat = "NV12"; 
-    string gstfile = "v4l2src device=" + str + " ! video/x-raw,format=" + gstformat + ",width=3840,height=2160,framerate=30/1 ! videoconvert ! appsink"; 
-    VideoCapture capture(gstfile); 
- 
-    while (count) 
-    { 
-        Mat frame; 
-        capture >> frame; 
- 
-        if (frame.empty()) { 
-            break; 
-        } 
-        int h = frame.rows; 
-        int w = frame.cols; 
-        const char *name = "video"; 
-        namedWindow(name, 0); 
-        imshow(name, frame); 
-        waitKey(30); 
-        count--; 
-    } 
-    return 0; 
-} 
- 
-``` 
- 
-Compile: 
- 
-```shell 
-gcc -o mipi mipi-camera.cpp -lopencv_imgproc -lopencv_core -lopencv_videoio -lopencv_imgcodecs -lopencv_highgui -std=c++11 -std=gnu++11 -Wall -std=c++11 -lstdc++ -I/usr/include/opencv4 
-``` 
- 
-Test: 
- 
-```shell 
-./mipi /dev/video50 
-``` 
- 
-==== Preview video on ubuntu desktop ==== 
- 
-<tabbox Ubuntu 24.04> 
- 
-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 
-``` 
- 
-You can use the command below to check display fps: 
- 
-```shell 
-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 
-``` 
- 
-<tabbox Ubuntu 22.04> 
- 
-You can use gstreamer ''clutterautovideosink'' 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 ! clutterautovideosink 
-``` 
- 
-You can use the command below to check display fps: 
- 
-```shell 
-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 
-``` 
- 
-You press ''Alt + F7'' and then move mouse to move the windown. 
- 
-</tabbox> 
- 
-===== Android ===== 
-WIP: 
- 
  
Last modified: 2026/09/15 02:13 by 127.0.0.1