Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:add-ons:imx415-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:edge2:add-ons:imx415-mipi-camera [2023/07/04 22:39]
nick
products:sbc:edge2:add-ons:imx415-mipi-camera [2023/07/05 01:58] (current)
nick
Line 1: Line 1:
 +{{indexmenu_n>30}}
 +
 +
 ====== Edge2 IMX415 MIPI Camera ====== ====== Edge2 IMX415 MIPI Camera ======
  
Line 13: Line 16:
 {{:products:sbc:edge2:add-ons:edge2-camera-imx415.webp?600|}} {{:products:sbc:edge2:add-ons:edge2-camera-imx415.webp?600|}}
  
-===== Upgrade System ===== +===== Camera Usage =====
- +
-Please follow the [[products:sbc:edge2:configurations:upgrade-system|documentation ]]to upgrade your system to latest version. +
- +
- +
-===== Edge2 MIPI Camera Usage ===== +
- +
-==== Video Node ==== +
- +
-You can find the video node from the table below. +
- +
-|        ^  Video Node    ^ +
-^  CAM1  |  /dev/video33 +
-^  CAM2  |  /dev/video24 +
-^  CAM3  |  /dev/video42 +
- +
-==== Record Video with Gstreamer ==== +
- +
-=== Record Video === +
- +
-Record video from ''CAM1'': +
- +
-```shell +
-gst-launch-1.0 v4l2src device=/dev/video33 io-mode=mmap num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video33.mp4 +
-``` +
- +
-Record video from ''CAM2'': +
- +
-```shell +
-gst-launch-1.0 v4l2src device=/dev/video24 io-mode=mmap num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video24.mp4 +
-``` +
- +
-Record video from ''CAM3'': +
- +
-```shell +
-gst-launch-1.0 v4l2src device=/dev/video42 io-mode=mmap num-buffers=300 ! mpph264enc ! h264parse ! qtmux ! filesink location=/tmp/video42.mp4 +
-``` +
- +
-==== Record Video with OpenCV ==== +
- +
-=== Install OpenCV === +
- +
-```shell +
-sudo apt update +
-sudo apt install libopencv-dev python3-opencv +
-``` +
- +
-```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, 1920); +
-    capture.set(CAP_PROP_FRAME_HEIGHT, 1080); +
-    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: +
- +
-Capture frame from ''CAM1'': +
- +
-```shell +
-./mipi /dev/video33 +
-``` +
- +
-Capture frame from ''CAM2'': +
- +
-```shell +
-./mipi /dev/video24 +
-``` +
- +
-Capture frame from ''CAM3'': +
- +
-```shell +
-./mipi /dev/video42 +
-``` +
- +
-==== Capture Frame with V4L2 API ==== +
- +
-=== Install V4l2 Utils === +
- +
-```shell +
-sudo apt update +
-sudo apt install v4l-utils +
-``` +
- +
-=== Capture Frame === +
- +
-Capture frame from ''CAM1'': +
- +
-```shell +
-v4l2-ctl -d /dev/video33 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data33.yuv --stream-count=1 --stream-poll +
-``` +
- +
-Capture frame from ''CAM2'': +
- +
-```shell +
-v4l2-ctl -d /dev/video24 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data24.yuv --stream-count=1 --stream-poll +
-``` +
- +
-Capture frame from ''CAM3'': +
- +
-```shell +
-v4l2-ctl -d /dev/video42 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data42.yuv --stream-count=1 --stream-poll +
-``` +
- +
-It will capture a ''3840x2160 NV12'' format frame to file ''/tmp/dataXX.yuv''+
- +
- +
-Preview the file: +
- +
-```shell +
-$ ffplay -f rawvideo -pixel_format nv12 -video_size 3840x2160 /tmp/dataXX.yuv+
  
-```+{{page>products:sbc:edge2:add-ons:edge2-mipi-camera&noheader}}
  
 ===== See Also ===== ===== See Also =====
Last modified: 2023/07/04 22:39 by nick