Retrieving 30bit rgb from GenICam camera

I am using a Jai RGB camera that is capable of delivering 30bit rgb output. Unfortunately I am not able to get access to the image data, no matter if set the output to raw or RGB16 bit.

I tried to get linear access to the image data:

IntPtr[] addrVPAT = new IntPtr[dimensions];
Cvb.Image.VPAEntry*[] pVPAT = new Cvb.Image.VPAEntry*[dimensions];

bool result=Cvb.Utilities.GetLinearAccess(img, 0, out pBase[0], out xInc[0], out yInc[0]);

=> result is false, so I try:

bool result=Cvb.Image.GetImageVPA(img, 0, out pBase[0], out addrVPAT[0]);

This method call evaluates to true, so afterwards I access the table:

byte*[] pSrc=new byte[dimensions];
// set pointer to first line
pSrc[k] = (byte*)pBase[0] + pVPAT[0][0].YEntry.ToInt64();
// get first value in line
byte v=*(pSrc[0]+pVPAT[0][0].XEntry.ToInt64());

All XEntries and YEntries evaluate to 0, so all my values are 0. It seems the table is empty.
Am I doing something wrong attempting to access the data, or is there actually no data, because the CVB can not get it from the camera?

Hi and welcome @pixelmaster,

from your description I guess you are using the GenICam.vin. Is the camera delivering RGB10p32 data? If yes, you get packed data in you pixel Buffer. This would explain why GetLinearAccess fails. If you want to directly access your pixel data you should use the RGB16 conversion (not raw). This enables you to use GetLinearAccess and GetImageVPA properly.

Also beware: the pointer arithmetic of linear access and VPAT access is for byte pointers. Thus all your logic using pBase, xInc and yInc need to be done on byte*s. When you dereference the pointer you must cast it to ushorts:

byte* pBase = …;
long xInc = …, yInc = …;

int x = …, y = …; // get the pixel at (x,y)
byte* pPixel = pBase + y * yInc + x * xInc;
ushort pixelValue = *(ushort*)pPixel;

1 Like

Hi parsd,
thank you for the hints.
I configured the camera for RGB10p32 data.
I configured the driver for RGB16.
I get a vaild Img object from the camera when grabbing, but call to GetLinearAccess fails, returned pointers contain only zeros. Same with GetImageVPA.

I get the same call results after configuring the driver to Raw.

So what is wrong? May be the driver is using a wrong format despite my setting? How can I check that?

Hi @pixelmaster,

if both fail it seem you are working on an invalid object. Can you try this (see the intro to new API on how to create a project):

var foundDevices = DeviceFactory.Discover();
var firstDeviceInfo = foundDevices[0]; // we simply assume we found at least one camera
firstDeviceInfo.SetParameter("PixelFormat", "4"); // 4 stands for RGB16 - 0 for RAW

using (var device = DeviceFactory.Open(firstDeviceInfo))
{
  var image = device.Stream.GetSnapshot();

  var imageData = image.Planes[0].GetLinearAccess<ushort>();
  var netData = new ushort[image.Width, image.Height];
  for (int y = 0; y < image.Height; y++)
  {
    for (int x = 0; x < image.Width; x++)
    {
      netData[x, y] = imageData[x, y];
    }
  }
}

This is very basic, but you should see pixel content after this…