This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:vim3:add-ons:os08a10-mipi-camera [2022/07/13 23:45] frank |
products:sbc:vim3:add-ons:os08a10-mipi-camera [2024/01/30 21:13] (current) nick |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== VIM3/3L ====== | + | ====== VIM3 OS08A10 MIPI Camera ====== |
| + | |||
| + | ===== Introduction ===== | ||
| + | |||
| + | This document mainly introduces [[https:// | ||
| + | |||
| + | ===== Hardware Connection | ||
| + | |||
| + | <WRAP important > | ||
| + | The reverse connection will burn the camera, please check the connection of the picture carefully before connecting. | ||
| + | </ | ||
| + | |||
| + | {{/ | ||
| + | |||
| + | |||
| + | ===== For 5.15 kernel ===== | ||
| + | |||
| + | Please check [[products: | ||
| + | |||
| + | ===== For 4.9 kernel ===== | ||
| + | |||
| + | ==== Guvcview ==== | ||
| + | |||
| + | The desktop version has '' | ||
| + | |||
| + | {{/ | ||
| + | |||
| + | The name of the MIPI camera is '' | ||
| + | |||
| + | {{/ | ||
| + | |||
| + | The resolution is set to '' | ||
| + | |||
| + | {{/ | ||
| + | |||
| + | After the setting is successful, you can use the camera normally. | ||
| + | |||
| + | ==== Command Line ==== | ||
| + | |||
| + | === Control IR-Cut via V4L2 === | ||
| + | |||
| + | The test needs to be conducted in the framebuffer mode, and switch to the framebuffer mode through the keyboard combination of '' | ||
| + | |||
| + | == Disable status == | ||
| + | |||
| + | ```shell | ||
| + | $ v4l2_test | ||
| + | ``` | ||
| + | |||
| + | == Enable status == | ||
| + | |||
| + | ```shell | ||
| + | $ v4l2_test | ||
| + | ``` | ||
| + | |||
| + | === Record Video via Gstreamer === | ||
| + | |||
| + | ```shell | ||
| + | $ gst-launch-1.0 v4l2src name=vsrc device=/ | ||
| + | ``` | ||
| + | |||
| + | The recorded video is saved in '' | ||
| + | |||
| + | ==== Demo Source Code ==== | ||
| + | |||
| + | In addition to this, you can also test the camera via program. | ||
| + | |||
| + | === Install Dependencies === | ||
| + | |||
| + | |||
| + | ```shell | ||
| + | sudo apt install libopencv-dev python3-opencv | ||
| + | ``` | ||
| + | |||
| + | === Python === | ||
| + | |||
| + | ```python mipi-camera.py | ||
| + | import cv2 | ||
| + | |||
| + | if __name__ == ' | ||
| + | |||
| + | val = True | ||
| + | |||
| + | cap = cv2.VideoCapture(0) | ||
| + | cap.set(cv2.CAP_PROP_FRAME_WIDTH, | ||
| + | cap.set(cv2.CAP_PROP_FRAME_HEIGHT, | ||
| + | |||
| + | fourcc = cv2.VideoWriter_fourcc(*' | ||
| + | |||
| + | out = cv2.VideoWriter(" | ||
| + | |||
| + | while val is True: | ||
| + | ret, frame = cap.read() | ||
| + | cv2.cvtColor(frame, | ||
| + | if frame is None: | ||
| + | break | ||
| + | else: | ||
| + | out.write(frame) | ||
| + | cv2.imshow(" | ||
| + | k = cv2.waitKey(1) & 0xFF | ||
| + | if k == 27: | ||
| + | break | ||
| + | |||
| + | cap.release() | ||
| + | out.release() | ||
| + | ``` | ||
| + | |||
| + | <WRAP info > | ||
| + | Please modify the number of the open camera according to the camera node. | ||
| + | </ | ||
| + | |||
| + | ==== C++ ==== | ||
| + | |||
| + | ```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_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; | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | == Compile == | ||
| + | |||
| + | ```shell | ||
| + | $ gcc -o mipi mipi.cpp -lopencv_imgproc -lopencv_core -lopencv_videoio -lopencv_imgcodecs -lopencv_highgui -std=c++11 -std=gnu++11 -Wall -std=c++11 -lstdc++ -I/ | ||
| + | ``` | ||
| + | |||
| + | == Run == | ||
| + | |||
| + | ```shell | ||
| + | $ ./mipi / | ||
| + | ``` | ||
| + | |||
| + | ===== See Also ===== | ||
| + | |||
| + | * [[pp> | ||
| + | * [[dl> | ||
| - | {{page> | ||