-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.h
99 lines (78 loc) · 2.25 KB
/
Header.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef HEADER_H
#define HEADER_H
#pragma once
#include "main.h"
#include <Windows.h>
#include <opencv2\opencv.hpp>
//#define PROJECTOR_WIDTH 1280
//#define PROJECTOR_HEIGHT 800
//#define CAMERA_WIDTH 1920
//#define CAMERA_HEIGHT 1200
//#define DISPLAY_NUMBER 1
//#define DISPLAY_WIDTH 1680
//#define DISPLAY_HEIGHT 0
namespace Projection{
typedef struct disp_prop{
int index;
int x,y,width,height;
} Disp_Prop;
static int dispCount=-1;
static std::vector<Disp_Prop> Disps_Prop;
//ディスプレイの情報入手
inline BOOL CALLBACK DispEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData ) {
Disp_Prop di;
di.index = dispCount++;
di.x = lprcMonitor->left;
di.y = lprcMonitor->top;
di.width = lprcMonitor->right - di.x;
di.height = lprcMonitor->bottom - di.y;
Disps_Prop.push_back(di);
return TRUE; // TRUEは探索継続,FALSEで終了
}
//ディスプレイ検出
inline void SearchDisplay(void) {
// 一度だけ実行する
if (dispCount == -1) {
dispCount = 0;
Disps_Prop = std::vector<Disp_Prop>();
EnumDisplayMonitors(NULL, NULL, DispEnumProc, 0);
Sleep(200);
}
}
//プロジェクション
inline void MySetFullScrean(const int num, const char *windowname){
HWND windowHandle = ::FindWindowA(NULL, windowname);
SearchDisplay();
if (NULL != windowHandle) {
//-ウィンドウスタイル変更(メニューバーなし、最前面)-
SetWindowLongPtr(windowHandle, GWL_STYLE, WS_POPUP);
SetWindowLongPtr(windowHandle, GWL_EXSTYLE, WS_EX_TOPMOST);
//-最大化する-
ShowWindow(windowHandle, SW_MAXIMIZE);
cv::setWindowProperty(windowname, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN );
//-ディスプレイを指定-
Disp_Prop di = Disps_Prop[num];
//-クライアント領域をディスプレーに合わせる-
SetWindowPos(windowHandle, NULL, di.x, di.y, di.width, di.height, SWP_FRAMECHANGED | SWP_NOZORDER);
}
}
// FPS計算
inline double calcFPS(){
static int stepCount = 0;
static int hoge = 0;
static double fps = 0;
stepCount++;
if (GetTickCount() - hoge >= 1000)
{
int elapsed = GetTickCount() - hoge;
fps = stepCount / (elapsed / 1000.0);
// 小数第2位で丸める
fps = (int)(fps * 10) / 10.0;
std::cout << "LC:" << fps << "[FPS]" << std::endl;
hoge = GetTickCount();
stepCount = 0;
}
return fps;
}
}
#endif