赞
踩
#include <iostream>
#include <string>
#include <vector>
#include <opencv2/core/internal.hpp>
class Loop_Invoker : public cv::ParallelLoopBody
{
public:
Loop_Invoker(const std::vector<std::string> & names) :
ParallelLoopBody(), m_names(names)
{}
virtual void operator()(const cv::Range &r) const
{
for (int i = r.start; i != r.end; ++i)
{
std::cout << m_names[i] << std::endl;
}
}
protected:
std::vector<std::string> m_names;
};
int main()
{
std::vector<std::string> name;
for (int i = 0; i != 20; ++i)
{
name.push_back(std::to_string(i));
}
cv::parallel_for_(cv::Range(0, 20), Loop_Invoker(name), 2);
return 0;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。