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

Why the uint8_t* to uint16_t* conversion in register_convert()? #6

Open
JMLX42 opened this issue Dec 25, 2019 · 4 comments
Open

Why the uint8_t* to uint16_t* conversion in register_convert()? #6

JMLX42 opened this issue Dec 25, 2019 · 4 comments

Comments

@JMLX42
Copy link

JMLX42 commented Dec 25, 2019

Hi,

thank you for your work.
I have a question though: could you please explain the uint8_t* to uint16_t* cast happening here ?

If depth is stored as an uint8_t, reading and writing it as an uint16_t won't have the expected outcome.
What am I missing?

Thanks,

@JMLX42 JMLX42 changed the title Why uint16_t conversion Why the uint8_t* to uint16_t* conversion in register_convert()? Dec 25, 2019
@mpottinger
Copy link

@promethe42 Im not the author but I just took a look and I did not see any uint8_t for the depth in the code. Strange.

16 bit depth is the standard format from the camera, I don't see any conversion going on in the code.

Not a C++ expert but all I see is the creation of a pointer to the 16 bit data.

@JMLX42
Copy link
Author

JMLX42 commented Dec 25, 2019

output is a std::vector<uint8_t> :

void register_convert(const ST::DepthFrame& depth_frame, const ST::ColorFrame& color_frame, std::vector<uint8_t>& output)

but inner data is casted into a uint16_t* here:

uint16_t* registered_data = reinterpret_cast<uint16_t*>(output.data());

The code works because of the 2* here when allocating. But it looks cumbersome to type output as uint8_t when the function actually expect/work on uint16_t.

@mpottinger
Copy link

@promethe42 ok yes now I see it. I don't know why either. The code also had other issues for me that I had to overcome.

@JMLX42
Copy link
Author

JMLX42 commented Dec 26, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants