This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
products:sbc:vim4:add-ons:imx415-mipi-camera [2023/07/04 22:50] nick created |
products:sbc:vim4:add-ons:imx415-mipi-camera [2025/05/14 22:38] (current) nick |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~tag> VIM4 IMX415 MIPI ISP IP~~ | ||
| + | {{indexmenu_n> | ||
| + | |||
| ====== VIM4 IMX415 MIPI Camera ====== | ====== VIM4 IMX415 MIPI Camera ====== | ||
| Line 13: | Line 16: | ||
| {{: | {{: | ||
| - | ===== Identify | + | ===== Different |
| <WRAP important > | <WRAP important > | ||
| - | + | There are two [[../ | |
| - | There are two versions | + | |
| - | please follow the documentation to identify your VIM4 version and choose the right documentation for your VIM4. | + | |
| </ | </ | ||
| + | /* | ||
| Please check the [[products: | Please check the [[products: | ||
| + | */ | ||
| + | ===== Camera Usage ===== | ||
| - | ===== Upgrade System ===== | + | * [[products: |
| - | + | * [[products: | |
| - | Please follow the [[products: | + | |
| - | + | ||
| - | + | ||
| - | ===== VIM4 MIPI Camera Usage ===== | + | |
| - | + | ||
| - | ==== Video Node ==== | + | |
| - | + | ||
| - | The video node for MIPI camera is ''/ | + | |
| - | + | ||
| - | ==== Record Video via Gstreamer ==== | + | |
| - | + | ||
| - | + | ||
| - | === Install Gstreamer Encoder Plugin === | + | |
| - | ```shell | + | |
| - | sudo apt update | + | |
| - | sudo apt install gstreamer-aml | + | |
| - | ``` | + | |
| - | + | ||
| - | === Record Video === | + | |
| - | ```shell | + | |
| - | gst-launch-1.0 v4l2src device=/ | + | |
| - | ``` | + | |
| - | + | ||
| - | + | ||
| - | ==== Record Video with OpenCV ==== | + | |
| - | + | ||
| - | === Install OpenCV === | + | |
| - | + | ||
| - | ```shell | + | |
| - | sudo apt update | + | |
| - | sudo apt install libopencv-dev python3-opencv | + | |
| - | ``` | + | |
| - | + | ||
| - | === C++ === | + | |
| - | + | ||
| - | + | ||
| - | == Get Frame via V4l2 == | + | |
| - | + | ||
| - | ```c++ | + | |
| - | #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 / | + | |
| - | ``` | + | |
| - | + | ||
| - | ===== New VIM4 MIPI Camera Usage ===== | + | |
| - | + | ||
| - | ==== Enable Overlays ==== | + | |
| - | + | ||
| - | If you want to use the OS08A10 MIPI camera, you need to enable it in [[products: | + | |
| - | + | ||
| - | ``` | + | |
| - | $ cat / | + | |
| - | fdt_overlays=vim4n-os08a10 | + | |
| - | ``` | + | |
| - | + | ||
| - | And then reboot to take effect. | + | |
| - | + | ||
| - | ==== Video Node ==== | + | |
| - | + | ||
| - | The video node is ''/ | + | |
| - | + | ||
| - | ==== Get Frames via Mediactl API ==== | + | |
| - | + | ||
| - | You can get the test source code here: https:// | + | |
| - | + | ||
| - | Download and build the test source code: | + | |
| - | + | ||
| - | <tabbox 5.4 kernel> | + | |
| - | + | ||
| - | + | ||
| - | ```shell | + | |
| - | $ git clone https:// | + | |
| - | $ cd v4l2_media_test | + | |
| - | $ git checkout e0482794337c01935593a91b621f9c42123cf175 | + | |
| - | $ g++ v4l2_test_raw.cpp -o v4l2_test_raw | + | |
| - | $ ls v4l2_test_raw | + | |
| - | v4l2_test_raw | + | |
| - | ``` | + | |
| - | + | ||
| - | <tabbox 5.15 kernel> | + | |
| - | + | ||
| - | ```shell | + | |
| - | $ git clone https:// | + | |
| - | $ cd v4l2_media_test | + | |
| - | $ g++ v4l2_test_raw.cpp -o v4l2_test_raw | + | |
| - | $ ls v4l2_test_raw | + | |
| - | v4l2_test_raw | + | |
| - | ``` | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | Test: | + | |
| - | + | ||
| - | ```shell | + | |
| - | $ ./ | + | |
| - | ``` | + | |
| - | + | ||
| - | It will capture 10 frames to file ''/ | + | |
| - | + | ||
| - | Preview the file: | + | |
| - | + | ||
| - | ```shell | + | |
| - | $ ffplay -f rawvideo -pixel_format nv21 -video_size 3840x2160 / | + | |
| - | + | ||
| - | ``` | + | |
| ===== See Also ===== | ===== See Also ===== | ||
| - | * [[pp>os08a10-8mp-camera|Buy | + | * [[pp>imx415-camera|Buy |
| - | * [[dl> | + | * [[dl> |