CARLA
Loading...
Searching...
No Matches
DepthCamera.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 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
8#include "Carla.h"
10
15
16ADepthCamera::ADepthCamera(const FObjectInitializer &ObjectInitializer)
17 : Super(ObjectInitializer)
18{
20 TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
22#if PLATFORM_LINUX
23 TEXT("Material'/Carla/PostProcessingMaterials/DepthEffectMaterial_GLSL.DepthEffectMaterial_GLSL'")
24#else
25 TEXT("Material'/Carla/PostProcessingMaterials/DepthEffectMaterial.DepthEffectMaterial'")
26#endif
27 );
28}
29
30void ADepthCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
31{
32 TRACE_CPUPROFILER_EVENT_SCOPE(ADepthCamera::PostPhysTick);
33 Super::PostPhysTick(World, TickType, DeltaSeconds);
34
36 return;
37
38 auto CaptureContext = MakeCaptureContext(*this);
39 ImageUtil::ReadSensorImageDataAsyncFColor(*this, [this, CaptureContext](
40 TArrayView<const FColor> Pixels,
41 FIntPoint Size) -> bool
42 {
43 SendDataToClient(*this, Pixels, CaptureContext);
44 return true;
45 });
46}
static FActorDefinition GetSensorDefinition()
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
ADepthCamera(const FObjectInitializer &ObjectInitializer)
static void SendDataToClient(SensorType &&Sensor, TArrayView< ElementType > SensorData, const FSensorCaptureContext &CaptureContext)
static FSensorCaptureContext MakeCaptureContext(const ASensor &Sensor)
Call on the game thread right after CaptureScene().
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)
bool ReadSensorImageDataAsyncFColor(AShaderBasedSensor &Sensor, ReadImageDataAsyncCallbackFColor &&Callback)
A definition of a Carla Actor with all the variation and attributes.