Resolve the error "call to 'abs' is ambiguous".

PiperOrigin-RevId: 502630518
This commit is contained in:
Jiuqiang Tang 2023-01-17 10:51:04 -08:00 committed by Copybara-Service
parent 7974171c3d
commit 7a4b450c50

View File

@ -16,6 +16,7 @@ limitations under the License.
#ifndef MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_RECT_H_ #ifndef MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_RECT_H_
#define MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_RECT_H_ #define MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_RECT_H_
#include <cmath>
#include <cstdlib> #include <cstdlib>
namespace mediapipe::tasks::components::containers { namespace mediapipe::tasks::components::containers {
@ -48,10 +49,10 @@ struct RectF {
}; };
inline bool operator==(const RectF& lhs, const RectF& rhs) { inline bool operator==(const RectF& lhs, const RectF& rhs) {
return abs(lhs.left - rhs.left) < kRectFTolerance && return std::fabs(lhs.left - rhs.left) < kRectFTolerance &&
abs(lhs.top - rhs.top) < kRectFTolerance && std::fabs(lhs.top - rhs.top) < kRectFTolerance &&
abs(lhs.right - rhs.right) < kRectFTolerance && std::fabs(lhs.right - rhs.right) < kRectFTolerance &&
abs(lhs.bottom - rhs.bottom) < kRectFTolerance; std::fabs(lhs.bottom - rhs.bottom) < kRectFTolerance;
} }
RectF ToRectF(const Rect& rect, int image_height, int image_width); RectF ToRectF(const Rect& rect, int image_height, int image_width);