Retrieving RGB value from CAM130

Ito 2010-03-15 10:20:09 Link
Hi All,

I have tried Camera Test function of 2440test.bin and it works properly.
But the problem is I don't know how to get RGB value nor YCrCb value of
each pixel. Is there anyone can help me?


Thanks,


Ito

Kailas V. Shetye 2010-03-15 10:38:32 Link
The following 2 sets of formulae are taken from information from Keith
Jack's excellent book "Video Demystified" (ISBN 1-878707-09-4).
RGB to YUV Conversion

    Y  =      (0.257 * R) + (0.504 * G) + (0.098 * B) + 16

    Cr = V =  (0.439 * R) - (0.368 * G) - (0.071 * B) + 128

    Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128


YUV to RGB Conversion

    B = 1.164(Y - 16)                   + 2.018(U - 128)

    G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)

    R = 1.164(Y - 16) + 1.596(V - 128)

In both these cases, you have to clamp the output values to keep them in
the [0-255] range

Kailas V. Shetye 2010-03-15 10:59:11 Link
taken from mjpg-streamer source:

  z = 0;
  while (cinfo.next_scanline < vd->height) {
    int x;
    unsigned char *ptr = line_buffer;

    for (x = 0; x < vd->width; x++) {
      int r, g, b;
      int y, u, v;

      if (!z)
        y = yuyv[0] << 8;
      else
        y = yuyv[2] << 8;
      u = yuyv[1] - 128;
      v = yuyv[3] - 128;

      r = (y + (359 * v)) >> 8;
      g = (y - (88 * u) - (183 * v)) >> 8;
      b = (y + (454 * u)) >> 8;

      *(ptr++) = (r > 255) ? 255 : ((r < 0) ? 0 : r);
      *(ptr++) = (g > 255) ? 255 : ((g < 0) ? 0 : g);
      *(ptr++) = (b > 255) ? 255 : ((b < 0) ? 0 : b);

      if (z++) {
        z = 0;
        yuyv += 4;
      }
    }

Ito 2010-03-15 10:59:37 Link
Hi Kailas,

May be there is miscommunication. yeah, I know that formulas, but the
problem is I don't know how to get RGB or YCrCb data from camera, or I can
say that I don't know which register I have to access to get RGB data. Can
you help me ?


Regards,



Ito

Ito 2010-03-15 11:01:42 Link
Hi Kailas,


do you mean it takes from frame buffer ? That is for linux, but I want to
use my mini2440 without OS.


Regards


Ito

Kailas V. Shetye 2010-03-15 11:32:59 Link
Attachment: CAMIF.C (27.77 KB)
oh yes. I did not notice that you have posted your question under "Non OS"
section.

I personally prefer busybox linux as it takes very less memory and I get
comfort of using ready made utilities and drivers.  

Hope the attached file will help you to understand LCD I/O.  This file is
there in the CD/DVD came along with the board.

regards,

Kailas

Ito 2010-03-15 11:53:50 Link
Hai Kailas,

Thank you for the file. It's really help me



Regards,


Ito

good 2011-01-03 06:27:36 Link
CAMIF.C is not enough to view video from cam130

Reply

Name
eMail (not visible)
Subject (no text only in upper case; no HELP, URGENT...)
Text
HTML tags are not supported and links are generated automatically if they start with http or ftp.
Please submit long source code or log files as attachment (only registered users).
Please enter the number 4605