Skip to content

Commit 977d931

Browse files
committed
[sphereDetection] Add helper function to fill output detection file
1 parent 4f74d6a commit 977d931

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

src/aliceVision/sphereDetection/sphereDetection.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,39 @@
3232
#include <opencv2/imgproc/imgproc.hpp>
3333

3434
// Boost JSON
35-
#include <boost/property_tree/ptree.hpp>
3635
#include <boost/property_tree/json_parser.hpp>
3736

3837
// SFMData
3938
#include <aliceVision/sfmData/SfMData.hpp>
4039
#include <aliceVision/sfmDataIO/sfmDataIO.hpp>
4140

42-
// namespaces
43-
namespace bpt = boost::property_tree;
44-
4541
namespace aliceVision {
4642
namespace sphereDetection {
4743

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+
4868
void modelExplore(Ort::Session& session)
4969
{
5070
// Define allocator
@@ -175,7 +195,7 @@ void sphereDetection(const sfmData::SfMData& sfmData, Ort::Session& session, fs:
175195
{
176196
// Spheres tree
177197
bpt::ptree spheresTree;
178-
198+
179199
for (auto& viewID : sfmData.getViews())
180200
{
181201
ALICEVISION_LOG_DEBUG("View Id: " << viewID);
@@ -216,29 +236,13 @@ void sphereDetection(const sfmData::SfMData& sfmData, Ort::Session& session, fs:
216236
}
217237
}
218238

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");
226239

227-
// Shape properties tree
228-
bpt::ptree shapeProperties;
229-
shapeProperties.put("color", "green");
230-
shapeTree.add_child("properties", shapeProperties);
231240

232-
// Shape observations tree
233-
shapeTree.add_child("observations", spheresTree);
234241

235-
// Add shape tree to shapes tree
236-
shapesTree.push_back(std::make_pair("", shapeTree));
237-
}
238242

239243
// Main tree
240244
bpt::ptree fileTree;
241-
fileTree.add_child("shapes", shapesTree);
245+
fillShapeTree(fileTree, spheresTree);
242246

243247
// Write JSON
244248
bpt::write_json(outputPath.string(), fileTree);

src/aliceVision/sphereDetection/sphereDetection.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// ONNXRuntime
1313
#include <onnxruntime_cxx_api.h>
1414

15+
// Boost Property Tree
16+
#include <boost/property_tree/ptree.hpp>
17+
1518
// SFMData
1619
#include <aliceVision/sfmData/SfMData.hpp>
1720
#include <aliceVision/sfmDataIO/sfmDataIO.hpp>
@@ -23,6 +26,7 @@ namespace sphereDetection {
2326

2427
// namespaces
2528
namespace fs = std::filesystem;
29+
namespace bpt = boost::property_tree;
2630

2731
struct Prediction
2832
{
@@ -31,6 +35,8 @@ struct Prediction
3135
cv::Size size;
3236
};
3337

38+
void fillShapeTree(bpt::ptree& fileTree, const bpt::ptree& spheresTree);
39+
3440
/**
3541
* @brief Print inputs and outputs of neural network, and checks the requirements
3642
* @param session The ONNXRuntime session

0 commit comments

Comments
 (0)