-
Notifications
You must be signed in to change notification settings - Fork 7
/
ConnectToCamera.cpp
48 lines (39 loc) · 1.32 KB
/
ConnectToCamera.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "MechEyeApi.h"
#include "SampleUtil.h"
#include <iostream>
int main()
{
std::cout << "Find Mech-Eye device..." << std::endl;
std::vector<mmind::api::MechEyeDeviceInfo> deviceInfoList =
mmind::api::MechEyeDevice::enumerateMechEyeDeviceList();
if (deviceInfoList.empty()) {
std::cout << "No Mech-Eye device found." << std::endl;
return -1;
}
for (int i = 0; i < deviceInfoList.size(); i++) {
std::cout << "Mech-Eye device index : " << i << std::endl;
printDeviceInfo(deviceInfoList[i]);
}
std::cout << "Please enter the device index you want to connect: ";
unsigned inputIndex;
while (1) {
std::string str;
std::cin >> str;
if (isNumber(str) && atoi(str.c_str()) < deviceInfoList.size()) {
inputIndex = atoi(str.c_str());
break;
}
std::cout << "Input invalid! Please enter the device index you want to connect: ";
}
mmind::api::ErrorStatus status;
mmind::api::MechEyeDevice device;
status = device.connect(deviceInfoList[inputIndex]);
if (!status.isOK()) {
showError(status);
return -1;
}
std::cout << "Connect Mech-Eye Success." << std::endl;
device.disconnect();
std::cout << "Disconnect Mech-Eye Success." << std::endl;
return 0;
}