Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f7686a9
Add K4A_RESULT_UNSUPPORTED to result enums.
AntonClaytonBursch Nov 6, 2020
70eaf43
Structs for device, color, depth. Enum for calibration. Functions to …
AntonClaytonBursch Nov 11, 2020
143cd46
Updates examples, src, tests and tools to use new config and color an…
AntonClaytonBursch Nov 11, 2020
7496015
Added fps mode structs and functions.
AntonClaytonBursch Nov 11, 2020
163d176
Updated code to reflect change to using fps mode.
AntonClaytonBursch Nov 11, 2020
bdb2ed3
Moded color, depth and fps enums from k4a/k4atypes.h to k4ainternal/m…
AntonClaytonBursch Nov 13, 2020
dc0db6b
Updated c++ wrapper to use new color and depth modes.
AntonClaytonBursch Nov 17, 2020
b7de2fb
Updated C++ wrapper with get device, depth, color and fps functions. …
AntonClaytonBursch Nov 17, 2020
f9dda0a
Update k4arecord/types.h and examples to use color, depth and fps mod…
AntonClaytonBursch Nov 19, 2020
051f8eb
added depth range to k4a_depth_mode_info, updated get color/depth/fps…
AntonClaytonBursch Nov 23, 2020
14ccb08
Update k4astaticimageproperties.h to use k4a.hpp instead of k4a.h
AntonClaytonBursch Nov 23, 2020
4bc4c00
Quick fix: forgot to add K4A_EXPORT to get mode and mode count functi…
AntonClaytonBursch Nov 23, 2020
e3d04a3
examples, tests, tools refactored to use new get mode functions
AntonClaytonBursch Nov 30, 2020
9ceb3e1
quick comments fix in calibration example and updates to color_ft tes…
AntonClaytonBursch Dec 3, 2020
b5b3806
Changed get modes loops for fps, color and depth.
AntonClaytonBursch Dec 9, 2020
33c964f
Viewer mode selection from radio to comboboxes
AntonClaytonBursch Dec 17, 2020
fcac45f
using mode info types instead of mode info type index
AntonClaytonBursch Dec 30, 2020
eed589a
refactor to use mode info instead of mode id
AntonClaytonBursch Dec 31, 2020
fc655bd
using depth/color/fps mode info instead of mode id
AntonClaytonBursch Jan 4, 2021
a85ed66
mode id changes and GUI cleanup
AntonClaytonBursch Jan 5, 2021
9c97825
revert back from using device mode info to device mode id for fps/col…
AntonClaytonBursch Jan 11, 2021
a488ed1
Use constants defined in usb_cmd_priv.h to set the vendor id and devi…
AntonClaytonBursch Jan 13, 2021
0289b22
Used const for color/depth/fps mode info initializers.
AntonClaytonBursch Jan 14, 2021
01893b2
Passing depth mode info down to point cloud viewer. Moved static k4a…
AntonClaytonBursch Jan 19, 2021
a1b772d
color, depth and fps mode infos saved in and parsed from recordings
AntonClaytonBursch Jan 20, 2021
158b641
Initialize the size and version of the mode structs
AntonClaytonBursch Jan 22, 2021
66bc1e5
Moved K4A_MSFT_VID, K4A_RGB_PID and K4A_DEPTH_PID to usbcommand.h. A…
AntonClaytonBursch Jan 22, 2021
2a70cd1
error handling for saving modes and device info in recording
AntonClaytonBursch Jan 22, 2021
5f99801
color, depth, fps mode info and device info saved in and parse from r…
AntonClaytonBursch Jan 22, 2021
af6d217
Fixing K4A build errors in src/record/internal/matroska_read.cpp abou…
JonathanESantos Jan 26, 2021
c541fde
SDK: docstring changes for Doxygen to run without errors.
JonathanESantos Jan 26, 2021
7a7854a
Merge pull request #1 from AntonClaytonBursch/user/jonsanto/Bug5456_F…
AntonClaytonBursch Jan 26, 2021
8f573d2
Merge pull request #2 from AntonClaytonBursch/user/jonsanto/Story5373…
AntonClaytonBursch Jan 26, 2021
e8fe464
K4A API: Adding to docstrings that functions may return status of UNS…
JonathanESantos Jan 26, 2021
d592958
linked k4a_math in viewer
AntonClaytonBursch Jan 26, 2021
5d51a26
Recording description from mode info saved in recording (or legacy de…
AntonClaytonBursch Jan 26, 2021
e3bfdb2
Merge pull request #3 from AntonClaytonBursch/user/jonsanto/Task5460_…
AntonClaytonBursch Jan 26, 2021
81b9de6
Use modes for k4arecorder
AntonClaytonBursch Jan 27, 2021
7a91853
Recorder mode option listed.
AntonClaytonBursch Jan 27, 2021
1bc8889
Merge branch 'api-update' of https://github.com/AntonClaytonBursch/Az…
AntonClaytonBursch Jan 27, 2021
162a016
k4aviewer: Removing audio support. To turn on audio support, in tools…
JonathanESantos Jan 27, 2021
1ccc23f
k4aviewer: Removing support for audio and clangformat wants to format…
JonathanESantos Jan 27, 2021
a828c1e
working on recorder command line validation
AntonClaytonBursch Jan 27, 2021
5be389d
Merge branch 'api-update' into user/jonsanto/Task5467_RemoveSupportFo…
JonathanESantos Jan 27, 2021
46e53da
k4arecorder: Minor editing.
JonathanESantos Jan 27, 2021
b493720
k4a: Adding functional tests for calling the added functions in k4a.h.
JonathanESantos Jan 28, 2021
b32f3ac
Removing commented-out code.
JonathanESantos Jan 28, 2021
6d28e16
k4a: Fixing a test in depth_ft.
JonathanESantos Jan 28, 2021
e8c0f22
Update main.cpp
JonathanESantos Jan 28, 2021
c7279c3
Update main.cpp
JonathanESantos Jan 28, 2021
da96ffc
Update main.cpp
JonathanESantos Jan 28, 2021
235ba8f
Update main.cpp
JonathanESantos Jan 28, 2021
8d2a3b1
Update main.cpp
JonathanESantos Jan 28, 2021
fa07ae8
Merge pull request #5 from AntonClaytonBursch/user/jonsanto/Task5466_…
AntonClaytonBursch Jan 28, 2021
df3b755
validate recorder cmd options
AntonClaytonBursch Jan 28, 2021
f82b42d
finished validating recording cmd options
AntonClaytonBursch Jan 28, 2021
1166777
Fixed get fps mode in recorder.
AntonClaytonBursch Jan 28, 2021
bab38b8
Merge branch 'api-update' into user/jonsanto/Task5467_RemoveSupportFo…
AntonClaytonBursch Jan 28, 2021
d9f616d
Merge pull request #4 from AntonClaytonBursch/user/jonsanto/Task5467_…
AntonClaytonBursch Jan 28, 2021
a5f6512
Fix broken Linux build.
JonathanESantos Jan 29, 2021
b4df263
k4a: ninja clangformat made these formatting changes.
JonathanESantos Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mode id changes and GUI cleanup
  • Loading branch information
AntonClaytonBursch committed Jan 5, 2021
commit a85ed66abce26ed0d6ab9b5789a2a89dbc285a6d
4 changes: 2 additions & 2 deletions include/k4a/k4atypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ typedef struct _k4a_calibration_t
k4a_calibration_extrinsics_t extrinsics[K4A_CALIBRATION_TYPE_NUM][K4A_CALIBRATION_TYPE_NUM];

// TODO: comment
k4a_depth_mode_info_t depth_mode_info; /**< Depth camera mode for which calibration was obtained. */
k4a_color_mode_info_t color_mode_info; /**< Color camera resolution for which calibration was obtained. */
k4a_depth_mode_info_t depth_mode_info; /**< Depth camera mode for which calibration was obtained. */
k4a_color_mode_info_t color_mode_info; /**< Color camera mode for which calibration was obtained. */

} k4a_calibration_t;

Expand Down
72 changes: 31 additions & 41 deletions tools/k4aviewer/k4adevicedockcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
if (ImGui::TreeNode("Depth Configuration"))
{
const bool depthSettingsEditable = !deviceIsStarted && m_config.EnableDepthCamera;
auto *pDepthMode = reinterpret_cast<int *>(&m_config.depth_mode_info.mode_id);
//ImGui::Text("Depth mode");
auto *pDepthModeInfo = reinterpret_cast<int *>(&m_config.depth_mode_id);

std::vector<std::pair<int, std::string>> depth_mode_items;
std::vector<k4a_depth_mode_info_t> depth_modes = m_device.get_depth_modes();
Expand Down Expand Up @@ -376,11 +375,10 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
description += " Deg";
}

depth_mode_items.push_back({ d, (const std::string)description });
depth_mode_items.push_back({ depth_mode.mode_id, (const std::string)description });
}

depthModeUpdated |=
ImGuiExtensions::K4AComboBox("Depth", "", ImGuiComboFlags_None, depth_mode_items, pDepthMode, depthSettingsEditable);
depthModeUpdated |= ImGuiExtensions::K4AComboBox("##Depth", "", ImGuiComboFlags_None, depth_mode_items, pDepthModeInfo, depthSettingsEditable);

ImGui::TreePop();
}
Expand All @@ -403,18 +401,15 @@ K4ADockControlStatus K4ADeviceDockControl::Show()

bool colorFormatUpdated = false;
auto *pColorFormat = reinterpret_cast<int *>(&m_config.ColorFormat);

ImGui::Text("Format");
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("BGRA", pColorFormat, K4A_IMAGE_FORMAT_COLOR_BGRA32, colorSettingsEditable);
colorFormatUpdated |= ImGuiExtensions::K4ARadioButton("BGRA", pColorFormat, K4A_IMAGE_FORMAT_COLOR_BGRA32, colorSettingsEditable);
ImGui::SameLine();
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("MJPG", pColorFormat, K4A_IMAGE_FORMAT_COLOR_MJPG, colorSettingsEditable);
colorFormatUpdated |= ImGuiExtensions::K4ARadioButton("MJPG", pColorFormat, K4A_IMAGE_FORMAT_COLOR_MJPG, colorSettingsEditable);
ImGui::SameLine();
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("NV12", pColorFormat, K4A_IMAGE_FORMAT_COLOR_NV12, colorSettingsEditable);
colorFormatUpdated |= ImGuiExtensions::K4ARadioButton("NV12", pColorFormat, K4A_IMAGE_FORMAT_COLOR_NV12, colorSettingsEditable);
ImGui::SameLine();
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("YUY2", pColorFormat, K4A_IMAGE_FORMAT_COLOR_YUY2, colorSettingsEditable);
colorFormatUpdated |= ImGuiExtensions::K4ARadioButton("YUY2", pColorFormat, K4A_IMAGE_FORMAT_COLOR_YUY2, colorSettingsEditable);

// Uncompressed formats are only supported at 720p.

Expand All @@ -427,16 +422,13 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
{
if (!imageFormatSupportsHighResolution)
{
m_config.color_mode_info = { sizeof(k4a_color_mode_info_t), K4A_ABI_VERSION, 1, 1280, 720, K4A_IMAGE_FORMAT_COLOR_MJPG, 90.0f, 59.0f, 5, 30 }; // 1 = K4A_COLOR_RESOLUTION_720P
m_config.color_mode_id = 1; // 1 = K4A_COLOR_RESOLUTION_720P
}
}

// TODO: remove
//auto *pColorResolution = reinterpret_cast<int *>(&m_config.ColorResolution);

auto *pColorMode = reinterpret_cast<int *>(&m_config.color_mode_info.mode_id);
auto *pColorModeInfo = reinterpret_cast<int *>(&m_config.color_mode_id);

//ImGui::Text("Resolution");
ImGui::Text("Resolution");

std::vector<std::pair<int, std::string>> color_mode_items;
std::vector<k4a_color_mode_info_t> color_modes = m_device.get_color_modes();
Expand All @@ -456,15 +448,11 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
description += std::to_string(height) + "p ";
description += std::to_string(width / common_factor) + ":" + std::to_string(height / common_factor);

color_mode_items.push_back({ c, (const std::string) description });
color_mode_items.push_back({ color_mode.mode_id, (const std::string) description });
}

colorResolutionUpdated |= ImGuiExtensions::K4AComboBox("Resolution",
"",
ImGuiComboFlags_None,
color_mode_items,
pColorMode,
colorSettingsEditable);
colorResolutionUpdated |= ImGuiExtensions::K4AComboBox("##Resolution", "", ImGuiComboFlags_None, color_mode_items, pColorModeInfo, colorSettingsEditable);

ImGui::TreePop();
}
if (ImGui::TreeNode("Color Controls"))
Expand Down Expand Up @@ -609,31 +597,31 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
if (m_config.color_mode_id == 6) // 6 = K4A_COLOR_RESOLUTION_3072P
{
// 4K supports up to 15FPS
//
m_config.fps_mode_id = 2; // 2 = K4A_FRAMES_PER_SECOND_15
m_config.fps_mode_id = 1; // 1 = K4A_FRAMES_PER_SECOND_15
}
}
if (depthModeUpdated || m_firstRun)
{
if (m_config.depth_mode_id == 4) // 4 = K4A_DEPTH_MODE_WFOV_UNBINNED
{
m_config.fps_mode_id = 2; // 2 = K4A_FRAMES_PER_SECOND_15
m_config.fps_mode_id = 1; // 1 = K4A_FRAMES_PER_SECOND_15
}
}

const bool supports30fps = !(m_config.EnableColorCamera && m_config.color_mode_id == 6) && !(m_config.EnableDepthCamera && m_config.depth_mode_id == 4); // 6 = K4A_COLOR_RESOLUTION_3072P, 4 = K4A_DEPTH_MODE_WFOV_UNBINNED

const bool enableFramerate = !deviceIsStarted && (m_config.EnableColorCamera || m_config.EnableDepthCamera);

//ImGui::Text("Framerate");

bool framerateUpdated = false;

// TODO: comment
// TODO: tooltip if 30 fps not available due to other settings
auto *pFPSMode = reinterpret_cast<int *>(&m_config.fps_mode_id);
auto *pFPSModeInfo = reinterpret_cast<int *>(&m_config.fps_mode_id);

ImGui::Text("Framerate");

ImGui::Indent();

// TODO: only returning 1 item in modes count
std::vector<std::pair<int, std::string>> fps_mode_items;
std::vector<k4a_fps_mode_info_t> fps_modes = m_device.get_fps_modes();
size_t fps_modes_size = fps_modes.size();
Expand All @@ -643,12 +631,12 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
int fps = (int)fps_mode.fps;
std::string description = std::to_string(fps) + " FPS";

fps_mode_items.push_back({ f, (const std::string)description });
fps_mode_items.push_back({ fps_mode.mode_id, (const std::string)description });
}

framerateUpdated |= ImGuiExtensions::K4AComboBox("Framerate", "", ImGuiComboFlags_None, fps_mode_items, pFPSMode);

framerateUpdated |= ImGuiExtensions::K4AComboBox("##Framerate", "", ImGuiComboFlags_None, fps_mode_items, pFPSModeInfo);

ImGui::Unindent();

ImGuiExtensions::K4ACheckbox("Disable streaming LED", &m_config.DisableStreamingIndicator, !deviceIsStarted);

Expand Down Expand Up @@ -697,7 +685,7 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
// the user interacts with the control
//
int maxDepthDelay = 0;
switch (m_config.fps_mode_info.mode_id)
switch (m_config.fps_mode_id)
{
case 2: // 2 = K4A_FRAMES_PER_SECOND_30
maxDepthDelay = std::micro::den / 30;
Expand Down Expand Up @@ -901,7 +889,7 @@ bool K4ADeviceDockControl::StartCameras()
return false;
}

k4a_device_configuration_t deviceConfig = m_config.ToK4ADeviceConfiguration();
k4a_device_configuration_t deviceConfig = m_config.ToK4ADeviceConfiguration(&m_device);

try
{
Expand Down Expand Up @@ -1076,11 +1064,13 @@ void K4ADeviceDockControl::SetViewType(K4AWindowSet::ViewType viewType)
}
}


k4a_depth_mode_info_t depth_mode_info = m_device.get_depth_mode(m_config.depth_mode_id);
k4a_color_mode_info_t color_mode_info = m_device.get_color_mode(m_config.color_mode_id);

switch (viewType)
{
case K4AWindowSet::ViewType::Normal:
k4a_depth_mode_info_t depth_mode_info = m_device.get_depth_mode(m_config.depth_mode_id);
k4a_color_mode_info_t color_mode_info = m_device.get_color_mode(m_config.color_mode_id);
K4AWindowSet::StartNormalWindows(m_deviceSerialNumber.c_str(),
&m_cameraDataSource,
m_config.EnableImu ? &m_imuDataSource : nullptr,
Expand All @@ -1095,7 +1085,7 @@ void K4ADeviceDockControl::SetViewType(K4AWindowSet::ViewType viewType)
case K4AWindowSet::ViewType::PointCloudViewer:
try
{
k4a::calibration calib = m_device.get_calibration(m_config.depth_mode_id, m_config.color_mode_id);
k4a::calibration calib = m_device.get_calibration(depth_mode_info, color_mode_info);
bool rgbPointCloudAvailable = m_config.EnableColorCamera && m_config.ColorFormat == K4A_IMAGE_FORMAT_COLOR_BGRA32;
K4AWindowSet::StartPointCloudWindow(m_deviceSerialNumber.c_str(),
calib,
Expand Down
4 changes: 2 additions & 2 deletions tools/k4aviewer/k4apointcloudvisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ void K4APointCloudVisualizer::SetPointSize(int size)
m_pointCloudRenderer.SetPointSize(size);
}

K4APointCloudVisualizer::K4APointCloudVisualizer(const bool enableColorPointCloud, const k4a::calibration &calibrationData, k4a::device * device) :
K4APointCloudVisualizer::K4APointCloudVisualizer(const bool enableColorPointCloud, const k4a::calibration &calibrationData) :
m_dimensions(PointCloudVisualizerTextureDimensions),
m_enableColorPointCloud(enableColorPointCloud),
m_calibrationData(calibrationData)
{
m_expectedValueRange = GetDepthModeRange(device->get_depth_mode(m_calibrationData.depth_mode_id));
m_expectedValueRange = GetDepthModeRange(m_calibrationData.depth_mode_info);
m_transformation = k4a::transformation(m_calibrationData);

glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer.Id());
Expand Down
2 changes: 1 addition & 1 deletion tools/k4aviewer/k4apointcloudvisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class K4APointCloudVisualizer
PointCloudVisualizationResult SetColorizationStrategy(ColorizationStrategy strategy);
void SetPointSize(int size);

K4APointCloudVisualizer(bool enableColorPointCloud, const k4a::calibration &calibrationData, k4a::device * device);
K4APointCloudVisualizer(bool enableColorPointCloud, const k4a::calibration &calibrationData);
~K4APointCloudVisualizer() = default;

K4APointCloudVisualizer(const K4APointCloudVisualizer &) = delete;
Expand Down
5 changes: 2 additions & 3 deletions tools/k4aviewer/k4apointcloudwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ const char *K4APointCloudWindow::GetTitle() const
K4APointCloudWindow::K4APointCloudWindow(std::string &&windowTitle,
bool enableColorPointCloud,
std::shared_ptr<K4ANonBufferingCaptureSource> &&captureSource,
const k4a::calibration &calibrationData,
k4a::device * device) :
const k4a::calibration &calibrationData) :
m_title(std::move(windowTitle)),
m_pointCloudVisualizer(enableColorPointCloud, calibrationData, device),
m_pointCloudVisualizer(enableColorPointCloud, calibrationData),
m_captureSource(std::move(captureSource)),
m_pointSize(DefaultPointSize),
m_enableColorPointCloud(enableColorPointCloud)
Expand Down
3 changes: 1 addition & 2 deletions tools/k4aviewer/k4apointcloudwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class K4APointCloudWindow : public IK4AVisualizationWindow
K4APointCloudWindow(std::string &&windowTitle,
bool enableColorPointCloud,
std::shared_ptr<K4ANonBufferingCaptureSource> &&captureSource,
const k4a::calibration &calibrationData,
k4a::device * device);
const k4a::calibration &calibrationData);
~K4APointCloudWindow() override = default;

K4APointCloudWindow(const K4APointCloudWindow &) = delete;
Expand Down
23 changes: 17 additions & 6 deletions tools/k4aviewer/k4aviewersettingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ constexpr char EndDeviceConfigurationTag[] = "EndDeviceConfiguration";
constexpr char EnableColorCameraTag[] = "EnableColorCamera";
constexpr char EnableDepthCameraTag[] = "EnableDepthCamera";
constexpr char ColorFormatTag[] = "ColorFormat";

constexpr char ColorResolutionTag[] = "ColorResolution";
constexpr char DepthModeTag[] = "DepthMode";
constexpr char FramerateTag[] = "Framerate";

constexpr char DepthDelayOffColorUsecTag[] = "DepthDelayOffColorUsec";
constexpr char WiredSyncModeTag[] = "WiredSyncMode";
constexpr char SubordinateDelayOffMasterUsecTag[] = "SubordinateDelayOffMasterUsec";
Expand All @@ -46,14 +48,17 @@ constexpr char EnableMicrophoneTag[] = "EnableMicrophone";

std::ostream &operator<<(std::ostream &s, const K4ADeviceConfiguration &val)
{
static_assert(sizeof(k4a_device_configuration_t) == 36, "Need to add a new setting");
// TODO: need to get the correct size
// static_assert(sizeof(k4a_device_configuration_t) == 36, "Need to add a new setting");
s << BeginDeviceConfigurationTag << std::endl;
s << Separator << EnableColorCameraTag << Separator << val.EnableColorCamera << std::endl;
s << Separator << EnableDepthCameraTag << Separator << val.EnableDepthCamera << std::endl;
s << Separator << ColorFormatTag << Separator << val.ColorFormat << std::endl;

s << Separator << ColorResolutionTag << Separator << val.color_mode_id << std::endl;
s << Separator << DepthModeTag << Separator << val.depth_mode_id << std::endl;
s << Separator << FramerateTag << Separator << val.fps_mode_id << std::endl;

s << Separator << DepthDelayOffColorUsecTag << Separator << val.DepthDelayOffColorUsec << std::endl;
s << Separator << WiredSyncModeTag << Separator << val.WiredSyncMode << std::endl;
s << Separator << SubordinateDelayOffMasterUsecTag << Separator << val.SubordinateDelayOffMasterUsec << std::endl;
Expand All @@ -79,7 +84,8 @@ std::istream &operator>>(std::istream &s, K4ADeviceConfiguration &val)

while (variableTag != EndDeviceConfigurationTag && s)
{
static_assert(sizeof(K4ADeviceConfiguration) == 36, "Need to add a new setting");
// TODO: need to get the correct size
// static_assert(sizeof(K4ADeviceConfiguration) == 36, "Need to add a new setting");

variableTag.clear();
s >> variableTag;
Expand Down Expand Up @@ -276,14 +282,19 @@ std::ostream &operator<<(std::ostream &s, const ViewerOption &val)
// The UI doesn't quite line up with the struct we actually need to give to the K4A API, so
// we have to do a bit of conversion.
//
k4a_device_configuration_t K4ADeviceConfiguration::ToK4ADeviceConfiguration() const
k4a_device_configuration_t K4ADeviceConfiguration::ToK4ADeviceConfiguration(k4a::device * device) const
{
k4a_device_configuration_t deviceConfig;

deviceConfig.color_format = ColorFormat;
deviceConfig.color_mode_id = EnableColorCamera ? color_mode_id : 0; // 0 = K4A_COLOR_RESOLUTION_OFF
deviceConfig.depth_mode_id = EnableDepthCamera ? depth_mode_id : 0; // 0 = K4A_DEPTH_MODE_OFF
deviceConfig.fps_mode_id = fps_mode_id;

k4a_depth_mode_info_t depth_mode_info = device->get_depth_mode(EnableDepthCamera ? depth_mode_id : 0); // 0 = K4A_DEPTH_MODE_OFF
k4a_color_mode_info_t color_mode_info = device->get_color_mode(EnableColorCamera ? color_mode_id : 0); // 0 = K4A_COLOR_RESOLUTION_OFF
k4a_fps_mode_info_t fps_mode_info = device->get_fps_mode(fps_mode_id);

deviceConfig.color_mode_info = color_mode_info;
deviceConfig.depth_mode_info = depth_mode_info ;
deviceConfig.fps_mode_info = fps_mode_info;

deviceConfig.depth_delay_off_color_usec = DepthDelayOffColorUsec;
deviceConfig.wired_sync_mode = WiredSyncMode;
Expand Down
12 changes: 8 additions & 4 deletions tools/k4aviewer/k4aviewersettingsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ struct K4ADeviceConfiguration
bool EnableDepthCamera = true;
k4a_image_format_t ColorFormat = K4A_IMAGE_FORMAT_COLOR_BGRA32;

k4a_color_mode_info_t color_mode_info = { sizeof(k4a_color_mode_info_t), K4A_ABI_VERSION, 1, 1280, 720, K4A_IMAGE_FORMAT_COLOR_MJPG, 90.0f, 59.0f, 5, 30 }; // K4A_COLOR_RESOLUTION_720P
k4a_depth_mode_info_t depth_mode_info = { sizeof(k4a_depth_mode_info_t), K4A_ABI_VERSION, 2, false, 640, 576, K4A_IMAGE_FORMAT_DEPTH16, 75.0f, 65.0f, 5, 30, 500, 4000 }; // K4A_DEPTH_MODE_NFOV_UNBINNED
k4a_fps_mode_info_t fps_mode_info = { sizeof(k4a_fps_mode_info_t), K4A_ABI_VERSION, 2, 30 }; // K4A_FRAMES_PER_SECOND_30
//k4a_color_mode_info_t color_mode_info = { sizeof(k4a_color_mode_info_t), K4A_ABI_VERSION, 1, 1280, 720, K4A_IMAGE_FORMAT_COLOR_MJPG, 90.0f, 59.0f, 5, 30 }; // K4A_COLOR_RESOLUTION_720P
//k4a_depth_mode_info_t depth_mode_info = { sizeof(k4a_depth_mode_info_t), K4A_ABI_VERSION, 2, false, 640, 576, K4A_IMAGE_FORMAT_DEPTH16, 75.0f, 65.0f, 5, 30, 500, 4000 }; // K4A_DEPTH_MODE_NFOV_UNBINNED
//k4a_fps_mode_info_t fps_mode_info = { sizeof(k4a_fps_mode_info_t), K4A_ABI_VERSION, 2, 30 }; // K4A_FRAMES_PER_SECOND_30

uint32_t color_mode_id = 1;
uint32_t depth_mode_id = 2;
uint32_t fps_mode_id = 2;

int32_t DepthDelayOffColorUsec = 0;
k4a_wired_sync_mode_t WiredSyncMode = K4A_WIRED_SYNC_MODE_STANDALONE;
Expand All @@ -45,7 +49,7 @@ struct K4ADeviceConfiguration

// Convert to a k4a_device_configuration_t suitable for passing to the K4A API
//
k4a_device_configuration_t ToK4ADeviceConfiguration() const;
k4a_device_configuration_t ToK4ADeviceConfiguration(k4a::device * device) const;
};

std::istream &operator>>(std::istream &s, K4ADeviceConfiguration &val);
Expand Down