42#include "CameraProperties.h"
43#include "ErrorStatus.h"
44#include "CommonTypes.h"
49 std::cout <<
"............................." << std::endl;
50 std::cout <<
"Model: " << cameraInfo.
model << std::endl;
52 const auto consoleCP = GetConsoleOutputCP();
53 SetConsoleOutputCP(CP_UTF8);
55 std::cout <<
"Device name: " << cameraInfo.
deviceName << std::endl;
57 SetConsoleOutputCP(consoleCP);
59 std::cout <<
"Serial number: " << cameraInfo.
serialNumber << std::endl;
60 std::cout <<
"IP address: " << cameraInfo.
ipAddress << std::endl;
61 std::cout <<
"Subnet mask: " << cameraInfo.
subnetMask << std::endl;
62 std::cout <<
"IP address assignment method: "
64 std::cout <<
"Hardware version: "
66 std::cout <<
"Firmware version: "
68 std::cout <<
"Support status: "
69 << (cameraInfo.
supported ?
"Supported" :
"Unsupported") << std::endl;
71 std::cout <<
"Last supported version: "
74 std::cout <<
"............................." << std::endl;
75 std::cout << std::endl;
80 std::cout <<
".....Camera temperatures....." << std::endl;
81 std::cout << std::fixed << std::setprecision(1);
82 std::cout <<
"CPU: " << cameraStatus.temperature.
cpuTemperature <<
"°C" << std::endl;
85 std::cout <<
"............................" << std::endl;
86 std::cout << std::defaultfloat << std::setprecision(6);
87 std::cout << std::endl;
93 std::cout <<
".....Image resolutions....." << std::endl;
94 std::cout <<
"2D image (texture): " << cameraResolutions.texture.width <<
" (width) × "
95 << cameraResolutions.texture.height <<
" (height)" << std::endl;
96 std::cout <<
"Depth map: " << cameraResolutions.depth.width <<
" (width) × "
97 << cameraResolutions.depth.height <<
" (height)" << std::endl;
100inline void printCameraMatrix(
const std::string& title,
103 std::cout << title <<
": " << std::endl
104 <<
" [" << cameraMatrix.
fx <<
", " << 0 <<
", " << cameraMatrix.
cx <<
"]"
107 <<
" [" << 0 <<
", " << cameraMatrix.
fy <<
", " << cameraMatrix.
cy <<
"]"
110 <<
" [" << 0 <<
", " << 0 <<
", " << 1 <<
"]" << std::endl;
111 std::cout << std::endl;
114inline void printCameraDistCoeffs(
const std::string& title,
117 std::cout << title <<
": " << std::endl
118 <<
" k1: " << distCoeffs.
k1 <<
", k2: " << distCoeffs.
k2
119 <<
", p1: " << distCoeffs.
p1 <<
", p2: " << distCoeffs.
p2 <<
", k3: " << distCoeffs.
k3
121 std::cout << std::endl;
126 std::cout <<
"Rotation: " << title <<
": " << std::endl;
127 for (
int i = 0; i < 3; i++) {
129 for (
int j = 0; j < 3; j++) {
130 std::cout << transform.
rotation[i][j];
134 std::cout <<
"]" << std::endl;
136 std::cout << std::endl;
137 std::cout <<
"Translation " << title <<
": " << std::endl;
139 <<
"mm, Z: " << transform.
translation[2] <<
"mm" << std::endl;
140 std::cout << std::endl;
145 printCameraMatrix(
"Texture 2D camera matrix", intrinsics.
texture.cameraMatrix);
146 printCameraDistCoeffs(
"Texture 2D camera distortion coefficients",
147 intrinsics.
texture.cameraDistortion);
149 printCameraMatrix(
"Depth 2D camera matrix", intrinsics.
depth.cameraMatrix);
150 printCameraDistCoeffs(
"Depth 2D camera distortion coefficients",
151 intrinsics.
depth.cameraDistortion);
153 printTransform(
"Transformation from depth 2D camera to texture 2D camera",
159 std::cout <<
"Looking for available cameras..." << std::endl;
162 if (deviceInfoList.empty()) {
163 std::cout <<
"No cameras are available." << std::endl;
167 for (
size_t i = 0; i < deviceInfoList.size(); i++) {
168 std::cout <<
"Mech-Eye device index: " << i << std::endl;
169 printCameraInfo(deviceInfoList[i]);
172 std::cout <<
"Enter the index of the device to which you want to connect: ";
173 unsigned inputIndex = 0;
178 if (std::regex_match(str.begin(), str.end(), std::regex{
"[0-9]+"}) &&
179 atoi(str.c_str()) <
static_cast<int>(deviceInfoList.size())) {
180 inputIndex = atoi(str.c_str());
183 std::cout <<
"The entered index is invalid. Please enter the device index again: ";
187 status = device.
connect(deviceInfoList[inputIndex]);
189 if (!status.
isOK()) {
194 std::cout <<
"Successfully connected to the camera." << std::endl;
198inline std::vector<mmind::eye::Camera> findAndConnectMultiCamera()
200 std::cout <<
"Looking for available cameras..." << std::endl;
203 if (cameraInfoList.empty()) {
204 std::cout <<
"No cameras are available." << std::endl;
208 for (
size_t i = 0; i < cameraInfoList.size(); i++) {
209 std::cout <<
"Mech-Eye device index: " << i << std::endl;
210 printCameraInfo(cameraInfoList[i]);
214 std::set<unsigned> indices;
217 std::cout <<
"Enter the indices of the devices to which you want to connect: " << std::endl;
218 std::cout <<
"Enter the character \"c\" at the end of all the indices" << std::endl;
223 if (std::regex_match(str.begin(), str.end(), std::regex{
"[0-9]+"}) &&
224 atoi(str.c_str()) <
static_cast<int>(cameraInfoList.size()))
225 indices.insert(atoi(str.c_str()));
227 std::cout <<
"The entered indices are invalid. Please enter the device indices again: ";
230 std::vector<mmind::eye::Camera> cameraList{};
232 for (
const auto index : indices) {
234 auto status = camera.
connect(cameraInfoList[index]);
236 cameraList.push_back(camera);
244inline bool confirmCapture3D()
247 <<
"Do you want the camera to capture 3D data? Enter \"y\" to confirm or \"n\" to cancel: "
250 std::string confirmStr;
251 std::cin >> confirmStr;
252 if (confirmStr ==
"y") {
254 }
else if (confirmStr ==
"n") {
255 std::cout <<
"The capture command was canceled." << std::endl;
258 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.
bool isEmpty() const
Checks if a Version object is empty.
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).
bool supported
The support status of the device.
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.
Version lastSupportedVersion
The last supported version 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.