File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/Sensors Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -33,19 +33,15 @@ void FImagePackingAsyncTask::DoWork() {
3333 // properly on client side. NOTE: This case also handles PixelsAsFloat
3434 // implicitly i.e. it ignores it and always sends back uint16 for depth
3535 if (bIsDepthImage && !ImageRequest.bCompress ) {
36- static constexpr float MAX_DEPTH = UINT16_MAX; // TODO move to config?
37-
3836 ImgResponse.ImageDataUInt8 .resize (
3937 RenderResult.Width * RenderResult.Height * 2 * sizeof (uint8));
4038
4139 uint8* DstPtr = ImgResponse.ImageDataUInt8 .data ();
4240 for (const auto & SrcPixel : RenderResult.UnrealImageFloat ) {
43- float DepthMilli = SrcPixel.R .GetFloat () * 1000 ; // m -> mm
44- DepthMilli = DepthMilli > MAX_DEPTH ? MAX_DEPTH : DepthMilli;
45- auto DepthMilliUInt16 = static_cast <uint16_t >(DepthMilli);
46- auto DepthMilliUInt8Ptr = reinterpret_cast <uint8_t *>(&DepthMilliUInt16);
47- *DstPtr++ = *DepthMilliUInt8Ptr++; // 1st byte of uint16 depth
48- *DstPtr++ = *DepthMilliUInt8Ptr; // 2nd byte of uint16 depth
41+ float DepthMilli = SrcPixel.R .GetFloat ();
42+ uint16 DepthUint16 = static_cast <uint16>(DepthMilli);
43+ *DstPtr++ = static_cast <uint8>(DepthUint16 & 0xFF ); // least significant byte
44+ *DstPtr++ = static_cast <uint8>((DepthUint16 >> 8 ) & 0xFF ); // most significant byte
4945 }
5046 }
5147 // Normal RGB images without compression or PixelsAsFloat requested
You can’t perform that action at this time.
0 commit comments