Skip to content
Snippets Groups Projects
Commit 1f233edf authored by Andre Mühlenbrock's avatar Andre Mühlenbrock
Browse files

Forgot some files...

parent 5ff73c49
No related branches found
No related tags found
No related merge requests found
File added
// Fill out your copyright notice in the Description page of Project Settings.
#include "RegistrationThread.h"
#include "HAL/PlatformProcess.h"
#include "RegistrationManager.h"
FRegistrationThread::FRegistrationThread(ARegistrationManager *registrationManager) :
thread(nullptr),
stopCounter(0),
registrationManager(registrationManager)
{
thread = FRunnableThread::Create(this, TEXT("FRegistrationThread"), 0, TPri_AboveNormal);
}
FRegistrationThread::~FRegistrationThread()
{
if (thread)
{
delete thread;
thread = nullptr;
}
}
void FRegistrationThread::Terminate()
{
Stop();
if (thread)
{
thread->WaitForCompletion();
}
}
bool FRegistrationThread::Init()
{
UE_LOG(LogTemp, Log, TEXT("Azure Kinect thread started."));
return true;
}
uint32 FRegistrationThread::Run()
{
if (!registrationManager)
return 1;
while (stopCounter.GetValue() == 0)
{
// Perform registration:
registrationManager->RegistrateOnCurrent();
// Use at maximum 10 images per second:
FPlatformProcess::Sleep(0.1);
}
return 0;
}
void FRegistrationThread::Stop()
{
stopCounter.Increment();
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "HAL/Runnable.h"
#include "HAL/RunnableThread.h"
class ARegistrationManager;
class VRKINECTREG_API FRegistrationThread : public FRunnable
{
public:
FRegistrationThread(ARegistrationManager* registrationManager);
~FRegistrationThread();
void Terminate();
virtual bool Init() override;
virtual uint32 Run() override;
virtual void Stop() override;
private:
FRunnableThread* thread;
FThreadSafeCounter stopCounter;
ARegistrationManager* registrationManager;
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment