Skip to content

Commit af74b04

Browse files
committed
viewer: switch to OpenGL v3 and add UI
1 parent ed45da2 commit af74b04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+10994
-3163
lines changed

.github/copilot-instructions.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# OpenMVS Copilot Instructions
2+
3+
OpenMVS is a multi-view stereo reconstruction library implementing a complete photogrammetry pipeline from camera poses + sparse point-cloud to textured mesh. The codebase is mature C++ with custom framework patterns.
4+
5+
## Project Architecture
6+
7+
### Core Namespaces & Structure
8+
- **MVS namespace**: Core reconstruction algorithms (`libs/MVS/`)
9+
- **VIEWER namespace**: 3D visualization application (`apps/Viewer/`)
10+
- **SEACAVE namespace**: Low-level utilities (`libs/Common/`)
11+
12+
### Key Libraries (libs/)
13+
- `Common/`: Custom framework (types, logging, containers, math utilities)
14+
- `MVS/`: Core MVS algorithms (Scene, Image, Camera, Mesh, PointCloud, etc.)
15+
- `IO/`: File format support (PLY, OBJ, MVS formats)
16+
- `Math/`: Mathematical primitives and operations
17+
18+
### Applications (apps/)
19+
Each app is a standalone executable for specific pipeline stages:
20+
- `DensifyPointCloud`: Dense reconstruction from sparse points
21+
- `ReconstructMesh`: Surface reconstruction from dense points
22+
- `RefineMesh`: Mesh quality improvement
23+
- `TextureMesh`: Apply textures to meshes
24+
- `Viewer`: Interactive 3D visualization with OpenGL
25+
- `Interface*`: Import/export to other pipelines (COLMAP, OpenMVG, etc.)
26+
27+
## Build System & Workflows
28+
29+
### Building
30+
```bash
31+
# Standard build (uses vcpkg for dependencies)
32+
mkdir make && cd make
33+
cmake ..
34+
cmake --build . -j4 # or ninja (generates ninja files)
35+
```
36+
37+
### Key Build Tools
38+
- **vcpkg**: Automatic dependency management (see `vcpkg.json`)
39+
- **CMake**: Primary build system with custom utilities in `build/Utils.cmake`
40+
- **ninja**: Preferred generator (faster than make)
41+
42+
### Development Builds
43+
- Debug builds in `make/bin/Debug/`
44+
- Built executables: `./bin/Debug/Viewer`, `./bin/Debug/DensifyPointCloud`, etc.
45+
- Use `cmake --build . -j4` from `make/` directory for incremental builds
46+
47+
## Code Patterns & Conventions
48+
49+
### Memory Management
50+
- Reference counting with automatic cleanup
51+
- RAII patterns throughout
52+
53+
### Logging & Debugging
54+
```cpp
55+
DEBUG("Message"); // Level 0 (always shown in debug)
56+
DEBUG_EXTRA("Details"); // Level 1 (verbose)
57+
VERBOSE("Info: %s", str); // General logging
58+
```
59+
60+
### Error Handling
61+
- `ASSERT(condition)` for debug checks
62+
- Return false/NULL for failures
63+
64+
### Common Typedefs
65+
```cpp
66+
typedef uint32_t IDX; // Array indices
67+
typedef SEACAVE::Point3f Point3f; // 3D points
68+
typedef SEACAVE::String String; // String type
69+
#define NO_ID ((IDX)-1) // Invalid index
70+
```
71+
Most of OpenMVS code uses custom point and matrix types derived from OpenCV types, e.g., `SEACAVE::Point3f`, `SEACAVE::Matrix4f`. Hoewever, some components use Eigen3 types, e.g. `SEACAVE::AABB3d` and `SEACAVE::Ray3d` classes. There custom types support convertion operation to and from Eigen3 types.
72+
73+
### Configuration
74+
- Build-time config in `ConfigLocal.h` (generated)
75+
- Runtime options via boost::program_options pattern
76+
- Feature flags like `OpenMVS_USE_CUDA`, `OpenMVS_USE_CERES`
77+
- Each library uses a precompiled header (`Common.h`) for common includes, like Eigen, OpenCV, etc.
78+
79+
## Viewer Application Specifics
80+
81+
### Key Classes
82+
- `Scene`: Main data container (MVS::Scene + rendering state)
83+
- `Window`: GLFW window management + input handling
84+
- `Renderer`: OpenGL rendering (points, meshes, cameras)
85+
- `Camera`: View/projection matrices + navigation
86+
- `UI`: ImGui interface components
87+
88+
### Rendering Pipeline
89+
```cpp
90+
window.Run(scene) →
91+
Render(scene) →
92+
renderer->RenderPointCloud/RenderMesh →
93+
OpenGL draw calls
94+
```
95+
96+
### Event System
97+
- GLFW events → Window callbacks → Control system updates
98+
- Render-only-on-change optimization uses `glfwWaitEventsTimeout()`
99+
- `Window::RequestRedraw()` triggers frame updates
100+
101+
## Integration Points
102+
103+
### File Formats
104+
- `.mvs`: Native binary format (boost serialization)
105+
- `.ply`: Point clouds and meshes (ASCII/binary)
106+
- `.obj`: Mesh export with MTL materials
107+
- Interface apps handle external formats (COLMAP, etc.)
108+
109+
### External Dependencies
110+
- **Eigen3**: Linear algebra (matrices, vectors)
111+
- **OpenCV**: Image processing and I/O
112+
- **CGAL**: Computational geometry
113+
- **Boost**: Serialization, program options, containers
114+
- **CUDA**: GPU acceleration (optional)
115+
- **GLFW/OpenGL**: Viewer rendering
116+
117+
### Cross-Component Communication
118+
- `MVS::Scene` is the central data exchange format
119+
- Applications typically: load scene → process → save scene
120+
- Viewer loads and visualizes any stage of the pipeline
121+
122+
## Testing & Debugging
123+
124+
### Running Tests
125+
```bash
126+
# From make/ directory
127+
ctest # Run all tests
128+
./bin/Debug/Tests # Direct test executable
129+
```
130+
131+
### Common Debugging
132+
- Use `DEBUG()` macros liberally
133+
- Check `ASSERT()` failures for logic errors
134+
- Viewer: Use F1 for help dialog, check console output
135+
- Memory issues: Build with `_DEBUG` for additional checks
136+
137+
## Performance Considerations
138+
139+
- Multi-threading via OpenMP (`#pragma omp parallel`)
140+
- CUDA kernels for GPU acceleration (when enabled)
141+
- Memory-mapped files for large datasets
142+
- Spatial data structures (octrees) for efficient queries
143+
- Viewer optimizations: frustum culling, render-only-on-change mode

apps/ReconstructMesh/ReconstructMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ int main(int argc, LPCTSTR* argv)
452452
scene.pointcloud.pointWeights.Release();
453453
if (!scene.ReconstructMesh(OPT::fDistInsert, OPT::bUseFreeSpaceSupport, OPT::bUseOnlyROI, 4, OPT::fThicknessFactor, OPT::fQualityFactor))
454454
return EXIT_FAILURE;
455-
VERBOSE("Mesh reconstruction completed: %u vertices, %u faces (%s)", scene.mesh.vertices.GetSize(), scene.mesh.faces.GetSize(), TD_TIMER_GET_FMT().c_str());
455+
VERBOSE("Mesh reconstruction completed: %u vertices, %u faces (%s)", scene.mesh.vertices.size(), scene.mesh.faces.size(), TD_TIMER_GET_FMT().c_str());
456456
#if TD_VERBOSE != TD_VERBOSE_OFF
457457
if (VERBOSITY_LEVEL > 2) {
458458
// dump raw mesh

0 commit comments

Comments
 (0)