实例介绍
【实例截图】
【核心代码】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Smartray.Sample
{
//
// CPP samples for Smartray scanners
//
class CSharpSamples
{
//
// Live Image Sample
// uses the predefined (default) Live Image Parameter Set (*.par, part of the installer) to configure the sensor
// starts Live Image data acquisition
//
public static void LiveImageSample()
{
using (SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.LiveImage);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.StopAcquisition();
sensor.GetLastImageData().SaveLiveImage("LiveImageSample_LiveImage");
sensor.Disconnect();
}
}
//
// PIL Image Sample (Inspection only)
// configures the sensor to acquire a combined PIL i.e. (Profile Intensity LaserLineThickness) Image
//
public static void PilImageSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureImageAquisition(Api.ImageAcquisitionType.ProfileIntensityLaserLineThickness, 250);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.StopAcquisition();
sensor.GetLastImageData().SavePilImage("PilImageSample_PilImage");
sensor.Disconnect();
}
}
//
// ZIL Image Sample (Inspection Measurement)
// configures the sensor to acquire a combined ZIL i.e. (Z-Map Intensity LaserLineThickness) Image
//
public static void ZmapImageSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadCalibrationDataFromSensor();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
// refine image aquiring parameters
sensor.ConfigureImageAquisition(Api.ImageAcquisitionType.ZMap, 200);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.StopAcquisition();
sensor.GetLastImageData().SaveZilImage("ZmapImageSample_ZilImage");
sensor.Disconnect();
}
}
//
// Point Cloud Sample (Inspection Measurement)
// configures the sensor to acquire a Point Cloud (This is NOT an image!)
//
public static void PointCloudSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadCalibrationDataFromSensor();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
// refine image acquiring parameters
sensor.ConfigureImageAquisition(Api.ImageAcquisitionType.PointCloud, 100);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.AcquirePointCloud();
sensor.StopAcquisition();
sensor.SavePointCloudToFile("PointCloudSample_PointCloudData");
sensor.Disconnect();
}
}
//
// DATA Trigger Sample
// shows image acquisition controlled by an DATA Trigger, Mode: Internal
//
public static void DataTriggerSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureDataTriggerToFrequencyHz(10);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.GetLastImageData().SavePilImage("DataTriggerSample_PILImage");
sensor.StopAcquisition();
sensor.Disconnect();
}
}
//
// START Trigger Sample
// shows image acquisition controlled by a Start Trigger
// Requirement: Please make sure to provide a START Trigger signal on on sensor's Input 1
//
public static void StartTriggerSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureStartTriggerOnHardwareInput(Api.StartTriggerSource.Input0);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.GetLastImageData().SavePilImage("StartTriggerSample_PilImage");
sensor.StopAcquisition();
sensor.Disconnect();
}
}
//
// Multiple Exposure Sample
// shows how to configure the sensor in multiple exposure mode, to scan a part which has a high dynamic range (HDR)
//
public static void DoubleExposureSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureExposureTimesMicroS(100, 1000);
sensor.SendParameterSet();
sensor.SetMultiExposureMode(Api.MultipleExposureMergeModeType.Merge);
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.GetLastImageData().SavePilImage("DoubleExposureSample_PilImage");
sensor.StopAcquisition();
sensor.Disconnect();
}
}
//
// Laser Settings Sample
// shows image acquisition using preconfigured laser settings
//
public static void LaserBrightnessSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.LiveImage);
sensor.ConfigureLaserBrightnessPercent(50);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.GetLastImageData().SaveLiveImage("LaserPowerSample_LiveImage");
sensor.StopAcquisition();
sensor.Disconnect();
}
}
//
// ROI Configuration Sample
// shows image acquisition using a cropped or windowed ROI (region of interest), to boost sensor scan rate
//
public static void RegionOfInterestSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureRegionOfInterestDivider(2);
sensor.SendParameterSet();
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.GetLastImageData().SavePilImage("RegionOfInterestSample_PilImage");
sensor.StopAcquisition();
sensor.Disconnect();
}
}
//
// Multi-Sensor Sample
// shows image acquisition from multiple sensors (2 sensors in this sample) at the same time
// Sensor 1: IP Address | Port Number: 192.168.178.200 | 40
// Sensor 2: IP Address | Port Number: 192.168.178.201 | 40
//
public static void MultiSensorSample()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor0 = sensorManager.CreateSensor("sensor 0", 0, "192.168.178.200");
Sensor sensor1 = sensorManager.CreateSensor("sensor 1", 1, "192.168.178.201");
sensor0.Connect();
sensor1.Connect();
sensor0.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor1.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor0.SendParameterSet();
sensor1.SendParameterSet();
sensor0.StartAcquisition();
sensor1.StartAcquisition();
sensor0.WaitForImage(1);
sensor1.WaitForImage(1);
sensor0.GetLastImageData().SavePilImage("MultiSensorSample_PilImage_Sensor0");
sensor1.GetLastImageData().SavePilImage("MultiSensorSample_PilImage_Sensor1");
sensor0.StopAcquisition();
sensor1.StopAcquisition();
sensor0.Disconnect();
sensor1.Disconnect();
}
}
//
// MSR Sample
// shows image acquisition from MSR mode(2 sensors in this sample)
// Requirement: 2 ECCO 75 sensors configured with:
// Sensor 1: IP Address | Port Number: 192.168.178.200 | 40
// Sensor 2: IP Address | Port Number: 192.168.178.201 | 40
//
public static void MSRSample()
{
using (SensorManager sensorManager = new SensorManager())
{
Sensor sensor0 = sensorManager.CreateSensor("sensor 0", 0, "192.168.178.200");
Sensor sensor1 = sensorManager.CreateSensor("sensor 1", 1, "192.168.178.201");
sensor0.Connect();
sensor0.LoadCalibrationDataFromSensor();
sensor1.Connect();
sensor1.LoadCalibrationDataFromSensor();
sensor0.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor1.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor0.SendParameterSet();
sensor1.SendParameterSet();
/*Need to call this function only once*/
sensor0.ConfigureMSRMode();
sensor0.StartAcquisition();
sensor1.StartAcquisition();
/*The ZIL callback is only delivered always for Sensor with the minimum sensor index , in this case 0 : Sensor 0*/
sensor0.WaitForImage(1);
sensor0.GetLastImageData().SavePilImage("MultiSensorSample_PilImage_Sensor0");
sensor0.StopAcquisition();
sensor1.StopAcquisition();
sensor0.Disconnect();
sensor1.Disconnect();
}
}
//
// Get Sensor Parameters Sample
// shows how to get the configured parameters from the sensor
//
public static void GetAllParameters()
{
using(SensorManager sensorManager = new SensorManager())
{
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadCalibrationDataFromSensor();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.SendParameterSet();
sensor.GetSensorResolution();
sensor.GetRegionOfInterestParameters();
sensor.GetExposureParameters();
sensor.GetLaserParameters();
sensor.GetStartTriggerParameters();
sensor.GetDataTriggerParameters();
sensor.GetReflectionFilterParameters();
sensor.GetAcquisitionParameters();
sensor.GetSensorInformation();
sensor.Disconnect();
}
}
public static void MetaDataSample()
{
using(SensorManager sensorManager = new SensorManager()) {
Sensor sensor = sensorManager.CreateSensor("sensor 0");
sensor.Connect();
sensor.LoadParameterSet(Sensor.ParameterSet.Snapshot3d);
sensor.ConfigureImageAquisition(Api.ImageAcquisitionType.ProfileIntensityLaserLineThickness, 100);
sensor.SendParameterSet();
sensor.SetMetaDataExportEnable(true);
sensor.StartAcquisition();
sensor.WaitForImage(1);
sensor.StopAcquisition();
sensor.GetLastImageData().SavePilImage("PilImageSample_PilImage");
sensor.ExportMetaData("meta_data.txt");
sensor.Disconnect();
}
}
}
}
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论