LMI2500系列相机SDK开发包C#版

/*
 * AcceleratorReceiveMeasurement.cs
 * 
 * Gocator 2000 Sample
 * Copyright (C) 2011-2019 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 *
 * Purpose: Demonstrates the simple use of the Accelerator by connecting to a sensor and receiving a measurement.
 * This allows processing to be performed on the PC rather than on the sensor.
 */

using System;
using Lmi3d.GoSdk;
using Lmi3d.Zen;
using Lmi3d.Zen.Io;
using Lmi3d.GoSdk.Messages;
using Lmi3d.GoSdk.AcceleratorMgr;
using System.Threading;

static class Constants
{
    public const string SENSOR_IP1 = "192.168.1.10"; // IP of the sensor used for sensor connection GoSystem_FindSensorByIpAddress() call.
    public const string SENSOR_IP2 = "192.168.1.11"; // IP of sensor 2
   
}

namespace AcceleratorReceiveMeasurement
{
    class AcceleratorReceiveMeasurement
    {
        static int Main(string[] args)
        {
            try
            {
                KApiLib.Construct();
                GoSdkLib.Construct();
                GoSystem system = new GoSystem();
                
                GoSensor sensor1,sensor2;
                KIpAddress ipAddress1 = KIpAddress.Parse(Constants.SENSOR_IP1);
                KIpAddress ipAddress2 = KIpAddress.Parse(Constants.SENSOR_IP2);                
                GoDataSet dataSet = new GoDataSet();
                
                sensor1 = system.FindSensorByIpAddress(ipAddress1);
                sensor2 = system.FindSensorByIpAddress(ipAddress2);

                GoAcceleratorMgr goAcceleratorMgr = new GoAcceleratorMgr();

                // create connection to system
                goAcceleratorMgr.SetSystem(system);

                // start Accelerator manager
                goAcceleratorMgr.Start();

                //Set Parameters for Acceleration 
                GoAcceleratorMgrSensorParam goAcceleratorMgrSensorParam1 = new GoAcceleratorMgrSensorParam();
                GoAccelSensorPortAllocPorts ports1 = new GoAccelSensorPortAllocPorts();

                GoAcceleratorMgrSensorParam goAcceleratorMgrSensorParam2 = new GoAcceleratorMgrSensorParam();
                GoAccelSensorPortAllocPorts ports2 = new GoAccelSensorPortAllocPorts();

                
                goAcceleratorMgrSensorParam1.PlatformIpAddress = KIpAddress.AnyV4;
                goAcceleratorMgrSensorParam1.Ports = ports1;
                
                goAcceleratorMgrSensorParam2.PlatformIpAddress = KIpAddress.AnyV4;
                goAcceleratorMgrSensorParam2.Ports = ports2;

                //Accelerate two sensors
                goAcceleratorMgr.Accelerate(sensor1.Id, goAcceleratorMgrSensorParam1);
                goAcceleratorMgr.Accelerate(sensor2.Id, goAcceleratorMgrSensorParam2);

                //Check accelerated status of sensor1
                for (UInt32 i = 0; i < 30; i++)
                {
                    GoSensorAccelState kStatus1 = sensor1.AccelerationState;
                    if (kStatus1 == 2)
                    {                      
                        Console.WriteLine("Sensor1 Accelerated");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Waiting for Sensor1 Accelerated...");
                    }
                    Thread.Sleep(1000);
                }

                //Check accelerated status of sensor2
                for (UInt32 i = 0; i < 30; i++)
                {
                    GoSensorAccelState kStatus2 = sensor2.AccelerationState;
                    if (kStatus2 == 2)
                    {
                        Console.WriteLine("Sensor2 Accelerated");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Waiting for Sensor2 Accelerated...");
                    }
                    Thread.Sleep(1000);
                }

                system.Refresh();
                
                sensor1.Connect();
                sensor2.Connect();

                system.EnableData(true);
                system.Start();
                // refer to SetupMeasurement.cs for setting up of the measurement tools
                dataSet = system.ReceiveData(300000);
                for (uint i = 0; i < dataSet.Count; i++)
                {

                    GoDataMsg dataObj = (GoDataMsg)dataSet.Get(i);
                    switch (dataObj.MessageType)
                    {
                        case GoDataMessageType.Stamp:
                            {
                                GoStampMsg stampMsg = (GoStampMsg)dataObj;
                                for (uint j = 0; j < stampMsg.Count; j++)
                                {
                                    GoStamp stamp = stampMsg.Get(j);
                                    Console.WriteLine("Frame Index = {0}", stamp.FrameIndex);
                                    Console.WriteLine("Time Stamp = {0}", stamp.Timestamp);
                                    Console.WriteLine("Encoder Value = {0}", stamp.Encoder);
                                }
                            }
                            break;
                        case GoDataMessageType.Measurement:
                            {
                                GoMeasurementMsg measurementMsg = (GoMeasurementMsg)dataObj;
                                for (uint k = 0; k < measurementMsg.Count; ++k)
                                {
                                    GoMeasurementData measurementData = measurementMsg.Get(k);
                                    Console.WriteLine("ID: {0}", measurementMsg.Id);
                                    Console.WriteLine("Value: {0}", measurementData.Value);
                                    Console.WriteLine("Decision: {0}", measurementData.Decision);
                                }
                            }
                            break;
                    }
                }
                system.Stop();
                //stop acceleration
                goAcceleratorMgr.Decelerate(sensor1.Id);
                goAcceleratorMgr.Decelerate(sensor2.Id);
            }
            catch (KException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }

            // wait for ENTER key
            Console.WriteLine("\nPress ENTER to continue");
            while (Console.ReadKey().Key != ConsoleKey.Enter) { }
            return 1;
        }
    }
}
  • 0
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: LMI 3D相机SDK取图主要是指通过使用LMI 3D相机的软件开发工具包(SDK)来获取相机采集的图像数据。LMI 3D相机是一种用于三维视觉应用的高性能相机,其SDK提供了各种功能和接口,使开发者能够灵活地控制相机并获取所需要的图像数据。 首先,开发者需要在自己的应用程序中集成LMI 3D相机SDK。这个SDK是由LMI公司提供的软件工具包,其中包含了相机的驱动程序和相关的API接口。通过调用SDK提供的函数,开发者可以实现对相机的控制和图像数据的获取。 其次,通过SDK提供的函数,开发者可以设置相机的参数,如曝光时间、增益、触发模式等。设置好相机的参数后,可以通过调用相机的采集函数开始获取图像数据。 在获取图像数据之前,开发者需要预先设置图像数据的格式以及存储位置。通常,SDK提供的函数可以将图像数据保存为图像文件,例如JPEG或BMP格式,也可以将图像数据保存为内存中的数组。 当图像数据获取完毕后,开发者可以对图像数据进行后续的处理和分析。通过SDK提供的函数,可以对图像进行滤波、图像配准、测量等操作,实现更加复杂的三维视觉应用。 总之,通过LMI 3D相机SDK取图,开发者可以方便地控制相机并获取所需的图像数据,为后续的处理和分析提供基础。这大大简化了三维视觉应用的开发流程,并提高了开发效率。 ### 回答2: LMI 3D相机SDK是一种用于取图的软件开发工具包,用于与LMI 3D相机进行交互并获取图像数据。 在使用LMI 3D相机SDK进行取图时,首先需要将SDK集成到开发环境中,例如使用C++开发的话,可以将SDK的库文件引入到项目中,并包含SDK的头文件。然后,可以使用SDK提供的函数和方法来进行图像的获取操作。 通过LMI 3D相机SDK,可以实现不同的取图操作,如实时图像流获取、单张图像采集、连续图像采集等。具体的取图方式和参数可根据开发需求进行设置和调整。 在进行取图操作之前,需要连接LMI 3D相机,并确保相机的正常工作。可以使用SDK提供的函数进行相机的初始化和连接。然后,可以使用SDK提供的函数开始取图操作,如调用图像采集函数、设置图像分辨率和图像格式等。 获取到图像数据后,可以进行进一步的处理和分析。可以使用SDK提供的图像处理函数进行图像的滤波、校正、增强等操作,以便得到更准确和清晰的图像结果。 总之,LMI 3D相机SDK提供了丰富的功能和方法,可以方便地进行图像的获取和处理。开发人员可以根据具体需求,使用SDK进行多种类型的取图操作,并通过对图像数据的处理和分析,实现各种应用和算法的开发

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值