This shows you the differences between two versions of the page.
| 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> | ||
| - | |||
| - | ====== VIM4 MIPI Camera Usage ====== | ||
| - | |||
| - | ===== Linux ===== | ||
| - | |||
| - | ==== Upgrade System ==== | ||
| - | |||
| - | Please follow the [[products: | ||
| - | |||
| - | ==== Video Node ==== | ||
| - | |||
| - | The video node for MIPI camera is ''/ | ||
| - | |||
| - | ==== 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=/ | ||
| - | ``` | ||
| - | |||
| - | |||
| - | ==== 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 < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | using | ||
| - | namespace | ||
| - | |||
| - | using | ||
| - | namespace | ||
| - | |||
| - | int main(int argc, char** argv) | ||
| - | { | ||
| - | int count=100; | ||
| - | string str = argv[1]; | ||
| - | string res=str.substr(10); | ||
| - | VideoCapture capture(stoi(res), | ||
| - | capture.set(CAP_PROP_FOURCC, | ||
| - | capture.set(CAP_PROP_FRAME_WIDTH, | ||
| - | capture.set(CAP_PROP_FRAME_HEIGHT, | ||
| - | while (count) | ||
| - | { | ||
| - | Mat frame; | ||
| - | capture >> frame; | ||
| - | |||
| - | if (frame.empty()) { | ||
| - | break; | ||
| - | } | ||
| - | int h = frame.rows; | ||
| - | int w = frame.cols; | ||
| - | const char *name = " | ||
| - | namedWindow(name, | ||
| - | imshow(name, | ||
| - | waitKey(30); | ||
| - | count--; | ||
| - | } | ||
| - | return 0; | ||
| - | } | ||
| - | |||
| - | ``` | ||
| - | |||
| - | Get Frame via Gstreamer: | ||
| - | |||
| - | ```c++ mipi-camera.cpp | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | using | ||
| - | namespace | ||
| - | |||
| - | using | ||
| - | namespace | ||
| - | |||
| - | int main(int argc, char** argv) | ||
| - | { | ||
| - | int count=100; | ||
| - | string str = argv[1]; | ||
| - | string gstformat = " | ||
| - | string gstfile = " | ||
| - | VideoCapture capture(gstfile); | ||
| - | |||
| - | while (count) | ||
| - | { | ||
| - | Mat frame; | ||
| - | capture >> frame; | ||
| - | |||
| - | if (frame.empty()) { | ||
| - | break; | ||
| - | } | ||
| - | int h = frame.rows; | ||
| - | int w = frame.cols; | ||
| - | const char *name = " | ||
| - | namedWindow(name, | ||
| - | imshow(name, | ||
| - | 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/ | ||
| - | ``` | ||
| - | |||
| - | Test: | ||
| - | |||
| - | ```shell | ||
| - | ./mipi / | ||
| - | ``` | ||
| - | |||
| - | ==== Preview video on ubuntu desktop ==== | ||
| - | |||
| - | <tabbox Ubuntu 24.04> | ||
| - | |||
| - | You can use gstreamer '' | ||
| - | |||
| - | ```shell | ||
| - | gst-launch-1.0 v4l2src device=/ | ||
| - | ``` | ||
| - | |||
| - | You can use the command below to check display fps: | ||
| - | |||
| - | ```shell | ||
| - | gst-launch-1.0 -v v4l2src device=/ | ||
| - | ``` | ||
| - | |||
| - | <tabbox Ubuntu 22.04> | ||
| - | |||
| - | You can use gstreamer '' | ||
| - | |||
| - | ```shell | ||
| - | gst-launch-1.0 v4l2src device=/ | ||
| - | ``` | ||
| - | |||
| - | You can use the command below to check display fps: | ||
| - | |||
| - | ```shell | ||
| - | gst-launch-1.0 -v v4l2src device=/ | ||
| - | ``` | ||
| - | |||
| - | You press '' | ||
| - | |||
| - | </ | ||
| - | |||
| - | ===== Android ===== | ||
| - | WIP: | ||
| - | |||