This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:vim4:add-ons:os08a10-mipi-camera [2022/10/31 23:15] nick |
products:sbc:vim4:add-ons:os08a10-mipi-camera [2023/09/10 01:10] (current) hyphop |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~tag> VIM4 MIPI Camera ISP IP~~ | ||
+ | |||
+ | {{indexmenu_n> | ||
+ | |||
====== VIM4 OS08A10 MIPI Camera ====== | ====== VIM4 OS08A10 MIPI Camera ====== | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This document mainly introduces | + | This document mainly introduces the usage of [[https:// |
===== Hardware Connection ===== | ===== Hardware Connection ===== | ||
<WRAP important > | <WRAP important > | ||
- | The reverse connection will burn the camera, please check the connection of the picture carefully before connecting. | + | The reverse connection will damage |
</ | </ | ||
- | {{/ | + | {{/ |
- | ===== Command Line ===== | + | ===== Identify VIM4 Version |
+ | <WRAP important > | ||
- | ==== Record Video via Gstreamer ==== | + | There are two versions of **VIM4**, they are **VIM4** and **New VIM4**, as they have different ISP IP core, so the usage of MIPI camera is also different, |
+ | please follow the documentation to identify your VIM4 version and choose the right documentation for your VIM4. | ||
- | |||
- | === Install Gstreamer === | ||
- | ```shell | ||
- | sudo apt update | ||
- | sudo apt install gstreamer-aml | ||
- | ``` | ||
- | |||
- | === Record Video === | ||
- | ```shell | ||
- | gst-launch-1.0 v4l2src device=/ | ||
- | ``` | ||
- | ===== Demo Source Code ===== | ||
- | |||
- | This part is some Demo Source Code that will guide you how to use it to test your camera. | ||
- | |||
- | ==== install OpenCV4 ==== | ||
- | |||
- | ```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++ ==== | + | Please check the [[products: |
- | + | ||
- | ```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: | + | ===== Upgrade System ===== |
- | ```sh | + | Please follow the [[products: |
- | $ 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/ | + | |
- | ``` | + | |
- | Run format: | + | ===== Camera Usage ===== |
- | ```sh | + | * [[products: |
- | $ ./test / | + | * [[products: |
- | ``` | + | |
===== See Also ===== | ===== See Also ===== | ||
- | * [[https:// | + | * [[pp>os08a10-8mp-camera|Buy OS08S10-8MP camera]] |
- | * [[https://dl.khadas.com/Hardware/Accessories/OS08A10/ | + | * [[dl> |
- | * [[https:// | + | |