Agrarsense
|
#include <DVSCamera.h>
Public Member Functions | |
ADVSCamera (const FObjectInitializer &ObjectInitializer) | |
virtual void | AddProcessingToFrameBuffer (TArray< FColor > &buffer) override |
virtual ESensorTypes | GetSensorType () const override |
void | ChangeDVSCameraParameters (FDVSCameraParameters NewParameters) |
FDVSCameraParameters | GetDVSCameraParameters () const |
UTopic * | GetDVSTopic () const |
FString | GetDVSTopicName () const |
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 |
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) |
Protected Member Functions | |
void | CreateROSTopic () override |
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) |
Private Member Functions | |
void | DVSInit (FDVSCameraParameters Parameters, bool SimulateSensor=true) |
void | Init (FCameraBaseParameters parameters, bool SimulateSensor=true) override |
virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
void | OnMainCameraWindowResized (ACamera *Camera, FCameraBaseParameters Params) |
void | ImageToGray (const TArray< FColor > &Buffer) |
void | ImageToLogGray (const TArray< FColor > &Buffer) |
void | SendRawDVSImageDataToROS () |
void | DVSWindowClosedCallback (const TSharedRef< SWindow > &Window) |
void | UpdateDVSWindowOutput (const TArray< FColor > &Buffer) |
float | FColorToGrayScaleFloat (const FColor &Color) |
void | ChangeParametersInternal () |
std::vector< DVSEvent > | SimulateDVS (const TArray< FColor > &Buffer) |
constexpr std::int64_t | SecToNanoSec (double seconds) |
constexpr double | NanoSecToSecTrunc (std::int64_t nanoseconds) |
Private Attributes | |
std::vector< DVSEvent > | EventArray |
TArray< double > | LastEventTimestamp |
TArray< float > | PreviousImage |
TArray< float > | LastImage |
TArray< float > | RefValues |
std::int64_t | CurrentTime |
FDVSCameraParameters | TempDVSCameraParameters |
FDVSCameraParameters | DVSCameraParameters |
UTopic * | DvsTopic = nullptr |
TArray< FColor > | DVSOutput |
bool | SetParentParameters = false |
bool | ParametersChanged = false |
TSharedPtr< FUnrealWindow > | DVSUnrealWindow |
TSharedPtr< ROSMessages::sensor_msgs::PointCloud2 > | PointCloudMessage |
FOnWindowClosed | OnDVSWindowClosed |
Static Private Attributes | |
static TArray< int32 > | ApprovedWidths |
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 |
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< 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 |
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" |
Class for Dynamic Vision Camera.
Definition at line 22 of file DVSCamera.h.
ADVSCamera::ADVSCamera | ( | const FObjectInitializer & | ObjectInitializer | ) |
Constructor for ADVSCamera.
ObjectInitializer | - The object initializer. |
Definition at line 30 of file DVSCamera.cpp.
References ACamera::UseParallelLateTick.
|
overridevirtual |
Add processing to the frame buffer.
buffer | - The frame buffer to process. |
Reimplemented from ACamera.
Definition at line 415 of file DVSCamera.cpp.
References ChangeParametersInternal(), DVSOutput, ParametersChanged, SendRawDVSImageDataToROS(), SimulateDVS(), and UpdateDVSWindowOutput().
void ADVSCamera::ChangeDVSCameraParameters | ( | FDVSCameraParameters | NewParameters | ) |
Change the DVS camera parameters.
NewParameters | - The new DVS camera parameters. |
Definition at line 154 of file DVSCamera.cpp.
References ASensor::CanSimulateSensor(), ChangeParametersInternal(), ParametersChanged, SetParentParameters, and TempDVSCameraParameters.
|
private |
Internal function to change camera parameters.
Definition at line 441 of file DVSCamera.cpp.
References FDVSCameraParameters::CameraParameters, ACamera::ChangeCameraParameters(), DVSCameraParameters, DVSUnrealWindow, ACamera::GetCameraHeight(), ACamera::GetCameraWidth(), ParametersChanged, SetParentParameters, and TempDVSCameraParameters.
Referenced by AddProcessingToFrameBuffer(), and ChangeDVSCameraParameters().
|
overrideprotectedvirtual |
Initialize the camera topic.
Reimplemented from ASensor.
Definition at line 358 of file DVSCamera.cpp.
References DvsTopic, ASensor::GetSensorIdentifier(), ASensor::IsROSConnected(), ASensor::ROSInstance, and ASensor::ROSTopic.
|
private |
Initialize the DVS camera with the specified parameters.
Parameters | - The DVS camera parameters. |
Definition at line 39 of file DVSCamera.cpp.
References FDVSCameraParameters::CameraParameters, DVSCameraParameters, and Init().
Referenced by USensorFactory::SpawnDVSCamera().
|
private |
Callback when the DVS window is closed.
Window | - The closed window. |
Definition at line 169 of file DVSCamera.cpp.
Referenced by Init().
|
overrideprivatevirtual |
Called when the camera's play ends.
EndPlayReason | - The reason for the end of play. |
Reimplemented from ACamera.
Definition at line 114 of file DVSCamera.cpp.
References DVSOutput, DvsTopic, DVSUnrealWindow, EventArray, LastEventTimestamp, LastImage, ACamera::OnCameraWindowResized, OnDVSWindowClosed, OnMainCameraWindowResized(), PointCloudMessage, PreviousImage, and RefValues.
|
private |
Convert an FColor to grayscale as a floating-point value.
Color | - The color to convert. |
Definition at line 176 of file DVSCamera.cpp.
References B_WEIGHT, G_WEIGHT, and R_WEIGHT.
Referenced by ImageToLogGray().
|
inline |
Get the current DVS camera parameters.
Definition at line 58 of file DVSCamera.h.
Referenced by USimulatorJsonExporter::ExportSensorToJSON().
|
inline |
Definition at line 64 of file DVSCamera.h.
|
inline |
Definition at line 70 of file DVSCamera.h.
|
inlineoverridevirtual |
Get this sensor parameters struct fields as one string.
Reimplemented from ACamera.
Definition at line 83 of file DVSCamera.h.
|
inlineoverridevirtual |
Get the sensor type.
Reimplemented from ACamera.
Definition at line 44 of file DVSCamera.h.
References DVSCamera.
|
private |
Convert an image to grayscale.
Buffer | - The image buffer to convert. |
Definition at line 181 of file DVSCamera.cpp.
References DVSCameraParameters, LastImage, and FDVSCameraParameters::ParalellImageConversion.
Referenced by SimulateDVS().
|
private |
Convert an image to log grayscale.
Buffer | - The image buffer to convert. |
Definition at line 192 of file DVSCamera.cpp.
References DVSCameraParameters, FColorToGrayScaleFloat(), INV_MAX_VALUE, LastImage, FDVSCameraParameters::LogEps, and FDVSCameraParameters::ParalellImageConversion.
Referenced by SimulateDVS().
|
overrideprivatevirtual |
Initialize the camera with the specified parameters.
parameters | - The camera parameters. |
SimulateSensor | - Whether to simulate the sensor. |
Reimplemented from ACamera.
Definition at line 45 of file DVSCamera.cpp.
References ACamera::CameraName, FDVSCameraParameters::CameraParameters, DVSCameraParameters, DVSOutput, DVSUnrealWindow, DVSWindowClosedCallback(), EventArray, ACamera::FilePrefix, ACamera::GetCameraHeight(), ACamera::GetCameraWidth(), ASensor::GetSensorIdentifier(), ACamera::OnCameraWindowResized, OnDVSWindowClosed, OnMainCameraWindowResized(), PointCloudMessage, ACamera::UnrealWindow, and FDVSCameraParameters::VisualizeDVSCamera.
Referenced by DVSInit().
|
inlineconstexprprivate |
Convert nanoseconds to seconds with truncation.
nanoseconds | - The time in nanoseconds to convert. |
Definition at line 227 of file DVSCamera.h.
Referenced by SimulateDVS().
|
private |
Callback when the main camera window is resized.
Camera | - The camera. |
Params | - The camera parameters. |
Definition at line 147 of file DVSCamera.cpp.
References DVSCameraParameters, ParametersChanged, SetParentParameters, and TempDVSCameraParameters.
|
inlineconstexprprivate |
Convert seconds to nanoseconds.
seconds | - The time in seconds to convert. |
Definition at line 217 of file DVSCamera.h.
Referenced by SimulateDVS().
|
private |
Send raw DVS image data to ROS (Robot Operating System).
Definition at line 394 of file DVSCamera.cpp.
References DvsTopic, EventArray, ASensor::IsROSConnected(), PointCloudMessage, and ASensor::SendDataToROS.
Referenced by AddProcessingToFrameBuffer().
|
private |
Definition at line 207 of file DVSCamera.cpp.
References CurrentTime, DVSCameraParameters, DVSOutput, Engine, EventArray, ACamera::GetCameraHeight(), ACamera::GetCameraWidth(), ImageToGray(), ImageToLogGray(), LastEventTimestamp, LastImage, NanoSecToSecTrunc(), FDVSCameraParameters::NegativeThreshold, FDVSCameraParameters::PositiveThreshold, PreviousImage, FDVSCameraParameters::RefractoryPeriodNs, RefValues, SecToNanoSec(), FDVSCameraParameters::SigmaNegativeThreshold, FDVSCameraParameters::SigmaPositiveThreshold, FDVSCameraParameters::SortByIncreasingTimestamp, and FDVSCameraParameters::UseLog.
Referenced by AddProcessingToFrameBuffer().
|
private |
Update the DVS window output with the provided buffer and dimensions.
Buffer | - The buffer to update. |
Definition at line 464 of file DVSCamera.cpp.
References ACamera::CaptureFrameTexture, and DVSUnrealWindow.
Referenced by AddProcessingToFrameBuffer().
|
friend |
Definition at line 97 of file DVSCamera.h.
|
staticprivate |
Definition at line 210 of file DVSCamera.h.
|
private |
Definition at line 183 of file DVSCamera.h.
Referenced by SimulateDVS().
|
private |
Definition at line 187 of file DVSCamera.h.
Referenced by ChangeParametersInternal(), DVSInit(), ImageToGray(), ImageToLogGray(), Init(), OnMainCameraWindowResized(), and SimulateDVS().
|
private |
Definition at line 198 of file DVSCamera.h.
Referenced by AddProcessingToFrameBuffer(), EndPlay(), Init(), and SimulateDVS().
|
private |
DVS Camera raw data ROS topic. Unlike other sensors, DVS camera has two topics. ROSTopic defined in sensor.h which publishes DVS camera image buffer, and this topic which publishes DVS camera raw event data as PointCloud2 message.
Definition at line 195 of file DVSCamera.h.
Referenced by CreateROSTopic(), EndPlay(), and SendRawDVSImageDataToROS().
|
private |
Definition at line 204 of file DVSCamera.h.
Referenced by ChangeParametersInternal(), EndPlay(), Init(), and UpdateDVSWindowOutput().
|
private |
Definition at line 167 of file DVSCamera.h.
Referenced by EndPlay(), Init(), SendRawDVSImageDataToROS(), and SimulateDVS().
|
private |
Definition at line 172 of file DVSCamera.h.
Referenced by EndPlay(), and SimulateDVS().
|
private |
Definition at line 178 of file DVSCamera.h.
Referenced by EndPlay(), ImageToGray(), ImageToLogGray(), and SimulateDVS().
|
private |
Definition at line 208 of file DVSCamera.h.
|
private |
Definition at line 202 of file DVSCamera.h.
Referenced by AddProcessingToFrameBuffer(), ChangeDVSCameraParameters(), ChangeParametersInternal(), and OnMainCameraWindowResized().
|
private |
Definition at line 206 of file DVSCamera.h.
Referenced by EndPlay(), Init(), and SendRawDVSImageDataToROS().
|
private |
Definition at line 175 of file DVSCamera.h.
Referenced by EndPlay(), and SimulateDVS().
|
private |
Definition at line 181 of file DVSCamera.h.
Referenced by EndPlay(), and SimulateDVS().
|
private |
Definition at line 200 of file DVSCamera.h.
Referenced by ChangeDVSCameraParameters(), ChangeParametersInternal(), and OnMainCameraWindowResized().
|
private |
Definition at line 185 of file DVSCamera.h.
Referenced by ChangeDVSCameraParameters(), ChangeParametersInternal(), and OnMainCameraWindowResized().