Visiosens Camera SDK 提供 C# 之 WPF 取像範例程式, 一般 Camera SDK 很少提供此種寫作範例程式, 當深入瞭解範例內容後, 其取像方式真是有顛覆傳統, 讓使用取像步驟大幅簡化, 而把時間專注於檢測工作, 例如取像格式判斷與設定如下:void ImageGet(
VfImageFormat imageFormat,
VfImage vfImage,
out bool supported
)
ParametersimageFormat Type:
VfImageFormat Chosen ImageFormat
vfImage Type:
VfImage Image Object
supported Type:
bool If set to
true, then chosen ImageFormat is supported; otherwise, not supported.
void ImageGet(
VfImageFormat imageFormat,
out VfImage vfImage
)
ParametersimageFormat Type:
VfImageFormat Requested image Format. Legal values are:
Raw8,
RawBayer8RG,
RawBayer8GR,
RawBayer8BG,
RawBayer8GB,
Grey8,
RGB888,
BGR888,
Grey888,
Raw10,
RawBayer10RG,
RawBayer10GR,
RawBayer10BG,
RawBayer10GB,
Grey10,
RGB101010,
BGR101010,
Grey101010,
Bitmap,
BitmapGrey,
Ignore
vfImage Type:
VfImage Image Object
VfImage dummyImage = new VfImage();
bool[] imageInfo = new bool[18];
// 8 Bit Resolution image formats.
m_vfuCameraObject.ImageGet(VfImageFormat.Raw8, dummyImage, out imageInfo[0]);
m_vfuCameraObject.ImageGet(VfImageFormat.Grey8, dummyImage, out imageInfo[1]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer8RG, dummyImage, out imageInfo[2]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer8GR, dummyImage, out imageInfo[3]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer8BG, dummyImage, out imageInfo[4]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer8GB, dummyImage, out imageInfo[5]);
m_vfuCameraObject.ImageGet(VfImageFormat.BGR888, dummyImage, out imageInfo[6]);
m_vfuCameraObject.ImageGet(VfImageFormat.RGB888, dummyImage, out imageInfo[7]);
// 10 Bit resolution image formats.
m_vfuCameraObject.ImageGet(VfImageFormat.Raw10, dummyImage, out imageInfo[8]);
m_vfuCameraObject.ImageGet(VfImageFormat.Grey10, dummyImage, out imageInfo[9]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer10RG, dummyImage, out imageInfo[10]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer10GR, dummyImage, out imageInfo[11]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer10BG, dummyImage, out imageInfo[12]);
m_vfuCameraObject.ImageGet(VfImageFormat.RawBayer10GB, dummyImage, out imageInfo[13]);
m_vfuCameraObject.ImageGet(VfImageFormat.BGR101010, dummyImage, out imageInfo[14]);
m_vfuCameraObject.ImageGet(VfImageFormat.RGB101010, dummyImage, out imageInfo[15]);
// Special image formats
m_vfuCameraObject.ImageGet(VfImageFormat.Bitmap, dummyImage, out imageInfo[16]);
m_vfuCameraObject.ImageGet(VfImageFormat.BitmapGrey, dummyImage, out imageInfo[17]);
//取像格式與範圍 ROI 可隨時切換
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
fg = False
If CheckBox1.Checked Then
m_vfuCameraObject.ImageRoiSet(New Rectangle(10, 10, 300, 300))
m_vfuCameraObject.ImageGet(VfImageFormat.BitmapGrey, dummyImage)
Else
m_vfuCameraObject.ImageRoiSet(New Rectangle(100, 100, 300, 300))
m_vfuCameraObject.ImageGet(VfImageFormat.Bitmap, dummyImage)
End If
PictureBox1.Image = CType(dummyImage.ImageData, Bitmap)
ct = ct + 1
Me.Text = DateTime.Now.ToLongTimeString + " Garb Frame Nums : " + ct.ToString + " ImageFormat : " + dummyImage.ImageFormat.ToString
fg = True
End Sub