Ask Your Question

fliker09's profile - activity

2016-12-19 20:40:03 -0600 received badge  Famous Question (source)
2015-04-17 10:12:24 -0600 received badge  Student (source)
2015-03-23 16:31:47 -0600 received badge  Notable Question (source)
2014-06-24 13:25:38 -0600 received badge  Popular Question (source)
2013-09-26 15:24:48 -0600 asked a question 2 cameras working together everywhere except OpenCV 2.4.6.1

I have 2 computers - one laptop and one desktop. On laptop is installed Ubuntu 12.04, on desktop - Ubuntu 12.10. On both compiled OpenCV 2.4.6.1. On the same computers, several months ago I was using 2.4.4. Now I got back to my project, compiled latest version, as I previously mentioned. And I got into trouble. I have 2 Logitech C270 webcams. Using qv4l2 and guvcview I can easily achieve 960x720@10fps on both cameras at the same time (and even 1280x960@5fps). But then trying to obtain the same with OpenCV it tells me "No space left on device". How is that only possible? Changing the FPS doesn't help (finally we got such long-awaited function!). What is going wrong? I tried to do diff compare between 2.4.4 and 2.4.6.1 and saw that problem doesn't lie in cap_libv4l.cpp as far as I can understand. So, help me please to understand what is wrong and how to fix it!

2013-09-26 15:08:06 -0600 commented question [Solved] How to make OpenCV to ask libv4l YUYV pixelformat instead of BGR24?

Starting from 2.4.6 where is no more need for this dirty workaround, CV_CAP_PROP_FPS is finally implemented. Hooray!

P.S. Regarding the speeds. Try this workaround: unplug your cameras, sudo modprobe -r uvcvideo, sudo modprobe uvcvideo quirk=0x80, plug your cameras back and check. In this way I achieved 1280x960@5fps instead of 640x480@15fps. No comments needed I hope ;)

2013-09-26 15:01:07 -0600 commented answer Using 2 Webcams Simultaneously

Starting from 2.4.6 where is no more need for this dirty workaround, CV_CAP_PROP_FPS is finally implemented. Hooray!

P.S. Regarding the speeds. Try this workaround: unplug your cameras, sudo modprobe -r uvcvideo, sudo modprobe uvcvideo quirk=0x80, plug your cameras back and check. In this way I achieved 1280x960@5fps instead of 640x480@15fps. No comments needed I hope ;)

2013-03-24 06:47:03 -0600 received badge  Supporter (source)
2013-03-24 06:46:43 -0600 answered a question Opencl support (bm,sgbm etc)

I would ask a question regarding using OpenCL in OpenCV. If we provide this OpenCL SDK:

http://malideveloper.arm.com/develop-for-mali/sdks/mali-opencl-sdk/

then compiling OpenCV will we get ability to use OpenCL-accelerated OpenCV on Mali GPU?

I found here:

https://community.freescale.com/thread/305019

that somebody is trying to get this working. What can you say about this?

2013-03-21 11:02:17 -0600 received badge  Editor (source)
2013-03-21 11:01:10 -0600 commented question [Solved] How to make OpenCV to ask libv4l YUYV pixelformat instead of BGR24?

How is that possible I don't know (if anybody could only explain to me...). So conclusion is simple - using YUYV it is possible with my USB host to get 2 cameras working at 640x480 only with 15 fps. I made necessary modification in cap_libv4l.cpp and recompiled OpenCV. Cameras are working nicely, thread closed as solved. My code from the question is unnecessary as libv4l do all the work.

2013-03-21 10:56:18 -0600 commented question [Solved] How to make OpenCV to ask libv4l YUYV pixelformat instead of BGR24?

I found the answer. Cameras are able to output exclusively YUYV and MJPG, as enumerated by v4l2-ctl. qv4l2 enumerates RGB24, BGR24, YU12 and YV12 in addition to mentioned above because it is from libv4l family. Libv4l library is able to convert any known input pixelformat to mentioned ones. So qv4l2 enumerates them as available because libv4l can convert to them! But that doesn't mean cameras are actually able to output in this pixelformats. Regarding FPS. I was checking with the help of mplayer if cameras are able to output 640x480@30fps. And it was lying (I understood that when observed extensive frame dropping). But here we get another mystery - mencoder and vlc gets 30 fps but bit depth gets down to 8 bits from 16 (so it means that instead of YUV 4:2:2 they get YUV 4:1:0).

2013-03-21 06:37:32 -0600 commented question [Solved] How to make OpenCV to ask libv4l YUYV pixelformat instead of BGR24?

Asked for help on Logitech forums. Here is what I got:

http://www.quickcamteam.net/documentation/faq/what-video-streaming-formats-are-supported">http://web.archive.org/web/20110807021632/http://www.quickcamteam.net/documentation/faq/what-video-streaming-formats-are-supported

Not much help... It seems what I will have to write on V4L2 forums :\

2013-03-19 12:19:02 -0600 asked a question [Solved] How to make OpenCV to ask libv4l YUYV pixelformat instead of BGR24?

I use at the moment OpenCV 2.4.4 on Linux Mint 14 (aka Ubuntu 12.10). I got 2 identical webcams (Logitech C270) and I need to run them simultaneously. From the start I want to say - using 2 USB hosts is not a solution for me. It is possible to run them simultaneously at 640x480@30 fps. But with one condition - use YUYV pixelformat. As all of us knows OpenCV uses BGR24 pixelformat. And here starts strange things... I am running v4l2-ctl -d /dev/video0 --list-formats and I get this:

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUV 4:2:2 (YUYV)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : MJPEG

As you can see we don't have here BGR24 pixelformat. For testing purposes I use qv4l2 application. It can list supported pixelformats and one of them is BGR24! How is that possible? Strange things continues... If I try BGR24 with qv4l2 (OpenCV force this one) I can't get higher than 15 fps for simultaneous running. How is that possible - call for unlisted pixelformat and get it?! The most strange thing - it gets it and USB host can't let through such a large datastream :\ This is weird because it means that v4l doesn't convert YUYV to BGR24, it just gets BGR24 from camera (???)! One the solution would be lowering fps, but I don't want to do that. As far as I know to achieve what I want I have to modify ./modules/highgui/src/cap_libv4l.cpp (cap_v4l.cpp doesn't play role, because it isn't even compiled). From the start I want to say - I am lame at programming. I made this changes:

1) I took from cap_v4l.cpp code which converts YUYV to RGB24:

/* convert from 4:2:2 YUYV interlaced to RGB24 */
/* based on ccvt_yuyv_bgr32() from camstream */
#define SAT(c) \
   if (c & (~255)) { if (c < 0) c = 0; else c = 255; }

static void
yuyv_to_rgb24 (int width, int height, unsigned char *src, unsigned char *dst)
{
   unsigned char *s;
   unsigned char *d;
   int l, c;
   int r, g, b, cr, cg, cb, y1, y2;

   l = height;
   s = src;
   d = dst;
   while (l--) {
      c = width >> 1;
      while (c--) {
         y1 = *s++;
         cb = ((*s - 128) * 454) >> 8;
         cg = (*s++ - 128) * 88;
         y2 = *s++;
         cr = ((*s - 128) * 359) >> 8;
         cg = (cg + (*s++ - 128) * 183) >> 8;

         r = y1 + cr;
         b = y1 + cb;
         g = y1 - cg;
         SAT(r);
         SAT(g);
         SAT(b);

     *d++ = b;
     *d++ = g;
     *d++ = r;

         r = y2 + cr;
         b = y2 + cb;
         g = y2 - cg;
         SAT(r);
         SAT(g);
         SAT(b);

     *d++ = b;
     *d++ = g;
     *d++ = r;
      }
   }
} 

2) Made OpenCV ask for YUYV instead BGR24 (here I show already modified code):

  /* libv4l will convert from any format to V4L2_PIX_FMT_YUYV */
  CLEAR (capture->form);
  capture->form.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  capture->form.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
  capture->form.fmt.pix.field       = V4L2_FIELD_ANY;
  capture->form.fmt.pix.width = capture->width;
  capture->form.fmt.pix.height = capture->height;
...
  if (V4L2_PIX_FMT_YUYV != capture->form.fmt.pix.pixelformat) {
      fprintf( stderr, "HIGHGUI ...
(more)
2013-03-18 08:32:09 -0600 commented answer Using 2 Webcams Simultaneously

It is pretty simple to change FPS. Go to ./modules/highgui/src/cap_libv4l.cpp and find this segment:

/* try to set framerate to 30 fps */
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;
xioctl (capture-&gt;deviceHandle, VIDIOC_S_PARM, &amp;setfps);

Change here 30 to desired FPS and after that recompile OpenCV. Yes, hard way, but it works. I've got problems with FOURCC - it isn't implemented. That's bad but I am okay to go the same way as for changing FPS. But I don't know how :\ (read my post in this thread for more details)

2013-03-18 08:20:38 -0600 answered a question Using 2 Webcams Simultaneously

I think it is a better idea to write here than create new thread. I also got 2 webcams and I need to run them simultaneously. From the start I want to say - using two USB chipsets is not a solution for me. It is possible to run them simultaneously at 640x480 and 30 fps. But with one condition - use YUYV colorspace (it is YUV 4:2:2 colorspace, all the rest are worse YUV variants). As all of us knows OpenCV uses BGR24 colospace. And here starts strange things... I am running "v4l2-ctl -d /dev/video0 --list-formats" and I get this:

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUV 4:2:2 (YUYV)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : MJPEG

As you can see we don't have here BGR24 colospace. For testing purposes I use qv4l2 application. It can list supported colorspaces and one of them is BGR24! How is that possible? Strange things continues... If I try BGR24 (OpenCV force this one) I can't get higher than 15 fps for simultaneous running. How is that possible - call for unlisted colospace and get it?! The most strange thing - it gets it and USB chipset can't let through such a large datastream :\ This is weird because it means that v4l doesn't convert YUYV to BGR24, it just gets BGR24 from camera (???)!