Python API Yolov3 with MIPI camera

@Frank I am using MIPI camera with VIM3. I would like to know, how do we get to know the camera device name?

When I do
ls /dev/video and then TAB:
video0 video1 video10 video11 video 12 video 13 videosync

I am just curious to know which is my MIPI device. Infact I tried to execute the program with all the device name, yet, I was not successful.

I got an error:
ValueError: invalid literal for int() with base 10: ‘dev/video0’

@Frank When I also try to run inference using, I am getting the following error.

@Akkisony If you plug in the usb camera to boot, video1 is your mipi camera

I have plugged it into MIPI CSI port.
I am getting this error. :confused:

@Akkisony Please follow this docs to check your mipi camera

@Frank Thanks, I had followed this documentaton before. It was working fine with me using Tengine SDK. I wanted to experiment Python API: Here I am not able to get the desired output.

Can you please answer this?
Can you please tell me what does “LISTSIZE, SPAN, GRID0” indicate?

@Akkisony I try my demo in my vim3. It work for me . Are you sure that the output of your model is the same as the official model output? This demo can only be used for yolov3. I don’t think the modified model can be used. If you want to use your own model, you should design and process it yourself.
The source code of the demonstration is open. You can compare it to tengine. Although it is the same demo, the data processing method is completely different. Your own model can be run on tengine, but it does not mean that it can run on this demo. I more than once tell you that all demos are just to demonstrate how to use api, not universal.

The demo code is open source. You can study and understand by yourself. There are a lot of data processing and principles related to numpy. I think how you should understand how python can transform data quickly. I can’t give you all the questions.

@Frank The parameters are already set as default value and hence, I could not find any information related to it.

SPAN = 3

I fixed my issue. I just wanted to know what those parameter indicated.

I was successful with Yolov3 picture demo.
Can you please help me with MIPI camera? As I said it was working fine with Tnegine SDK.
I am facing issues only with Python API.

@Frank When I try to use MIPI using C++, I am getting the following error.

When I run this:
gcc -o test test.cpp -lopencv_imgproc -lopencv_core -lopencv_videoio -lopencv_imgcodecs -lopencv_highgui -std=c++11 -std=gnu++11 -Wall -std=c++11 -lstdc++

test.cpp:1:10: fatal error: opencv2/highgui/highgui.hpp: No such file or directory
1 | #include <opencv2/highgui/highgui.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.


#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <iostream>
#include <string>
namespace  cv;

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()) {
        int h = frame.rows;
        int w = frame.cols;
        const char *name = "video";
        namedWindow(name, 0);
        imshow(name, frame);
    return 0;

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

@Frank Thanks.
I got an error with /dev/video0.
But, it works with /dev/video1.

Now, I have to check with the I dont know why am I getting an error there.

@Akkisony Could it work now ?

@Frank No, its not working with :confused:


This is a bug encountered by another user before, you may be able to refer to.

@Frank Thanks for your input.I tried, but it did not work.I think the previous person had some error with input picture size as well.

khadas@Khadas:~/Python-API/ksnn-examples/darknet$ python3 --nb-file yolov3-5-class/yolov3-5.nb --so-lib yolov3-5-class/ --video-device /dev/video0
|—+ KSNN Version: v0.1 ±–|
Create Neural Network: 114ms or 114692us
Traceback (most recent call last):
File “”, line 194, in
cap = cv.VideoCapture(int(cap_num))
ValueError: invalid literal for int() with base 10: ‘/dev/video0’

I tried with video0 and video1. Yet same error.

@Akkisony It should be --video-device 1.not /dev/video1

@Frank Thanks. As it was /dev/video1 using the tengine, I did the same here.

Now it works! :smiley: Super :slight_smile:
I couldn’t find a way to close this issue. I request you to do it. If I have any issue, i’ll create a new topic.
Thanks again @Frank