Merge branch 'release/v2.4.0' of http://gitlab.mynt.com/mynteye/mynt-eye-s-sdk into release/v2.4.0
This commit is contained in:
commit
d041f22d7e
|
@ -252,6 +252,11 @@ class MYNTEYE_API API {
|
||||||
*/
|
*/
|
||||||
void SetOptionValue(const Option &option, std::int32_t value);
|
void SetOptionValue(const Option &option, std::int32_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the option value.
|
||||||
|
*/
|
||||||
|
bool SetOptionValue(const Option &option, std::uint64_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the option action.
|
* Run the option action.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -223,6 +223,10 @@ class MYNTEYE_API Device {
|
||||||
* Set the option value.
|
* Set the option value.
|
||||||
*/
|
*/
|
||||||
void SetOptionValue(const Option &option, std::int32_t value);
|
void SetOptionValue(const Option &option, std::int32_t value);
|
||||||
|
/**
|
||||||
|
* Set the option value.
|
||||||
|
*/
|
||||||
|
bool SetOptionValue(const Option &option, std::uint64_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the option action.
|
* Run the option action.
|
||||||
|
|
|
@ -125,6 +125,7 @@ make_executable2(ctrl_imu_low_pass_filter SRCS control/imu_low_pass_filter.cc WI
|
||||||
make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV)
|
make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV)
|
||||||
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
|
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
|
||||||
make_executable2(ctrl_iic_adress SRCS control/iic_address.cc WITH_OPENCV)
|
make_executable2(ctrl_iic_adress SRCS control/iic_address.cc WITH_OPENCV)
|
||||||
|
make_executable2(ctrl_sync_timestamp SRCS control/sync_timestamp.cc WITH_OPENCV)
|
||||||
make_executable2(ctrl_auto_exposure
|
make_executable2(ctrl_auto_exposure
|
||||||
SRCS control/auto_exposure.cc util/cv_painter.cc
|
SRCS control/auto_exposure.cc util/cv_painter.cc
|
||||||
WITH_OPENCV
|
WITH_OPENCV
|
||||||
|
|
56
samples/tutorials/control/sync_timestamp.cc
Normal file
56
samples/tutorials/control/sync_timestamp.cc
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#include <opencv2/highgui/highgui.hpp>
|
||||||
|
|
||||||
|
#include "mynteye/logger.h"
|
||||||
|
#include "mynteye/api/api.h"
|
||||||
|
|
||||||
|
MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
auto &&api = API::Create(argc, argv);
|
||||||
|
if (!api) return 1;
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
auto &&request = api->SelectStreamRequest(&ok);
|
||||||
|
if (!ok) return 1;
|
||||||
|
api->ConfigStreamRequest(request);
|
||||||
|
|
||||||
|
Model model = api->GetModel();
|
||||||
|
|
||||||
|
if (model != Model::STANDARD200B) {
|
||||||
|
LOG(INFO) << "Sorry, This device don't support sync timestamp";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model == Model::STANDARD200B) {
|
||||||
|
std::uint64_t value = 10;
|
||||||
|
auto ok = api->SetOptionValue(Option::SYNC_TIMESTAMP, value);
|
||||||
|
if (ok) {
|
||||||
|
LOG(INFO) << "Set timestamp is successful.";
|
||||||
|
} else {
|
||||||
|
LOG(INFO) << "Set timestamp is failed.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
api->Start(Source::VIDEO_STREAMING);
|
||||||
|
|
||||||
|
cv::namedWindow("frame");
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
api->WaitForStreams();
|
||||||
|
|
||||||
|
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||||
|
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||||
|
|
||||||
|
cv::Mat img;
|
||||||
|
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||||
|
cv::imshow("frame", img);
|
||||||
|
|
||||||
|
char key = static_cast<char>(cv::waitKey(1));
|
||||||
|
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
api->Stop(Source::VIDEO_STREAMING);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -368,6 +368,10 @@ void API::SetOptionValue(const Option &option, std::int32_t value) {
|
||||||
device_->SetOptionValue(option, value);
|
device_->SetOptionValue(option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool API::SetOptionValue(const Option &option, std::uint64_t value) {
|
||||||
|
return device_->SetOptionValue(option, value);
|
||||||
|
}
|
||||||
|
|
||||||
bool API::RunOptionAction(const Option &option) const {
|
bool API::RunOptionAction(const Option &option) const {
|
||||||
return device_->RunOptionAction(option);
|
return device_->RunOptionAction(option);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ int XuHalfDuplexId(Option option) {
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case Option::SYNC_TIMESTAMP:
|
case Option::SYNC_TIMESTAMP:
|
||||||
return 2;
|
return 3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG(FATAL) << "No half duplex id for " << option;
|
LOG(FATAL) << "No half duplex id for " << option;
|
||||||
|
@ -332,7 +332,7 @@ bool Channels::SetControlValue(const Option &option, std::uint64_t value) {
|
||||||
LOG(WARNING) << option << " set value useless";
|
LOG(WARNING) << option << " set value useless";
|
||||||
break;
|
break;
|
||||||
case Option::SYNC_TIMESTAMP:
|
case Option::SYNC_TIMESTAMP:
|
||||||
return XuHalfDuplexSet(option, XU_SYNC_TIMESTAMP);
|
return XuHalfDuplexSet(option, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG(ERROR) << "Unsupported option " << option;
|
LOG(ERROR) << "Unsupported option " << option;
|
||||||
|
@ -719,6 +719,29 @@ bool Channels::XuHalfDuplexSet(Option option, xu_cmd_t cmd) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Channels::XuHalfDuplexSet(Option option, std::uint64_t value) const {
|
||||||
|
int id = XuHalfDuplexId(option);
|
||||||
|
std::uint8_t data[20] = {static_cast<std::uint8_t>(id & 0xFF),
|
||||||
|
static_cast<std::uint8_t>(value & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 8) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 16) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 24) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 32) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 40) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 48) & 0xFF),
|
||||||
|
static_cast<std::uint8_t>((value >> 56) & 0xFF)};
|
||||||
|
|
||||||
|
if (XuControlQuery(CHANNEL_HALF_DUPLEX, uvc::XU_QUERY_SET, 20, data)) {
|
||||||
|
VLOG(2) << "XuHalfDuplexSet value (0x" << std::hex << std::uppercase << value
|
||||||
|
<< ") of " << option << " success";
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
LOG(WARNING) << "XuHalfDuplexSet value (0x" << std::hex << std::uppercase
|
||||||
|
<< value << ") of " << option << " failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Channels::XuImuWrite(const ImuReqPacket &req) const {
|
bool Channels::XuImuWrite(const ImuReqPacket &req) const {
|
||||||
auto &&data = req.to_data();
|
auto &&data = req.to_data();
|
||||||
if (XuControlQuery(
|
if (XuControlQuery(
|
||||||
|
|
|
@ -112,6 +112,7 @@ class MYNTEYE_API Channels {
|
||||||
void XuCamCtrlSet(Option option, std::int32_t value) const;
|
void XuCamCtrlSet(Option option, std::int32_t value) const;
|
||||||
|
|
||||||
bool XuHalfDuplexSet(Option option, xu_cmd_t cmd) const;
|
bool XuHalfDuplexSet(Option option, xu_cmd_t cmd) const;
|
||||||
|
bool XuHalfDuplexSet(Option option, std::uint64_t value) const;
|
||||||
|
|
||||||
bool XuImuWrite(const ImuReqPacket &req) const;
|
bool XuImuWrite(const ImuReqPacket &req) const;
|
||||||
bool XuImuRead(ImuResPacket *res) const;
|
bool XuImuRead(ImuResPacket *res) const;
|
||||||
|
|
|
@ -381,6 +381,14 @@ void Device::SetOptionValue(const Option &option, std::int32_t value) {
|
||||||
channels_->SetControlValue(option, value);
|
channels_->SetControlValue(option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::SetOptionValue(const Option &option, std::uint64_t value) {
|
||||||
|
if (!Supports(option)) {
|
||||||
|
LOG(WARNING) << "Unsupported option: " << option;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return channels_->SetControlValue(option, value);
|
||||||
|
}
|
||||||
|
|
||||||
bool Device::RunOptionAction(const Option &option) const {
|
bool Device::RunOptionAction(const Option &option) const {
|
||||||
if (!Supports(option)) {
|
if (!Supports(option)) {
|
||||||
LOG(WARNING) << "Unsupported option: " << option;
|
LOG(WARNING) << "Unsupported option: " << option;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user