Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim3:add-ons:os08a10-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
Last revision Both sides next revision
products:sbc:vim3:add-ons:os08a10-mipi-camera [2023/12/29 05:16]
nick
products:sbc:vim3:add-ons:os08a10-mipi-camera [2023/12/29 05:31]
nick
Line 1: Line 1:
 ====== VIM3 OS08A10 MIPI Camera ====== ====== VIM3 OS08A10 MIPI Camera ======
  
-{{page>products:sbc:common:add-ons:os08a10-mipi-camera&noheader}}+===== Introduction ===== 
 + 
 +This document mainly introduces [[https://www.khadas.com/product-page/os08a10-8mp-camera | OS08A10 MIPI Camera]]. The first part of the document describes how to connect. The second part introduces how to use it under Ubuntu. The third part introduces how to use it under Android. 
 + 
 +===== Hardware Connection ===== 
 + 
 +<WRAP important > 
 +The reverse connection will burn the camera, please check the connection of the picture carefully before connecting. 
 +</WRAP> 
 + 
 +{{/products/sbc/common/accessories/docs-vim3-camera-os8a10.png?600|docs-vim3-camera-os8a10}} 
 + 
 + 
 +===== For 5.15 kernel ===== 
 + 
 +Please check [[products:sbc:vim3:add-ons:vim3-mipi-camera|]] 
 + 
 +===== For 4.9 kernel ===== 
 + 
 +==== Guvcview ==== 
 + 
 +The desktop version has ''Guvcview'' pre-installed, find and open this application in the application list. 
 + 
 +{{/products/sbc/common/accessories/mipi-guvcview-icon.png|mipi-guvcview-icon}} 
 + 
 +The name of the MIPI camera is ''Juno R2''
 + 
 +{{/products/sbc/common/accessories/mipi-guvcview-setting.png?600|mipi-guvcview-setting}} 
 + 
 +The resolution is set to ''1920x1080'' and the RGB format is ''BGR3-BGR3''
 + 
 +{{/products/sbc/common/accessories/mipi-guvcview-seccess.png?600|mipi-guvcview-seccess}} 
 + 
 +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 ''Ctrl''+''Alt''+''F1''
 + 
 +== Disable status ==  
 + 
 +```shell 
 +$ v4l2_test  -c 1 -p 0 -F 0 -f 0 -D 0 -R 1 -r 2 -d 2 -N 1000 -n 800 -w 0 -e 1 -I 0 -b /dev/fb0 -v /dev/video0 
 +``` 
 + 
 +== Enable status == 
 + 
 +```shell 
 +$ v4l2_test  -c 1 -p 0 -F 0 -f 0 -D 0 -R 1 -r 2 -d 2 -N 1000 -n 800 -w 0 -e 1 -I 1 -b /dev/fb0 -v /dev/video0 
 +``` 
 + 
 +=== Record Video via Gstreamer === 
 + 
 +```shell 
 +$ gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB ! filesink location=.//test.rgb 
 +``` 
 + 
 +The recorded video is saved in ''test.rgb''
 + 
 +==== 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__ == '__main__': 
 + 
 +    val = True 
 + 
 +    cap = cv2.VideoCapture(0) 
 +    cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) 
 +    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) 
 + 
 +    fourcc = cv2.VideoWriter_fourcc(*'XVID'
 + 
 +    out = cv2.VideoWriter("./test.avi", fourcc, 20.0, (640, 480), True) 
 + 
 +    while val is True: 
 +        ret, frame = cap.read() 
 +        cv2.cvtColor(frame,cv2.COLOR_RGB2BGR) 
 +        if frame is None: 
 +            break 
 +        else: 
 +            out.write(frame) 
 +            cv2.imshow("video", frame) 
 +            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. 
 +</WRAP> 
 + 
 +==== C++ ==== 
 + 
 +```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)); 
 +    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.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 
 +``` 
 + 
 +== Run == 
 + 
 +```shell 
 +$ ./mipi /dev/videoX 
 +``` 
 + 
 +===== See Also ===== 
 + 
 +  * [[pp>os08a10-8mp-camera|Buy OS08A10 8MP Camera]] 
 +  * [[dl>products/add-ons/os08a10/|OS08A10 Hardware Documentations]] 
  
Last modified: 2024/01/30 21:13 by nick