Hi,
I would like to ask a bit of your help to use the image to be sent to an external Api for Processing. this external API ( Barcode reader ) takes a pointer address, width and height.
I have Managed to get it working Ok with the following Code but I have to make a copy to an array to retrieve an address to the image buffer - what I would like is read direct from the image ( I am using cvb.net)
thanks for the help.
public int DecodeByte(Device device, int ROITop, int ROILeft, int ROIWidth, int ROIHeight)
{
int retCode;
int offset = 0;
var img = device.DeviceImage.Planes[0].Map().MapTo8Bit();
var width = img.Width;
var height = img.Height;
var myNewImage = img.Planes[0].GetLinearAccess();
var pBase = myNewImage.BasePtr;
var XInc = myNewImage.XInc;
var YInc = myNewImage.YInc;
byte[] srcVal2 = new byte[width * height];
for (int y = 0; y < height; y++)
{
byte* pSrcLine = (byte*)pBase + y * (int)YInc;
for (int x = 0; x < width; x++)
{
var srcVal = *(pSrcLine + x * (int)XInc);
srcVal2[offset++] = srcVal;
}
}
fixed (byte* pix = &srcVal2[0])
{
// Set image properties
CRD_Set(handle, P_IMAGE_ADDRESS, (void*)pix); // address of Image here
CRD_Set(handle, P_IMAGE_WIDTH, (void*)width);
CRD_Set(handle, P_IMAGE_HEIGHT, (void*)height);
CRD_Set(handle, P_IMAGE_BUF_WIDTH, (void*)width);
// Set Region of Interest for decoding
CRD_Set(handle, P_BC_ROI_TOP, (void*)ROITop);
CRD_Set(handle, P_BC_ROI_LEFT, (void*)ROILeft);
CRD_Set(handle, P_BC_ROI_WIDTH, (void*)ROIWidth);
CRD_Set(handle, P_BC_ROI_HEIGHT, (void*)ROIHeight);
CRD_Set(handle, P_ENABLE_QR_2005, (void*)1);
retCode = CRD_Decode(handle);
}
return retCode;
}