41#include "CameraProperties.h"
42#include "ErrorStatus.h"
43#include "CommonTypes.h"
48 std::cout <<
"............................." << std::endl;
49 std::cout <<
"Model: " << cameraInfo.
model << std::endl;
51 const auto consoleCP = GetConsoleOutputCP();
52 SetConsoleOutputCP(CP_UTF8);
54 std::cout <<
"Device name: " << cameraInfo.
deviceName << std::endl;
56 SetConsoleOutputCP(consoleCP);
58 std::cout <<
"Serial number: " << cameraInfo.
serialNumber << std::endl;
59 std::cout <<
"IP address: " << cameraInfo.
ipAddress << std::endl;
60 std::cout <<
"Subnet mask: " << cameraInfo.
subnetMask << std::endl;
61 std::cout <<
"IP address assignment method: "
63 std::cout <<
"Hardware version: "
65 std::cout <<
"Firmware version: "
67 std::cout <<
"............................." << std::endl;
68 std::cout << std::endl;
73 std::cout <<
".....Camera temperatures....." << std::endl;
74 std::cout <<
"CPU: " << cameraStatus.temperature.
cpuTemperature <<
"°C" << std::endl;
77 std::cout <<
"............................" << std::endl;
79 std::cout << std::endl;
85 std::cout <<
".....Image resolutions....." << std::endl;
86 std::cout <<
"2D image (texture): " << cameraResolutions.texture.width <<
" (width) × "
87 << cameraResolutions.texture.height <<
" (height)" << std::endl;
88 std::cout <<
"Depth map: " << cameraResolutions.depth.width <<
" (width) × "
89 << cameraResolutions.depth.height <<
" (height)" << std::endl;
92inline void printCameraMatrix(
const std::string& title,
95 std::cout << title <<
": " << std::endl
96 <<
" [" << cameraMatrix.
fx <<
", " << 0 <<
", " << cameraMatrix.
cx <<
"]"
99 <<
" [" << 0 <<
", " << cameraMatrix.
fy <<
", " << cameraMatrix.
cy <<
"]"
102 <<
" [" << 0 <<
", " << 0 <<
", " << 1 <<
"]" << std::endl;
103 std::cout << std::endl;
106inline void printCameraDistCoeffs(
const std::string& title,
109 std::cout << title <<
": " << std::endl
110 <<
" k1: " << distCoeffs.
k1 <<
", k2: " << distCoeffs.
k2
111 <<
", p1: " << distCoeffs.
p1 <<
", p2: " << distCoeffs.
p2 <<
", k3: " << distCoeffs.
k3
113 std::cout << std::endl;
118 std::cout <<
"Rotation: " << title <<
": " << std::endl;
119 for (
int i = 0; i < 3; i++) {
121 for (
int j = 0; j < 3; j++) {
122 std::cout << transform.
rotation[i][j];
126 std::cout <<
"]" << std::endl;
128 std::cout << std::endl;
129 std::cout <<
"Translation " << title <<
": " << std::endl;
131 <<
"mm, Z: " << transform.
translation[2] <<
"mm" << std::endl;
132 std::cout << std::endl;
137 printCameraMatrix(
"Texture 2D camera matrix", intrinsics.
texture.cameraMatrix);
138 printCameraDistCoeffs(
"Texture 2D camera distortion coefficients",
139 intrinsics.
texture.cameraDistortion);
141 printCameraMatrix(
"Depth 2D camera matrix", intrinsics.
depth.cameraMatrix);
142 printCameraDistCoeffs(
"Depth 2D camera distortion coefficients",
143 intrinsics.
depth.cameraDistortion);
145 printTransform(
"Transformation from depth 2D camera to texture 2D camera",
151 std::cout <<
"Looking for available cameras..." << std::endl;
154 if (deviceInfoList.empty()) {
155 std::cout <<
"No cameras are available." << std::endl;
159 for (
int i = 0; i < deviceInfoList.size(); i++) {
160 std::cout <<
"Mech-Eye device index: " << i << std::endl;
161 printCameraInfo(deviceInfoList[i]);
164 std::cout <<
"Enter the index of the device to which you want to connect: ";
165 unsigned inputIndex = 0;
170 if (std::regex_match(str.begin(), str.end(), std::regex{
"[0-9]+"}) &&
171 atoi(str.c_str()) < deviceInfoList.size()) {
172 inputIndex = atoi(str.c_str());
175 std::cout <<
"The entered index is invalid. Please enter the device index again: ";
179 status = device.
connect(deviceInfoList[inputIndex]);
181 if (!status.
isOK()) {
186 std::cout <<
"Successfully connected to the camera." << std::endl;
190inline std::vector<mmind::eye::Camera> findAndConnectMultiCamera()
192 std::cout <<
"Looking for available cameras..." << std::endl;
195 if (cameraInfoList.empty()) {
196 std::cout <<
"No cameras are available." << std::endl;
200 for (
int i = 0; i < cameraInfoList.size(); i++) {
201 std::cout <<
"Mech-Eye device index: " << i << std::endl;
202 printCameraInfo(cameraInfoList[i]);
206 std::set<unsigned> indices;
209 std::cout <<
"Enter the indices of the devices to which you want to connect: " << std::endl;
210 std::cout <<
"Enter the character \"c\" at the end of all the indices" << std::endl;
215 if (std::regex_match(str.begin(), str.end(), std::regex{
"[0-9]+"}) &&
216 atoi(str.c_str()) < cameraInfoList.size())
217 indices.insert(atoi(str.c_str()));
219 std::cout <<
"The entered indices are invalid. Please enter the device indices again: ";
222 std::vector<mmind::eye::Camera> cameraList{};
224 auto iter = indices.cbegin();
225 for (
int i = 0; i < indices.size(); ++i, ++iter) {
227 auto status = camera.
connect(cameraInfoList[*iter]);
229 cameraList.push_back(camera);
237inline bool confirmCapture3D()
240 <<
"Do you want the camera to capture 3D data? Enter \"y\" to confirm or \"n\" to cancel: "
243 std::string confirmStr;
244 std::cin >> confirmStr;
245 if (confirmStr ==
"y") {
247 }
else if (confirmStr ==
"n") {
248 std::cout <<
"The capture command was canceled." << std::endl;
251 std::cout <<
"The entered character was invalid. Please enter \"y\" to confirm or "
Operates the camera. Use Camera::connect to connect an available camera, and then call the correspond...
static std::vector< CameraInfo > discoverCameras(unsigned int timeoutMs=5000)
Discovers all available cameras and returns the list of information of all available cameras....
ErrorStatus connect(const CameraInfo &info, unsigned int timeoutMs=5000)
Connects to a camera using CameraInfo.
std::string toString() const
Converts a Version object to a string.
Describes the distortion parameters.
double k1
Radial distortion coefficients.
double k3
Radial distortion coefficients.
double p2
Tangential distortion coefficients.
double k2
Radial distortion coefficients.
double p1
Tangential distortion coefficients.
Defines the camera information.
IpAssignmentMethod ipAssignmentMethod
The IP address assignment method of the device.
std::string serialNumber
The serial number of the device.
Version hardwareVersion
The version of the hardware (pre-determined in the factory).
std::string deviceName
The device name (UTF-8 encoded).
std::string model
The device model, such as Mech-Eye NANO.
Version firmwareVersion
The version of the firmware (upgradable).
std::string subnetMask
The subnet mask of the device.
std::string ipAddress
The IP address of the device.
Defines the 3D camera intrinsic parameters, including the intrinsic parameters of the texture 2D came...
Intrinsics2DCamera texture
Intrinsics2DCamera depth
The intrinsic parameters of the depth 2D camera(s) for capturing the depth map.
Transformation depthToTexture
Describes the camera intrinsic parameter matrix.
double cx
Principal point.
double cy
Principal point.
Defines the camera image resolutions, including the resolutions of the 2D image (texture) and depth m...
Describes the camera's statuses.
float projectorTemperature
The temperature (in °C) of the camera projector.
float cpuTemperature
The temperature (in °C) of the camera CPU.
Describes the types of errors.
bool isOK() const
Returns true if the operation succeeded.