Add some resolution,format and frame rate.

This commit is contained in:
Kalman
2018-08-05 23:18:51 +08:00
parent b139fd21c3
commit 33d3f15b86
13 changed files with 205 additions and 75 deletions

View File

@@ -24,7 +24,8 @@ int main(int argc, char *argv[]) {
auto &&api = API::Create(argc, argv);
if (!api)
return 1;
api->SetStreamRequest(
Resolution::RES_2560x800, Format::YUYV, FrameRate::RATE_20_FPS);
// api->SetOptionValue(Option::FRAME_RATE, 25);
// api->SetOptionValue(Option::IMU_FREQUENCY, 500);
api->SetOptionValue(Option::IR_CONTROL, 80);
@@ -105,7 +106,7 @@ int main(int argc, char *argv[]) {
auto &&motion_datas = api->GetMotionDatas();
motion_count += motion_datas.size();
for (auto &&data : motion_datas) {
for (auto &&data : motion_datas) {
LOG(INFO) << ", timestamp: " << data.imu->timestamp
<< ", accel_x: " << data.imu->accel[0]
<< ", accel_y: " << data.imu->accel[1]

View File

@@ -50,6 +50,8 @@ int main(int argc, char *argv[]) {
// device->RunOptionAction(Option::ZERO_DRIFT_CALIBRATION);
std::size_t left_count = 0;
device->SetStreamRequest(
Resolution::RES_2560x800, Format::YUYV, FrameRate::RATE_30_FPS);
device->SetStreamCallback(
Stream::LEFT, [&left_count](const device::StreamData &data) {
CHECK_NOTNULL(data.img);
@@ -75,7 +77,7 @@ int main(int argc, char *argv[]) {
device->SetMotionCallback([&imu_count](const device::MotionData &data) {
CHECK_NOTNULL(data.imu);
++imu_count;
VLOG(2) << "Imu count: " << imu_count;
VLOG(2) << "Imu count: " << imu_count;
VLOG(2) << ", timestamp: " << data.imu->timestamp
<< ", accel_x: " << data.imu->accel[0]
<< ", accel_y: " << data.imu->accel[1]
@@ -101,7 +103,7 @@ int main(int argc, char *argv[]) {
auto &&motion_datas = device->GetMotionDatas();
motion_count += motion_datas.size();
for (auto &&data : motion_datas) {
for (auto &&data : motion_datas) {
LOG(INFO) << ", timestamp: " << data.imu->timestamp
<< ", accel_x: " << data.imu->accel[0]
<< ", accel_y: " << data.imu->accel[1]

View File

@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) {
const auto frame_empty = [&frame]() { return frame == nullptr; };
uvc::set_device_mode(
*device, 1280, 480, static_cast<int>(Format::YUYV), 25,
*device, 1280, 400, static_cast<int>(Format::RGB888), 20,
[&mtx, &cv, &frame, &frame_ready](
const void *data, std::function<void()> continuation) {
// reinterpret_cast<const std::uint8_t *>(data);
@@ -143,8 +143,8 @@ int main(int argc, char *argv[]) {
}
// only lastest frame is valid
cv::Mat img(480, 1280, CV_8UC2, const_cast<void *>(frame->data));
cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2);
cv::Mat img(400, 1280, CV_8UC3, const_cast<void *>(frame->data));
// cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2);
cv::imshow("frame", img);
frame = nullptr;