This repository has been archived by the owner on Jul 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "MediaPipeCppExample.h" | ||
#include "DrawDebugHelpers.h" | ||
|
||
AMediaPipeCppExample::AMediaPipeCppExample() | ||
{ | ||
PrimaryActorTick.bCanEverTick = true; | ||
|
||
Root = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent")); | ||
Pipeline = CreateDefaultSubobject<UMediaPipePipelineComponent>(TEXT("Pipeline")); | ||
Observer = CreateDefaultSubobject<UMediaPipeLandmarkObserverComponent>(TEXT("Observer")); | ||
|
||
Pipeline->PipelineName = TEXT("pipe0"); | ||
Pipeline->GraphNodes.Add(TEXT("pose_landmarks")); | ||
|
||
Observer->PipelineName = TEXT("pipe0"); | ||
Observer->StreamName = TEXT("pose_world_landmarks"); | ||
Observer->LandmarkListType = EMediaPipeLandmarkListType::LandmarkList; | ||
Observer->AxisX = EMediaPipeLandmarkAxisMapping::Z; | ||
Observer->AxisY = EMediaPipeLandmarkAxisMapping::X; | ||
Observer->AxisZ = EMediaPipeLandmarkAxisMapping::NegY; | ||
Observer->WorldScale = FVector(100, 100, 100); | ||
Observer->MinVisibility = 0.5; | ||
Observer->MinPresence = 0.5; | ||
|
||
Pipeline->AddObserver(Observer); | ||
} | ||
|
||
void AMediaPipeCppExample::OnConstruction(const FTransform& Transform) | ||
{ | ||
Super::OnConstruction(Transform); | ||
RegisterAllComponents(); | ||
} | ||
|
||
void AMediaPipeCppExample::BeginPlay() | ||
{ | ||
Super::BeginPlay(); | ||
Pipeline->Start(); | ||
} | ||
|
||
void AMediaPipeCppExample::EndPlay(const EEndPlayReason::Type EndPlayReason) | ||
{ | ||
Pipeline->Stop(); | ||
Super::EndPlay(EndPlayReason); | ||
} | ||
|
||
void AMediaPipeCppExample::Tick(float DeltaSeconds) | ||
{ | ||
if (Observer && Observer->HaveDetections()) | ||
{ | ||
int ObjectId = 0; | ||
const auto& Landmarks = Observer->GetLandmarkList(ObjectId); | ||
const int Count = Landmarks.Num(); | ||
|
||
auto* World = GetWorld(); | ||
auto Transform = GetActorTransform(); | ||
|
||
for (int i = 0; i < Count; i++) | ||
{ | ||
const auto& L = Landmarks[i]; | ||
if ((L.Visibility > Observer->MinVisibility) && (L.Presence > Observer->MinPresence)) | ||
{ | ||
auto Pos = Transform.TransformPosition(L.Pos); | ||
DrawDebugPoint(World, Pos, 10.0f, FColor(255, 0, 0)); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "MediaPipePipelineComponent.h" | ||
#include "MediaPipeLandmarkObserverComponent.h" | ||
#include "MediaPipeCppExample.generated.h" | ||
|
||
UCLASS(ClassGroup="MediaPipe") | ||
class AMediaPipeCppExample : public AActor | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
AMediaPipeCppExample(); | ||
void OnConstruction(const FTransform& Transform) override; | ||
void BeginPlay() override; | ||
void EndPlay(const EEndPlayReason::Type EndPlayReason) override; | ||
void Tick(float DeltaSeconds) override; | ||
|
||
UPROPERTY() | ||
USceneComponent* Root = nullptr; | ||
|
||
UPROPERTY() | ||
UMediaPipePipelineComponent* Pipeline = nullptr; | ||
|
||
UPROPERTY() | ||
UMediaPipeLandmarkObserverComponent* Observer = nullptr; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
using UnrealBuildTool; | ||
|
||
public class MediaPipeDemo : ModuleRules | ||
{ | ||
public MediaPipeDemo(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); | ||
|
||
PrivateDependencyModuleNames.AddRange(new string[] { }); | ||
public MediaPipeDemo(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
// Uncomment if you are using Slate UI | ||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); | ||
|
||
// Uncomment if you are using online features | ||
// PrivateDependencyModuleNames.Add("OnlineSubsystem"); | ||
PublicDependencyModuleNames.AddRange(new string[] { | ||
"Core", | ||
"CoreUObject", | ||
"Engine", | ||
"InputCore", | ||
"MediaPipe" | ||
}); | ||
|
||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true | ||
} | ||
PrivateDependencyModuleNames.AddRange(new string[] { }); | ||
} | ||
} |