Mercurial Hosting > traffic-intelligence
diff trajectorymanagement/src/PointOperations.h @ 1159:e1e7acef8eab
moved trajectory management library into Traffic Intelligence
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 22 Feb 2021 22:09:35 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trajectorymanagement/src/PointOperations.h Mon Feb 22 22:09:35 2021 -0500 @@ -0,0 +1,46 @@ +#ifndef POINTOPERATIONS_H_ +#define POINTOPERATIONS_H_ + +#include "opencv2/core/core.hpp" + +template<typename Ti, typename Tr> + std::basic_istream<Ti>& operator>>(std::basic_istream<Ti>& in, cv::Point_<Tr>& point) +{ + Tr x, y; + if (in >> x >> y) + { + point.x = x; + point.y = y; + } + return in; +} + +template<typename Ti, typename Tr> +std::basic_istream<Ti>& operator>>(std::basic_istream<Ti>& in, cv::Point3_<Tr>& point) +{ + Tr x, y, z; + if (in >> x >> y >> z) + { + point.x = x; + point.y = y; + point.z = z; + } + return in; +} + + +template<typename Tr> +inline std::ostringstream& operator<<(std::ostringstream& out, const cv::Point_<Tr>& point) +{ + out << point.x << " " << point.y; + return out; +} + +template<typename Tr> +inline std::ostringstream& operator<<(std::ostringstream& out, const cv::Point3_<Tr>& point) +{ + out << point.x << " " << point.y << " " << point.z; + return out; +} + +#endif /* POINTOPERATIONS_H_ */