Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
82 lines (76 loc) · 3.06 KB
/
Copy pathmain.cpp
File metadata and controls
82 lines (76 loc) · 3.06 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
/**
* Camera Calibration & Augmented Reality
* =======================================
* Single entry point for all eight tasks.
*
* Usage:
* ./ar_project <task> [camera_index | video_file]
*
* task 1 – Detect and extract checkerboard corners (live display)
* task 2 – Collect and save calibration images (calib_N.png)
* task 3 – Calibrate camera; loads calib_N.png, saves calibration.yml
* task 4 – Calculate current camera position (read calib, solvePnP, print R/T)
* task 5 – Project outside board corners onto image (reprojection check)
* task 6 – Render virtual rocket object anchored to the board
* task 7 – Detect Harris corner features in live video (with buttons)
* task 8 – AR on static images or pre-captured video sequences
*
* Examples:
* ./ar_project 1 # Task 1, default webcam
* ./ar_project 2 1 # Task 2, webcam index 1
* ./ar_project 3 # Task 3, default webcam
* ./ar_project 4 # Task 4, default webcam
* ./ar_project 5 # Task 5, default webcam
* ./ar_project 6 # Task 6, default webcam
* ./ar_project 7 # Task 7, default webcam
*
* Notes:
* - Tasks 4, 5, 6 require calibration.yml produced by Task 3.
* - The checkerboard must have 9x6 internal corners (BOARD_COLS x BOARD_ROWS).
* - Press 'q' or ESC in any window to quit.
* - Press 's' to save a snapshot in Tasks 1, 2, 4, 5, 6.
*/
#include "task1.h"
#include "task2.h"
#include "task3.h"
#include "task4.h"
#include "task5.h"
#include "task6.h"
#include "task7.h"
#include "task8.h"
#include <iostream>
#include <string>
static void printUsage(const char* prog)
{
std::cout
<< "\nCamera Calibration & AR Project\n"
<< "================================\n"
<< "Usage: " << prog << " <task> [camera_index | video_file]\n\n"
<< " 1 Detect checkerboard corners (live)\n"
<< " 2 Collect calibration images → calib_N.png\n"
<< " 3 Calibrate camera → calibration.yml\n"
<< " 4 Camera position (solvePnP, print R/T) [needs calibration.yml]\n"
<< " 5 Project outside corners [needs calibration.yml]\n"
<< " 6 Virtual shapes — wireframe + shaded [needs calibration.yml]\n"
<< " 7 Harris corner feature detection (live buttons)\n"
<< " 8 Custom target AR (ORB matching, any flat object) [needs calibration.yml]\n\n";
}
int main(int argc, char* argv[])
{
if (argc < 2) { printUsage(argv[0]); return 1; }
std::string t(argv[1]);
if (t == "1") runTask1(argc, argv);
else if (t == "2") runTask2(argc, argv);
else if (t == "3") runTask3(argc, argv);
else if (t == "4") runTask4(argc, argv);
else if (t == "5") runTask5(argc, argv);
else if (t == "6") runTask6(argc, argv);
else if (t == "7") runTask7(argc, argv);
else if (t == "8") runTask8(argc, argv);
else {
std::cerr << "[ERROR] Unknown task: " << t << "\n";
printUsage(argv[0]);
return 1;
}
return 0;
}