-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
107 lines (91 loc) · 3.74 KB
/
main.cpp
File metadata and controls
107 lines (91 loc) · 3.74 KB
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
100
101
102
103
104
105
106
107
/* ***********************************************************
*
* Description:
* main.cpp: Main application entry point.
*
* The program supports two execution modes:
* - CLI mode: runs batch processing on one or more datasets and writes results to disk
* - UI mode : interactive viewer to inspect a dataset frame with visual + numeric feedback
*
* Notes:
* - CLI mode is selected when at least one command-line argument is provided (argc > 1).
* - UI mode is the default when launched without arguments.
*
* ----------------------------------------------------------
*
* Copyright (C) 2026 Claudio Z. (cloudofoz)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* **********************************************************/
#include "opencv2/opencv.hpp"
#include "raylib.h"
#include "d2n_cli.h"
#include "d2n_ui.h"
//---------------------------------------------------------------
// Default window size for the UI. The window is resizable, so these
// values only define the initial resolution.
constexpr int screenWidth = 1280;
constexpr int screenHeight = 720;
//---------------------------------------------------------------
int main(int argc, char** argv)
{
// Reduce OpenCV console output messages
cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);
// If arguments are provided, run in CLI mode and exit immediately.
// This is done to keep the program behavior simple: either batch processing or interactive viewer.
if (argc > 1)
{
return d2n_cli(argc, argv) ? 0 : -1;
}
// UI mode setup (raylib).
// Make the window resizable and keep raylib logging at warning level.
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
SetTraceLogLevel(LOG_WARNING);
InitWindow(screenWidth, screenHeight, "Depth To Normals: Viewer");
// Load window icon
Image app_icon = LoadImage("./assets/icons/app_icon.png");
if (IsImageValid(app_icon))
{
SetWindowIcon(app_icon);
UnloadImage(app_icon);
}
// UIContext: ui_init allocates/initialize any internal resources
// (textures, dataset list, default parameters, etc.).
UIContext ui_ctx = {};
ui_init(ui_ctx);
// Limit rendering to a stable frame rate.
SetTargetFPS(30);
// Main UI loop.
// The viewer is drawn every frame
// Data processing is done only when the user changes dataset/frame/parameters.
while (!WindowShouldClose())
{
BeginDrawing();
// Neutral dark gray background
ClearBackground({ 20, 20, 20, 255 });
// ui_draws() handles all UI rendering and per-frame interactions
ui_draw(ui_ctx);
EndDrawing();
}
// Cleanup
ui_free(ui_ctx);
CloseWindow();
return 0;
}