嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 3 元微信扫码支付:3 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
halcon basler相机
private void OnImageReadyEventCallback()
{
if (InvokeRequired)
{
/* If called from a different thread, we must use the Invoke method to marshal the call to the proper thread. */
BeginInvoke(new ImageProvider.ImageReadyEventHandler(OnImageReadyEventCallback));
return;
}
try
{
/* Acquire the image from the image provider. Only show the latest image. The camera may acquire images faster than images can be displayed*/
ImageProvider.Image image = m_imageProvider.GetLatestImage();
/* Check if the image has been removed in the meantime. */
if (image != null)
{
/* Check if the image is compatible with the currently used bitmap. */
if (BitmapFactory.IsCompatible(m_bitmap, image.Width, image.Height, image.Color))
{
/* Update the bitmap with the image data. */
BitmapFactory.UpdateBitmap(m_bitmap, image.Buffer, image.Width, image.Height, image.Color);
/* To show the new image, request the display control to update itself. */
}
else /* A new bitmap is required. */
{
BitmapFactory.CreateBitmap(out m_bitmap, image.Width, image.Height, image.Color);
BitmapFactory.UpdateBitmap(m_bitmap, image.Buffer, image.Width, image.Height, image.Color);
/* We have to dispose the bitmap after assigning the new one to the display control. */
//Bitmap bitmap = pictureBox.Image as Bitmap;
/* Provide the display control with the new bitmap. This action automatically updates the display. */
//pictureBox.Image = m_bitmap;
//if (bitmap != null)
//{
/* Dispose the bitmap. */
//bitmap.Dispose();
//}
}
HObject theImage = null;
HOperatorSet.GenEmptyObj(out theImage);
theImage.Dispose();
HTuple width, height;
BitmapToHObject(m_bitmap, out theImage);
HOperatorSet.ClearWindow(hWindowControl1.HalconWindow);
HOperatorSet.GetImageSize(theImage, out width, out height);
HOperatorSet.SetPart(hWindowControl1.HalconWindow, 0, 0, height, width);
HOperatorSet.DispObj(theImage, hWindowControl1.HalconWindow);
if (isSave)
{
isSave = false;
ImageSave(theImage);
}
/* The processing of the image is done. Release the image buffer. */
m_imageProvider.ReleaseImage();
/* The buffer can be used for the next image grabs. */
}
}
catch (Exception e)
{
ShowException(e, m_imageProvider.GetLastErrorMessage());
}
}