<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with ov5640]]></title><description><![CDATA[A list of topics that have been tagged with ov5640]]></description><link>http://community.onion.io/tags/ov5640</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 00:47:45 GMT</lastBuildDate><atom:link href="http://community.onion.io/tags/ov5640.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Nov 2020 13:08:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[V4L2 UVC camera]]></title><description><![CDATA[<p dir="auto">I am trying to get a camera stream of a OV5640 camera (DELOCK 96368) which is connected over usb to the omega2 with uvc.<br />
With the provided example of the mjpg-streamer it works nice to stream about 20-30 fps at fullHD.</p>
<p dir="auto">Now I want to use the camera in my c++ application, so I am using the v4l2 api. I looked at different examples and also the mjpg-streamer source code, but I could not find a solution.</p>
<p dir="auto">My program is working, it detects the camera, and also gets images, but only at 10 fps..<br />
The settings of the image format, this is supported by the camera, the v4l2 api reports these as available.</p>
<pre><code>    v4l2_format imageFormat;
    imageFormat.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    imageFormat.fmt.pix.width = 640;
    imageFormat.fmt.pix.height = 480;
    imageFormat.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
    imageFormat.fmt.pix.field = V4L2_FIELD_ANY;
    // tell the device you are using this format
    if(ioctl(m_fd, VIDIOC_S_FMT, &amp;imageFormat) &lt; 0){
        perror("Device could not set format, VIDIOC_S_FMT");
        return -1;
    }
</code></pre>
<p dir="auto">I am setting the fps manually:</p>
<pre><code>struct v4l2_streamparm setfps;
memset(&amp;setfps, 0, sizeof(struct v4l2_streamparm));
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;
setfps.parm.capture.timeperframe.denominator = 30;
ret = ioctl(m_fd, VIDIOC_S_PARM, &amp;setfps);
printf("set fps ret: %d, framerate set to %d/%d\n", ret, setfps.parm.capture.timeperframe.numerator, setfps.parm.capture.timeperframe.denominator);
</code></pre>
<p dir="auto">Setting the buffer to be memory mapped:</p>
<pre><code>    v4l2_requestbuffers requestBuffer = {0};
    requestBuffer.count = 1; // one request buffer
    requestBuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; // request a buffer wich we an use for capturing frames
    requestBuffer.memory = V4L2_MEMORY_MMAP;

    if(ioctl(m_fd, VIDIOC_REQBUFS, &amp;requestBuffer) &lt; 0){
        printf("Could not request buffer from device, VIDIOC_REQBUFS");
        return 1;
    }

    v4l2_buffer queryBuffer = {0};
    queryBuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    queryBuffer.memory = V4L2_MEMORY_MMAP;
    queryBuffer.index = 0;
    if(ioctl(m_fd, VIDIOC_QUERYBUF, &amp;queryBuffer) &lt; 0){
        perror("Device did not return the buffer information, VIDIOC_QUERYBUF");
        return 1;
    }
    // use a pointer to point to the newly created buffer
    // mmap() will map the memory address of the device to
    // an address in memory
    m_buffer = (char*)mmap(NULL, queryBuffer.length, PROT_READ | PROT_WRITE, MAP_SHARED,
                        m_fd, queryBuffer.m.offset);
    memset(m_buffer, 0, queryBuffer.length);
</code></pre>
<p dir="auto">Then I do the start streaming once (code not shown here) and then I dequery and query the buffers:</p>
<pre><code>    // queue
    if (ioctl(m_fd, VIDIOC_QBUF, &amp;bufferinfo) &lt; 0) {
        perror("Could not queue buffer, VIDIOC_QBUF");
        return 1;
    }
   
    // dequeue
    if (ioctl(m_fd, VIDIOC_DQBUF, &amp;bufferinfo) &lt; 0) {
        perror("Could not dequeue the buffer, VIDIOC_DQBUF");
        return 1;
    }
</code></pre>
<p dir="auto">I am stopping the timing of the two functions, the dequeuing need about 100ms, which explain the 10 fps.</p>
<p dir="auto">But no matter what I change it does not work faster.<br />
The mjpg-streamer uses almost the same api calls, one difference is the</p>
<pre><code>    /*
     * recent linux-uvc driver (revision &gt; ~#125) requires to use dynctrls
     * for pan/tilt/focus/...
     * dynctrls must get initialized
     */
    if(dynctrls)
        initDynCtrls(cams[id].videoIn-&gt;fd);

    enumerateControls(cams[id].videoIn, cams[id].pglobal, id); // enumerate V4L2 controls after UVC extended mapping

</code></pre>
<p dir="auto">But I think thats only for advanced options.</p>
]]></description><link>http://community.onion.io/topic/4322/v4l2-uvc-camera</link><guid isPermaLink="true">http://community.onion.io/topic/4322/v4l2-uvc-camera</guid><dc:creator><![CDATA[joh]]></dc:creator><pubDate>Wed, 04 Nov 2020 13:08:26 GMT</pubDate></item></channel></rss>