Working with 3D-Cameras of Automation Technology in CVB

Hi support team,
When I use this method, how can I get imgDC0, imgDC1 and imgDC2 pointer?
If using
Dim imageDataDC1 As LinearAccessData = imgDC1 .Planes(0).GetLinearAccess()
Dim basePtrDC1 As IntPtr = imageDataDC1.BasePtr
the error will occure at GetLinearAccess().

Thank you for your support.

Hi @Charlene,

What kind of error do you get? If it is an exception, the documentation might give you a hint:

FormatException If the plane’s pixels are not accessible linearly
System.ObjectDisposedException If Parent has already been disposed
InvalidOperationException Thrown if the size of T and DataType.BytesPerPixel are unequal.

If you get the LinearAccessData keep following in mind:
For Visual Basic .Net you need to use the helper functions provided in the System.Runtime.InteropServices.Marshal class for the increments.

Hi @Sebastian

When I use
Dim rect As New Rect(0, 1, img.Width - 1, img.Height - 1)
Image = img.Map(rect, Size)
Dim imageData As LinearAccessData = Image.Planes(0).GetLinearAccess() 'the error is at this line
Dim basePtr As IntPtr = imageData.BasePtr
it will show the error:
System.ArgumentException
HResult=0x80070057
Message=Operation Linear Access only supported on linear VPATs.
Source=Stemmer.Cvb

The problem should be the pixel is skipping. It is non-linear.
Can we use GetImageVPA() to get non-linear mapped image pointer?
Which function of CVB.Net can be used?

Thank you for your reply.

@Charlene
In the ImagePlane you can use the GetVPATAccess() function to access the VPAT access to the plane´s pixels.

Hi @Sebastian
Could you give me a example how to use GetVPATAccess()?
I am not familier with the code how to use GetVPATAccess().
I cannot find out CVB sample to use this function.

Thank you.

@Charlene
Hey!

Have a look at the little example below. This should explain how to access the VPAT Access Data.

var device = DeviceFactory.Open(@"%CVB%Drivers\GenICam.vin");
             
device.Stream.Start();

for(int i = 0; i < 10; i++)
{
    var image = device.Stream.Wait();
    var vpaAccessData = image.Planes[0].GetVPATAccess<byte>();

    Console.WriteLine(vpaAccessData[500, 500]);
}
device.Stream.Abort();

Furthermore, here is a link for the CVB Online Documentation
( https://help.commonvisionblox.com/NextGen/14.0/index.html ), or if more precisely needed the GetVPATAccess Method ( https://help.commonvisionblox.com/NextGen/14.0/cvbnet/d6/df0/struct_stemmer_1_1_cvb_1_1_image_plane.html#a988c5eddc936b27b3d91c776a8a22bab )

Thanks and regards
Silas

Hi @silas
Thanks for your promp answer.
How can I convert vpaAccessData to “IntPtr” data type so that I can convert CVB image format to other image format?

Yours sincerely
Charlene

@Charlene
Hey!

You can achieve that by simply using the VPAT from the image plane and getting the corresponding Base Pointer.

var vpat = image.Planes[0].Vpat; 
IntPtr vpatPtr = vpat.BasePtr;

Regards
Silas

@Charlene
Hey!
I´ve come to a possible workaround regarding the VPAT Access. If you either copy or clone the image you´ll be able to do linear access on the copied/cloned image and avoid VPAT access.
Note that VPAT access is one of the slower access modes, so linear access is preferred.

var copiedImage = image.Copy();
var clonedImage = image.Clone();    

Regards
Silas

1 Like

@silas
Thanks.
It works now.

Yours sincerely
Charlene

1 Like