Limit values of frame rate and imu frequency

This commit is contained in:
John Zhao 2018-04-14 20:21:40 +08:00
parent 9fcbb066bb
commit 730d221637
3 changed files with 37 additions and 13 deletions

View File

@ -16,8 +16,8 @@
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 通道地址 | 说明 |
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----------- | :----- |
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | |
| IMU 频率 | imu_frequency | 2 | 200 | 200 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | |
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | 步进为5即有效值为{10,15,20,25,30,35,40,45,50,55,60} |
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | 有效值为{100,200,250,333,500} |
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0x0100 | 0开启自动曝光 1关闭 |
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |

View File

@ -5,6 +5,8 @@
#include <bitset>
#include <chrono>
#include <iomanip>
#include <iterator>
#include <sstream>
#include <stdexcept>
MYNTEYE_BEGIN_NAMESPACE
@ -152,6 +154,19 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) {
}
return true;
};
auto in_values = [&option, &value](std::vector<std::int32_t> values) {
if (std::find(values.begin(), values.end(), value) != values.end()) {
return true;
} else {
std::ostringstream ss;
std::copy(
values.begin(), values.end(),
std::ostream_iterator<std::int32_t>(ss, ","));
LOG(WARNING) << option << " set value invalid, must be {" << ss.str()
<< "}";
return false;
}
};
switch (option) {
case Option::GAIN:
case Option::BRIGHTNESS:
@ -162,8 +177,17 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) {
LOG(WARNING) << option << " set value failed";
}
} break;
case Option::FRAME_RATE:
case Option::IMU_FREQUENCY:
case Option::FRAME_RATE: {
if (!in_range() ||
!in_values({10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60}))
break;
XuCamCtrlSet(option, value);
} break;
case Option::IMU_FREQUENCY: {
if (!in_range() || !in_values({100, 200, 250, 333, 500}))
break;
XuCamCtrlSet(option, value);
} break;
case Option::EXPOSURE_MODE:
case Option::MAX_GAIN:
case Option::MAX_EXPOSURE_TIME:

View File

@ -17,23 +17,23 @@
<!-- device options, -1 will not set the value -->
<!-- gain range: [0,48]-->
<!-- gain range: [0,48] -->
<arg name="gain" default="-1" />
<!-- <arg name="gain" default="24" /> -->
<!-- brightness range: [0,240]-->
<!-- brightness range: [0,240] -->
<arg name="brightness" default="-1" />
<!-- <arg name="brightness" default="120" /> -->
<!-- contrast range: [0,255]-->
<!-- contrast range: [0,255] -->
<arg name="contrast" default="-1" />
<!-- <arg name="contrast" default="127" /> -->
<!-- frame_rate range: [10,60]-->
<!-- frame_rate range: {10,15,20,25,30,35,40,45,50,55,60} -->
<arg name="frame_rate" default="-1" />
<!-- <arg name="frame_rate" default="25" /> -->
<!-- imu_frequency range: [200,500]-->
<!-- imu_frequency range: {100,200,250,333,500} -->
<arg name="imu_frequency" default="-1" />
<!-- <arg name="imu_frequency" default="200" /> -->
@ -41,19 +41,19 @@
<arg name="exposure_mode" default="-1" />
<!-- <arg name="exposure_mode" default="0" /> -->
<!-- max_gain range: [0,48]-->
<!-- max_gain range: [0,48] -->
<arg name="max_gain" default="-1" />
<!-- <arg name="max_gain" default="48" /> -->
<!-- max_exposure_time range: [0,240]-->
<!-- max_exposure_time range: [0,240] -->
<arg name="max_exposure_time" default="-1" />
<!-- <arg name="max_exposure_time" default="240" /> -->
<!-- desired_brightness range: [0,255]-->
<!-- desired_brightness range: [0,255] -->
<arg name="desired_brightness" default="-1" />
<!-- <arg name="desired_brightness" default="192" /> -->
<!-- ir_control range: [0,160]-->
<!-- ir_control range: [0,160] -->
<arg name="ir_control" default="-1" />
<!-- <arg name="ir_control" default="0" /> -->