Update for tutoyials
This commit is contained in:
parent
f59c918e81
commit
61b0d85292
|
@ -124,7 +124,6 @@ make_executable2(ctrl_manual_exposure
|
||||||
SRCS control/manual_exposure.cc util/cv_painter.cc
|
SRCS control/manual_exposure.cc util/cv_painter.cc
|
||||||
WITH_OPENCV
|
WITH_OPENCV
|
||||||
)
|
)
|
||||||
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
|
|
||||||
|
|
||||||
# intermediate level
|
# intermediate level
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,19 @@ int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api)
|
||||||
return 1;
|
return 1;
|
||||||
|
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||||
|
|
||||||
// auto-exposure: 0
|
// auto-exposure: 0
|
||||||
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||||
|
|
||||||
// max_gain: range [0,48], default 48
|
// max_gain: range [0,255], default 8
|
||||||
api->SetOptionValue(Option::MAX_GAIN, 48);
|
api->SetOptionValue(Option::MAX_GAIN, 8);
|
||||||
// max_exposure_time: range [0,240], default 240
|
// max_exposure_time: range [0,1000], default 333
|
||||||
api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 240);
|
api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 333);
|
||||||
// desired_brightness: range [0,255], default 192
|
// desired_brightness: range [1,255], default 122
|
||||||
api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 192);
|
api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 122);
|
||||||
|
// min_exposure_time: range [0,1000], default 0
|
||||||
|
api->SetOptionValue(Option::MIN_EXPOSURE_TIME, 0);
|
||||||
|
|
||||||
LOG(INFO) << "Enable auto-exposure";
|
LOG(INFO) << "Enable auto-exposure";
|
||||||
LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN);
|
LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN);
|
||||||
|
@ -41,10 +44,12 @@ int main(int argc, char *argv[]) {
|
||||||
<< api->GetOptionValue(Option::MAX_EXPOSURE_TIME);
|
<< api->GetOptionValue(Option::MAX_EXPOSURE_TIME);
|
||||||
LOG(INFO) << "Set DESIRED_BRIGHTNESS to "
|
LOG(INFO) << "Set DESIRED_BRIGHTNESS to "
|
||||||
<< api->GetOptionValue(Option::DESIRED_BRIGHTNESS);
|
<< api->GetOptionValue(Option::DESIRED_BRIGHTNESS);
|
||||||
|
LOG(INFO) << "Set MIN_EXPOSURE_TIME to "
|
||||||
|
<< api->GetOptionValue(Option::MIN_EXPOSURE_TIME);
|
||||||
|
|
||||||
api->Start(Source::VIDEO_STREAMING);
|
api->Start(Source::VIDEO_STREAMING);
|
||||||
|
|
||||||
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE));
|
CVPainter painter(30);
|
||||||
|
|
||||||
cv::namedWindow("frame");
|
cv::namedWindow("frame");
|
||||||
|
|
||||||
|
|
|
@ -22,22 +22,11 @@
|
||||||
MYNTEYE_USE_NAMESPACE
|
MYNTEYE_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(Resolution::RES_1280x400);
|
||||||
|
// auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api)
|
||||||
return 1;
|
return 1;
|
||||||
|
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||||
// Attention: must set FRAME_RATE and IMU_FREQUENCY together, otherwise won't
|
|
||||||
// succeed.
|
|
||||||
|
|
||||||
// FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
|
|
||||||
api->SetOptionValue(Option::FRAME_RATE, 25);
|
|
||||||
// IMU_FREQUENCY values: 100, 200, 250, 333, 500
|
|
||||||
api->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
|
||||||
|
|
||||||
LOG(INFO) << "Set FRAME_RATE to " << api->GetOptionValue(Option::FRAME_RATE);
|
|
||||||
LOG(INFO) << "Set IMU_FREQUENCY to "
|
|
||||||
<< api->GetOptionValue(Option::IMU_FREQUENCY);
|
|
||||||
|
|
||||||
// Count img
|
// Count img
|
||||||
std::atomic_uint img_count(0);
|
std::atomic_uint img_count(0);
|
||||||
api->SetStreamCallback(
|
api->SetStreamCallback(
|
||||||
|
@ -46,13 +35,6 @@ int main(int argc, char *argv[]) {
|
||||||
++img_count;
|
++img_count;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Count imu
|
|
||||||
std::atomic_uint imu_count(0);
|
|
||||||
api->SetMotionCallback([&imu_count](const api::MotionData &data) {
|
|
||||||
CHECK_NOTNULL(data.imu);
|
|
||||||
++imu_count;
|
|
||||||
});
|
|
||||||
|
|
||||||
api->Start(Source::ALL);
|
api->Start(Source::ALL);
|
||||||
|
|
||||||
cv::namedWindow("frame");
|
cv::namedWindow("frame");
|
||||||
|
@ -85,7 +67,5 @@ int main(int argc, char *argv[]) {
|
||||||
<< ", cost: " << elapsed_ms << "ms";
|
<< ", cost: " << elapsed_ms << "ms";
|
||||||
LOG(INFO) << "Img count: " << img_count
|
LOG(INFO) << "Img count: " << img_count
|
||||||
<< ", fps: " << (1000.f * img_count / elapsed_ms);
|
<< ", fps: " << (1000.f * img_count / elapsed_ms);
|
||||||
LOG(INFO) << "Imu count: " << imu_count
|
|
||||||
<< ", hz: " << (1000.f * imu_count / elapsed_ms);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
// 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.
|
|
||||||
#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;
|
|
||||||
|
|
||||||
// Detect infrared add-ons
|
|
||||||
LOG(INFO) << "Support infrared: " << std::boolalpha
|
|
||||||
<< api->Supports(AddOns::INFRARED);
|
|
||||||
LOG(INFO) << "Support infrared2: " << std::boolalpha
|
|
||||||
<< api->Supports(AddOns::INFRARED2);
|
|
||||||
|
|
||||||
// Get infrared intensity range
|
|
||||||
auto &&info = api->GetOptionInfo(Option::IR_CONTROL);
|
|
||||||
LOG(INFO) << Option::IR_CONTROL << ": {" << info << "}";
|
|
||||||
|
|
||||||
// Set infrared intensity value
|
|
||||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
|
@ -24,25 +24,20 @@ int main(int argc, char *argv[]) {
|
||||||
auto &&api = API::Create(argc, argv);
|
auto &&api = API::Create(argc, argv);
|
||||||
if (!api)
|
if (!api)
|
||||||
return 1;
|
return 1;
|
||||||
|
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||||
|
|
||||||
// manual-exposure: 1
|
// manual-exposure: 1
|
||||||
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
||||||
|
|
||||||
// gain: range [0,48], default 24
|
|
||||||
api->SetOptionValue(Option::GAIN, 24);
|
|
||||||
// brightness/exposure_time: range [0,240], default 120
|
// brightness/exposure_time: range [0,240], default 120
|
||||||
api->SetOptionValue(Option::BRIGHTNESS, 120);
|
api->SetOptionValue(Option::BRIGHTNESS, 120);
|
||||||
// contrast/black_level_calibration: range [0,255], default 127
|
|
||||||
api->SetOptionValue(Option::CONTRAST, 127);
|
|
||||||
|
|
||||||
LOG(INFO) << "Enable manual-exposure";
|
LOG(INFO) << "Enable manual-exposure";
|
||||||
LOG(INFO) << "Set GAIN to " << api->GetOptionValue(Option::GAIN);
|
|
||||||
LOG(INFO) << "Set BRIGHTNESS to " << api->GetOptionValue(Option::BRIGHTNESS);
|
LOG(INFO) << "Set BRIGHTNESS to " << api->GetOptionValue(Option::BRIGHTNESS);
|
||||||
LOG(INFO) << "Set CONTRAST to " << api->GetOptionValue(Option::CONTRAST);
|
|
||||||
|
|
||||||
api->Start(Source::VIDEO_STREAMING);
|
api->Start(Source::VIDEO_STREAMING);
|
||||||
|
|
||||||
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE));
|
CVPainter painter(30);
|
||||||
|
|
||||||
cv::namedWindow("frame");
|
cv::namedWindow("frame");
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ std::shared_ptr<Device> select() {
|
||||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
LOG(INFO) << "MYNT EYE devices:";
|
LOG(INFO) << "MYNT EYE devices:";
|
||||||
for (size_t i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
auto &&device = devices[i];
|
auto &&device = devices[i];
|
||||||
|
@ -44,7 +44,7 @@ std::shared_ptr<Device> select() {
|
||||||
<< ", name: " << device->GetInfo(Info::DEVICE_NAME)
|
<< ", name: " << device->GetInfo(Info::DEVICE_NAME)
|
||||||
<< ", sn: " << device->GetInfo(Info::SERIAL_NUMBER);
|
<< ", sn: " << device->GetInfo(Info::SERIAL_NUMBER);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
std::shared_ptr<Device> device = nullptr;
|
std::shared_ptr<Device> device = nullptr;
|
||||||
if (n <= 1) {
|
if (n <= 1) {
|
||||||
device = devices[0];
|
device = devices[0];
|
||||||
|
|
|
@ -348,9 +348,10 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||||
api_->EnableStreamData(Stream::POINTS);
|
api_->EnableStreamData(Stream::POINTS);
|
||||||
api_->SetStreamCallback(
|
api_->SetStreamCallback(
|
||||||
Stream::POINTS, [this](const api::StreamData &data) {
|
Stream::POINTS, [this](const api::StreamData &data) {
|
||||||
|
ros::Time stamp = hardTimeToSoftTime(data.img->timestamp);
|
||||||
static std::size_t count = 0;
|
static std::size_t count = 0;
|
||||||
++count;
|
++count;
|
||||||
publishPoints(data, count, ros::Time::now());
|
publishPoints(data, count, stamp);
|
||||||
});
|
});
|
||||||
is_published_[Stream::POINTS] = true;
|
is_published_[Stream::POINTS] = true;
|
||||||
}
|
}
|
||||||
|
@ -367,10 +368,10 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||||
api_->EnableStreamData(stream);
|
api_->EnableStreamData(stream);
|
||||||
api_->SetStreamCallback(
|
api_->SetStreamCallback(
|
||||||
stream, [this, stream](const api::StreamData &data) {
|
stream, [this, stream](const api::StreamData &data) {
|
||||||
// data.img is null, not hard timestamp
|
ros::Time stamp = hardTimeToSoftTime(data.img->timestamp);
|
||||||
static std::size_t count = 0;
|
static std::size_t count = 0;
|
||||||
++count;
|
++count;
|
||||||
publishCamera(stream, data, count, ros::Time::now());
|
publishCamera(stream, data, count, stamp);
|
||||||
});
|
});
|
||||||
is_published_[stream] = true;
|
is_published_[stream] = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user