浏览代码

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

/aisv614_0.2.0
Steven Borkman 4 年前
当前提交
468fe37b
共有 1 个文件被更改,包括 2 次插入26 次删除
  1. 28
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs

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()

正在加载...
取消
保存