Skip to content

Commit

Permalink
Del using namespace mapillary/opensfm/opensfm/src/dense/depthmap_bind.h
Browse files Browse the repository at this point in the history
Summary:
Removes a `using namespace` from the global namespace in pursuit of enabling `-Wheader-hygiene`.
Qualifies instances that relied on the `using namespace`.

Reviewed By: dmm-fb

Differential Revision: D60114516

fbshipit-source-id: d8741cc8a56bf07fb9e596bd219e4ef42468451e
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jul 25, 2024
1 parent 1106198 commit 670d53e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
29 changes: 14 additions & 15 deletions opensfm/src/dense/depthmap_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#include <dense/depthmap.h>
#include <foundation/python_types.h>

using namespace foundation;

namespace dense {

class DepthmapEstimatorWrapper {
public:
void AddView(pyarray_d K, pyarray_d R, pyarray_d t, pyarray_uint8 image,
pyarray_uint8 mask) {
void AddView(foundation::pyarray_d K, foundation::pyarray_d R, foundation::pyarray_d t, foundation::pyarray_uint8 image,
foundation::pyarray_uint8 mask) {
if ((image.shape(0) != mask.shape(0)) || (image.shape(1) != mask.shape(1))){
throw std::invalid_argument("image and mask must have matching shapes.");
}
Expand Down Expand Up @@ -57,13 +56,13 @@ class DepthmapEstimatorWrapper {

py::object ComputeReturnValues(const DepthmapEstimatorResult &result) {
py::list retn;
retn.append(py_array_from_data(result.depth.ptr<float>(0),
retn.append(foundation::py_array_from_data(result.depth.ptr<float>(0),
result.depth.rows, result.depth.cols));
retn.append(py_array_from_data(result.plane.ptr<float>(0),
retn.append(foundation::py_array_from_data(result.plane.ptr<float>(0),
result.plane.rows, result.plane.cols, 3));
retn.append(py_array_from_data(result.score.ptr<float>(0),
retn.append(foundation::py_array_from_data(result.score.ptr<float>(0),
result.score.rows, result.score.cols));
retn.append(py_array_from_data(result.nghbr.ptr<int>(0), result.nghbr.rows,
retn.append(foundation::py_array_from_data(result.nghbr.ptr<int>(0), result.nghbr.rows,
result.nghbr.cols));
return std::move(retn);
}
Expand All @@ -78,7 +77,7 @@ class DepthmapCleanerWrapper {

void SetMinConsistentViews(int n) { dc_.SetMinConsistentViews(n); }

void AddView(pyarray_d K, pyarray_d R, pyarray_d t, pyarray_f depth) {
void AddView(foundation::pyarray_d K, foundation::pyarray_d R, foundation::pyarray_d t, foundation::pyarray_f depth) {
dc_.AddView(K.data(), R.data(), t.data(), depth.data(), depth.shape(1),
depth.shape(0));
}
Expand All @@ -89,7 +88,7 @@ class DepthmapCleanerWrapper {
py::gil_scoped_release release;
dc_.Clean(&depth);
}
return py_array_from_data(depth.ptr<float>(0), depth.rows, depth.cols);
return foundation::py_array_from_data(depth.ptr<float>(0), depth.rows, depth.cols);
}

private:
Expand All @@ -100,8 +99,8 @@ class DepthmapPrunerWrapper {
public:
void SetSameDepthThreshold(float t) { dp_.SetSameDepthThreshold(t); }

void AddView(pyarray_d K, pyarray_d R, pyarray_d t, pyarray_f depth,
pyarray_f plane, pyarray_uint8 color, pyarray_uint8 label) {
void AddView(foundation::pyarray_d K, foundation::pyarray_d R, foundation::pyarray_d t, foundation::pyarray_f depth,
foundation::pyarray_f plane, foundation::pyarray_uint8 color, foundation::pyarray_uint8 label) {
if ((depth.shape(0) != plane.shape(0)) || (depth.shape(1) != plane.shape(1))){
throw std::invalid_argument("depth and plane must have matching shapes.");
}
Expand All @@ -128,10 +127,10 @@ class DepthmapPrunerWrapper {

py::list retn;
int n = int(points.size()) / 3;
retn.append(py_array_from_data(points.data(), n, 3));
retn.append(py_array_from_data(normals.data(), n, 3));
retn.append(py_array_from_data(colors.data(), n, 3));
retn.append(py_array_from_data(labels.data(), n));
retn.append(foundation::py_array_from_data(points.data(), n, 3));
retn.append(foundation::py_array_from_data(normals.data(), n, 3));
retn.append(foundation::py_array_from_data(colors.data(), n, 3));
retn.append(foundation::py_array_from_data(labels.data(), n));
return std::move(retn);
}

Expand Down
6 changes: 3 additions & 3 deletions opensfm/src/dense/openmvs_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace dense {

class OpenMVSExporter {
public:
void AddCamera(const std::string &camera_id, pyarray_d K, uint32_t width, uint32_t height) {
void AddCamera(const std::string &camera_id, foundation::pyarray_d K, uint32_t width, uint32_t height) {
MVS::Interface::Platform platform;
platform.name = camera_id;
MVS::Interface::Platform::Camera camera;
Expand All @@ -22,7 +22,7 @@ class OpenMVSExporter {
}

void AddShot(const std::string &path, const std::string &maskPath, const std::string &shot_id,
const std::string &camera_id, pyarray_d R, pyarray_d C) {
const std::string &camera_id, foundation::pyarray_d R, foundation::pyarray_d C) {
const double *C_data = C.data();

int platform_id = platform_ids_[camera_id];
Expand All @@ -45,7 +45,7 @@ class OpenMVSExporter {
scene_.images.push_back(image);
}

void AddPoint(pyarray_d coordinates, py::list shot_ids) {
void AddPoint(foundation::pyarray_d coordinates, py::list shot_ids) {
const double *x = coordinates.data();

MVS::Interface::Vertex vertex;
Expand Down

0 comments on commit 670d53e

Please sign in to comment.