浏览代码

Aisv614 fix (#34)

* updated code to use capture camera flipy and removed perception flip y code

* updated changelog for bug fix
/main
GitHub 4 年前
当前提交
f3b1a74e
共有 2 个文件被更改,包括 3 次插入26 次删除
  1. 1
      com.unity.perception/CHANGELOG.md
  2. 28
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs

1
com.unity.perception/CHANGELOG.md


### Removed
### Fixed
Fixed bug that prevented RGB captures to be written out to disk
### Security

28
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


using (s_WriteFrame.Auto())
{
var dataColorBuffer = (byte[])r.data.colorBuffer;
if (flipY)
FlipImageY(dataColorBuffer, height);
byte[] encodedData;
using (s_EncodeAndSave.Auto())
{

}
};
CaptureCamera.Capture(cam, colorFunctor);
CaptureCamera.Capture(cam, colorFunctor, flipY: flipY);
Profiler.EndSample();
}

#else
return false;
#endif
}
static unsafe void FlipImageY(byte[] dataColorBuffer, int height)
{
using (s_FlipY.Auto())
{
var stride = dataColorBuffer.Length / height;
var buffer = new NativeArray<byte>(stride, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
fixed(byte* colorBufferPtr = &dataColorBuffer[0])
{
var unsafePtr = (byte*)buffer.GetUnsafePtr();
for (var row = 0; row < height / 2; row++)
{
var nearRowStartPtr = colorBufferPtr + stride * row;
var oppositeRowStartPtr = colorBufferPtr + stride * (height - row - 1);
UnsafeUtility.MemCpy(unsafePtr, oppositeRowStartPtr, stride);
UnsafeUtility.MemCpy(oppositeRowStartPtr, nearRowStartPtr, stride);
UnsafeUtility.MemCpy(nearRowStartPtr, unsafePtr, stride);
}
}
buffer.Dispose();
}
}
void OnSimulationEnding()

正在加载...
取消
保存