Log error and return if no devices
This commit is contained in:
parent
276406dd1e
commit
de0f0d0639
|
@ -25,14 +25,22 @@ class Device;
|
|||
|
||||
namespace device {
|
||||
|
||||
/** Detecting MYNT EYE devices and prompt user to select one */
|
||||
/**
|
||||
* Detecting MYNT EYE devices and prompt user to select one.
|
||||
* @return the selected device, or `nullptr` if none.
|
||||
*/
|
||||
MYNTEYE_API std::shared_ptr<Device> select();
|
||||
|
||||
} // namespace device
|
||||
|
||||
namespace utils {
|
||||
|
||||
/** Get real exposure time in ms from virtual value, according to its frame rate
|
||||
/**
|
||||
* Get real exposure time in ms from virtual value, according to its frame rate.
|
||||
* @param frame_rate the frame rate of the device.
|
||||
* @param exposure_time the virtual exposure time.
|
||||
* @return the real exposure time in ms, or the virtual value if frame rate is
|
||||
* invalid.
|
||||
*/
|
||||
MYNTEYE_API float get_real_exposure_time(
|
||||
std::int32_t frame_rate, std::uint16_t exposure_time);
|
||||
|
|
|
@ -22,6 +22,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// api->SetOptionValue(Option::FRAME_RATE, 25);
|
||||
// api->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
||||
|
|
|
@ -27,6 +27,8 @@ int main(int argc, char *argv[]) {
|
|||
glog_init _(argc, argv);
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
/*
|
||||
{ // auto-exposure
|
||||
device->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
|
|
|
@ -23,6 +23,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// auto-exposure: 0
|
||||
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
|
|
|
@ -24,6 +24,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Attention: must set FRAME_RATE and IMU_FREQUENCY together, otherwise won't
|
||||
// succeed.
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Detect infrared add-ons
|
||||
LOG(INFO) << "Support infrared: " << std::boolalpha
|
||||
|
|
|
@ -23,6 +23,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// manual-exposure: 1
|
||||
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME);
|
||||
LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER);
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// api->EnableStreamData(Stream::DISPARITY);
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
|
|
|
@ -28,6 +28,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Attention: must not block the callbacks.
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
|
||||
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
|
||||
|
|
|
@ -23,6 +23,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Enable this will cache the motion datas until you get them.
|
||||
api->EnableMotionDatas();
|
||||
|
|
|
@ -19,6 +19,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Motion intrinsics: {" << api->GetMotionIntrinsics() << "}";
|
||||
LOG(INFO) << "Motion extrinsics left to imu: {"
|
||||
|
|
|
@ -23,6 +23,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::POINTS);
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||
|
|
|
@ -21,6 +21,8 @@ MYNTEYE_USE_NAMESPACE
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
|
||||
|
||||
|
|
|
@ -41,17 +41,24 @@ std::shared_ptr<API> API::Create() {
|
|||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(std::shared_ptr<Device> device) {
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||
static glog_init _(argc, argv);
|
||||
return std::make_shared<API>(device::select());
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device) {
|
||||
static glog_init _(argc, argv);
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,35 @@ class MYNTEYE_API API {
|
|||
explicit API(std::shared_ptr<Device> device);
|
||||
/*virtual*/ ~API();
|
||||
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @return the API instance.
|
||||
* @note This will call device::select() to select a device.
|
||||
*/
|
||||
static std::shared_ptr<API> Create();
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param device the selected device.
|
||||
* @return the API instance.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(std::shared_ptr<Device> device);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param argc the arg count.
|
||||
* @param argv the arg values.
|
||||
* @return the API instance.
|
||||
* @note This will init glog with args and call device::select() to select a
|
||||
* device.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(int argc, char *argv[]);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param argc the arg count.
|
||||
* @param argv the arg values.
|
||||
* @param device the selected device.
|
||||
* @return the API instance.
|
||||
* @note This will init glog with args.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device);
|
||||
|
||||
|
|
|
@ -28,7 +28,10 @@ std::shared_ptr<Device> select() {
|
|||
auto &&devices = context.devices();
|
||||
|
||||
size_t n = devices.size();
|
||||
LOG_IF(FATAL, n <= 0) << "No MYNT EYE devices :(";
|
||||
if (n <= 0) {
|
||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LOG(INFO) << "MYNT EYE devices:";
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
|
|
@ -29,6 +29,8 @@ int main(int argc, char *argv[]) {
|
|||
glog_init _(argc, argv);
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
/*
|
||||
{ // auto-exposure
|
||||
device->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
|
|
|
@ -32,6 +32,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
tools::DeviceWriter writer(device);
|
||||
writer.WriteDeviceInfo(filepath);
|
||||
|
|
|
@ -32,6 +32,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
tools::DeviceWriter writer(device);
|
||||
writer.WriteImgParams(filepath);
|
||||
|
|
|
@ -32,6 +32,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
tools::DeviceWriter writer(device);
|
||||
writer.WriteImuParams(filepath);
|
||||
|
|
|
@ -29,6 +29,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
dir.append(OS_SEP "SN").append(device->GetInfo()->serial_number);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user