Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add template param for pointer type to k4a::image::get_buffer() #1499

Open
diablodale opened this issue Jan 29, 2021 · 1 comment · May be fixed by #1533
Open

add template param for pointer type to k4a::image::get_buffer() #1499

diablodale opened this issue Jan 29, 2021 · 1 comment · May be fixed by #1533
Assignees
Labels
Enhancement New feature or request

Comments

@diablodale
Copy link

I suggest adding a c++ template parameter to k4a::image::get_buffer() so that the pointer type returned can be easily controlled. There is significant probability the image buffer doesn't contain 8-bit data, and significant probability the caller needs a pointer other than uint8_t*. This is extremely common when interoperating with OpenCV.

// desired usage
uint16_t* mydataptr = myimage.get_buffer<uint16_t>();
void* needvoid = myimage.get_buffer<void>();

Describe the solution you'd like

Could be as quick a hack as...

template<typename T = uint8_t>
T *get_buffer() noexcept
{
    return (T*)k4a_image_get_buffer(m_handle);
}

Describe alternatives you've considered

Without the template parameter, I have multiple casts of multiple kinds throughout code. It is litter with no benefit.

@diablodale diablodale added Enhancement New feature or request Triage Needed The Issue still needs to be reviewed by Azure Kinect team members. labels Jan 29, 2021
@qm13 qm13 removed the Triage Needed The Issue still needs to be reviewed by Azure Kinect team members. label Feb 1, 2021
@UnaNancyOwen
Copy link
Contributor

This is a good idea. This will not have any bad side effects to existing code, because template parameter is set to default uint8_t.

@qm13 qm13 self-assigned this Feb 4, 2021
@HlibKazakov2000 HlibKazakov2000 linked a pull request Mar 18, 2021 that will close this issue
7 tasks
@HlibKazakov2000 HlibKazakov2000 self-assigned this Mar 18, 2021
@qm13 qm13 assigned dasparli and unassigned qm13 and HlibKazakov2000 Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants