Page 1 of 1

RPi + NoIR 5Mp camera v4l capture

Posted: Tue Nov 04, 2014 7:45 pm
by makgab
Hi!

I tried a qtv4l app on RPi with 5Mp NoIR camrea:
* Small board size: 25mm x 20mm x 9mm
* A 5MP (2592×1944 pixels) Omnivision 5647 sensor in a fixed focus module
* Support 1080p30, 720p60 and 640x480p60/90 video record

I can compile that sample app. But I can't use that camera with capture 5Mp image.
How can I use the higher resolutions for capture image? Or it works in fixed focus module only? What does it mean exactly?

Re: RPi + NoIR 5Mp camera v4l capture

Posted: Wed Nov 05, 2014 9:31 pm
by 6by9
Have you loaded the Pi V4L2 driver?

Code: Select all

sudo modprobe bcm2835-v4l2

Re: RPi + NoIR 5Mp camera v4l capture

Posted: Wed Nov 05, 2014 9:48 pm
by makgab
6by9 wrote:Have you loaded the Pi V4L2 driver?

Code: Select all

sudo modprobe bcm2835-v4l2
Yes. The camera works with it. If I load the module (modprobe bcm2835-v4l2) then the device file "/dev/video0" will be created.
How can I use the high resolution (5Mp) in C++?

I modified the code of app:

Code: Select all

...
    // if button pressed
    if ( state18 == "0" ) {
        onStopCapture();
        // Save Image
        QString savepath = file_path;
        QByteArray ba;
        QBuffer buffer(&ba);
        buffer.open(QIODevice::WriteOnly);
        // writes image into ba in PNG format
        video->img.save(savepath, "PNG", -1);
..
It is ok, but in lower resolution. How can I use the high (5Mp) resolution?

Re: RPi + NoIR 5Mp camera v4l capture

Posted: Thu Nov 06, 2014 6:52 am
by 6by9
makgab wrote:It is ok, but in lower resolution. How can I use the high (5Mp) resolution?
You just need to ask the V4L2 driver to provide the image at the resolution you want. It supports multiple formats (I420, YUYV, NV12 and 21, RGB24, RGBX32, H264, MJPEG, and JPEG from memory), and H264 is the only one that has a resolution limit at 1080P.
Where is it failing? Is it that you are just running out of memory in your app due to it doing something silly?

Re: RPi + NoIR 5Mp camera v4l capture

Posted: Thu Nov 06, 2014 11:41 am
by makgab
6by9 wrote: You just need to ask the V4L2 driver to provide the image at the resolution you want. It supports multiple formats (I420, YUYV, NV12 and 21, RGB24, RGBX32, H264, MJPEG, and JPEG from memory), and H264 is the only one that has a resolution limit at 1080P.
Where is it failing? Is it that you are just running out of memory in your app due to it doing something silly?
I need to use other format type instead of "fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE"?:

Code: Select all

...
void CaptureThread::run(){
//do real stuff
fd = -1;
dev_name = "/dev/video0";


    fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
    if (fd < 0) {
           qDebug("Cannot open device");
           return;
    }


    static struct v4lconvert_data *v4lconvert_data;
    static struct v4l2_format src_fmt;
    static unsigned char *dst_buf;

    CLEAR(fmt);
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
...

Re: RPi + NoIR 5Mp camera v4l capture

Posted: Thu Nov 06, 2014 7:09 pm
by 6by9
Sorry, not enough resource to investigate all potential V4L2 apps.
Having a very quick look at the code, it is the 3 lines after the snippet you quote that may I needed.

Code: Select all

    fmt.fmt.pix.width       = 640;
    fmt.fmt.pix.height      = 480;
    fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
    fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
V4L2_PIX_FMT_RGB24 is the pixel format that I was referring to. Look at the V4L2 spec (http://hverkuil.home.xs4all.nl/spec/med ... -FMT-RGB24) for all the potential formats, although it looks like that app only supports RGB24 and strongly prefers VGA.

Code: Select all

    if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
           printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
           //exit(EXIT_FAILURE);
           return;
    }
    if ((fmt.fmt.pix.width != 640) || (fmt.fmt.pix.height != 480))
           printf("Warning: driver is sending image at %dx%d\n",
                   fmt.fmt.pix.width, fmt.fmt.pix.height);
I couldn't say why it wants VGA in particular, but that is the way it is set up.

Suffice to say the V4L2 driver does support images up to 5MPix in numerous formats (look through the table at https://github.com/raspberrypi/linux/bl ... 5-camera.c starting line 72 for the list). It looks like your app may not.