CARLA
Loading...
Searching...
No Matches
SceneCaptureCamera.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
11#include <util/ue-header-guard-begin.h>
13#include <util/ue-header-guard-end.h>
14
16{
17 constexpr bool bEnableModifyingPostProcessEffects = true;
19 TEXT("rgb"),
20 bEnableModifyingPostProcessEffects);
21}
22
23ASceneCaptureCamera::ASceneCaptureCamera(const FObjectInitializer& ObjectInitializer)
24 : Super(ObjectInitializer)
25{
27 TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
28}
29
31{
32 Super::BeginPlay();
33}
34
38
42
43void ASceneCaptureCamera::EndPlay(const EEndPlayReason::Type EndPlayReason)
44{
45 Super::EndPlay(EndPlayReason);
46}
47
48void ASceneCaptureCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
49{
50 TRACE_CPUPROFILER_EVENT_SCOPE(ASceneCaptureCamera::PostPhysTick);
51 Super::PostPhysTick(World, TickType, DeltaSeconds);
52
54 return;
55
56 auto CaptureContext = MakeCaptureContext(*this);
57 ImageUtil::ReadSensorImageDataAsyncFColor(*this, [this, CaptureContext](
58 TArrayView<const FColor> Pixels,
59 FIntPoint Size) -> bool
60 {
61 SendDataToClient(*this, Pixels, CaptureContext);
62 return true;
63 });
64}
65
66#ifdef CARLA_HAS_GBUFFER_API
67void ASceneCaptureCamera::SendGBufferTextures(FGBufferRequest& GBuffer)
68{
69 SendGBufferTexturesInternal(*this, GBuffer);
70}
71#endif
static FActorDefinition GetSensorDefinition()
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
virtual void OnLastClientDisconnected() override
void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void OnFirstClientConnected() override
ASceneCaptureCamera(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.