Move select device to utils

This commit is contained in:
John Zhao
2018-04-20 12:44:23 +08:00
parent a3f90d31c7
commit 3899b020b8
5 changed files with 78 additions and 66 deletions

View File

@@ -3,8 +3,8 @@
#include "mynteye/glog_init.h"
#include "mynteye/context.h"
#include "mynteye/device.h"
#include "mynteye/utils.h"
#include "mynteye/times.h"
@@ -15,38 +15,7 @@ MYNTEYE_USE_NAMESPACE
int main(int argc, char *argv[]) {
glog_init _(argc, argv);
LOG(INFO) << "Detecting MYNT EYE devices";
Context context;
auto &&devices = context.devices();
size_t n = devices.size();
LOG_IF(FATAL, n <= 0) << "No MYNT EYE devices :(";
LOG(INFO) << "MYNT EYE devices:";
for (size_t i = 0; i < n; i++) {
auto &&device = devices[i];
auto &&name = device->GetInfo(Info::DEVICE_NAME);
LOG(INFO) << " index: " << i << ", name: " << name;
}
std::shared_ptr<Device> device = nullptr;
if (n <= 1) {
device = devices[0];
LOG(INFO) << "Only one MYNT EYE device, select index: 0";
} else {
while (true) {
size_t i;
LOG(INFO) << "There are " << n << " MYNT EYE devices, select index: ";
std::cin >> i;
if (i >= n) {
LOG(WARNING) << "Index out of range :(";
continue;
}
device = devices[i];
break;
}
}
auto &&device = device::select();
/*
{ // auto-exposure
device->SetOptionValue(Option::EXPOSURE_MODE, 0);