CARLA
 
载入中...
搜索中...
未找到
Tagger.h
浏览该文件的文档.
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#pragma once
8
9#include "GameFramework/Actor.h"
10#include "Components/PrimitiveComponent.h"
11
15
16#include "Tagger.generated.h"
17
18namespace crp = carla::rpc;
19
20/// Sets actors' custom depth stencil value for semantic segmentation according
21/// to their meshes.
22///
23/// Non-static functions present so it can be dropped into the scene for testing
24/// purposes.
25UCLASS()
26class CARLA_API ATagger : public AActor
27{
28 GENERATED_BODY()
29
30public:
31
32 /// Set the tag of an actor.
33 ///
34 /// If bTagForSemanticSegmentation true, activate the custom depth pass. This
35 /// pass is necessary for rendering the semantic segmentation. However, it may
36 /// add a performance penalty since occlusion doesn't seem to be applied to
37 /// objects having this value active.
38 static void TagActor(const AActor &Actor, bool bTagForSemanticSegmentation);
39
40
41 /// Set the tag of every actor in level.
42 ///
43 /// If bTagForSemanticSegmentation true, activate the custom depth pass. This
44 /// pass is necessary for rendering the semantic segmentation. However, it may
45 /// add a performance penalty since occlusion doesn't seem to be applied to
46 /// objects having this value active.
47 static void TagActorsInLevel(UWorld &World, bool bTagForSemanticSegmentation);
48
49 static void TagActorsInLevel(ULevel &Level, bool bTagForSemanticSegmentation);
50
51 /// Retrieve the tag of an already tagged component.
53 {
54 return static_cast<crp::CityObjectLabel>(Component.CustomDepthStencilValue);
55 }
56
57 /// Retrieve the tags of an already tagged actor. CityObjectLabel::None is
58 /// not added to the array.
59 static void GetTagsOfTaggedActor(const AActor &Actor, TSet<crp::CityObjectLabel> &Tags);
60
61 /// Return true if @a Component has been tagged with the given @a Tag.
62 static bool MatchComponent(const UPrimitiveComponent &Component, crp::CityObjectLabel Tag)
63 {
64 return (Tag == GetTagOfTaggedComponent(Component));
65 }
66
67 /// Retrieve the tags of an already tagged actor. CityObjectLabel::None is
68 /// not added to the array.
69 static FString GetTagAsString(crp::CityObjectLabel Tag);
70
71 /// Method that computes the label corresponding to a folder path
72 static crp::CityObjectLabel GetLabelByFolderName(const FString &String);
73
74 /// Method that computes the label corresponding to an specific object
75 /// using the folder path in which it is stored
76 template <typename T>
77 static crp::CityObjectLabel GetLabelByPath(const T *Object) {
78 const FString Path = Object->GetPathName();
79 TArray<FString> StringArray;
80 Path.ParseIntoArray(StringArray, TEXT("/"), false);
81 return (StringArray.Num() > 4 ? GetLabelByFolderName(StringArray[4]) : crp::CityObjectLabel::None);
82 }
83
84 static void SetStencilValue(UPrimitiveComponent &Component,
85 const crp::CityObjectLabel &Label, const bool bSetRenderCustomDepth);
86
87 static FLinearColor GetActorLabelColor(const AActor &Actor, const crp::CityObjectLabel &Label);
88
89 static bool IsThing(const crp::CityObjectLabel &Label);
90
91 ATagger();
92
93protected:
94
95#if WITH_EDITOR
96 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
97#endif // WITH_EDITOR
98
99private:
100
101 UPROPERTY(Category = "Tagger", EditAnywhere)
102 bool bTriggerTagObjects = false;
103
104 UPROPERTY(Category = "Tagger", EditAnywhere)
105 bool bTagForSemanticSegmentation = false;
106};
Sets actors' custom depth stencil value for semantic segmentation according to their meshes.
Definition Tagger.h:27
static crp::CityObjectLabel GetTagOfTaggedComponent(const UPrimitiveComponent &Component)
Retrieve the tag of an already tagged component.
Definition Tagger.h:52
static bool MatchComponent(const UPrimitiveComponent &Component, crp::CityObjectLabel Tag)
Return true if Component has been tagged with the given Tag.
Definition Tagger.h:62
static crp::CityObjectLabel GetLabelByPath(const T *Object)
Method that computes the label corresponding to an specific object using the folder path in which it ...
Definition Tagger.h:77