Agrarsense
|
#include <Camera.h>
Public Member Functions | |
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 |
ASensorModel * | GetSensorModel () 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) |
Public Attributes | |
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 | |
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) |
Protected Attributes | |
bool | UseParallelLateTick = true |
FDelegateHandle | OnPreTickDelegate |
FDelegateHandle | OnPostTickDelegate |
FString | CameraName = "Camera " |
FString | FilePrefix = "Data/Camera_" |
UTextureRenderTarget2D * | CaptureRenderTarget = nullptr |
USceneCaptureComponent2D * | CaptureComponent2D = nullptr |
UTexture2D * | CaptureFrameTexture |
TSharedPtr< FUnrealWindow > | UnrealWindow |
FTickEntry | TickEntry |
TWeakObjectPtr< UMaterialInstanceDynamic > | IceMaterialInstance |
TWeakObjectPtr< UMaterial > | PhysicLensDistortion |
Protected Attributes inherited from ASensor | |
UTopic * | ROSTopic = nullptr |
bool | SendDataToROS = true |
ULogFile * | LogFile = nullptr |
FString | FileSavePath |
UROSIntegrationGameInstance * | ROSInstance = nullptr |
Private Member Functions | |
void | StartFrameGrabber () |
void | ReleaseFrameGrabber () |
void | FrameGrabberCapture () |
void | OnWindowClosed (const TSharedRef< SWindow > &Window) |
void | SetupCamera (FCameraBaseParameters parameters) |
bool | ShouldSimulate (const float DeltaSeconds) |
Private Attributes | |
TSharedPtr< FFrameGrabber > | FrameGrabber |
FCameraBaseParameters | CameraParameters |
FCameraBaseParameters | TempParams |
AGeoReferencingSystem * | GeoReferencingSystem = nullptr |
bool | ParametersChanged = false |
FOnWindowClosed | OnWindowClosedDelegate |
TSharedPtr< ROSMessages::sensor_msgs::Image > | ImageMsg |
int | ImageWidth = 1280 |
int | ImageHeight = 720 |
bool | SaveCurrentFrameToDiskRequested = false |
bool | ShouldSimulateCamera = true |
float | CameraFrameRate = 0.0f |
float | FrameRateTimer = 0.0f |
int | ImageNumber = 0 |
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 () |
Static Protected Member Functions inherited from ASensor | |
template<typename InStructType > | |
static FString | StructToString (const InStructType &InStruct) |
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" |
Camera sensor base class. All other Camera sensors are inherited from this class.
This creates custom Unreal Engine Window and renders USceneCaptureComponent2D into it. Then the Window screen pixels are read by FrameGrabber API which depending on the Camera type, might add processing on the read pixels. The pixels are then saved to disk if SaveDataToDisk is set to true and data is sent to ROS.
ACamera::ACamera | ( | const FObjectInitializer & | ObjectInitializer | ) |
Setup new ACamera class
FObjectInitializer | default ObjectInitializer |
Definition at line 29 of file Camera.cpp.
References CaptureComponent2D, and CaptureRenderTarget.
void ACamera::AddPostProcessingMaterial | ( | const FString & | Path, |
float | Weight = 1.0f |
||
) |
Adds a post-processing material from the specified file path.
Path | The file path to the post-processing material. |
Weight | The weight or influence of the material. Default is 1.0f. |
Definition at line 55 of file Camera.cpp.
References CaptureComponent2D, ASensor::GetSensorName(), and SimulatorLog::Log().
Referenced by ASemanticSegmentationCamera::Init(), and ADepthCamera::SetupDepthMaterial().
|
protectedvirtual |
Reimplemented in ADVSCamera.
Definition at line 541 of file Camera.cpp.
Referenced by FrameGrabberCapture().
void ACamera::AddWidgetToWindow | ( | UWidget * | WidgetToAdd | ) |
Add Widget to custom Unreal Window
Definition at line 714 of file Camera.cpp.
References UnrealWindow.
Referenced by SetupCamera().
|
overrideprotectedvirtual |
Reimplemented from ASensor.
Definition at line 376 of file Camera.cpp.
References ATickManager::AddTick(), BindTick(), EndOfFrame(), EndOfFrameParellel(), ASensor::GetComponentsToHide(), HidePrimitiveComponent(), OnPostTickDelegate, OnPreTickDelegate, ASensor::OnPrimitiveAdded, PreActorTick(), TickEntry, and UseParallelLateTick.
void ACamera::ChangeCameraParameters | ( | FCameraBaseParameters | newParameters | ) |
Change Camera parameters on the fly. Callable from blueprint.
FCameraBaseParameters | CameraParameters struct |
Definition at line 50 of file Camera.cpp.
References SetupCamera().
Referenced by ADepthCamera::ChangeDepthCameraParameters(), ADVSCamera::ChangeParametersInternal(), AThermalCamera::ChangeThermalCameraParameters(), and ResizeCamera().
|
overrideprotectedvirtual |
Create Text file for this sensor if it has not been created already. Text file will be created to ROOT/Data/Run/Logs directory. Filename will be SensorName_ID_UnixTimestamp.txt Can be overriden by individual sensor if needed.
Reimplemented from ASensor.
Definition at line 89 of file Camera.cpp.
References ULogFile::Create(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FilePath, ASensor::FileSavePath, FLogFileSettings::FileWriteOptions, GeoReferencingSystem, FLogFileSettings::KeepFileOpen, ASensor::LogFile, FLogFileSettings::OverrideFilePath, Overwrite, Queue, FLogFileSettings::QueueLength, FLogFileSettings::Timestamp, and ASensor::WriteToLogFile().
Referenced by Init().
|
protectedvirtual |
Definition at line 469 of file Camera.cpp.
References FrameGrabberCapture().
Referenced by BeginPlay().
|
protectedvirtual |
Definition at line 474 of file Camera.cpp.
References FrameGrabberCapture().
Referenced by BeginPlay().
|
overrideprotectedvirtual |
Reimplemented from ASensor.
Reimplemented in ADepthCamera, ADVSCamera, and AThermalCamera.
Definition at line 411 of file Camera.cpp.
References CaptureComponent2D, CaptureRenderTarget, IceMaterialInstance, ImageMsg, OnPostTickDelegate, OnPreTickDelegate, OnWindowClosedDelegate, ReleaseFrameGrabber(), ATickManager::RemoveTick(), TickEntry, UnrealWindow, and UseParallelLateTick.
|
private |
Capture screen pixels with FrameGrabber
Definition at line 506 of file Camera.cpp.
References AddProcessingToFrameBuffer(), CameraParameters, FrameGrabber, FrameGrabberCapture(), ImageHeight, ImageWidth, SaveCurrentFrameToDiskRequested, SaveImageToDisk(), FCameraBaseParameters::SaveImageToDisk, ASensor::SendDataToROS, SendImageDataToROS(), and ShouldSimulateCamera.
Referenced by EndOfFrame(), EndOfFrameParellel(), and FrameGrabberCapture().
|
inline |
Definition at line 198 of file Camera.h.
Referenced by ADVSCamera::ChangeParametersInternal(), ADVSCamera::Init(), and ADVSCamera::SimulateDVS().
|
inline |
Get current Camera parameters
Definition at line 90 of file Camera.h.
Referenced by USimulatorJsonExporter::ExportSensorToJSON().
|
inline |
Definition at line 192 of file Camera.h.
Referenced by ADVSCamera::ChangeParametersInternal(), ADVSCamera::Init(), and ADVSCamera::SimulateDVS().
|
inline |
Get CaptureComponent USceneCaptureComponent2D pointer.
Definition at line 113 of file Camera.h.
Referenced by ADepthCamera::SetupDepthMaterial(), and AThermalCamera::SetupMaterial().
|
inline |
Get UTextureRenderTarget2D pointer.
|
inlineoverridevirtual |
Get current LidarParameters struct fields as one string.
Reimplemented from ASensor.
Reimplemented in ADepthCamera, ADVSCamera, and AThermalCamera.
|
inlineoverridevirtual |
Get type of the sensor
Reimplemented from ASensor.
Reimplemented in ADepthCamera, ADVSCamera, ASemanticSegmentationCamera, and AThermalCamera.
Definition at line 73 of file Camera.h.
References RGBCamera.
Referenced by SetupCamera(), and StartFrameGrabber().
|
protected |
Definition at line 547 of file Camera.cpp.
References CaptureComponent2D.
Referenced by BeginPlay().
|
virtual |
Initialize new Camera sensor
FCameraBaseParameters | CameraParameters struct |
Reimplemented in ADepthCamera, ADVSCamera, ASemanticSegmentationCamera, and AThermalCamera.
Definition at line 80 of file Camera.cpp.
References ASensor::CreateDataSavePath(), CreateLogFile(), ASensor::SetSimulateSensor(), and SetupCamera().
Referenced by USensorFactory::SpawnCamera().
|
private |
On camera window closed event
Window | reference to SWindow pointer |
Definition at line 701 of file Camera.cpp.
References Destroy, and OnCameraWindowClosed.
Referenced by SetupCamera().
|
protectedvirtual |
Definition at line 452 of file Camera.cpp.
References CaptureComponent2D, FrameGrabber, PreActorTick(), and ShouldSimulate().
Referenced by BeginPlay(), and PreActorTick().
|
private |
Release FrameGrabber and destroy UTexture2D
Definition at line 589 of file Camera.cpp.
References CaptureFrameTexture, and FrameGrabber.
Referenced by EndPlay(), and StartFrameGrabber().
void ACamera::RemovePostProcessingMaterial | ( | UMaterial * | Material | ) |
Removes a specified post-processing material.
Material | A pointer to the material to be removed. |
Definition at line 71 of file Camera.cpp.
References CaptureComponent2D.
Referenced by ADepthCamera::SetupDepthMaterial().
void ACamera::RemoveWidgetFromWindow | ( | UWidget * | WidgetToRemove | ) |
Remove Widget from custom Unreal Window
Definition at line 722 of file Camera.cpp.
References UnrealWindow.
void ACamera::ResizeCamera | ( | int | Width = 1280 , |
int | Height = 720 |
||
) |
Resize camera and custom Unreal Window certain size
Definition at line 750 of file Camera.cpp.
References CameraParameters, ChangeCameraParameters(), FCameraBaseParameters::Height, and FCameraBaseParameters::Width.
|
protected |
Definition at line 671 of file Camera.cpp.
References GeoReferencingSystem, ASensor::LogFile, UCoordinateConversionUtilities::UnrealToGeographicCoordinates(), and ASensor::WriteToLogFile().
Referenced by SaveImageToDisk().
|
inline |
|
protected |
Save Image data as png to disk
FrameBuffer | Image buffer |
width | Image width |
height | Image height |
Definition at line 630 of file Camera.cpp.
References ASensor::FileSavePath, ImageNumber, SimulatorLog::Log(), SaveCameraMetaDataToDisk(), and SaveImageToDisk().
Referenced by FrameGrabberCapture(), and SaveImageToDisk().
|
protectedvirtual |
Construct ROS Image msg and send data to ROS topic
FrameBuffer | Pixel array |
width | Image width |
height | Image height |
Definition at line 607 of file Camera.cpp.
References ASensor::GetROSTopic(), ImageMsg, ASensor::IsROSConnected(), ASensor::SendDataToROS, and SendImageDataToROS().
Referenced by FrameGrabberCapture(), and SendImageDataToROS().
void ACamera::SetShadowRendering | ( | bool | RenderShadows | ) |
Set should this camera USceneCaptureComponent2D render shadows
Definition at line 730 of file Camera.cpp.
References CaptureComponent2D.
Referenced by ADepthCamera::Init(), ASemanticSegmentationCamera::Init(), and AThermalCamera::Init().
void ACamera::SetTemporalAA | ( | bool | SetTemporal | ) |
Set USceneCaptureComponent2D TemporalAA on or off.
Definition at line 741 of file Camera.cpp.
References CaptureComponent2D.
Referenced by SetupCamera().
|
private |
Setup all needed things to make Camera operate.
Definition at line 125 of file Camera.cpp.
References AddWidgetToWindow(), FCameraBaseParameters::Aperture, FCameraBaseParameters::BloomIntensity, CameraFrameRate, CameraParameters, CaptureComponent2D, CaptureRenderTarget, FCameraBaseParameters::ChromAberrIntensity, FCameraBaseParameters::ChromAberrOffset, ASensor::CreateROSTopic(), FCameraBaseParameters::DepthBlurAmount, FCameraBaseParameters::DepthBlurRadius, DepthCamera, FCameraBaseParameters::DofBladeCount, FCameraBaseParameters::DofMinFStop, FCameraBaseParameters::Enable16BitFormat, FCameraBaseParameters::ExposureMaxBrightness, FCameraBaseParameters::ExposureMinBrightness, FCameraBaseParameters::ExposureSpeedDown, FCameraBaseParameters::ExposureSpeedUp, FCameraBaseParameters::FilmBlackClip, FCameraBaseParameters::FilmShoulder, FCameraBaseParameters::FilmSlope, FCameraBaseParameters::FilmToe, FCameraBaseParameters::FilmWhiteClip, FCameraBaseParameters::FocalDistance, FCameraBaseParameters::FOV, ASensor::GetSensorIdentifier(), GetSensorType(), FCameraBaseParameters::Height, FCameraBaseParameters::IceLensEffectAngle, FCameraBaseParameters::IceLensEffectStrength, IceMaterialInstance, ImageHeight, ImageMsg, ImageWidth, FCameraBaseParameters::ISO, FCameraBaseParameters::LensFlareIntensity, FCameraBaseParameters::MotionBlurIntensity, FCameraBaseParameters::MotionBlurMax, FCameraBaseParameters::MotionBlurMinObjSize, OnCameraWindowResized, OnWindowClosed(), OnWindowClosedDelegate, PhysicLensDistortion, FCameraBaseParameters::PostProcessingEffects, RGBCamera, FCameraBaseParameters::SendDataToROS, ASensor::SendDataToROS, SetTemporalAA(), UCameraWidgetBase::Setup(), FCameraBaseParameters::ShutterSpeed, StartFrameGrabber(), FCameraBaseParameters::TargetFrameRate, FCameraBaseParameters::TargetGamma, UnrealWindow, FCameraBaseParameters::UseIceLensEffect, FCameraBaseParameters::UsePhysicLensDistortionEffect, FCameraBaseParameters::UseTemporalAA, FCameraBaseParameters::WhiteTemp, FCameraBaseParameters::WhiteTint, and FCameraBaseParameters::Width.
Referenced by ChangeCameraParameters(), and Init().
|
private |
Should this camera sensor be simulated this frame
Definition at line 479 of file Camera.cpp.
References CameraFrameRate, CameraParameters, ASensor::CanSimulateSensor(), FrameRateTimer, ShouldSimulateCamera, and FCameraBaseParameters::TargetFrameRate.
Referenced by PreActorTick().
|
private |
Setup and start FrameGrabber
Definition at line 555 of file Camera.cpp.
References CaptureFrameTexture, DVSCamera, FrameGrabber, GetSensorType(), ReleaseFrameGrabber(), TextureFormat, and UnrealWindow.
Referenced by SetupCamera().
|
private |
Definition at line 350 of file Camera.h.
Referenced by SetupCamera(), and ShouldSimulate().
|
protected |
Camera title name for the new Unreal Window For example: "Camera 2 Window" or "ThermalCamera 1 Window" Accessible in inherited classes.
Definition at line 262 of file Camera.h.
Referenced by ADepthCamera::Init(), ADVSCamera::Init(), ASemanticSegmentationCamera::Init(), and AThermalCamera::Init().
|
private |
Current Camera parameters. If you wish to change Camera parameters, call ChangeCameraParameters() method.
Definition at line 330 of file Camera.h.
Referenced by FrameGrabberCapture(), ResizeCamera(), SetupCamera(), and ShouldSimulate().
|
protected |
Definition at line 270 of file Camera.h.
Referenced by ACamera(), AddPostProcessingMaterial(), EndPlay(), HidePrimitiveComponent(), PreActorTick(), RemovePostProcessingMaterial(), SetShadowRendering(), SetTemporalAA(), and SetupCamera().
|
protected |
public UTexture2D variable pointer BlueprintReadOnly.
Definition at line 277 of file Camera.h.
Referenced by ReleaseFrameGrabber(), StartFrameGrabber(), and ADVSCamera::UpdateDVSWindowOutput().
|
protected |
Definition at line 267 of file Camera.h.
Referenced by ACamera(), EndPlay(), and SetupCamera().
|
protected |
Definition at line 264 of file Camera.h.
Referenced by ADepthCamera::Init(), ADVSCamera::Init(), ASemanticSegmentationCamera::Init(), and AThermalCamera::Init().
|
private |
FrameGrabber TSharedPtr
Definition at line 313 of file Camera.h.
Referenced by FrameGrabberCapture(), PreActorTick(), ReleaseFrameGrabber(), and StartFrameGrabber().
|
private |
Definition at line 351 of file Camera.h.
Referenced by ShouldSimulate().
|
private |
Definition at line 335 of file Camera.h.
Referenced by CreateLogFile(), and SaveCameraMetaDataToDisk().
|
protected |
Definition at line 283 of file Camera.h.
Referenced by EndPlay(), and SetupCamera().
|
private |
Definition at line 344 of file Camera.h.
Referenced by FrameGrabberCapture(), and SetupCamera().
|
private |
Definition at line 341 of file Camera.h.
Referenced by EndPlay(), SendImageDataToROS(), and SetupCamera().
|
private |
Definition at line 353 of file Camera.h.
Referenced by SaveImageToDisk().
|
private |
Definition at line 343 of file Camera.h.
Referenced by FrameGrabberCapture(), and SetupCamera().
FCameraDelegate_OnWindowClosed ACamera::OnCameraWindowClosed |
On Camera sensor destroyed event. BlueprintAssignable.
Definition at line 140 of file Camera.h.
Referenced by OnWindowClosed().
FCameraDelegate_OnWindowResized ACamera::OnCameraWindowResized |
On Camera sensor window resized event. BlueprintAssignable.
Definition at line 147 of file Camera.h.
Referenced by ADVSCamera::EndPlay(), ADVSCamera::Init(), and SetupCamera().
|
protected |
Definition at line 225 of file Camera.h.
Referenced by BeginPlay(), and EndPlay().
|
protected |
Definition at line 222 of file Camera.h.
Referenced by BeginPlay(), and EndPlay().
|
private |
Definition at line 339 of file Camera.h.
Referenced by EndPlay(), and SetupCamera().
|
protected |
Definition at line 285 of file Camera.h.
Referenced by SetupCamera().
|
private |
Definition at line 346 of file Camera.h.
Referenced by FrameGrabberCapture().
|
private |
Definition at line 348 of file Camera.h.
Referenced by FrameGrabberCapture(), and ShouldSimulate().
|
private |
TEnumAsByte<ETextureRenderTargetFormat> ACamera::TextureFormat = ETextureRenderTargetFormat::RTF_RGBA8 |
public TEnumAsByte<ETextureRenderTargetFormat> variable BlueprintReadOnly.
Definition at line 133 of file Camera.h.
Referenced by StartFrameGrabber().
|
protected |
Definition at line 281 of file Camera.h.
Referenced by BeginPlay(), and EndPlay().
|
protected |
Definition at line 279 of file Camera.h.
Referenced by AddWidgetToWindow(), EndPlay(), ADVSCamera::Init(), RemoveWidgetFromWindow(), SetupCamera(), and StartFrameGrabber().
|
protected |
Definition at line 220 of file Camera.h.
Referenced by ADVSCamera::ADVSCamera(), BeginPlay(), and EndPlay().