Skip to content

Commit

Permalink
Calculate the exported frame base on the captured frame and the numbe…
Browse files Browse the repository at this point in the history
…r of frames still waiting to be exported

Calculate the exported frame base on the captured frame and the number of frames still waiting to be exported
  • Loading branch information
Sserpenthraxus-nv committed Oct 11, 2019
1 parent 035ea9e commit 924b1b5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
Expand Up @@ -613,6 +613,20 @@ float ANVSceneCapturerActor::GetCapturedDuration() const
return CapturedDuration;
}

int32 ANVSceneCapturerActor::GetExportedFrameCount() const
{
UNVSceneDataExporter* CurrentSceneDataExporter = Cast<UNVSceneDataExporter>(SceneDataHandler);
if (CurrentSceneDataExporter)
{
uint32 PendingToExportImagesCount = CurrentSceneDataExporter->GetPendingToExportImagesCount();
uint32 PendingToExportFrameCount = (ImageToCapturePerFrame > 0) ? FMath::CeilToFloat(float(PendingToExportImagesCount) / ImageToCapturePerFrame) : PendingToExportImagesCount;
uint32 CapturedFrameCount = GetCapturedFrameCounter().GetTotalFrameCount();
return (PendingToExportFrameCount <= CapturedFrameCount) ? (CapturedFrameCount - PendingToExportFrameCount) : 0;
}

return 0;
}

TArray<FNVNamedImageSizePreset> const& ANVSceneCapturerActor::GetImageSizePresets()
{
return GetDefault<ANVSceneCapturerActor>()->ImageSizePresets;
Expand Down Expand Up @@ -660,6 +674,23 @@ void ANVSceneCapturerActor::UpdateViewpointList()
return A.GetDisplayName() < B.GetDisplayName();
});
}

// Count the number of images we need to capture and export every frame
ImageToCapturePerFrame = 0;
for (const auto& CheckViewpointComp : ViewpointList)
{
if (CheckViewpointComp)
{
for (const auto& CheckSceneFeatureExtractor : CheckViewpointComp->FeatureExtractorList)
{
const UNVSceneFeatureExtractor_PixelData* FeatureExtractorScenePixels = Cast<UNVSceneFeatureExtractor_PixelData>(CheckSceneFeatureExtractor);
if (FeatureExtractorScenePixels && FeatureExtractorScenePixels->IsEnabled())
{
ImageToCapturePerFrame++;
}
}
}
}
}

bool ANVSceneCapturerActor::CanHandleMoreSceneData() const
Expand Down
Expand Up @@ -288,10 +288,10 @@ void UNVSceneDataExporter::ExportCapturerSettings()

void UNVSceneDataExporter::OnStopCapturingSceneData()
{
if (ImageExporterThread.IsValid())
{
ImageExporterThread->Stop();
}
if (ImageExporterThread.IsValid())
{
ImageExporterThread->Stop();
}
}

void UNVSceneDataExporter::OnCapturingCompleted()
Expand Down Expand Up @@ -392,6 +392,15 @@ FString UNVSceneDataExporter::GetExportFilePath(UNVSceneFeatureExtractor* Captur
return ExportFilePath;
}

uint32 UNVSceneDataExporter::GetPendingToExportImagesCount() const
{
if (ImageExporterThread.IsValid())
{
return ImageExporterThread->GetPendingImagesCount();
}
return 0;
}

//=================================== UNVSceneDataVisualizer ===================================
UNVSceneDataVisualizer::UNVSceneDataVisualizer()
{
Expand Down
Expand Up @@ -180,6 +180,8 @@ class NVSCENECAPTURER_API ANVSceneCapturerActor : public AActor
float GetCaptureProgressFraction() const;
UFUNCTION(BlueprintCallable, Category = "Capturer")
float GetCapturedDuration() const;
UFUNCTION(BlueprintCallable, Category = "Capturer")
int32 GetExportedFrameCount() const;

UFUNCTION(BlueprintCallable, Category = "Capturer")
TArray<UNVSceneCapturerViewpointComponent*> GetViewpointList();
Expand Down Expand Up @@ -311,4 +313,7 @@ class NVSCENECAPTURER_API ANVSceneCapturerActor : public AActor

UPROPERTY(Transient)
TArray<UNVSceneCapturerViewpointComponent*> ViewpointList;

UPROPERTY(Transient)
int32 ImageToCapturePerFrame;
};
Expand Up @@ -133,6 +133,8 @@ class NVSCENECAPTURER_API UNVSceneDataExporter : public UNVSceneDataHandler
int32 FrameIndex,
const FString& FileExtension) const;

uint32 GetPendingToExportImagesCount() const;

protected:
void ExportCapturerSettings();

Expand Down
Expand Up @@ -128,8 +128,7 @@ void UNVSceneCapturerHUD_ExporterControlPanel::Update()
const FString ExportedFolderPath = SceneDataExporter ? SceneDataExporter->GetConfiguredOutputDirectoryName(): TEXT("");

const uint64 CapturerCounter = ActiveCapturerActor->GetCapturedFrameCounter().GetTotalFrameCount();
// TODO: Get the exported frame count from the UNVSceneDataExporter
const int32 ExportedFrameCount = 0;
const int32 ExportedFrameCount = ActiveCapturerActor->GetExportedFrameCount();
const int32 NumberOfScenesToExport = ActiveCapturerActor->GetNumberOfFramesToCapture();
const ENVSceneCapturerState ExporterState = ActiveCapturerActor->GetCurrentState();
const float CapturedFPS = ActiveCapturerActor->GetCapturedFPS();
Expand Down

0 comments on commit 924b1b5

Please sign in to comment.