使用流程

本章介绍使用Mech-Eye API控制相机的基本流程。本章图片及描述中使用C++ Mech-Eye API的类和方法名称,不同语言的对应名称详见代码示例。

operation workflow

发现

调用Camera类中的discoverCameras()方法枚举当前可连接的全部相机,并获取各个相机的信息。

  • C++

  • C#

  • Python

std::vector<mmind::eye::CameraInfo> cameraInfoList = mmind::eye::Camera::discoverCameras();
var cameraInfoList = Camera.DiscoverCameras();
camera_info_list = Camera.discover_cameras()

连接

实例化Camera类后,调用该类中的connect()方法,通过IP地址或由discoverCameras()方法获取的设备信息连接对应的相机。

  • C++

  • C#

  • Python

mmind::eye::Camera camera;
mmind::eye::ErrorStatus status = camera.connect(cameraInfoList[inputIndex]);
mmind::eye::Camera cameras;
mmind::eye::ErrorStatus status = camera.connect("192.168.0.10");
var camera = new Camera();
var status = camera.Connect(cameraInfoList[inputIndex]);
var camera = new Camera();
var status = camera.Connect("192.168.0.10");
camera = Camera()
camera.connect("192.168.0.10")

配置

调用UserSetManager类和UserSet类中的方法,选择相机的参数组并调节参数。

  1. 调用UserSetManager类中的selectUserSet方法选择需使用的参数组。

    可通过该类中的getAllUserSetNames()方法获取相机所有可用参数组。
    • C++

    • C#

    • Python

    mmind::eye::UserSetManager userSetManager = camera.userSetManager();
    std::vector<std::string> userSets;
    auto status = userSetManager.getAllUserSetNames(userSets);
    status = userSetManager.selectUserSet(userSets.front());
    var userSetManager = camera.UserSetManager();
    List<string> userSets = new List<string>();
    var status = userSetManager.GetAllUserSetNames(ref userSets);
    status = userSetManager.SelectUserSet(userSets[0]);
    user_set_manager = camera.userSetManager()
    error, user_sets = user_set_manager.get_all_user_set_names()
    user_set_manager.select_user_set(user_sets[0])
  2. 调用UserSet类中的getAvailableParameters()方法获取当前参数组中的全部参数信息,并确认各个参数的数据类型。

    • C++

    • C#

    • Python

    mmind::eye::UserSet currentUserSet = camera.currentUserSet();
    std::vector<Parameter*> parameters = currentUserSet.getAvailableParameters();
    var currentUserSet = camera.CurrentUserSet();
    var parameters = currentUserSet.GetAvailableParameters();
    current_user_set = camera.current_user_set()
    arameters = current_user_set.get_available_parameters()
  3. 调用UserSet类中的getIntValue()及类似方法,获取某一参数当前的值。

    • C++

    • C#

    • Python

    int fringeContrastThreshold = 0;
    currentUserSet.getIntValue(mmind::eye::pointcloud_processing_setting::FringeContrastThreshold::name, fringeContrastThreshold);
    var fringeContrastThreshold = new int();
    camera.CurrentUserSet().GetIntValue(MMind.Eye.PointCloudProcessingSetting.FringeContrastThreshold.Name, ref fringeContrastThreshold);
    error, fringe_contrast_threshold = current_user_set.get_int_value(PointCloudFringeContrastThreshold.name)
  4. 调用UserSet类中的setIntValue()及类似方法,设置某一参数的值。

    • C++

    • C#

    • Python

    auto status = currentUserSet.setIntValue(mmind::eye::pointcloud_processing_setting::FringeContrastThreshold::name, 15);
    var status = currentUserSet.SetIntValue(MMind.Eye.PointCloudProcessingSetting.FringeContrastThreshold.Name, 15);
    status = current_user_set.set_int_value(PointCloudFringeContrastThreshold.name, 15)
  5. 调用UserSet类中的saveAllParametersToDevice()方法,将设置的参数值保存至相机中。

    • C++

    • C#

    • Python

    auto status = currentUserSet.SaveAllParametersToDevice();
    var status = currentUserSet.SaveAllParametersToDevice();
    status = current_user_set.save_all_parameters_to_device()

采集和获取数据

Mech-Eye API提供多种方法用于采集和获取数据,可单独采集2D或3D数据,也可同时采集2D和3D数据。

  • 采集并获取用于生成2D图的数据:

    • C++

    • C#

    • Python

    mmind::eye::Frame2D frame2D;
    camera.capture2D(frame2D);
    mmind::eye::Color2DImage color = frame2D.getColorImage();
    mmind::eye::GrayScale2DImage gray= frame2D.getGrayScaleImage();
    var frame = new Frame2D();
    camera.Capture2D(ref frame);
    var color = frame.GetColorImage();
    var gray = frame.GetGrayScaleImage();
    frame_2d = Frame2D()
    camera.capture_2d(frame_2d)
    color = frame.get_color_image()
    gray = frame.get_gray_scale_image()
  • 采集并获取用于生成深度图和无纹理点云的数据:

    • C++

    • C#

    • Python

    mmind::eye::Frame3D frame3D;
    camera.capture3D(frame3D);
    mmind::eye::DepthMap depth = frame3D.getDepthMap();
    mmind::eye::PointCloud cloud= frame3D.getUntexturedPointCloud();
    var frame = new Frame3D();
    camera.Capture3D(ref frame);
    var depth = frame.GetDepthMap();
    var cloud = frame.GetUntexturedPointCloud();
    frame_3d = Frame3D()
    camera.capture_3d(frame_3d)
    depth = frame.get_depth_map()
    cloud = frame_3d.get_untextured_point_cloud()
  • 采集并获取用于生成2D图、深度图和纹理点云的数据:

    • C++

    • C#

    • Python

    mmind::eye::Frame2DAnd3D frame2DAnd3D;
    camera.capture2DAnd3D(frame2DAnd3D);
    mmind::eye::Color2DImage color = frame2DAnd3D.frame2D().getColorImage();
    mmind::eye::DepthMap depth = frame2DAnd3D.frame3D().getDepthMap();
    mmind::eye::TexturedPointCloud cloud = frame2DAnd3D.getTexturedPointCloud();
    var frame = new Frame2DAnd3D();
    camera.Capture2DAnd3D(ref frame);
    var color = frame2DAnd3D.Frame2D().GetColorImage();
    var depth = frame2DAnd3D.Frame3D().GetDepthMap();
    var cloud = frame2DAnd3D.GetTexturedPointCloud();
    frame = Frame2DAnd3D()
    camera.capture_2d_and_3d(frame)
    color = frame.frame_2d().get_color_image()
    depth = frame.frame_3d().get_depth_image()
    cloud = frame.get_textured_point_cloud()
  • 采集并获取用于生成深度图和含法向量的无纹理点云的数据:

    • C++

    • C#

    • Python

    mmind::eye::Frame3D frame3D;
    camera.capture3DWithNormal(frame3D);
    mmind::eye::DepthMap depth = frame3D.getDepthMap();
    PointCloudWithNormals pointCloud = frame3D.getUntexturedPointCloudWithNormals();
    var frame3D = new Frame3D();
    camera.Capture3DWithNormal(ref frame3D);
    var depth = frame3D.GetDepthMap();
    var pointCloud = frame3D.GetUntexturedPointCloudWithNormals();
    frame_3d = Frame3D()
    camera.capture_3d_with_normal(frame_3d)
    depth = frame_3d.get_depth_map()
    point_cloud = frame_3d.get_untextured_point_cloud_with_normals()
  • 采集并获取用于生成2D图、深度图和含法向量的纹理点云的数据:

    • C++

    • C#

    • Python

    mmind::eye::Frame2DAnd3D frame2DAnd3D;
    camera.capture2DAnd3DWithNormal(frame2DAnd3D);
    mmind::eye::Color2DImage color = frame2DAnd3D.frame2D().getColorImage();
    mmind::eye::DepthMap depth = frame2DAnd3D.frame3D().getDepthMap();
    TexturedPointCloudWithNormals pointCloud = frame2DAnd3D.getTexturedPointCloudWithNormals();
    var frame2DAnd3D = new Frame2DAnd3D();
    camera.Capture2DAnd3DWithNormal(ref frame2DAnd3D);
    var color = frame2DAnd3D.Frame2D().GetColorImage();
    var depth = frame2DAnd3D.Frame3D().GetDepthMap();
    var pointCloud = frame2DAnd3D.GetTexturedPointCloudWithNormals();
    frame_2d_and_3d = Frame2DAnd3D()
    camera.capture_2d_and_3d_with_normal(frame_2d_and_3d)
    color = frame_2d_and_3d.frame_2d().get_color_image()
    depth = frame_2d_and_3d.frame_3d().get_depth_map()
    point_cloud = frame_2d_and_3d.get_textured_point_cloud_with_normals()

断开连接

调用Camera类中的disconnect()方法,断开与当前相机的连接。

  • C++

  • C#

  • Python

camera.disconnect();
camera.Disconnect();
camera.disconnect()

本章介绍了使用Mech-Eye API控制相机的基本流程。下一章提供Mech-Eye API的参考手册。

我们重视您的隐私

我们使用 cookie 为您在我们的网站上提供最佳体验。继续使用该网站即表示您同意使用 cookie。如果您拒绝,将使用一个单独的 cookie 来确保您在访问本网站时不会被跟踪或记住。