CARLA
SceneCaptureCamera.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #include "Carla.h"
10 #include <chrono>
11 
12 #include "Runtime/RenderCore/Public/RenderingThread.h"
13 
15 {
16  constexpr bool bEnableModifyingPostProcessEffects = true;
18  TEXT("rgb"),
19  bEnableModifyingPostProcessEffects);
20 }
21 
22 ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer &ObjectInitializer)
23  : Super(ObjectInitializer)
24 {
26  TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
27 }
28 
30 {
31  Super::BeginPlay();
32 }
33 
35 {
36 }
37 
39 {
40 }
41 
42 void ASceneCaptureCamera::EndPlay(const EEndPlayReason::Type EndPlayReason)
43 {
44  Super::EndPlay(EndPlayReason);
45 }
46 
47 void ASceneCaptureCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
48 {
49  TRACE_CPUPROFILER_EVENT_SCOPE(ASceneCaptureCamera::PostPhysTick);
50  ENQUEUE_RENDER_COMMAND(MeasureTime)
51  (
52  [](auto &InRHICmdList)
53  {
54  std::chrono::time_point<std::chrono::high_resolution_clock> Time =
55  std::chrono::high_resolution_clock::now();
56  auto Duration = std::chrono::duration_cast< std::chrono::milliseconds >(Time.time_since_epoch());
57  uint64_t Milliseconds = Duration.count();
58  FString ProfilerText = FString("(Render)Frame: ") + FString::FromInt(FCarlaEngine::GetFrameCounter()) +
59  FString(" Time: ") + FString::FromInt(Milliseconds);
60  TRACE_CPUPROFILER_EVENT_SCOPE_TEXT(*ProfilerText);
61  }
62  );
63  FPixelReader::SendPixelsInRenderThread<ASceneCaptureCamera, FColor>(*this);
64 }
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
ASceneCaptureCamera(const FObjectInitializer &ObjectInitializer)
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight...
A definition of a Carla Actor with all the variation and attributes.
static uint64_t GetFrameCounter()
Definition: CarlaEngine.h:64
static FActorDefinition GetSensorDefinition()
virtual void OnFirstClientConnected() override
void EndPlay(const EEndPlayReason::Type EndPlayReason) override
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
void BeginPlay() override
virtual void OnLastClientDisconnected() override