Usage Examples

On this page:

 

Blueprint

Initialize Omnicept/Glia

 

Polling sensor data

 

Sensor Data Delegates

 

Connection events and Omnicept sensor data may be received via delegates. These delegates will fire when new sensor data arrives or when a connection event occurs. To get the Glia Delegate Object use the function GetGliaDelegates. 

 

Blueprint Camera

The Camera Image struct contains a Byte Array field called “Image Data,” which holds the raw image data from Omnicept camera sensors. The “Location” field may be used to identify the source of the Camera Image message, such as “Mouth”.  

Raw image data may be streamed to a Dynamic Material Instance of an existing Material with a Texture2D parameter, as implemented in the Construction Script and Event Graph blueprints shown below

 

Blueprints:

Material:

 

Eye-tracking Raycast

C++

Initialize Omnicept/Glia


void UMyGlia::ConnectToGliaAsync(const FString clientID, const FString accessKey, const ELicensingModel requestedLicense)
{
        UHPGliaClient::ConnectToGliaAsync(clientID, accessKey, licenseMode);
}

 

Polling sensor data


void UMyGlia::GetHeartRate(int& OutHeartRate)
{
    OutHeartRate = 0;
    bool worked = UHPGliaClient::GetHeartRate(OutHeartRate);
}

 

Sensor Data Delegates

.h

#pragma once
#include "CoreMinimal.h"
#include "HPGliaClient.h"
#include "Components/ActorComponent.h"
#include "CLMonitorComponent.generated.h"

UCLASS(ClassGroup=(GliaDemos), meta=(BlueprintSpawnableComponent, Blueprintable) )
class OMNICEPTDEMOS_API UCLMonitorComponent : public UActorComponent
{
GENERATED_BODY()
public:
    UCLMonitorComponent();

protected:
    TArray<float> samples;
    float cogLoadAcum = 0;

public:
    UFUNCTION(BlueprintCallable, Category = "Cognitive Load")
    void StartMonitoring();
    UFUNCTION(BlueprintCallable, Category = "Cognitive Load")
    void StopMonitoring();
    
    UFUNCTION()
    void RegisterCognitiveLoad(FCognitiveLoad CognitiveLoad);
    UFUNCTION(BlueprintCallable, Category = "Cognitive Load")
    TArray<float> GetData();
    UFUNCTION(BlueprintCallable, Category = "Cognitive Load")
    float GetMean();
};

 

 

.cpp

#include "CLMonitorComponent.h"

UCLMonitorComponent::UCLMonitorComponent()
{
    PrimaryComponentTick.bCanEverTick = false;
}

void UCLMonitorComponent::StartMonitoring() {
    UE_LOG(LogTemp, Warning, TEXT("Monitor Started"));
   
    samples.Empty();
    cogLoadAcum = 0;
    UHPGliaDelegates * gliaDelegates = UHPGliaClient::GetGliaDelegates();
    gliaDelegates->OnCogLoadReceived.AddDynamic(this, &UCLMonitorComponent::RegisterCognitiveLoad);
}

void UCLMonitorComponent::StopMonitoring() {
    UE_LOG(LogTemp, Warning, TEXT("Monitor Stopped"));
    UHPGliaDelegates * gliaDelegates = UHPGliaClient::GetGliaDelegates();
    gliaDelegates->OnCogLoadReceived.RemoveDynamic(this, &UCLMonitorComponent::RegisterCognitiveLoad);
}

void UCLMonitorComponent::RegisterCognitiveLoad(FCognitiveLoad CognitiveLoad) {
    samples.Add(CognitiveLoad.CognitiveLoad);
    cogLoadAcum += CognitiveLoad.CognitiveLoad;
}

TArray<float> UCLMonitorComponent::GetData() {
    return samples;
}

float UCLMonitorComponent::GetMean() {
    return (cogLoadAcum / samples.Num());
}