Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make minor adjustments to depth-metrics.h and a few dependencies to i… #11404

Merged
merged 3 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(COMMON_SRC
"${CMAKE_CURRENT_LIST_DIR}/float3.h"
"${CMAKE_CURRENT_LIST_DIR}/float4.h"
"${CMAKE_CURRENT_LIST_DIR}/matrix4.h"
"${CMAKE_CURRENT_LIST_DIR}/plane.h"
"${CMAKE_CURRENT_LIST_DIR}/rect.h"
"${CMAKE_CURRENT_LIST_DIR}/rendering.h"
"${CMAKE_CURRENT_LIST_DIR}/model-views.h"
Expand Down
4 changes: 4 additions & 0 deletions common/float3.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inline float3 cross( const float3 & a, const float3 & b )
return { a.y * b.z - b.y * a.z, a.x * b.z - b.x * a.z, a.x * b.y - a.y * b.x };
}

inline float operator*(const float3& a, const float3& b) {
return a.x * b.x + a.y * b.y + a.z * b.z;
}

inline float3 operator*( const float3 & a, float t )
{
return { a.x * t, a.y * t, a.z * t };
Expand Down
25 changes: 25 additions & 0 deletions common/plane.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.

#pragma once

#include "float3.h"

namespace rs2 {

struct plane {
float a;
float b;
float c;
float d;
};

inline bool operator==(const plane& lhs, const plane& rhs) {
return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d;
}

inline float evaluate_plane(const plane& plane, const float3& point) {
return plane.a * point.x + plane.b * point.y + plane.c * point.z + plane.d;
}

}
20 changes: 1 addition & 19 deletions common/rendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "float2.h"
#include "rect.h"
#include "animated.h"
#include "plane.h"

#include <vector>
#include <algorithm>
Expand Down Expand Up @@ -111,20 +112,6 @@ namespace rs2
return b * t + a * (1 - t);
}

struct plane
{
float a;
float b;
float c;
float d;
};
inline bool operator==(const plane& lhs, const plane& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d; }

inline float evaluate_plane(const plane& plane, const float3& point)
{
return plane.a * point.x + plane.b * point.y + plane.c * point.z + plane.d;
}

inline float3 lerp(const float3& a, const float3& b, float t)
{
return b * t + a * (1 - t);
Expand Down Expand Up @@ -163,11 +150,6 @@ namespace rs2
return res;
}

inline float operator*(const float3& a, const float3& b)
{
return a.x*b.x + a.y*b.y + a.z*b.z;
}

inline bool is_valid(const plane_3d& p)
{
std::vector<float> angles;
Expand Down
17 changes: 13 additions & 4 deletions tools/depth-quality/depth-metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
// Plane Fit implementation follows http://www.ilikebigbits.com/blog/2015/3/2/plane-from-points algorithm

#pragma once
#include <vector>
#include <mutex>

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <algorithm>
#include <array>
#include <imgui.h>
#include <cmath>
#include <mutex>
#include <vector>

#include <librealsense2/rs.hpp>
#include "rendering.h"

#include "float3.h"
#include "plane.h"


namespace rs2
{
Expand Down