Im重複するcv :: Points2fをベクトル内で見つけて数えようとしています。この目的のために、私は次の関数を使用しようとしました。しかし、逆参照値rv[*val]++
を使用しようとしたときにエラーが発生しました。私は(重複するものなし)キーのリストを容器にhabeしたい終わりcv :: Points2fのベクトルで重複を数える
std::map<cv::Point2f, unsigned int> counter(const std::vector<Point2f>& vals)
{
std::map<Point2f, unsigned int> rv;
for (auto val = vals.begin(); val != vals.end(); ++val) {
rv[*val]++;
}
return rv;
}
と元のベクトルでそれらのそれぞれを発見した回数。
次のベクトル
vector<Point2f> v{Point2f(2,2),Point2f(3,3),Point2f(1,2),Point2f(2,2),Point2f(3,3)};
のために私はこの情報の入った容器を取得したい: (1,2)1。 (2,2)2;ちょうど私のように多様なノートとエラーが出る明確にする
: (3,3)2
EDIT
/usr/include/c++/5/bits/stl_function.h:387:20: error: no match for ‘operator<’ (operand types are ‘const cv::Point_<float>’ and ‘const cv::Point_<float>’)
{ return __x < __y; }
/usr/local/include/opencv2/core/cvstd.hpp:1031:20: note: no known conversion for argument 1 from ‘const cv::Point_<float>’ to ‘const cv::String&’
は事前にありがとうございました!マップは、それがoperator<
を使用してelmentsだソートしますので、
「*エラー*」とは何ですか? –