Agrarsense
PhotoCapture.h
Go to the documentation of this file.
1// Copyright (c) 2024 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10
11#include "PhotoCapture.generated.h"
12
13class ACamera;
14
15USTRUCT(Blueprintable)
16struct AGRARSENSE_API FCaptureData
17{
18 GENERATED_BODY()
19
20 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
21 TArray<ACamera*> Cameras;
22
23 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
24 TArray<FTransform> CapturePositions;
25
26 /*
27 * If true, captures additional photos at the same location with different yaw rotations (e.g., 360 view without top/bottom).
28 */
29 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
30 bool CaptureRotatedViews = false;
31
32 /*
33 * Use can give dataCapture json locations in either World locations or GPS locations.
34 */
35 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
36 bool UseGPSLocation = false;
37
38 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
39 int32 CurrentCaptureIndex = 0;
40
41 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
42 int32 FramesToKeepInSamePosition = 4;
43};
44
45/*
46* This Actor automates the process of gathering synthetic camera data by capturing images
47* at predefined positions.
48* Usage:
49* 1) Spawn any Camera (RGB, Depth, Semantic, Thermal or DVS)
50* 2) Spawn this Actor and call SetupPhotoCapture with FCaptureData struct
51*/
52UCLASS()
53class AGRARSENSE_API APhotoCapture : public AActor
54{
55 GENERATED_BODY()
56
57public:
58
59 APhotoCapture(const FObjectInitializer& ObjectInitializer);
60
61 UFUNCTION(BlueprintCallable)
62 void SetupPhotoCapture(FCaptureData NewCaptureData);
63
64protected:
65
66 virtual void BeginPlay() override;
67
68 virtual void Tick(float DeltaTime) override;
69
70 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
71
72private:
73
74 /*
75 * Capture one Image each frame and move to next position next frame.
76 */
77 void Capture();
78
79 void UpdateCameraPositions(const FTransform& Transform);
80
81 void CaptureImages();
82
83 void DestroyCameras();
84
86
87 int32 FrameCounter = 0;
88};
Definition: Camera.h:53
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
Definition: Camera.cpp:426
virtual void BeginPlay() override
Definition: Camera.cpp:379
FCaptureData CaptureData
Definition: PhotoCapture.h:85