CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Sensor
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
7
#include "
Carla/Sensor/SemanticSegmentationCamera.h
"
8
#include "
Carla.h
"
9
#include "
Actor/ActorBlueprintFunctionLibrary.h
"
10
11
FActorDefinition
ASemanticSegmentationCamera::GetSensorDefinition
()
12
{
13
return
UActorBlueprintFunctionLibrary::MakeCameraDefinition
(TEXT(
"semantic_segmentation"
));
14
}
15
16
ASemanticSegmentationCamera::ASemanticSegmentationCamera
(
17
const
FObjectInitializer &ObjectInitializer)
18
: Super(ObjectInitializer)
19
{
20
AddPostProcessingMaterial
(
21
TEXT(
"Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"
));
22
AddPostProcessingMaterial
(
23
TEXT(
"Material'/Carla/PostProcessingMaterials/GTMaterial.GTMaterial'"
));
24
}
25
26
void
ASemanticSegmentationCamera::SetUpSceneCaptureComponent
(
USceneCaptureComponent2D
&SceneCapture)
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
35
void
ASemanticSegmentationCamera::PostPhysTick
(UWorld *World, ELevelTick TickType,
float
DeltaSeconds)
36
{
37
TRACE_CPUPROFILER_EVENT_SCOPE(
ASemanticSegmentationCamera::PostPhysTick
);
38
Super::PostPhysTick(World, TickType, DeltaSeconds);
39
40
if
(!
AreClientsListening
())
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
}
ActorBlueprintFunctionLibrary.h
Carla.h
SemanticSegmentationCamera.h
ASemanticSegmentationCamera::PostPhysTick
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
Definition
SemanticSegmentationCamera.cpp:35
ASemanticSegmentationCamera::GetSensorDefinition
static FActorDefinition GetSensorDefinition()
Definition
SemanticSegmentationCamera.cpp:11
ASemanticSegmentationCamera::ASemanticSegmentationCamera
ASemanticSegmentationCamera(const FObjectInitializer &ObjectInitializer)
Definition
SemanticSegmentationCamera.cpp:16
ASemanticSegmentationCamera::SetUpSceneCaptureComponent
void SetUpSceneCaptureComponent(USceneCaptureComponent2D &SceneCapture) override
Definition
SemanticSegmentationCamera.cpp:26
ASensor::SendDataToClient
static void SendDataToClient(SensorType &&Sensor, TArrayView< ElementType > SensorData, const FSensorCaptureContext &CaptureContext)
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Sensor/Sensor.h:233
ASensor::MakeCaptureContext
static FSensorCaptureContext MakeCaptureContext(const ASensor &Sensor)
Call on the game thread right after CaptureScene().
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Sensor/Sensor.h:197
ASensor::AreClientsListening
bool AreClientsListening()
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Sensor/Sensor.h:124
AShaderBasedSensor::AddPostProcessingMaterial
bool AddPostProcessingMaterial(const FString &Path)
Load the UMaterialInstanceDynamic at the given Path and append it to the list of shaders with Weight.
Definition
ShaderBasedSensor.cpp:23
UActorBlueprintFunctionLibrary::MakeCameraDefinition
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
Definition
ActorBlueprintFunctionLibrary.cpp:373
USceneCaptureComponent2D
ImageUtil::ReadSensorImageDataAsyncFColor
bool ReadSensorImageDataAsyncFColor(AShaderBasedSensor &Sensor, ReadImageDataAsyncCallbackFColor &&Callback)
Definition
ImageUtil.cpp:512
FActorDefinition
A definition of a Carla Actor with all the variation and attributes.
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Actor/ActorDefinition.h:20
Generated by
1.18.0