|
32 | 32 | #include <opencv2/imgproc/imgproc.hpp> |
33 | 33 |
|
34 | 34 | // Boost JSON |
35 | | -#include <boost/property_tree/ptree.hpp> |
36 | 35 | #include <boost/property_tree/json_parser.hpp> |
37 | 36 |
|
38 | 37 | // SFMData |
39 | 38 | #include <aliceVision/sfmData/SfMData.hpp> |
40 | 39 | #include <aliceVision/sfmDataIO/sfmDataIO.hpp> |
41 | 40 |
|
42 | | -// namespaces |
43 | | -namespace bpt = boost::property_tree; |
44 | | - |
45 | 41 | namespace aliceVision { |
46 | 42 | namespace sphereDetection { |
47 | 43 |
|
| 44 | +void fillShapeTree(bpt::ptree& fileTree, const bpt::ptree& spheresTree) |
| 45 | +{ |
| 46 | + bpt::ptree shapesTree; |
| 47 | + { |
| 48 | + // Shape tree |
| 49 | + bpt::ptree shapeTree; |
| 50 | + shapeTree.put("name", "Manual Sphere Detection"); |
| 51 | + shapeTree.put("type", "Circle"); |
| 52 | + |
| 53 | + // Shape properties tree |
| 54 | + bpt::ptree shapeProperties; |
| 55 | + shapeProperties.put("color", "green"); |
| 56 | + shapeTree.add_child("properties", shapeProperties); |
| 57 | + |
| 58 | + // Shape observations tree |
| 59 | + shapeTree.add_child("observations", spheresTree); |
| 60 | + |
| 61 | + // Add shape tree to shapes tree |
| 62 | + shapesTree.push_back(std::make_pair("", shapeTree)); |
| 63 | + } |
| 64 | + |
| 65 | + fileTree.add_child("shapes", shapesTree); |
| 66 | +} |
| 67 | + |
48 | 68 | void modelExplore(Ort::Session& session) |
49 | 69 | { |
50 | 70 | // Define allocator |
@@ -175,7 +195,7 @@ void sphereDetection(const sfmData::SfMData& sfmData, Ort::Session& session, fs: |
175 | 195 | { |
176 | 196 | // Spheres tree |
177 | 197 | bpt::ptree spheresTree; |
178 | | - |
| 198 | + |
179 | 199 | for (auto& viewID : sfmData.getViews()) |
180 | 200 | { |
181 | 201 | ALICEVISION_LOG_DEBUG("View Id: " << viewID); |
@@ -216,29 +236,13 @@ void sphereDetection(const sfmData::SfMData& sfmData, Ort::Session& session, fs: |
216 | 236 | } |
217 | 237 | } |
218 | 238 |
|
219 | | - // Shapes tree |
220 | | - bpt::ptree shapesTree; |
221 | | - { |
222 | | - // Shape tree |
223 | | - bpt::ptree shapeTree; |
224 | | - shapeTree.put("name", "Sphere Detection"); |
225 | | - shapeTree.put("type", "Circle"); |
226 | 239 |
|
227 | | - // Shape properties tree |
228 | | - bpt::ptree shapeProperties; |
229 | | - shapeProperties.put("color", "green"); |
230 | | - shapeTree.add_child("properties", shapeProperties); |
231 | 240 |
|
232 | | - // Shape observations tree |
233 | | - shapeTree.add_child("observations", spheresTree); |
234 | 241 |
|
235 | | - // Add shape tree to shapes tree |
236 | | - shapesTree.push_back(std::make_pair("", shapeTree)); |
237 | | - } |
238 | 242 |
|
239 | 243 | // Main tree |
240 | 244 | bpt::ptree fileTree; |
241 | | - fileTree.add_child("shapes", shapesTree); |
| 245 | + fillShapeTree(fileTree, spheresTree); |
242 | 246 |
|
243 | 247 | // Write JSON |
244 | 248 | bpt::write_json(outputPath.string(), fileTree); |
|
0 commit comments