积累不是性病的一部分

cla*_*rkk 5 c++ opencv

我是 C++(和 OpenCV)的新手。找到一些代码并尝试编译它,但出现错误。这是什么意思?

\n

首先accumulate是,std::accumulate()但是编译器返回了一个错误,告诉它不是 的成员std。然后我将其更改为cv::accumulate()但现在我收到新错误?也许它应该是的成员std,但我缺少包含头文件?

\n
In file included from txtbin.hpp:11,\n                 from txtbin.cpp:12:\ndewarp.hpp: In member function \xe2\x80\x98std::vector<cv::Point_<double> > Dewarp::keypoints_from_samples(const std::vector<std::vector<cv::Point_<double> > >&, std::vector<double, std::allocator<double> >&, std::vector<std::vector<double, std::allocator<double> > >&)\xe2\x80\x99:\ndewarp.hpp:96:47: error: invalid initialization of reference of type \xe2\x80\x98cv::InputArray\xe2\x80\x99 {aka \xe2\x80\x98const cv::_InputArray&\xe2\x80\x99} from expression of type \xe2\x80\x98std::vector<double, std::allocator<double> >::iterator\xe2\x80\x99\n   96 |   double mean = cv::accumulate(py_coords.begin(), py_coords.end(), 0.0) / py_coords.size();\n
Run Code Online (Sandbox Code Playgroud)\n

代码

\n
std::vector<double> px_coords, py_coords;\n\nfor(const std::vector<cv::Point2d>& points : span_points){\n        std::vector<double> py_coords, px_coords;\n        for(const cv::Point2d& point : points){\n            py_coords.push_back(point.dot(y_dir));\n            px_coords.push_back(point.dot(x_dir) - px0);\n        }\n        double mean = cv::accumulate(py_coords.begin(), py_coords.end(), 0.0) / py_coords.size();\n        y_coords.push_back(mean - py0);\n        x_coords.push_back(px_coords);\n    }\n
Run Code Online (Sandbox Code Playgroud)\n