CARLA
Loading...
Searching...
No Matches
SemanticSegmentationCamera.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
17 const FObjectInitializer &ObjectInitializer)
18 : Super(ObjectInitializer)
19{
21 TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
23 TEXT("Material'/Carla/PostProcessingMaterials/GTMaterial.GTMaterial'"));
24}
25
27{
28 Super::SetUpSceneCaptureComponent(SceneCapture);
29 // This sensor's post-process material samples the segmentation ID buffer;
30 // ask the renderer to run the segmentation pass for this capture (it is
31 // skipped for every capture that does not opt in).
32 SceneCapture.bRequiresSegmentationPass = true;
33}
34
35void ASemanticSegmentationCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
36{
37 TRACE_CPUPROFILER_EVENT_SCOPE(ASemanticSegmentationCamera::PostPhysTick);
38 Super::PostPhysTick(World, TickType, DeltaSeconds);
39
41 return;
42
43 auto CaptureContext = MakeCaptureContext(*this);
44 ImageUtil::ReadSensorImageDataAsyncFColor(*this, [this, CaptureContext](
45 TArrayView<const FColor> Pixels,
46 FIntPoint Size) -> bool
47 {
48 SendDataToClient(*this, Pixels, CaptureContext);
49 return true;
50 });
51}
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
static FActorDefinition GetSensorDefinition()
ASemanticSegmentationCamera(const FObjectInitializer &ObjectInitializer)
void SetUpSceneCaptureComponent(USceneCaptureComponent2D &SceneCapture) override
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.