MYNT-EYE-S-SDK/src/mynteye/device/context.cc

49 lines
1.5 KiB
C++
Raw Normal View History

2018-05-10 09:46:34 +03:00
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2018-10-27 16:24:04 +03:00
#include "mynteye/device/context.h"
2018-04-04 05:50:27 +03:00
2018-09-04 10:12:04 +03:00
#include "mynteye/logger.h"
2018-04-04 05:50:27 +03:00
2018-10-27 16:24:04 +03:00
#include "mynteye/device/device.h"
#include "mynteye/uvc/uvc.h"
2018-04-04 05:50:27 +03:00
MYNTEYE_BEGIN_NAMESPACE
Context::Context() : context_(uvc::create_context()) {
VLOG(2) << __func__;
for (auto &&device : uvc::query_devices(context_)) {
auto name = uvc::get_name(*device);
auto vid = uvc::get_vendor_id(*device);
auto pid = uvc::get_product_id(*device);
// auto video_name = uvc::get_video_name(*device);
2018-04-08 17:35:49 +03:00
VLOG(2) << "UVC device detected, name: " << name << ", vid: 0x" << std::hex
<< vid << ", pid: 0x" << std::hex << pid;
2018-04-04 05:50:27 +03:00
if (vid == MYNTEYE_VID) {
2018-04-04 06:38:36 +03:00
auto d = Device::Create(name, device);
if (d) {
devices_.push_back(d);
} else {
LOG(ERROR) << "Device is not supported by MYNT EYE.";
}
2018-04-04 05:50:27 +03:00
}
}
}
Context::~Context() {
VLOG(2) << __func__;
}
MYNTEYE_END_NAMESPACE