当前位置:   article > 正文

cv::parallel_for__cv:: parallar for

cv:: parallar for
#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;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/657430
推荐阅读
相关标签
  

闽ICP备14008679号