Minor Fixes Error Messages, K4aViewer Button, Multi Device Tests (#876)
* 1) better error messages around multi device delay settings being wrong, 2) a random number generating function, 3) Code uses random number generating common function, adn 4) K4aViewer now has a button to refresh the color controls if they change via firmware state change. * Fixing build break * Fixing Build Breaks * Update src/capturesync/capturesync.c * Update src/capturesync/capturesync.c * Update src/capturesync/capturesync.c * fixed build breaks * Enhanced debug output
This commit is contained in:
Родитель
a00e353ca0
Коммит
3b8d2ece25
|
@ -685,9 +685,10 @@ static k4a_result_t validate_configuration(k4a_context_t *device, const k4a_devi
|
|||
if (config->subordinate_delay_off_master_usec > fps_in_usec)
|
||||
{
|
||||
result = K4A_RESULT_FAILED;
|
||||
LOG_ERROR(
|
||||
"The configured subordinate device delay from the master device cannot exceed one frame interval.",
|
||||
0);
|
||||
LOG_ERROR("The configured subordinate device delay from the master device cannot exceed one frame "
|
||||
"interval of %d. User requested %d",
|
||||
fps_in_usec,
|
||||
config->subordinate_delay_off_master_usec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,7 +720,10 @@ static k4a_result_t validate_configuration(k4a_context_t *device, const k4a_devi
|
|||
if (config->depth_delay_off_color_usec < -fps || config->depth_delay_off_color_usec > fps)
|
||||
{
|
||||
result = K4A_RESULT_FAILED;
|
||||
LOG_ERROR("The configured depth_delay_off_color_usec must be within +/- one frame interval.", 0);
|
||||
LOG_ERROR("The configured depth_delay_off_color_usec must be within +/- one frame interval of %d. User "
|
||||
"requested %d",
|
||||
fps,
|
||||
config->depth_delay_off_color_usec);
|
||||
}
|
||||
}
|
||||
else if (!depth_enabled && !color_enabled)
|
||||
|
|
|
@ -17,6 +17,9 @@ std::ostream &operator<<(std::ostream &s, const k4a_buffer_result_t &val);
|
|||
|
||||
extern "C" {
|
||||
|
||||
// Generate a Random number between min and max and is inclive of both min and max
|
||||
#define RAND_VALUE(min, max) (((int64_t)((max) - (min) + 1) * (int64_t)(rand()) / (int64_t)RAND_MAX) + min)
|
||||
|
||||
// Initialize default k4a specific unittest behavior
|
||||
void k4a_unittest_init();
|
||||
void k4a_unittest_deinit();
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#define NULL_IMAGE 0
|
||||
#define NULL_DEVICE 0
|
||||
|
||||
const int SAMPLES_TO_STABILIZE = 10;
|
||||
|
||||
// How close 2 timestamps should be to be considered accurately synchronized.
|
||||
const int MAX_SYNC_CAPTURE_DIFFERENCE_USEC = 100;
|
||||
|
||||
|
@ -242,8 +244,7 @@ static k4a_result_t open_master_and_subordinate(k4a_device_t *master, k4a_device
|
|||
*master = device;
|
||||
device = NULL;
|
||||
}
|
||||
|
||||
if (*subordinate == NULL && sync_in_cable_present)
|
||||
else if (*subordinate == NULL && sync_in_cable_present)
|
||||
{
|
||||
*subordinate = device;
|
||||
device = NULL;
|
||||
|
@ -361,8 +362,7 @@ static k4a_result_t verify_ts(int64_t ts_1, int64_t ts_2, int64_t ts_offset, con
|
|||
if (ts_result > MAX_SYNC_CAPTURE_DIFFERENCE_USEC)
|
||||
{
|
||||
printf(" ERROR timestamps are not within range.\n TS1 + TS_Offset should be ~= TS2. %s\n ts1=%" PRId64
|
||||
" "
|
||||
"ts2=%" PRId64 " ts_offset=%" PRId64 " diff=%" PRId64 "\n",
|
||||
" ts2=%" PRId64 " ts_offset=%" PRId64 " diff=%" PRId64 "\n",
|
||||
error_message,
|
||||
ts_1,
|
||||
ts_2,
|
||||
|
@ -377,12 +377,27 @@ TEST_F(multidevice_sync_ft, multi_sync_validation)
|
|||
{
|
||||
k4a_device_t master, subordinate;
|
||||
k4a_fps_t frame_rate = K4A_FRAMES_PER_SECOND_30;
|
||||
int32_t fps_in_usec = 1000000 / (int32_t)k4a_convert_fps_to_uint(frame_rate);
|
||||
|
||||
int frame_rate_rand = rand(); // Throw away first rand() result
|
||||
frame_rate_rand = (int)RAND_VALUE(0, 2);
|
||||
switch (frame_rate_rand)
|
||||
{
|
||||
case 0:
|
||||
frame_rate = K4A_FRAMES_PER_SECOND_5;
|
||||
break;
|
||||
case 1:
|
||||
frame_rate = K4A_FRAMES_PER_SECOND_15;
|
||||
break;
|
||||
default:
|
||||
frame_rate = K4A_FRAMES_PER_SECOND_30;
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t fps_in_usec = 1000000 / (int32_t)k4a_convert_fps_to_uint(frame_rate);
|
||||
ASSERT_EQ(open_master_and_subordinate(&master, &subordinate), K4A_RESULT_SUCCEEDED);
|
||||
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, set_power_and_exposure(master, 8330, 2));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, set_power_and_exposure(subordinate, 8330, 2));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, set_power_and_exposure(master, 8330, 2)) << "Master Device";
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, set_power_and_exposure(subordinate, 8330, 2)) << "Subordinate Device";
|
||||
|
||||
k4a_device_configuration_t default_config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
|
||||
default_config.color_format = K4A_IMAGE_FORMAT_COLOR_MJPG;
|
||||
|
@ -395,23 +410,26 @@ TEST_F(multidevice_sync_ft, multi_sync_validation)
|
|||
|
||||
k4a_device_configuration_t s_config = default_config;
|
||||
s_config.wired_sync_mode = K4A_WIRED_SYNC_MODE_SUBORDINATE;
|
||||
s_config.depth_delay_off_color_usec = (2 * fps_in_usec * rand() / RAND_MAX - fps_in_usec);
|
||||
s_config.subordinate_delay_off_master_usec = (uint32_t)(1 * fps_in_usec * rand() / RAND_MAX);
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, k4a_device_start_cameras(subordinate, &s_config));
|
||||
s_config.depth_delay_off_color_usec = (int32_t)RAND_VALUE(-fps_in_usec, fps_in_usec);
|
||||
s_config.subordinate_delay_off_master_usec = (uint32_t)RAND_VALUE(0, fps_in_usec);
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, k4a_device_start_cameras(subordinate, &s_config)) << "Subordinate Device";
|
||||
|
||||
k4a_device_configuration_t m_config = default_config;
|
||||
m_config.wired_sync_mode = K4A_WIRED_SYNC_MODE_MASTER;
|
||||
m_config.depth_delay_off_color_usec = (2 * fps_in_usec * rand() / RAND_MAX - fps_in_usec);
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, k4a_device_start_cameras(master, &m_config));
|
||||
m_config.depth_delay_off_color_usec = (int32_t)RAND_VALUE(-fps_in_usec, fps_in_usec);
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED, k4a_device_start_cameras(master, &m_config)) << "Master Device";
|
||||
|
||||
printf("Test Running with the following settings:\n");
|
||||
printf(" Frame Rate: %s\n",
|
||||
frame_rate == K4A_FRAMES_PER_SECOND_5 ? "5" : (frame_rate == K4A_FRAMES_PER_SECOND_15 ? "15" : "30"));
|
||||
printf(" Master depth_delay_off_color_usec: %d\n", m_config.depth_delay_off_color_usec);
|
||||
printf(" Sub depth_delay_off_color_usec: %d\n", s_config.depth_delay_off_color_usec);
|
||||
printf(" Sub subordinate_delay_off_master_usec: %d\n", s_config.subordinate_delay_off_master_usec);
|
||||
|
||||
printf("\nDelta = Time off master color.\n");
|
||||
printf("\nDelta = Time off master color. All times in usec\n");
|
||||
printf("Master Color, Master IR(Delta), Sub Color(Delta), Sub IR(Delta)\n");
|
||||
printf("---------------------------------------------------------------\n");
|
||||
|
||||
for (int x = 0; x < 100; x++)
|
||||
{
|
||||
k4a_capture_t cap_m, cap_s;
|
||||
|
@ -431,30 +449,34 @@ TEST_F(multidevice_sync_ft, multi_sync_validation)
|
|||
ts_m_ir = (int64_t)k4a_image_get_device_timestamp_usec(image_ir_m);
|
||||
ts_s_ir = (int64_t)k4a_image_get_device_timestamp_usec(image_ir_s);
|
||||
|
||||
printf("%9" PRId64 ", %9" PRId64 "(%5" PRId64 "), %9" PRId64 "(%5" PRId64 "), %9" PRId64 "(%5" PRId64 ")\n",
|
||||
printf("%9" PRId64 ", %9" PRId64 "(%5" PRId64 "), %9" PRId64 "(%5" PRId64 "), %9" PRId64 "(%5" PRId64 ") %s\n",
|
||||
ts_m_c,
|
||||
ts_m_ir,
|
||||
ts_m_ir - ts_m_c,
|
||||
ts_s_c,
|
||||
ts_s_c - ts_m_c,
|
||||
ts_s_ir,
|
||||
ts_s_ir - ts_m_c);
|
||||
ts_s_ir - ts_s_c,
|
||||
x > SAMPLES_TO_STABILIZE ? "Validating" : "Stabilizing");
|
||||
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_m_c,
|
||||
ts_m_ir,
|
||||
m_config.depth_delay_off_color_usec,
|
||||
"TS1 is Master Color, TS2 is Master Ir"));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_s_c,
|
||||
ts_s_ir,
|
||||
s_config.depth_delay_off_color_usec,
|
||||
"TS1 is Subordinate Color, TS2 is Subordinate Ir"));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_m_c,
|
||||
ts_s_c,
|
||||
(int64_t)s_config.subordinate_delay_off_master_usec,
|
||||
"TS1 is Master Color, TS2 is Subordinate Color"));
|
||||
if (x > SAMPLES_TO_STABILIZE)
|
||||
{
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_m_c,
|
||||
ts_m_ir,
|
||||
m_config.depth_delay_off_color_usec,
|
||||
"TS1 is Master Color, TS2 is Master Ir"));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_s_c,
|
||||
ts_s_ir,
|
||||
s_config.depth_delay_off_color_usec,
|
||||
"TS1 is Subordinate Color, TS2 is Subordinate Ir"));
|
||||
ASSERT_EQ(K4A_RESULT_SUCCEEDED,
|
||||
verify_ts(ts_m_c,
|
||||
ts_s_c,
|
||||
(int64_t)s_config.subordinate_delay_off_master_usec,
|
||||
"TS1 is Master Color, TS2 is Subordinate Color"));
|
||||
}
|
||||
|
||||
k4a_image_release(image_c_m);
|
||||
k4a_image_release(image_c_s);
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
#include <azure_c_shared_utility/threadapi.h>
|
||||
#include <azure_c_shared_utility/envvariable.h>
|
||||
|
||||
#define TS_TO_MS(ts) ((long long)((ts) / 1)) // TS convertion to milliseconds
|
||||
#define LLD(val) ((int64_t)(val))
|
||||
#define TS_TO_MS(ts) (LLD((ts) / 1)) // TS convertion to milliseconds
|
||||
|
||||
#define K4A_IMU_SAMPLE_RATE 1666 // +/- 2%
|
||||
|
||||
|
@ -234,7 +235,7 @@ TEST_P(throughput_perf, testTest)
|
|||
int missed_count = 0;
|
||||
int not_synchronized_count = 0;
|
||||
uint64_t last_ts = UINT64_MAX;
|
||||
uint64_t fps_in_usec = 0;
|
||||
int32_t fps_in_usec = 0;
|
||||
uint64_t last_color_ts = 0;
|
||||
uint64_t last_depth16_ts = 0;
|
||||
uint64_t last_ir16_ts = 0;
|
||||
|
@ -301,7 +302,7 @@ TEST_P(throughput_perf, testTest)
|
|||
if (g_depth_delay_off_color_usec == 0)
|
||||
{
|
||||
// Create delay that can be +fps to -fps
|
||||
config.depth_delay_off_color_usec = (int32_t)(2 * fps_in_usec * ((uint64_t)rand()) / RAND_MAX - fps_in_usec);
|
||||
config.depth_delay_off_color_usec = (int32_t)RAND_VALUE(-fps_in_usec, fps_in_usec);
|
||||
}
|
||||
|
||||
printf("Config being used is:\n");
|
||||
|
@ -391,10 +392,10 @@ TEST_P(throughput_perf, testTest)
|
|||
ts = k4a_image_get_device_timestamp_usec(image);
|
||||
adjusted_max_ts = std::max(ts, adjusted_max_ts);
|
||||
static_assert(sizeof(ts) == 8, "this should not be wrong");
|
||||
printf(" %9lld[%6lld][%6lld]",
|
||||
printf(" %9" PRId64 "[%6" PRId64 "][%6" PRId64 "]",
|
||||
TS_TO_MS(ts),
|
||||
TS_TO_MS(ts - last_color_ts),
|
||||
(long long int)k4a_image_get_exposure_usec(image));
|
||||
LLD(k4a_image_get_exposure_usec(image)));
|
||||
|
||||
// TS should increase
|
||||
EXPECT_GT(ts, last_color_ts);
|
||||
|
@ -414,7 +415,7 @@ TEST_P(throughput_perf, testTest)
|
|||
depth = true;
|
||||
ts = k4a_image_get_device_timestamp_usec(image);
|
||||
adjusted_max_ts = std::max(ts - (uint64_t)config.depth_delay_off_color_usec, adjusted_max_ts);
|
||||
printf(" | %9lld[%6lld]", TS_TO_MS(ts), TS_TO_MS(ts - last_ir16_ts));
|
||||
printf(" | %9" PRId64 "[%6" PRId64 "]", TS_TO_MS(ts), TS_TO_MS(ts - last_ir16_ts));
|
||||
|
||||
// TS should increase
|
||||
EXPECT_GT(ts, last_ir16_ts);
|
||||
|
@ -433,7 +434,7 @@ TEST_P(throughput_perf, testTest)
|
|||
{
|
||||
ts = k4a_image_get_device_timestamp_usec(image);
|
||||
adjusted_max_ts = std::max(ts - (uint64_t)config.depth_delay_off_color_usec, adjusted_max_ts);
|
||||
printf(" | %9lld[%6lld]", TS_TO_MS(ts), TS_TO_MS(ts - last_depth16_ts));
|
||||
printf(" | %9" PRId64 "[%6" PRId64 "]", TS_TO_MS(ts), TS_TO_MS(ts - last_depth16_ts));
|
||||
|
||||
// TS should increase
|
||||
EXPECT_GT(ts, last_depth16_ts);
|
||||
|
@ -497,21 +498,21 @@ TEST_P(throughput_perf, testTest)
|
|||
// the color image is delayed due to perf issues. When this happens we just ignore the sample because our
|
||||
// time stamp logic has already moved beyond the time this sample was supposed to arrive at.
|
||||
}
|
||||
else if ((adjusted_max_ts - last_ts) >= (fps_in_usec * 15 / 10))
|
||||
else if ((adjusted_max_ts - last_ts) >= ((unsigned)(fps_in_usec * 15 / 10)))
|
||||
{
|
||||
// Calc how many captures we didn't get. If the delta between the last two time stamps is more than 1.5
|
||||
// * fps_in_usec then we count
|
||||
int missed_this_period = ((int)((adjusted_max_ts - last_ts) / fps_in_usec));
|
||||
int32_t missed_this_period = (int32_t)(adjusted_max_ts - last_ts) / fps_in_usec;
|
||||
missed_this_period--; // We got a new time stamp to do this math, so this count has 1 too many, remove
|
||||
// it
|
||||
if (((adjusted_max_ts - last_ts) % fps_in_usec) > fps_in_usec / 2)
|
||||
if (((adjusted_max_ts - last_ts) % ((unsigned)fps_in_usec)) > ((unsigned)fps_in_usec) / 2)
|
||||
{
|
||||
missed_this_period++;
|
||||
}
|
||||
printf("Missed %d captures before previous capture %lld %lld\n",
|
||||
printf("Missed %d captures before previous capture %" PRId64 " %" PRId64 "\n",
|
||||
missed_this_period,
|
||||
(long long)adjusted_max_ts,
|
||||
(long long)last_ts);
|
||||
LLD(adjusted_max_ts),
|
||||
LLD(last_ts));
|
||||
if (missed_this_period > capture_count)
|
||||
{
|
||||
missed_count += capture_count;
|
||||
|
|
|
@ -588,6 +588,13 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
|
|||
|
||||
// clang-format on
|
||||
|
||||
if (ImGui::Button("Refresh"))
|
||||
{
|
||||
LoadColorSettingsCache();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Reset to default##RGB"))
|
||||
{
|
||||
ApplyDefaultColorSettings();
|
||||
|
|
Загрузка…
Ссылка в новой задаче