NVIDIA DeepLearning Dataset Synthesizer (NDDS)
 All Classes Namespaces Functions Variables Typedefs Pages
NVSceneFeatureExtractor_DataExport.h
1 /*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10 
11 #pragma once
12 
13 #include "NVSceneFeatureExtractor.h"
14 #include "NVSceneCapturerUtils.h"
15 #include "NVSceneFeatureExtractor_DataExport.generated.h"
16 
17 USTRUCT(BlueprintType)
18 struct NVSCENECAPTURER_API FNVDataExportSettings
19 {
20  GENERATED_BODY()
21 
22 public:
23  FNVDataExportSettings();
24 
25 public: // Editor properties
26  UPROPERTY(EditAnywhere, Category = "Export")
27  ENVIncludeObjects IncludeObjectsType;
28 
29  /// If true, the exporter will ignore all the hidden actors in game
30  UPROPERTY(EditAnywhere, Category = "Export")
31  bool bIgnoreHiddenActor;
32 
33  /// How to generate 3d bounding box for each exported actor mesh
34  UPROPERTY(EditAnywhere, Category = "Export")
35  ENVBoundsGenerationType BoundsType;
36 
37  /// How to generate the 2d bounding box for each exported actor mesh
38  UPROPERTY(EditAnywhere, Category = "Export")
39  ENVBoundBox2dGenerationType BoundingBox2dType;
40 
41  UPROPERTY(EditAnywhere, Category = "Export")
42  bool bOutputEvenIfNoObjectsAreInView;
43 
44  UPROPERTY(EditAnywhere, Category = "Export")
45  FFloatInterval DistanceScaleRange;
46 
47  /// If true, all the image space coordinates are exported in absolute pixel
48  /// Otherwise the coordinates are in ratio between the position and the image size
49  UPROPERTY(EditAnywhere, Category = "Export")
50  bool bExportImageCoordinateInPixel;
51 };
52 
53 // Base class for all the feature extractors that export the scene data to json file
54 UCLASS(Abstract)
56 {
57  GENERATED_BODY()
58 
59 public:
60  UNVSceneFeatureExtractor_AnnotationData(const FObjectInitializer& ObjectInitializer);
61 
62  virtual void StartCapturing() override;
63  virtual void UpdateCapturerSettings() override;
64 
65  /// Callback function get called after capturing scene's annotation data
66  /// TSharedPtr<FJsonObject> - The JSON object contain the annotation data
67  /// UNVSceneFeatureExtractor_AnnotationData* - Reference to the feature extractor that captured the scene annotation data
69 
70  /// Capture the annotation data of the scene and return it in JSON format
72 
73 protected:
74  TSharedPtr<FJsonObject> CaptureSceneAnnotationData();
75  virtual void UpdateSettings() override;
76 
77  void UpdateProjectionMatrix();
78  /// NOTE: May make this function static
79  bool GatherActorData(const AActor* CheckActor, FCapturedObjectData& ActorData);
80  bool ShouldExportActor(const AActor* CheckActor) const;
81  bool IsActorInViewFrustum(const FConvexVolume& ViewFrustum, const AActor* CheckActor) const;
82 
83  FVector ProjectWorldPositionToImagePosition(const FVector& WorldPosition) const;
84 
85  FBox2D GetBoundingBox2D(const AActor* CheckActor, bool bClampToImage = true) const;
86  /// Calculate a 2D axis-aligned bounding box of a 3d shape knowing its vertexes on the viewport
87  FBox2D Calculate2dAABB(TArray<FVector> Vertexes, bool bClampToImage = true) const;
88  /// Calculate a 2D axis-aligned bounding box of a static mesh on the viewport
89  FBox2D Calculate2dAABB_MeshComplexCollision(const class UMeshComponent* CheckMeshComp, bool bClampToImage = true) const;
90 
91 protected: // Editor properties
92  UPROPERTY(EditAnywhere, SimpleDisplay, Category = Config, meta=(ShowOnlyInnerProperties))
93  FNVDataExportSettings DataExportSettings;
94 
95  UPROPERTY(Transient)
96  FMatrix ViewProjectionMatrix;
97 
98  UPROPERTY(Transient)
99  FMatrix ProjectionMatrix;
100 
101 protected: // Transient properties
102  FNVDataExportSettings ProtectedDataExportSettings;
103 };
TFunction< void(TSharedPtr< FJsonObject >, UNVSceneFeatureExtractor_AnnotationData *)> OnFinishedCaptureSceneAnnotationDataCallback
Callback function get called after capturing scene's annotation data TSharedPtr - The JS...