This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: Video analytics fails

Part Number: AM5728


Tool/software: Linux

Hi,

TI, I build the Video Analytics demo in the ti-processor-sdk-linux-am57xx-evm-03_02_00_05,but I found that it can not work fine.I run /usr/bin/qt-opencv-opencl-opengl-multithreaded, it is OK!But when I run the qt-opencv-opencl-opengl-multithreaded that I build,it shows me that "/dev/video1 does not support read i/o" which is printf in the CameraGrab.cpp 270 lines.

I entry the ti-processor-sdk-linux-am57xx-evm-03_02_00_05 path,then run "make qt-opencv-opencl-opengl-multithreaded" to build it.

I use a USB-OV5640 camera,I look into the uvc_v4l2.c(kernel),finding the uvc driver don't support the V4L2_CAP_READWRITE,so I doubt that the source code of qt-opencv-opencl-opengl-multithreaded in the system is not same as the the source code of  ti-processor-sdk-linux-am57xx-evm-03_02_00_05.

How can I get the original source?

thanks

  • Hello,

    Please build this by following this guide:
    processors.wiki.ti.com/index.php

    This guide is for PSDK 3.02, here is the guide for the latest PSDK:
    processors.wiki.ti.com/.../Processor_SDK_Building_The_SDK

    Hope this helps.

    BR
    Margarita
  • Hi

    source of qt-opencv-opencl-opengl-multithreaded  is using V4L2_CAP_READWRITE that is not supported. but  qt-opencv-opencl-opengl-multithreaded in /usr/bin/ works by usb camera.

    static int init_device(char *dev_name)
    {
        struct v4l2_capability cap;
        struct v4l2_cropcap cropcap;
        struct v4l2_crop crop;
        struct v4l2_format fmt;
        unsigned int min;
    
        pr_debug("%s: called!\n", __func__);
    
        if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
            if (EINVAL == errno) {
                fprintf(stderr, "%s is no V4L2 device\n", dev_name);
                            return 0;
            } else {
                fprintf (stderr, "VIDIOC_QUERYCAP");
                            return 0;
            }
        }
    
        pr_debug("\tdriver: %s\n"
             "\tcard: %s \n"
             "\tbus_info: %s\n",
                cap.driver, cap.card, cap.bus_info);
        pr_debug("\tversion: %u.%u.%u\n",
                (cap.version >> 16) & 0xFF,
                (cap.version >> 8) & 0xFF,
                cap.version & 0xFF);
        pr_debug("\tcapabilities: 0x%08x\n", cap.capabilities);
    
        if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
            fprintf(stderr, "%s is no video capture device\n", dev_name);
                    return 0;
        }
    
        if (!(cap.capabilities & V4L2_CAP_READWRITE)) {
              fprintf(stderr, "%s does not support read i/o\n", dev_name);
                    return 0;
        }
    
        /* Select video input, video standard and tune here. */
        CLEAR(cropcap);
        cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        if (0 == xioctl(fd, VIDIOC_CROPCAP, &cropcap)) {
            pr_debug("\tcropcap.type: %d\n", cropcap.type);
            pr_debug("\tcropcap.bounds.left: %d\n", cropcap.bounds.left);
            pr_debug("\tcropcap.bounds.top: %d\n", cropcap.bounds.top);
            pr_debug("\tcropcap.bounds.width: %d\n", cropcap.bounds.width);
            pr_debug("\tcropcap.bounds.height: %d\n", cropcap.bounds.height);
    
            pr_debug("\tcropcap.defrect.left: %d\n", cropcap.defrect.left);
            pr_debug("\tcropcap.defrect.top: %d\n", cropcap.defrect.top);
            pr_debug("\tcropcap.defrect.width: %d\n", cropcap.defrect.width);
            pr_debug("\tcropcap.defrect.height: %d\n", cropcap.defrect.height);
    
            pr_debug("\tcropcap.pixelaspect.numerator: %d\n", cropcap.pixelaspect.numerator);
            pr_debug("\tcropcap.pixelaspect.denominator: %d\n", cropcap.pixelaspect.denominator);
            pr_debug("\n");
    
            CLEAR(crop);
            crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
            crop.c = cropcap.defrect; /* reset to default */
    
            if (-1 == xioctl(fd, VIDIOC_S_CROP, &crop)) {
                switch (errno) {
                case EINVAL:
                    /* Cropping not supported. */
                    break;
                default:
                    /* Errors ignored. */
                    pr_debug("\tcropping not supported\n");
                    break;
                }
            }
        } else {
            /* Errors ignored. */
        }
        CLEAR(fmt);
        fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
            fmt.fmt.pix.width       = FORCED_WIDTH;
            fmt.fmt.pix.height      = FORCED_HEIGHT;
            fmt.fmt.pix.pixelformat = FORCED_FORMAT;
            fmt.fmt.pix.field       = FORCED_FIELD;
    
            pr_debug("\tfmt.fmt.pix.pixelformat: %c,%c,%c,%c\n",
                    fmt.fmt.pix.pixelformat & 0xFF,
                    (fmt.fmt.pix.pixelformat >> 8) & 0xFF,
                    (fmt.fmt.pix.pixelformat >> 16) & 0xFF,
                    (fmt.fmt.pix.pixelformat >> 24) & 0xFF
                    );
            pr_debug("\n");
    
            if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt)) return 0;
    
            frame_pix_width  = fmt.fmt.pix.width;
            frame_pix_height = fmt.fmt.pix.height;
        /* Buggy driver paranoia. */
        min = fmt.fmt.pix.width * 2;
        if (fmt.fmt.pix.bytesperline < min)
            fmt.fmt.pix.bytesperline = min;
        min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;
        if (fmt.fmt.pix.sizeimage < min)
            fmt.fmt.pix.sizeimage = min;
            pr_debug("\tBytes per line %d frame height %d frame size %d\n",
                     fmt.fmt.pix.bytesperline, fmt.fmt.pix.height, fmt.fmt.pix.sizeimage);
        buffer_capture_length = fmt.fmt.pix.sizeimage;
            buffer_capture_ptr    = (unsigned char *)malloc(buffer_capture_length);
            return 1;
    }
    
    

    It shows that the two programs are different. 

    How can I get the original source?

    thanks

  • Hello,

    Please check my previous post and follow the steps.
    The last command must be:
    MACHINE=am57xx-evm bitbake qt-opencv-opencl-opengl-multithreaded
    This will download, compile, install qt-opencv-opencl-opengl-multithreaded and the dependencies.
    In this guide you also could find the command for recompile if you make modifications in the code.

    BR
    Margarita
  • Hello,

    Please if this answers your question could you click on "This resolved my issue button" .
    You could open a new topic for new issues/questions.

    BR
    Margarita