Agrarsense
Public Member Functions | Protected Member Functions | List of all members
AInstanceSegmentationCamera Class Reference

#include <InstanceSegmentationCamera.h>

Inheritance diagram for AInstanceSegmentationCamera:
Inheritance graph
[legend]
Collaboration diagram for AInstanceSegmentationCamera:
Collaboration graph
[legend]

Public Member Functions

 AInstanceSegmentationCamera (const FObjectInitializer &ObjectInitializer)
 
void Init (FCameraBaseParameters parameters, bool SimulateSensor=true) override
 
virtual ESensorTypes GetSensorType () const override
 
- Public Member Functions inherited from ACamera
 ACamera (const FObjectInitializer &ObjectInitializer)
 
virtual void Init (FCameraBaseParameters parameters, bool SimulateSensor=true)
 
virtual ESensorTypes GetSensorType () const override
 
void ChangeCameraParameters (FCameraBaseParameters newParameters)
 
FCameraBaseParameters GetCameraParameters ()
 
void AddPostProcessingMaterial (const FString &Path, float Weight=1.0f)
 
void RemovePostProcessingMaterial (UMaterial *Material)
 
USceneCaptureComponent2D * GetCaptureComponent2D () const
 
UTextureRenderTarget2D * GetCaptureRenderTarget2D () const
 
void AddWidgetToWindow (UWidget *WidgetToAdd)
 
void RemoveWidgetFromWindow (UWidget *WidgetToRemove)
 
void SetShadowRendering (bool RenderShadows)
 
void DisableShowFlags ()
 
void SetTemporalAA (bool SetTemporal)
 
void ResizeCamera (int Width=1280, int Height=720)
 
void AddHiddenActor (AActor *Actor)
 
void SaveCurrentFrameToDisk ()
 
int GetCameraWidth () const
 
int GetCameraHeight () const
 
void SetUseGimbal (bool UseGimbal)
 
virtual FString GetParametersAsString () const override
 
- Public Member Functions inherited from ASensor
 ASensor (const FObjectInitializer &ObjectInitializer)
 
FString ExportToJsonFile (const FString &FileName)
 
virtual ESensorTypes GetSensorType () const
 
FString GetSensorIdentifier () const
 
void SetSensorIdentifier (const FString newIdentifier)
 
FString GetSensorName () const
 
virtual FString GetParametersAsString () const
 
AVehicleIsAttachedToVehicle () const
 
void SetSensorName (const FString newName)
 
FString GetTopicName ()
 
UTopic * GetROSTopic () const
 
void SetSimulateSensor (bool SimulateSensor)
 
bool CanSimulateSensor () const
 
ASensorModelGetSensorModel () const
 
void SetSensorModel (ASensorModel *NewSensorModel)
 
FORCEINLINE bool IsROSConnected () const
 
UROSIntegrationGameInstance * GetROSGameInstance () const
 
virtual FString GetActorID_Implementation () const override
 
virtual FString GetActorName_Implementation () const override
 
virtual FString GetActorInformation_Implementation () const override
 
virtual void SetActorName_Implementation (const FString &NewActorName) override
 
virtual void SetActorIDAndName_Implementation (const FString &NewActorName, const FString &NewID) override
 
void SetParentActorPtr (AActor *ParentActorPtr)
 
- Public Member Functions inherited from IActorInformation
FString GetActorID () const
 
FString GetActorName () const
 
FString GetActorInformation () const
 
void SetActorName (const FString &NewActorName)
 
void SetActorIDAndName (const FString &NewActorName, const FString &NewID)
 

Protected Member Functions

virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) final override
 
virtual void AddProcessingToFrameBuffer (TArray< FColor > &buffer) final override
 
- Protected Member Functions inherited from ACamera
virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
void PreActorTick (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
void EndOfFrame (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
void EndOfFrameParellel (float DeltaTime)
 
virtual void AddProcessingToFrameBuffer (TArray< FColor > &buffer)
 
void ApplyGammaCorrectionLUT (TArray< FColor > &Buffer)
 
void SendImageDataToROS (const TArray< FColor > &FrameBuffer, int32 Width, int32 Height)
 
void HidePrimitiveComponent (UPrimitiveComponent *PrimitiveComponent)
 
void SaveImageToDisk (const TArray< FColor > FrameBuffer, int32 Width, int32 Height)
 
void SaveCameraMetaDataToDisk (const FString &ImageName)
 
void CreateLogFile () override
 
- Protected Member Functions inherited from ASensor
virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
FString CreateTimeStampString () const
 
virtual void CreateROSTopic ()
 
virtual void DestroyROSTopic ()
 
virtual void CreateDataSavePath ()
 
bool IsLogFileCreated ()
 
virtual void CreateLogFile ()
 
void WriteToLogFile (const FString &Message)
 

Additional Inherited Members

- Static Public Member Functions inherited from ASensor
static void HideComponentForAllCameras (UPrimitiveComponent *PrimitiveComponent)
 
static TMap< FString, FColor > GetSemanticColors ()
 
static TArray< TWeakObjectPtr< UPrimitiveComponent > > GetComponentsToHide ()
 
- Static Public Member Functions inherited from IActorInformation
static void SetAndValidateActorIDAndName (FString &ActorName, FString &ActorID, TWeakObjectPtr< AActor > Actor)
 
static bool DestroyActorByID (const FString &ID)
 
static AActor * GetActorByID (const FString &ID)
 
template<typename T >
static TArray< T * > GetActorsWithInterface ()
 
static void PrintAllIds ()
 
- Public Attributes inherited from ACamera
TEnumAsByte< ETextureRenderTargetFormat > TextureFormat = ETextureRenderTargetFormat::RTF_RGBA8
 
FCameraDelegate_OnWindowClosed OnCameraWindowClosed
 
FCameraDelegate_OnWindowResized OnCameraWindowResized
 
- Public Attributes inherited from ASensor
FSensorDestroy OnSensorDestroy
 
FString AttachedToComponent
 
FName AttachedToBone
 
- Static Protected Member Functions inherited from ASensor
template<typename InStructType >
static FString StructToString (const InStructType &InStruct)
 
- Protected Attributes inherited from ACamera
bool UseParallelLateTick = true
 
FDelegateHandle OnPreTickDelegate
 
FDelegateHandle OnPostTickDelegate
 
FString CameraName = "Camera "
 
FString FilePrefix = "Data/Camera_"
 
UTextureRenderTarget2D * CaptureRenderTarget = nullptr
 
USceneCaptureComponent2D * CaptureComponent2D = nullptr
 
UTexture2D * CaptureFrameTexture
 
TSharedPtr< FUnrealWindowUnrealWindow
 
FTickEntry TickEntry
 
TWeakObjectPtr< UMaterialInstanceDynamic > IceMaterialInstance
 
TWeakObjectPtr< UMaterial > PhysicLensDistortion
 
APIDDroneDronePtr = nullptr
 
FRotator SensorSetRotation
 
bool AllowGimbal = true
 
- Protected Attributes inherited from ASensor
UTopic * ROSTopic = nullptr
 
bool SendDataToROS = true
 
ULogFileLogFile = nullptr
 
AActor * ParentActor = nullptr
 
FString FileSavePath
 
UROSIntegrationGameInstance * ROSInstance = nullptr
 
- Static Protected Attributes inherited from ASensor
static FPrimitiveAdded OnPrimitiveAdded
 
static const FName NiagaraPointsInt = "User.PointCount"
 
static const FName NiagaraHitPoints = "User.HitPoints"
 
static const FName NiagaraHitColors = "User.HitColors"
 
static const FName NiagaraPointsFloat = "User.Test"
 

Detailed Description

Class for Instance Segmentation Camera. Limitiations: 1) Unlike other sensors, this sensor only works on our fork of Unreal Engine as custom render pass is required 2) Doesn't support non-nanite meshes and sees through them (simulator maps don't have that many non-nanite meshes though) 3) Doesn't support ISMs (instance static meshes):

Definition at line 22 of file InstanceSegmentationCamera.h.

Constructor & Destructor Documentation

◆ AInstanceSegmentationCamera()

AInstanceSegmentationCamera::AInstanceSegmentationCamera ( const FObjectInitializer &  ObjectInitializer)

Definition at line 13 of file InstanceSegmentationCamera.cpp.

13 : Super(ObjectInitializer)
14{
15 PrimaryActorTick.bCanEverTick = false;
16}

Member Function Documentation

◆ AddProcessingToFrameBuffer()

void AInstanceSegmentationCamera::AddProcessingToFrameBuffer ( TArray< FColor > &  buffer)
finaloverrideprotectedvirtual

Add processing to the frame buffer.

Parameters
buffer- The frame buffer to process.

Reimplemented from ACamera.

Definition at line 65 of file InstanceSegmentationCamera.cpp.

66{
67 // Old way
68 //FColor* BufferPtr = buffer.GetData();
69
70 //for (int32 i = 0; i < buffer.Num(); ++i)
71 //{
72 // // Convert the current FColor (sRGB 0-255) to FLinearColor (linear 0.0-1.0)
73 // FLinearColor pixel = FLinearColor::FromSRGBColor(BufferPtr[i]);
74
75 // // Process the pixel and convert it back to FColor (sRGB 0-255)
76 // // This step applies gamma correction and ensures values are properly adjusted
77 // BufferPtr[i] = FColor(
78 // FMath::RoundToInt(pixel.R * 255.0f),
79 // FMath::RoundToInt(pixel.G * 255.0f),
80 // FMath::RoundToInt(pixel.B * 255.0f));
81 //}
82
84}
void ApplyGammaCorrectionLUT(TArray< FColor > &Buffer)
Definition: Camera.cpp:600

References ACamera::ApplyGammaCorrectionLUT().

◆ EndPlay()

void AInstanceSegmentationCamera::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
finaloverrideprotectedvirtual

Reimplemented from ACamera.

Definition at line 48 of file InstanceSegmentationCamera.cpp.

49{
50 Super::EndPlay(EndPlayReason);
51
52#ifdef InstanceSegmentationPass_EXISTS
55 {
56 UWorld* World = GetWorld();
57 if (GEngine && World)
58 {
59 GEngine->Exec(World, TEXT("r.EnableSegmentationRendering 0"));
60 }
61 }
62#endif
63}
static int32 InstanceSegmentationCameraCount

References InstanceSegmentationCameraCount.

◆ GetSensorType()

virtual ESensorTypes AInstanceSegmentationCamera::GetSensorType ( ) const
inlineoverridevirtual

Get type of the sensor

Returns
Sensor's type

Reimplemented from ACamera.

Definition at line 36 of file InstanceSegmentationCamera.h.

References InstanceSegmentationCamera.

◆ Init()

void AInstanceSegmentationCamera::Init ( FCameraBaseParameters  parameters,
bool  SimulateSensor = true 
)
overridevirtual

Initialize new Camera sensor

Parameters
FCameraBaseParametersCameraParameters struct

Reimplemented from ACamera.

Definition at line 18 of file InstanceSegmentationCamera.cpp.

19{
20 // Defined in Camera.h
21 CameraName = "InstanceSegmentationCamera ";
22 FilePrefix = "Data/InstanceSegmentationCamera_";
23
24 AddPostProcessingMaterial("/Game/Agrarsense/Materials/PostProcessingMaterials/M_InstanceSegmentation.M_InstanceSegmentation");
25 Super::Init(parameters, SimulateSensor);
26
27 // This camera doesn't need to render shadows
28 SetShadowRendering(false);
29
30 // Or many other advanced show flags.
32
33#ifdef InstanceSegmentationPass_EXISTS
34 // If user is using AGRARSENSE Unreal Engine fork, we can utilize this sensor
35 UWorld* World = GetWorld();
36 if (GEngine && World)
37 {
38 GEngine->Exec(World, TEXT("r.EnableSegmentationRendering 1"));
39 }
41#else
42 // else log and destroy this Actor as the user cannot use this sensor anyway.
43 SimulatorLog::Log("InstanceSegmentationCamera.cpp: This sensor is only supported with our AGRARSENSE fork of the engine.");
44 Destroy();
45#endif
46}
void AddPostProcessingMaterial(const FString &Path, float Weight=1.0f)
Definition: Camera.cpp:60
FString FilePrefix
Definition: Camera.h:281
void SetShadowRendering(bool RenderShadows)
Definition: Camera.cpp:849
FString CameraName
Definition: Camera.h:279
void DisableShowFlags()
Definition: Camera.cpp:889
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)

References ACamera::AddPostProcessingMaterial(), ACamera::CameraName, Destroy, ACamera::DisableShowFlags(), ACamera::FilePrefix, InstanceSegmentationCameraCount, SimulatorLog::Log(), and ACamera::SetShadowRendering().


The documentation for this class was generated from the following files: