CARLA
 
载入中...
搜索中...
未找到
OpticalFlowCamera.cpp
浏览该文件的文档.
1#include "Carla.h"
3#include "HAL/IConsoleManager.h"
4
6
8
13
14AOpticalFlowCamera::AOpticalFlowCamera(const FObjectInitializer &ObjectInitializer)
15 : Super(ObjectInitializer)
16{
19 TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
21 TEXT("Material'/Carla/PostProcessingMaterials/VelocityMaterial.VelocityMaterial'"));
22}
23
24void AOpticalFlowCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
25{
26 auto CVarForceOutputsVelocity = IConsoleManager::Get().FindConsoleVariable(TEXT("r.BasePassForceOutputsVelocity"));
27 int32 OldValue = CVarForceOutputsVelocity->GetInt();
28 CVarForceOutputsVelocity->Set(1);
29
30 std::function<TArray<float>(void *, uint32)> Conversor = [](void *Data, uint32 Size)
31 {
32 TArray<float> IntermediateBuffer;
33 int32 Count = Size / sizeof(FFloat16Color);
34 DEBUG_ASSERT(Count * sizeof(FFloat16Color) == Size);
35 FFloat16Color *Buf = reinterpret_cast<FFloat16Color *>(Data);
36 IntermediateBuffer.Reserve(Count * 2);
37 for (int i=0; i<Count; ++i)
38 {
39 float x = (Buf->R.GetFloat() - 0.5f) * 4.f;
40 float y = (Buf->G.GetFloat() - 0.5f) * 4.f;
41 IntermediateBuffer.Add(x);
42 IntermediateBuffer.Add(y);
43 ++Buf;
44 }
45 return IntermediateBuffer;
46 };
47 FPixelReader::SendPixelsInRenderThread<AOpticalFlowCamera, float>(*this, true, Conversor);
48
49 CVarForceOutputsVelocity->Set(OldValue);
50}
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
static FActorDefinition GetSensorDefinition()
AOpticalFlowCamera(const FObjectInitializer &ObjectInitializer)
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
void Enable16BitFormat(bool Enable=false)
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight.
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
A definition of a Carla Actor with all the variation and attributes.