Skip to content

Instantly share code, notes, and snippets.

@zxytim
Created September 6, 2014 09:22
Show Gist options
  • Save zxytim/2fea4e6f9f9d68ba5bf8 to your computer and use it in GitHub Desktop.
Save zxytim/2fea4e6f9f9d68ba5bf8 to your computer and use it in GitHub Desktop.
//#include "opencv_traits.hh"
#include <opencv2/core/core.hpp>
#include <set>
#include <tuple>
#include <map>
#include <vector>
template <typename value_t>
struct Value_ {
value_t value = 0;
Value_() {}
Value_(value_t v): value(v) {}
};
typedef Value_<int> Value;
bool operator < (const Value &u, const Value &v) {
return u.value < v.value;
}
bool operator < (const cv::Vec3b &a, const cv::Vec3b &b) {
return std::tie(a[0], a[1], a[2]) < std::tie(b[0], b[1], b[2]);
}
int main () {
// std::map<cv::Vec3b, int> s;
// s[cv::Vec3b(0, 255, 0)] = 1; // <-- won't compile
std::map<Value, int> sv;
sv[Value(1)] = 1; // <-- but this will do
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment