Agrarsense
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
AThermalCamera Class Reference

#include <ThermalCamera.h>

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

Public Member Functions

 AThermalCamera (const FObjectInitializer &ObjectInitializer)
 
void ChangeThermalCameraParameters (FThermalCameraParameters Parameters)
 
FThermalCameraParameters GetThermalCameraParameters () const
 
virtual ESensorTypes GetSensorType () const override
 
virtual FString GetParametersAsString () 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 SetTemporalAA (bool SetTemporal)
 
void ResizeCamera (int Width=1280, int Height=720)
 
void SaveCurrentFrameToDisk ()
 
int GetCameraWidth () const
 
int GetCameraHeight () const
 
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
 
void SetSensorName (const FString newName)
 
virtual FString GetTopicName ()
 
UTopic * GetROSTopic () const
 
void SetSimulateSensor (bool SimulateSensor)
 
bool CanSimulateSensor () const
 
ASensorModelGetSensorModel () const
 
void SetSensorModel (ASensorModel *NewSensorModel)
 
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
 
- 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)
 

Private Member Functions

virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
void ThermalInit (FThermalCameraParameters Parameters, bool SimulateSensor=true)
 
void Init (FCameraBaseParameters parameters, bool SimulateSensor=true) override
 
void SetupMaterial ()
 
void UpdateThermalMaterial ()
 

Private Attributes

FThermalCameraParameters ThermalCameraParameters
 
TWeakObjectPtr< UMaterialInstanceDynamic > ThermalMaterial
 

Static Private Attributes

static const FName WidthNoise = "WidthNoise"
 
static const FName HeightNoise = "HeightNoise"
 
static const FName WarmColor = "WarmColor"
 
static const FName WarmColor2 = "WarmColor2"
 
static const FName ColdColor = "ColdColor"
 
static const FName ColdColor2 = "ColdColor2"
 

Friends

class USensorFactory
 

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
 
- Protected Member Functions inherited from ACamera
virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
virtual void PreActorTick (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
virtual void EndOfFrame (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
virtual void EndOfFrameParellel (float DeltaTime)
 
virtual void AddProcessingToFrameBuffer (TArray< FColor > &buffer)
 
virtual 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
 
virtual void CreateROSTopic ()
 
virtual void DestroyROSTopic ()
 
virtual void CreateDataSavePath ()
 
bool IsLogFileCreated ()
 
virtual void CreateLogFile ()
 
void WriteToLogFile (const FString &Message)
 
- 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
 
- Protected Attributes inherited from ASensor
UTopic * ROSTopic = nullptr
 
bool SendDataToROS = true
 
ULogFileLogFile = 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 Thermal camera. This camera uses post processing material to color all certain objects (such as animals) with warm colors and everything else with cold colors.

Definition at line 21 of file ThermalCamera.h.

Constructor & Destructor Documentation

◆ AThermalCamera()

AThermalCamera::AThermalCamera ( const FObjectInitializer &  ObjectInitializer)

Definition at line 11 of file ThermalCamera.cpp.

11 : Super(ObjectInitializer)
12{
13 PrimaryActorTick.bCanEverTick = false;
14}

Member Function Documentation

◆ ChangeThermalCameraParameters()

void AThermalCamera::ChangeThermalCameraParameters ( FThermalCameraParameters  Parameters)

Definition at line 43 of file ThermalCamera.cpp.

44{
45 // Set new Thermal camera parameters
46 ThermalCameraParameters = Parameters;
47
48 // Update material
50
51 // Notify Camera base class to change FCameraBaseParameters
53}
void ChangeCameraParameters(FCameraBaseParameters newParameters)
Definition: Camera.cpp:50
void UpdateThermalMaterial()
FThermalCameraParameters ThermalCameraParameters
Definition: ThermalCamera.h:73
FCameraBaseParameters CameraParameters

References FThermalCameraParameters::CameraParameters, ACamera::ChangeCameraParameters(), ThermalCameraParameters, and UpdateThermalMaterial().

◆ EndPlay()

void AThermalCamera::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprivatevirtual

Called when the camera's play ends.

Parameters
EndPlayReason- The reason for the end of play.

Reimplemented from ACamera.

Definition at line 36 of file ThermalCamera.cpp.

37{
38 Super::EndPlay(EndPlayReason);
39
40 ThermalMaterial.Reset();
41}
TWeakObjectPtr< UMaterialInstanceDynamic > ThermalMaterial
Definition: ThermalCamera.h:75

References ThermalMaterial.

◆ GetParametersAsString()

virtual FString AThermalCamera::GetParametersAsString ( ) const
inlineoverridevirtual

Get this sensor parameters struct fields as one string.

Reimplemented from ACamera.

Definition at line 50 of file ThermalCamera.h.

51 {
53 }
static FString StructToString(const InStructType &InStruct)
Definition: Sensor.h:305

◆ GetSensorType()

virtual ESensorTypes AThermalCamera::GetSensorType ( ) const
inlineoverridevirtual

Get type of the sensor

Returns
Sensor's type

Reimplemented from ACamera.

Definition at line 42 of file ThermalCamera.h.

43 {
45 }

References ThermalCamera.

◆ GetThermalCameraParameters()

FThermalCameraParameters AThermalCamera::GetThermalCameraParameters ( ) const
inline

Definition at line 33 of file ThermalCamera.h.

34 {
36 }

Referenced by USimulatorJsonExporter::ExportSensorToJSON().

◆ Init()

void AThermalCamera::Init ( FCameraBaseParameters  parameters,
bool  SimulateSensor = true 
)
overrideprivatevirtual

Initialize new Camera sensor

Parameters
FCameraBaseParametersCameraParameters struct

Reimplemented from ACamera.

Definition at line 22 of file ThermalCamera.cpp.

23{
24 // Defined in Camera.h
25 CameraName = "ThermalCamera ";
26 FilePrefix = "Data/ThermalCamera_";
27
29
30 // Call Camera base class Init
31 Super::Init(parameters, SimulateSensor);
32
33 SetShadowRendering(false);
34}
FString FilePrefix
Definition: Camera.h:264
void SetShadowRendering(bool RenderShadows)
Definition: Camera.cpp:730
FString CameraName
Definition: Camera.h:262

References ACamera::CameraName, ACamera::FilePrefix, ACamera::SetShadowRendering(), and SetupMaterial().

Referenced by ThermalInit().

◆ SetupMaterial()

void AThermalCamera::SetupMaterial ( )
private

Definition at line 55 of file ThermalCamera.cpp.

56{
57 // Get SceneCaptureComponent2D from the base Camera class
58 USceneCaptureComponent2D* SceneCaptureComponent = GetCaptureComponent2D();
59
60 if (SceneCaptureComponent)
61 {
62 FPostProcessSettings& PostProcessSettings = SceneCaptureComponent->PostProcessSettings;
63 if (!ThermalMaterial.IsValid())
64 {
65 FString Path = "/Game/Agrarsense/Materials/PostProcessingMaterials/M_ThermalCameraMaterial.M_ThermalCameraMaterial";
66 UMaterial* BaseMaterial = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), nullptr, *Path));
67 if (BaseMaterial)
68 {
69 UMaterialInstanceDynamic* DynamicMaterialInstance = UMaterialInstanceDynamic::Create(BaseMaterial, this);
70 ThermalMaterial = DynamicMaterialInstance;
71 PostProcessSettings.AddBlendable(ThermalMaterial.Get(), 1.0f);
73 }
74 }
75 }
76}
USceneCaptureComponent2D * GetCaptureComponent2D() const
Definition: Camera.h:113

References ACamera::GetCaptureComponent2D(), ThermalMaterial, and UpdateThermalMaterial().

Referenced by Init().

◆ ThermalInit()

void AThermalCamera::ThermalInit ( FThermalCameraParameters  Parameters,
bool  SimulateSensor = true 
)
private

Definition at line 16 of file ThermalCamera.cpp.

17{
18 ThermalCameraParameters = Parameters;
20}
void Init(FCameraBaseParameters parameters, bool SimulateSensor=true) override

References FThermalCameraParameters::CameraParameters, Init(), and ThermalCameraParameters.

Referenced by USensorFactory::SpawnThermalCamera().

◆ UpdateThermalMaterial()

void AThermalCamera::UpdateThermalMaterial ( )
private

Definition at line 78 of file ThermalCamera.cpp.

79{
80 UMaterialInstanceDynamic* Material = ThermalMaterial.Get();
81 if (Material)
82 {
83 float Width, Height;
85 {
88 }
89 else
90 {
93 }
94
95 // Set material instance dynamic parameters.
96 Material->SetScalarParameterValue(WidthNoise, Width);
97 Material->SetScalarParameterValue(HeightNoise, Height);
98
99 Material->SetVectorParameterValue(WarmColor, ThermalCameraParameters.WarmColor);
100 Material->SetVectorParameterValue(WarmColor2, ThermalCameraParameters.WarmColor2);
101
102 Material->SetVectorParameterValue(ColdColor, ThermalCameraParameters.ColdColor);
103 Material->SetVectorParameterValue(ColdColor2, ThermalCameraParameters.ColdColor2);
104 }
105}
static const FName ColdColor2
Definition: ThermalCamera.h:83
static const FName WidthNoise
Definition: ThermalCamera.h:77
static const FName WarmColor
Definition: ThermalCamera.h:80
static const FName ColdColor
Definition: ThermalCamera.h:82
static const FName WarmColor2
Definition: ThermalCamera.h:81
static const FName HeightNoise
Definition: ThermalCamera.h:78

References FThermalCameraParameters::AllowCustomNoiseResolution, FThermalCameraParameters::CameraParameters, ColdColor, FThermalCameraParameters::ColdColor, ColdColor2, FThermalCameraParameters::ColdColor2, FCameraBaseParameters::Height, HeightNoise, FThermalCameraParameters::HeightResolutionNoise, ThermalCameraParameters, ThermalMaterial, WarmColor, FThermalCameraParameters::WarmColor, WarmColor2, FThermalCameraParameters::WarmColor2, FCameraBaseParameters::Width, WidthNoise, and FThermalCameraParameters::WidthResolutionNoise.

Referenced by ChangeThermalCameraParameters(), and SetupMaterial().

Friends And Related Function Documentation

◆ USensorFactory

friend class USensorFactory
friend

Definition at line 57 of file ThermalCamera.h.

Member Data Documentation

◆ ColdColor

const FName AThermalCamera::ColdColor = "ColdColor"
inlinestaticprivate

Definition at line 82 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().

◆ ColdColor2

const FName AThermalCamera::ColdColor2 = "ColdColor2"
inlinestaticprivate

Definition at line 83 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().

◆ HeightNoise

const FName AThermalCamera::HeightNoise = "HeightNoise"
inlinestaticprivate

Definition at line 78 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().

◆ ThermalCameraParameters

FThermalCameraParameters AThermalCamera::ThermalCameraParameters
private

◆ ThermalMaterial

TWeakObjectPtr<UMaterialInstanceDynamic> AThermalCamera::ThermalMaterial
private

Definition at line 75 of file ThermalCamera.h.

Referenced by EndPlay(), SetupMaterial(), and UpdateThermalMaterial().

◆ WarmColor

const FName AThermalCamera::WarmColor = "WarmColor"
inlinestaticprivate

Definition at line 80 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().

◆ WarmColor2

const FName AThermalCamera::WarmColor2 = "WarmColor2"
inlinestaticprivate

Definition at line 81 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().

◆ WidthNoise

const FName AThermalCamera::WidthNoise = "WidthNoise"
inlinestaticprivate

Definition at line 77 of file ThermalCamera.h.

Referenced by UpdateThermalMaterial().


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