-
-
Save dilne/f2c3ee67fdf5fd66f55752b93087663c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fill out your copyright notice in the Description page of Project Settings. | |
#pragma once | |
class ASceneCapture2D; //forward declaration | |
#include "CoreMinimal.h" | |
#include "GameFramework/Actor.h" | |
#include "CaptureManager.generated.h" | |
USTRUCT() | |
struct FRenderRequest { | |
GENERATED_BODY() | |
TArray<FColor> Image; | |
FRenderCommandFence RenderFence; | |
bool isPNG; | |
FRenderRequest() { | |
isPNG = false; | |
} | |
}; | |
UCLASS() | |
class TIMMHESS_API ACaptureManager : public AActor | |
{ | |
GENERATED_BODY() | |
public: | |
// Sets default values for this actor's properties | |
ACaptureManager(); | |
// Color Capture Components | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture") | |
ASceneCapture2D* ColorCaptureComponents; | |
protected: | |
// Called when the game starts or when spawned | |
virtual void BeginPlay() override; | |
void SetupColorCaptureComponents(ASceneCapture2D* captureComponent); | |
public: | |
// Called every frame | |
virtual void Tick(float DeltaTime) override; | |
protected: | |
// RenderRequest Queue | |
TQueue<FRenderRequest*> RenderRequestQueue; | |
public: | |
UFUNCTION(BlueprintCallable, Category = "ImageCapture") | |
void CaptureColorNonBlocking(ASceneCapture2D* CaptureComponent, bool IsSegmentation = false); | |
protected: | |
// Creates an async task that will save the captured image to disk | |
void RunAsyncImageSaveTask(TArray<uint8> Image, FString ImageName); | |
}; | |
class AsyncSaveImageToDiskTask : public FNonAbandonableTask { | |
public: | |
AsyncSaveImageToDiskTask(TArray<uint8> Image, FString ImageName); | |
~AsyncSaveImageToDiskTask(); | |
// Required by UE4! | |
FORCEINLINE TStatId GetStatId() const { | |
RETURN_QUICK_DECLARE_CYCLE_STAT(AsyncSaveImageToDiskTask, STATGROUP_ThreadPoolAsyncTasks); | |
} | |
protected: | |
TArray<uint8> ImageCopy; | |
FString FileName = "test"; | |
public: | |
void DoWork(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment