迁移指南(从2.1.0版本到2.2.0版本)

您正在查看最新版本(V2.4.1)的文档。如果您想查阅其他版本的文档,可以点击页面右上角“切换版本”按钮进行切换。

■ 如果您不确定当前使用的产品是哪个版本,请随时联系梅卡曼德技术支持。

Mech-Eye API 2.2.0进行了重构,在保留原有的全部功能的基础上,调整为更加清晰的结构,并提供新增功能。

本章列出Mech-Eye API 2.2.0相对于Mech-Eye API 2.1.0的主要变更,如希望在已有客户端程序中使用2.2.0版本的Mech-Eye API,可参考本章修改客户端程序。

导入模块

Mech-Eye API 2.2.0中,导入模块的语句发生以下变更:

2.1.0 2.2.0
  • C++

  • C#

  • Python

#include "MechEyeApi.h"

using namespace mmind::api;
using mmind.apiSharp;
from MechEye import Device
  • C++

  • C#

  • Python

#include "Camera.h"

using namespace mmind::eye;
using MMind.Eye;
from mecheye.shared import *
from mecheye.area_scan_3d_camera import *
from mecheye.area_scan_3d_camera_utils import *

创建相机对象

Mech-Eye API 2.2.0中,创建一个代表相机的对象的语句发生以下变更:

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::MechEyeDevice device;
var device = new MechEyeDevice();
device = Device()
  • C++

  • C#

  • Python

mmind::eye::Camera camera;
var camera = new Camera();
camera = Camera()

发现与连接相机

Mech-Eye API 2.2.0中,发现与连接相机的语句发生以下变更:

2.1.0 2.2.0
  • C++

  • C#

  • Python

std::vector<mmind::api::MechEyeDeviceInfo> deviceInfoList = mmind::api::MechEyeDevice::enumerateMechEyeDeviceList();

mmind::api::MechEyeDevice device;
device.connect(deviceInfoList[0]);
var deviceInfoList = MechEyeDevice.EnumerateMechEyeDeviceList();

var device = new MechEyeDevice();
device.Connect(deviceInfoList[0]);
device_list = Device.get_device_list()

device = Device()
device.connect(device_list[0])
  • C++

  • C#

  • Python

std::vector<mmind::eye::CameraInfo> cameraInfoList = mmind::eye::Camera::discoverCameras();

mmind::eye::Camera camera;
camera.connect(cameraInfoList[0]);
var cameraInfoList = Camera.DiscoverCameras();

var camera = new Camera();
camera.Connect(cameraInfoList[0]);
camera_infos = Camera.discover_cameras()

camera = Camera()
camera.connect(camera_infos[0])

管理参数组

Mech-Eye API 2.2.0通过类对参数组和参数相关功能进行了分类和层级划分,详见类的功能层级。此处列举出常用功能的变更。

2.1.0 2.2.0
  • C++

  • C#

  • Python

std::vector<std::string> userSets;
device.getAllUserSets(userSets);

std::string currentUserSetName;
device.getCurrentUserSet(currentUserSet);

device.setCurrentUserSet(userSets.front());

device.addUserSet("NewSetting");

device.saveAllSettingsToUserSets();
var userSets = new List<string>();
device.GetAllUserSets(ref userSets);

std::string currentUserSetName = "";
device.GetCurrentUserSet(ref currentUserSetName);

device.SetCurrentUserSet(userSets[0])

device.AddUserSet("NewSetting");

device.SaveAllSettingsToUserSets();
# Obtain the names of all parameter groups.
user_sets = device.get_all_user_sets()

# Get the name of the current parameter group.
current_user_set = device.get_current_user_set()

# Select a parameter group.
device.set_current_user_set(user_sets[0])

# Add a parameter group.
device.add_user_set("NewSetting")

# Save the current parameter settings to the parameter group.
device.save_all_settings_to_user_set()
  • C++

  • C#

  • Python

std::vector<std::string> userSets;
mmind::eye::UserSetManager& userSetManager = camera.userSetManager();
userSetManager.getAllUserSetNames(userSets);

mmind::eye::UserSet& curSettings = userSetManager.currentUserSet();
std::string currentName;
curSettings.getName(currentName);

userSetManager.selectUserSet(userSets.front());

userSetManager.addUserSet("NewSetting");

camera.currentUserSet().saveAllParametersToDevice();
var userSetManager = camera.UserSetManager();
var userSets = new List<string>();
userSetManager.GetAllUserSetNames(ref userSets);

var currentName = userSetManager.CurrentUserSet().GetName();

userSetManager.SelectUserSet(userSets[0]);

userSetManager.AddUserSet("NewSetting");

camera.CurrentUserSet().SaveAllParametersToDevice();
# Obtain the names of all parameter groups.
user_set_manager = camera.userSetManager()
error, user_sets = user_set_manager.get_all_user_set_names()

# Get the name of the current parameter group.
current_user_set = user_set_manager.current_user_set().get_name()

# Select a parameter group.
user_set_manager.select_user_set(user_sets[0])

# Add a parameter group.
user_set_manager.add_user_set("NewSetting")

# Save the current parameter settings to the parameter group.
camera.current_user_set().save_all_parameters_to_device()

设置与获取参数值

Mech-Eye API 2.2.0通过类对参数组和参数相关功能进行了分类和层级划分,详见类的功能层级

同时,Mech-Eye API 2.2.0按照参数的数据类型提供通用的方法,用于设置与获取参数值。

Mech-Eye API 2.2.0区分了以下参数数据类型:

  • _Int

  • _Float

  • _Bool

  • _Enum

  • _Roi

  • _Range

  • _FloatArray

以下小节给出各数据类型的示例。

_Int类型

点云后处理分组下的条纹对比度阈值参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setFringeContrastThreshold(15);

int fringeContrastThreshold = 0;
device.getFringeContrastThreshold(fringeContrastThreshold);
device.SetFringeContrastThreshold(15);

var fringeContrastThreshold = new int();
device.GetFringeContrastThreshold(ref fringeContrastThreshold);
device.set_fringe_contrast_threshold(15)

fringe_contrast_threshold = device.get_fringe_contrast_threshold()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/PointCloudProcessing.h"

camera.currentUserSet().setIntValue(mmind::eye::pointcloud_processing_setting::FringeContrastThreshold::name, 15);

int fringeContrastThreshold = 0;
camera.currentUserSet().getIntValue(mmind::eye::pointcloud_processing_setting::FringeContrastThreshold::name, fringeContrastThreshold);
camera.CurrentUserSet().SetIntValue(MMind.Eye.PointCloudProcessingSetting.FringeContrastThreshold.Name, 15);

var fringeContrastThreshold = new int();
camera.CurrentUserSet().GetIntValue(MMind.Eye.PointCloudProcessingSetting.FringeContrastThreshold.Name, ref fringeContrastThreshold);
camera.current_user_set().set_int_value(PointCloudFringeContrastThreshold.name, 15)

error, fringe_contrast_threshold = camera.current_user_set().get_int_value(PointCloudFringeContrastThreshold.name)

_Float类型

2D参数分组下的曝光时间参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setScan2DExposureTime(100);

double scan2DExposureTime = 0;
device.getScan2DExposureTime(scan2DExposureTime);
device.setScan2DExposureTime(100);

var scan2DExposureTime = new double();
device.GetScan2DExposureTime(ref scan2DExposureTime);
device.set_scan_2d_exposure_time(100)

scan_2d_exposure_time = device.get_scan_2d_exposure_time()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/Scanning2D.h"

camera.currentUserSet().setFloatValue(mmind::eye::scanning2d_setting::ExposureTime::name, 100);

double scan2DExposureTime = 0;
camera.currentUserSet().getFloatValue(mmind::eye::scanning2d_setting::ExposureTime::name, scan2DExposureTime);
camera.CurrentUserSet().SetFloatValue(MMind.Eye.Scanning2DSetting.ExposureTime.Name, true);

var scan2DExposureTime = new double();
camera.CurrentUserSet().GetFloatValue(MMind.Eye.Scanning2DSetting.ExposureTime.Name, ref scan2DExposureTime);
camera.current_user_set().set_float_value(Scanning2DExposureTime.name, 100)

error, scan_2d_exposure_time = camera.current_user_set().get_float_value(Scanning2DExposureTime.name)

_Bool类型

2D参数分组下的色调映射参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setScan2DToneMappingEnable(true);

bool toneMappingEnable = false;
device.getScan2DToneMappingEnable(toneMappingEnable);
device.SetScan2DToneMappingEnable(true);

var toneMappingEnable = new bool();
device.GetScan2DToneMappingEnable(ref toneMappingEnable);
device.set_scan_2d_tone_mapping_enable(True)

tone_mapping_enable = device.get_scan_2d_tone_mapping_enable()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/Scanning2D.h"

camera.currentUserSet().setBoolValue(mmind::eye::scanning2d_setting::ToneMappingEnable::name, true);

bool toneMappingEnable = false;
camera.currentUserSet().getBoolValue(mmind::eye::scanning2d_setting::ToneMappingEnable::name, toneMappingEnable);
camera.CurrentUserSet().SetBoolValue(MMind.Eye.Scanning2DSetting.ToneMappingEnable.Name, true);

var toneMappingEnable = new bool();
camera.CurrentUserSet().GetBoolValue(MMind.Eye.Scanning2DSetting.ToneMappingEnable.Name, ref toneMappingEnable);
camera.current_user_set().set_bool_value(Scanning2DToneMappingEnable.name, True)

error, tone_mapping_enable = camera.current_user_set().get_bool_value(Scanning2DToneMappingEnable.name)

_Enum类型

点云后处理分组中的表面平滑参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setCloudSurfaceSmoothingMode(mmind::api::PointCloudProcessingSettings::PointCloudSurfaceSmoothing::Normal);

mmind::api::PointCloudProcessingSettings::PointCloudSurfaceSmoothing surfaceSmoothing;
device.getCloudSurfaceSmoothingMode(surfaceSmoothing);
device.SetCloudSurfaceSmoothingMode(PointCloudSurfaceSmoothing.Normal);

var surfaceSmoothingMode = new PointCloudSurfaceSmoothing();
device.GetCloudSurfaceSmoothingMode(ref surfaceSmoothingMode);
device.set_cloud_surface_smoothing_mode("Normal")
cloud_surface_smoothing_mode = device.get_cloud_surface_smoothing_mode()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/PointCloudProcessing.h"

camera.currentUserSet().setEnumValue(mmind::eye::pointcloud_processing_setting::SurfaceSmoothing::name,
        static_cast<int>(mmind::eye::pointcloud_processing_setting::SurfaceSmoothing::Value::Normal));

int surfaceSmoothing = 0;
camera.currentUserSet().currentUserSet.getEnumValue(mmind::eye::pointcloud_processing_setting::SurfaceSmoothing::name, surfaceSmoothing);
camera.currentUserSet().SetEnumValue(MMind.Eye.PointCloudProcessingSetting.SurfaceSmoothing.Name, (int)MMind.Eye.PointCloudProcessingSetting.SurfaceSmoothing.Value.Normal);

var surfaceSmoothingMode = new int();
camera.currentUserSet().GetEnumValue(MMind.Eye.PointCloudProcessingSetting.SurfaceSmoothing.Name, ref surfaceSmoothingMode);
camera.current_user_set().set_enum_value(PointCloudSurfaceSmoothing.name, PointCloudSurfaceSmoothing.Value_Normal)
error, cloud_surface_smoothing_mode = camera.current_user_set().get_enum_value(PointCloudSurfaceSmoothing.name)

_Roi类型

感兴趣区域参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setScan3DROI(mmind::api::ROI(0, 0, 500, 500));

mmind::api::ROI roi;
device.getScan3DROI(roi);
device.SetScan3DROI(new ROI(0, 0, 500, 500));

var roi = new ROI();
device.GetScan3DROI(ref roi);
device.set_scan_3d_roi(0, 0, 500, 500)

roi = device.get_scan_3d_roi()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/Scanning3D.h"

camera.currentUserSet().setRoiValue(mmind::eye::scanning3d_setting::ROI::name, mmind::eye::ROI(0, 0, 500, 500));

mmind::eye::ROI roi;
camera.currentUserSet().getRoiValue(mmind::eye::scanning3d_setting::ROI::name, roi);
camera.CurrentUserSet().SetRoiValue(MMind.Eye.Scanning3DSetting.ROI.Name, new ROI(0, 0, 500, 500));

var roi = new ROI();
camera.CurrentUserSet().GetRoiValue(MMind.Eye.Scanning3DSetting.ROI.Name, ref roi);
camera.current_user_set().set_roi_value(Scanning3DROI.name, ROI(0, 0, 500, 500))

error, roi = camera.current_user_set().get_roi_value(Scanning3DROI.name)

_Range类型

深度范围参数为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setDepthRange(mmind::api::DepthRange(100, 2000));

mmind::api::DepthRange depthRange;
device.getDepthRange(depthRange);
device.SetDepthRange(new DepthRange(100, 2000));

val depthRange = new DepthRange();
device.GetDepthRange(ref depthRange);
device.set_depth_range(100, 2000)

depth_range = device.get_depth_range()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/Scanning3D.h"

camera.currentUserSet().setRangeValue(mmind::eye::scanning3d_setting::DepthRange::name, mmind::eye::Range<int>{100, 2000});

mmind::eye::Range<int> rangeValue;
camera.currentUserSet().getRangeValue(mmind::eye::scanning3d_setting::DepthRange::name, rangeValue);
camera.CurrentUserSet().SetRangeValue(MMind.Eye.Scanning3DSetting.DepthRange.Name, new IntRange(100, 2000));

var range = new IntRange();
camera.CurrentUserSet().GetRangeValue(MMind.Eye.Scanning3DSetting.DepthRange.Name, ref range);
camera.current_user_set().set_range_value(Scanning3DDepthRange.name, RangeInt(100, 1000))

error, range = camera.current_user_set().get_range_value(Scanning3DDepthRange.name)

_FloatArray类型

3D参数分组中的多个曝光时间为例。

2.1.0 2.2.0
  • C++

  • C#

  • Python

device.setScan3DExposure(std::vector<double>{5, 10});

std::vector<double> exposureSequence;
device.getScan3DExposure(exposureSequence);
device.SetScan3DExposure(new List<double> { 5, 10 });

var exposureSequence = new List<double>();
device.GetScan3DExposure(ref exposureSequence);
device.set_scan_3d_exposure([5.0, 10.0])

exposure_sequence = device.get_scan_3d_exposure()
  • C++

  • C#

  • Python

#include "area_scan_3d_camera/parameters/Scanning3D.h"

camera.currentUserSet().setFloatArrayValue(mmind::eye::scanning3d_setting::ExposureSequence::name, std::vector<double>{5, 10});

std::vector<double> exposureSequence;
camera.currentUserSet().getFloatArrayValue(mmind::eye::scanning3d_setting::ExposureSequence::name, exposureSequence);
camera.CurrentUserSet().SetFloatArrayValue(MMind.Eye.Scanning3DSetting.ExposureSequence.Name, new List<double> { 5, 10 });

var exposureSequence = new List<double>();
camera.CurrentUserSet().GetFloatArrayValue(MMind.Eye.Scanning3DSetting.ExposureSequence.Name, ref exposureSequence);
camera.current_user_set().set_float_array_value(Scanning3DExposureSequence.name, [5, 10])

error, exposure_sequence = camera.current_user_set().get_float_array_value(Scanning3DExposureSequence.name)

采集数据

Mech-Eye API 2.2.0中,采集数据的语句发生以下变更:

采集2D图

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::ColorMap color;
device.captureColorMap(color);
var color = new ColorMap();
device.CaptureColorMap(ref color);
color_map = device.capture_color()
  • C++

  • C#

  • Python

mmind::eye::Frame2D frame2D;
camera.capture2D(frame2D);
mmind::eye::Color2DImage color = frame3D.getColorImage();
var frame = new Frame2D();
camera.Capture2D(ref frame);
var color = frame.GetColorImage();
frame_2d = Frame2D()
camera.capture_2d(frame_2d)
color = frame.get_color_image()

采集深度图

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::DepthMap depth;
device.captureDepthMap(depth);
var depth = new DepthMap();
device.CaptureDepthMap(ref depth);
depth_map = device.capture_depth()
  • C++

  • C#

  • Python

mmind::eye::Frame3D frame3D;
camera.capture3D(frame3D);
mmind::eye::DepthMap depth = frame3D.getDepthMap();
var frame = new Frame3D();
camera.Capture3D(ref frame);
var depth = frame.GetDepthMap();
frame_3d = Frame3D()
camera.capture_3d(frame_3d)
depth = frame_3d.get_depth_map()

采集无纹理点云

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::PointXYZMap pointXYZMap;
device.capturePointXYZMap(pointXYZMap);
var pointXYZMap = new PointXYZMap();
device.CapturePointXYZMap(ref pointXYZMap);
points_xyz = device.capture_point_xyz()
  • C++

  • C#

  • Python

mmind::eye::Frame3D frame3D;
camera.capture3D(frame3D);
mmind::eye::PointCloud cloud = frame3D.getUntexturedPointCloud();
var frame = new Frame3D();
camera.Capture3D(ref frame);
var cloud = frame.GetUntexturedPointCloud();
frame_3d = Frame3D()
camera.capture_3d(frame_3d)
cloud = frame_3d.get_untextured_point_cloud()

采集纹理点云

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::PointXYZBGRMap pointXYZBGRMap;
device.capturePointXYZBGRMap(pointXYZBGRMap);
var pointXYZBGRMap = new PointXYZBGRMap();
device.CapturePointXYZBGRMap(ref pointXYZBGRMap)
points_xyz_bgr = device.capture_point_xyz_bgr()
  • C++

  • C#

  • Python

mmind::eye::Frame2DAnd3D frame2DAnd3D;
camera.capture2DAnd3D(frame2DAnd3D);
mmind::eye::TexturedPointCloud cloud = frame2DAnd3D.getTexturedPointCloud();
var frame = new Frame2DAnd3D();
camera.Capture2DAnd3D(ref frame);
var cloud = frame.GetTexturedPointCloud();
frame = Frame2DAnd3D()
camera.capture_2d_and_3d(frame)
cloud = frame.get_textured_point_cloud()

获取相机的信息和属性

Mech-Eye API 2.2.0通过类对相机的各类信息和属性进行了分类。详见类的功能层级

获取相机信息

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::MechEyeDeviceInfo deviceInfo;
device.getDeviceInfo(deviceInfo);

std::string model = deviceInfo.model;
std::string serialNumber = deviceInfo.id;
std::string firmwareVersion = deviceInfo.firmwareVersion;
var deviceInfo = new MechEyeDeviceInfo();
device.GetDeviceInfo(ref deviceInfo);

var model = deviceInfo.model;
var serialNumber = deviceInfo.id;
var firmwareVersion = deviceInfo.firmwareVersion;
device_info = device.get_device_info()
  • C++

  • C#

  • Python

mmind::eye::CameraInfo cameraInfo;
camera.getCameraInfo(cameraInfo);

std::string model = cameraInfo.model;
std::string serialNumber = cameraInfo.serialNumber;
std::string firmwareVersion = cameraInfo.firmwareVersion.toString();
var cameraInfo = new CameraInfo();
camera.GetCameraInfo(ref cameraInfo);

var model = cameraInfo.Model;
var serialNumber = cameraInfo.SerialNumber;
var firmwareVersion = cameraInfo.FirmwareVersion.ToString();
camera_info = CameraInfo()
camera.get_camera_info(camera_info)

获取相机温度

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::DeviceTemperature devicetemperature;
device.getDeviceTemperature(devicetemperature);

float cpu = devicetemperature.cpuTemperature;
float projector = devicetemperature.projectorModuleTemperature;
var temperature = new DeviceTemperature();
device.GetDeviceTemperature(ref temperature);

var cpu = temperature.cpu;
var projector = temperature.projectorModule;
device_temperature = device.get_device_temperature()

cpu = device_temperature.cpu_temperature()
projector = device_temperature.projector_module_temperature()
  • C++

  • C#

  • Python

mmind::eye::CameraStatus cameraStatus;
camera.getCameraStatus(cameraStatus);

float cpu = cameraStatus.temperature.cpuTemperature;
float projector = cameraStatus.temperature.projectorTemperature;
var cameraStatus = new CameraStatus();
camera.GetCameraStatus(ref cameraStatus);

var cpu = cameraStatus.Temperature.CpuTemperature;
var projector = cameraStatus.Temperature.ProjectorModuleTemperature;
camera_status = CameraStatus()
camera.get_camera_status(camera_status)

cpu = camera_status.temperature.cpu_temperature
projector = camera_status.temperature.projector_module_temperature

获取图像分辨率

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::DeviceResolution deviceResolution;
device.getDeviceResolution(deviceResolution);

unsigned int textureWidth = deviceResolution.colorMapWidth;
unsigned int textureHeight = deviceResolution.colorMapHeight;
unsigned int depthWidth = deviceResolution.depthMapWidth;
unsigned int depthHeight = deviceResolution.depthMapHeight;
var deviceResolution = new DeviceResolution();
device.GetDeviceResolution(ref deviceResolution);

var textureWidth = deviceResolution.colorMapWidth;
var textureHeight = deviceResolution.colorMapHeight;
var depthWidth = deviceResolution.depthMapWidth;
var depthHeight = deviceResolution.depthMapHeight;
device_resolution = device.get_device_resolution()

texture_width = device_resolution.color_width()
texture_height = device_resolution.color_height()
depth_width = device_resoution.depth_width()
depth_height = device_resolution.depth_height()
  • C++

  • C#

  • Python

mmind::eye::CameraResolutions cameraResolutions;
camera.getCameraResolutions(cameraResolutions);

unsigned int textureWidth = cameraResolutions.texture.width;
unsigned int textureHeight = cameraResolutions.texture.height;
unsigned int depthWidth = cameraResolutions.depth.width;
unsigned int depthHeight = cameraResolutions.depth.height;
var cameraResolutions = new CameraResolutions();
camera.GetCameraResolutions(ref cameraResolutions);

var textureWidth = cameraResolutions.Texture.Width;
var textureHeight = cameraResolutions.Texture.Height;
var depthWidth = cameraResolutions.Depth.Width;
var depthHeight = cameraResolutions.Depth.Height;
camera_resolutions = CameraResolutions()
camera.get_camera_resolutions(camera_resolutions)

texture_width = camera_resolutions.texture.width
texture_height = camera_resolutions.texture.height
depth_width = camera_resolutions.depth.width
depth_height = camera_resolutions.depth.height

获取相机内参

2.1.0 2.2.0
  • C++

  • C#

  • Python

mmind::api::DeviceIntri deviceIntri;
device.getDeviceIntri(deviceIntri);

const mmind::eye::CameraIntri textureIntri = deviceIntri.textureCameraIntri;

const double fx = textureIntri.cameraMatrix[0];
const double fy = textureIntri.cameraMatrix[1];
const double cx = textureIntri.cameraMatrix[2];
const double cy = textureIntri.cameraMatrix[3];

const double k1 = textureIntri.distortion[0];
const double k2 = textureIntri.distortion[1];
const double p1 = textureIntri.distortion[2];
const double p2 = textureIntri.distortion[3];
const double k3 = textureIntri.distortion[4];
var deviceIntri = new DeviceIntri();
device.GetDeviceIntri(ref deviceIntri);

var textureCameraIntri = deviceIntri.textureCameraIntri;

const double fx = textureCameraIntri.fx;
const double fy = textureCameraIntri.fy;
const double cx = textureCameraIntri.cx;
const double cy = textureCameraIntri.cy;

const double k1 = textureCameraIntri.k1;
const double k2 = textureCameraIntri.k2;
const double p1 = textureCameraIntri.p1;
const double p2 = textureCameraIntri.p2;
const double k3 = textureCameraIntri.k3;
device_intri = device.get_device_intrinsic()

texture_intri = device_intri.texture_camera_intrinsic()

fx = texture_intri.camera_matrix_fx()
fy = textrue_intri.camera_matrix_fy()
cx = texture_intri.camera_matrix_cx()
cy = texture_intri.camera_matrix_cy()

k1 = texture_intri.dist_coeffs_k1()
k2 = texture_intri.dist_coeffs_k2()
p1 = texture_intri.dist_coeffs_p1()
p2 = texture_intri.dist_coeffs_p2()
k3 = texture_intri.dist_coeffs_k3()
  • C++

  • C#

  • Python

mmind::eye::CameraIntrinsics intrinsics;
camera.getCameraIntrinsics(intrinsics);

const mmind::eye::Intrinsics2dCamera textureIntrinsics = intrinsics.texture;
const mmind::eye::CameraMatrix cameraMatrix = textureIntrinsics.cameraMatrix;
const double fx = cameraMatrix.fx;
const double fy = cameraMatrix.fy;
const double cx = cameraMatrix.cx;
const double cy = cameraMatrix.cy;

const mmind::eye::CameraDistortion distCoeffs = intrinsics.texture.cameraDistortion;
const double k1 = distCoeffs.k1;
const double k2 = distCoeffs.k2;
const double p1 = distCoeffs.p1;
const double p2 = distCoeffs.p2;
const double k3 = distCoeffs.k3;
var intrinsics = new CameraIntrinsics();
camera.GetCameraIntrinsics(ref intrinsics);

var textureIntrinsics = intrinsics.Texture;

const double fx = textureIntrinsics.CameraMatrix.Fx;
const double fy = textureIntrinsics.CameraMatrix.Fy;
const double cx = textureIntrinsics.CameraMatrix.Cx;
const double cy = textureIntrinsics.CameraMatrix.Cy;

const double k1 = textureIntrinsics.CameraDistortion.K1;
const double k2 = textureIntrinsics.CameraDistortion.K2;
const double p1 = textureIntrinsics.CameraDistortion.P1;
const double p2 = textureIntrinsics.CameraDistortion.P2;
const double k3 = textureIntrinsics.CameraDistortion.K3;
intrinsics = CameraIntrinsics()
camera.get_camera_intrinsics(intrinsics)

texture_intrinsics = intrinsics.texture
camera_matrix = texture_intrinsics.camera_matrix
fx = camera_matrix.fx
fy = camera_matrix.fy
cx = camera_matrix.cx
cy = camera_matrix.cy

camera_distortion = texture_intrinsics.camera_distortion
k1 = camera_distortion.k1
k2 = camera_distortion.k2
p1 = camera_distortion.p1
p2 = camera_distortion.p2
k3 = camera_distortion.k3

新增功能

Mech-Eye API 2.2.0新增了多个便捷的新功能。

如需使用以下新增功能,则必须参考本章修改客户端程序,以应用2.2.0版本的Mech-Eye API。

计算点云法向量

调用以下新增方法,可直接获取包含法向量的3D数据,减少后续数据处理的工作量。

获取带法向量的无纹理点云

  • C++

  • C#

  • Python

mmind::eye::Frame3D frame3D;
camera.capture3DWithNormal(frame3D);

PointCloudWithNormals pointCloud = frame3D.getUntexturedPointCloudWithNormals();
var frame3D = new Frame3D();
camera.Capture3DWithNormal(ref frame3D);

var pointCloud = frame3D.GetUntexturedPointCloudWithNormals();
frame_3d = Frame3D()
camera.capture_3d_with_normal(frame_3d)

point_cloud = frame_3d.get_untextured_point_cloud_with_normals()

获取带法向量的纹理点云

  • C++

  • C#

  • Python

mmind::eye::Frame2DAnd3D frame2DAnd3D;
camera.capture2DAnd3DWithNormal(frame2DAnd3D);

TexturedPointCloudWithNormals pointCloud = frame2DAnd3D.getTexturedPointCloudWithNormals();
var frame2DAnd3D = new Frame2DAnd3D();
camera.Capture2DAnd3DWithNormal(ref frame2DAnd3D);

var pointCloud = frame2DAnd3D.GetTexturedPointCloudWithNormals();
frame_2d_and_3d = Frame2DAnd3D()
camera.capture_2d_and_3d_with_normal(frame_2d_and_3d)

point_cloud = frame_2d_and_3d.get_textured_point_cloud_with_normals()

保存点云

调用以下新增方法,可直接保存PLY、PCD或CSV格式的点云,无需依赖第三方软件库。

保存无纹理点云

  • C++

  • C#

  • Python

mmind::eye::Frame3D frame3D;
camera.capture3D(frame3D);

frame3D.saveUntexturedPointCloud(mmind::eye::FileFormat::PLY, "PointCloud.ply");
var frame3D = new frame3D();
camera.Capture3D(ref frame3D);

frame3D.SaveUntexturedPointCloud(FileFormat.PLY, "PointCloud.ply");
frame_3d = Frame3D()
camera.capture_3d(frame_3d)

frame_3d.save_untextured_point_cloud(FileFormat_PLY, "PointCloud.ply")

保存纹理点云

  • C++

  • C#

  • Python

mmind::eye::Frame2DAnd3D frame2DAnd3D;
camera.capture2DAnd3D(frame2DAnd3D);

frame2DAnd3D.saveTexturedPointCloud(mmind::eye::FileFormat::PLY, "TexturedPointCloud.ply");
var frame2DAnd3D = new Frame2DAnd3D();
camera.Capture2DAnd3D(ref frame2DAnd3D);

frame2DAnd3D.SaveTexturedPointCloud(FileFormat.PLY, "TexturedPointCloud.ply");
frame_2d_and_3d = Frame2DAnd3D()
camera.capture_2d_and_3d(frame_2d_and_3d)

frame_2d_and_3d.save_textured_point_cloud(FileFormat_PLY, "TexturedPointCloud.ply")

导入与导出参数组

调用以下新增方法,可将所有参数组保存为JSON文件,或从JSON文件导入并替换所有参数组。

导入参数组

  • C++

  • C#

  • Python

camera.userSetManager().loadFromFile("camera_config.json");
camera.UserSetManager().LoadFromFile("camera_config.json");
camera.user_set_manager().load_from_file("camera_config.json")
  • C++

  • C#

  • Python

camera.userSetManager().saveToFile("camera_config.json");
camera.UserSetManager().SaveToFile("camera_config.json");
camera.user_set_manager().save_to_file("camera_config.json")

检测相机连接状态

新增心跳信号发送机制,可用于检测相机断开连接的问题。

设置心跳信号的频率

通过以下方法可设置心跳信号的频率:

  • C++

  • C#

  • Python

camera.setHeartbeatInterval(1000);
camera.SetHeartbeatInterval(1000);
camera.set_heartbeat_interval(1000)

注册回调函数

通过以下方法注册回调函数,可自动检测到相机断开连接的情况并提供报错:

  • C++

  • C#

  • Python

mmind::eye::CameraEvent::EventCallback callback = [](mmind::eye::CameraEvent::Event event, void* pUser) {
        std::cout << "A camera event has occurred. The event ID is " << event << "." << std::endl;
    };

mmind::eye::CameraEvent::registerCameraEventCallback(camera, callback, nullptr, mmind::eye::CameraEvent::CAMERA_EVENT_DISCONNECTED);
private static void CallbackFunc(CameraEvent.Event cameraEvent, IntPtr pUser)
{
    Console.WriteLine("A camera event has occurred. The event ID is {0}.", cameraEvent);
}

Utils.ShowError(CameraEvent.RegisterCameraEventCallback(ref camera, CallbackFunc, IntPtr.Zero, (uint)CameraEvent.Event.CAMERA_EVENT_DISCONNECTED));
class CustomCallback(EventCallbackBase):
    def __init__(self):
        super().__init__()

    def run(self, event):
        print("A camera event has occurred. The event ID is {0}.".format(event))

camera_event = CameraEvent()
callback = CustomCallback()
show_error(camera_event.register_camera_event_callback(camera, callback, CameraEvent.CAMERA_EVENT_ALL))

我们重视您的隐私

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