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/11/02 23:30] nick |
products:sbc:vim4:add-ons:os08a10-mipi-camera [2025/05/14 22:39] (current) nick |
||
|---|---|---|---|
| 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 |
| </ | </ | ||
| - | {{/ | + | {{/ |
| + | ===== Identify VIM4 Version ===== | ||
| - | ===== Record Video via Gstreamer ===== | + | <WRAP important > |
| + | 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 Encoder Plugin ==== | ||
| - | ```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()) { | + | ===== Upgrade System ===== |
| - | break; | + | |
| - | } | + | |
| - | int h = frame.rows; | + | |
| - | int w = frame.cols; | + | |
| - | const char *name = " | + | |
| - | namedWindow(name, | + | |
| - | imshow(name, | + | |
| - | waitKey(30); | + | |
| - | count--; | + | |
| - | } | + | |
| - | return 0; | + | |
| - | } | + | |
| - | ``` | + | |
| - | Compile: | + | Please follow the [[products:sbc: |
| - | ```sh | + | ===== Camera Usage ===== |
| - | $ 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: | + | * [[products:sbc: |
| + | * [[products: | ||
| - | ```sh | ||
| - | $ ./test /dev/videoX | ||
| - | ``` | ||
| - | */ | ||
| ===== See Also ===== | ===== See Also ===== | ||
| * [[pp> | * [[pp> | ||
| - | * [[dl> | + | * [[dl> |
| - | + | ||