CARLA
 
载入中...
搜索中...
未找到
InstanceSegmentationCamera.cpp
浏览该文件的文档.
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#include "Carla.h"
11
13
14#include "Components/SceneCaptureComponent2D.h"
15
20
22 const FObjectInitializer &ObjectInitializer)
23 : Super(ObjectInitializer)
24{
25 AddPostProcessingMaterial(TEXT("Material'/Carla/PostProcessingMaterials/PhysicLensDistortion.PhysicLensDistortion'"));
26 // TODO: Setup OnActorSpawnHandler so we can refresh components
27 // World->AddOnActorSpawnedHandler(FOnActorSpawned::FDelegate::CreateRaw(this, &AInstanceSegmentationCamera::OnActorSpawned));
28}
29
31{
32 Super::SetUpSceneCaptureComponent(SceneCapture);
33
34 ApplyViewMode(VMI_Unlit, true, SceneCapture.ShowFlags);
35
36 SceneCapture.ShowFlags.SetNotDrawTaggedComponents(false); // TaggedComponent detects this and sets view relevance for proxy material
37
38 SceneCapture.ShowFlags.SetAtmosphere(false);
39
40 SceneCapture.PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList;
41
42 TArray<UObject *> TaggedComponents;
43 GetObjectsOfClass(UTaggedComponent::StaticClass(), TaggedComponents, false, EObjectFlags::RF_ClassDefaultObject, EInternalObjectFlags::AllFlags);
44
45 TArray<UPrimitiveComponent *> ShowOnlyComponents;
46 for (UObject *Object : TaggedComponents) {
47 UPrimitiveComponent *Component = Cast<UPrimitiveComponent>(Object);
48 SceneCapture.ShowOnlyComponents.Emplace(Component);
49 }
50}
51
52void AInstanceSegmentationCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
53{
54 TRACE_CPUPROFILER_EVENT_SCOPE(AInstanceSegmentationCamera::PostPhysTick);
55
57 TArray<UObject *> TaggedComponents;
58 GetObjectsOfClass(UTaggedComponent::StaticClass(), TaggedComponents, false, EObjectFlags::RF_ClassDefaultObject, EInternalObjectFlags::AllFlags);
59
60 SceneCapture->ClearShowOnlyComponents();
61 for (UObject *Object : TaggedComponents) {
62 UPrimitiveComponent *Component = Cast<UPrimitiveComponent>(Object);
63 SceneCapture->ShowOnlyComponents.Emplace(Component);
64 }
65
66 FPixelReader::SendPixelsInRenderThread<AInstanceSegmentationCamera, FColor>(*this);
67
68}
void SetUpSceneCaptureComponent(USceneCaptureComponent2D &SceneCapture) override
static FActorDefinition GetSensorDefinition()
void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaSeconds) override
AInstanceSegmentationCamera(const FObjectInitializer &ObjectInitializer)
USceneCaptureComponent2D * GetCaptureComponent2D()
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)
A definition of a Carla Actor with all the variation and attributes.