forked from simondlevy/UE4_OpenCV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VisionHUD.h
66 lines (49 loc) · 1.43 KB
/
VisionHUD.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* VisionHUD: Heads-Up Display class for OpenCV projects with UnrealEngine4
*
* Adapted from https://answers.unrealengine.com/questions/193827/how-to-get-texture-pixels-using-utexturerendertarg.html
*
* Copyright (C) 2017 Simon D. Levy
*
* MIT License
*/
#pragma once
#include "CoreMinimal.h"
#include "Engine.h"
#include "GameFramework/Character.h"
#include "Engine/TextureRenderTarget2D.h"
#include "VisionAlgorithm.h"
#include <opencv2/core.hpp>
#include "VisionHUD.generated.h"
/**
*
*/
UCLASS()
class SIDESCROLLERCPP_API AVisionHUD : public AHUD
{
GENERATED_BODY()
protected:
// Arbirary params for display
const float LEFTX = 45.f;
const float TOPY = 90.f;
const FLinearColor BORDER_COLOR = FLinearColor::Yellow;
const float BORDER_WIDTH = 2.0f;
// These should agree with the specification of the render target in your blueprint
const wchar_t * RENDER_TARGET_NAME = L"/Game/T_Minimap";
const EPixelFormat RENDER_TARGET_PIXEL_FORMAT = PF_B8G8R8A8;
// Access to MiniMap camera stream
UTextureRenderTarget2D* MiniMapTextureRenderTarget;
FRenderTarget* MiniMapRenderTarget;
TArray<FColor> MiniMapSurfData;
AVisionHUD();
~AVisionHUD();
virtual void DrawHUD() override;
void drawBorder(float lx, float uy, float rx, float by);
// Computed by constructor, used in DrawHUD
int _rows;
int _cols;
// BGR color bytes array
uint8_t* _bgrbytes;
// implementation of your vision algorithm
VisionAlgorithm * _algorithm;
};