structure_core_ros icon indicating copy to clipboard operation
structure_core_ros copied to clipboard

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

Open JMLX42 opened this issue 5 years ago • 4 comments

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 avatar Dec 25 '19 10:12 JMLX42

@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.

mpottinger avatar Dec 25 '19 13:12 mpottinger

output is a std::vector<uint8_t> :

https://github.com/chadrockey/structure_core_ros/blob/a59e98a9620979bdcc824eaafd73909235eed358/include/register.hpp#L41

but inner data is casted into a uint16_t* here:

https://github.com/chadrockey/structure_core_ros/blob/a59e98a9620979bdcc824eaafd73909235eed358/include/register.hpp#L74

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.

JMLX42 avatar Dec 25 '19 17:12 JMLX42

@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.

mpottinger avatar Dec 25 '19 23:12 mpottinger

Do you have an up to date version?

Regards

On Thu, Dec 26, 2019, 00:13 mpottinger [email protected] wrote:

@promethe42 https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chadrockey/structure_core_ros/issues/6?email_source=notifications&email_token=AAHT2LZ36SEOQTUX6GYW2ULQ2PSJPA5CNFSM4J7EBNHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHUUV2I#issuecomment-568937193, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHT2LZAAXORA7IKH3UAFADQ2PSJPANCNFSM4J7EBNHA .

JMLX42 avatar Dec 26 '19 06:12 JMLX42