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, out xInc, out yInc);
=> result is false, so I try:
bool result=Cvb.Image.GetImageVPA(img, 0, out pBase, out addrVPAT);
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 + pVPAT.YEntry.ToInt64();
// get first value in line
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
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
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;
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?
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; // 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.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…