Azure-kinect-sensor-sdk: Add function to get default configuration for k4a_device_configuration_t

Created on 13 Aug 2019  路  5Comments  路  Source: microsoft/Azure-Kinect-Sensor-SDK

I propose add function to get default configuration for k4a_device_configuration_t.
Currently, It is necessary to set all k4a_device_configuration_t members in user code.
If default configuration can be retrieved, developer just have only to rewrite necessary member variables.

I think it is developer helpfull. I think it is meaningful to provide this function in SDK.

// k4a.h
K4A_EXPORT k4a_device_configuration_t k4a_get_default_device_configuration(void);

// k4a.c
k4a_device_configuration_t k4a_get_default_device_configuration(void)
{
    k4a_device_configuration_t configuration;
    configuration.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
    configuration.color_resolution = K4A_COLOR_RESOLUTION_720P;
    configuration.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
    configuration.camera_fps = K4A_FRAMES_PER_SECOND_30;
    configuration.synchronized_images_only = true;
    configuration.depth_delay_off_color_usec = 0;
    configuration.wired_sync_mode = K4A_WIRED_SYNC_MODE_STANDALONE;
    configuration.subordinate_delay_off_master_usec = 0;
    configuration.disable_streaming_indicator = false;
    return configuration;
}
// Before
k4a_device_configuration_t configuration;
configuration.color_format                      = K4A_IMAGE_FORMAT_COLOR_BGRA32;
configuration.color_resolution                  = K4A_COLOR_RESOLUTION_720P;
configuration.depth_mode                        = K4A_DEPTH_MODE_NFOV_UNBINNED;
configuration.camera_fps                        = K4A_FRAMES_PER_SECOND_30;
configuration.synchronized_images_only          = true;
configuration.depth_delay_off_color_usec        = 0;
configuration.wired_sync_mode                   = K4A_WIRED_SYNC_MODE_STANDALONE;
configuration.subordinate_delay_off_master_usec = 0;
configuration.disable_streaming_indicator       = false;
device.start_cameras( &configuration );

// After
k4a_device_configuration_t configuration = k4a_get_default_device_configuration();
configuration.color_resolution = K4A_COLOR_RESOLUTION_1080P;
device.start_cameras( &configuration );

What do you think? Thanks,

Enhancement

All 5 comments

We currently have a default config initialization called K4A_DEVICE_CONFIG_INIT_DISABLE_ALL, which has all the cameras disabled by default.
This shortens the above a little bit to:

        k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
        config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
        config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
        config.color_resolution = K4A_COLOR_RESOLUTION_1080P;
        config.synchronized_images_only = true;

It might make sense to add another helper with some more reasonable defaults, such as the above config.

We currently have a default config initialization called K4A_DEVICE_CONFIG_INIT_DISABLE_ALL, which has all the cameras disabled by default.

@xthexder Oh, I wasn鈥檛 aware of that. Thanks,

It is a good idea to define a new constant to provide default settings like K4A_DEVICE_CONFIG_INIT_DISABLE_ALL. I think it makes more sense than defining new function.

static const k4a_device_configuration_t K4A_DEVICE_CONFIG_INIT_DEFAULT = { K4A_IMAGE_FORMAT_COLOR_BGRA32,
                                                                           K4A_COLOR_RESOLUTION_720P,
                                                                           K4A_DEPTH_MODE_NFOV_UNBINNED,
                                                                           K4A_FRAMES_PER_SECOND_30,
                                                                           true,
                                                                           0,
                                                                           K4A_WIRED_SYNC_MODE_STANDALONE,
                                                                           0,
                                                                           false };

@xthexder I updated my pull request. Please see it. Thanks,

Sorry for the delay, just back from vacation. I am not supper comfortable calling this 'default' when it is very specific to 720P, NFOV Unbinned, and BGRA32. While it might be good for 1 user, another would still need the code below, which is not much different from the code @xthexder shared.

k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DEFAULT;
config.color_format = K4A_IMAGE_FORMAT_COLOR_MJPG;
config.depth_mode = K4A_DEPTH_MODE_WFOV_UNBINNED;
config.color_resolution = K4A_COLOR_RESOLUTION_1080P;

I would be more in favor of a function/macro that took these three values in as parameters.

@wes-b I see, It can be easily by initialize config with K4A_DEVICE_CONFIG_INIT_DEFAULT.
And, I think your opinion that it is enough is right. (However, It still needs to be setting to more 4-elements until to standard settings of k4aviewer. The difference between me and your opinion is whether it feels troublesome.)
I will withdraw this proposal once. Thanks,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RenderHeadsMrT picture RenderHeadsMrT  路  3Comments

AdrienPfeufferCarmenta picture AdrienPfeufferCarmenta  路  4Comments

legacydev picture legacydev  路  3Comments

rfilkov picture rfilkov  路  3Comments

natelowry picture natelowry  路  3Comments