opencv_lambda_body.h
Go to the documentation of this file.
1 /*
2  * OpenVINS: An Open Platform for Visual-Inertial Research
3  * Copyright (C) 2018-2023 Patrick Geneva
4  * Copyright (C) 2018-2023 Guoquan Huang
5  * Copyright (C) 2018-2023 OpenVINS Contributors
6  * Copyright (C) 2018-2019 Kevin Eckenhoff
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OV_CORE_OPENCV_LAMBDA_BODY_H
23 #define OV_CORE_OPENCV_LAMBDA_BODY_H
24 
25 #include <functional>
26 #include <opencv2/opencv.hpp>
27 
28 namespace ov_core {
29 
30 /*
31  * @brief Helper class to do OpenCV parallelization
32  *
33  * This is a utility class required to build with older version of opencv
34  * On newer versions this doesn't seem to be needed, but here we just use it to ensure we can work for more opencv version.
35  * https://answers.opencv.org/question/65800/how-to-use-lambda-as-a-parameter-to-parallel_for_/?answer=130691#post-id-130691
36  */
37 class LambdaBody : public cv::ParallelLoopBody {
38 public:
39  explicit LambdaBody(const std::function<void(const cv::Range &)> &body) { _body = body; }
40  void operator()(const cv::Range &range) const override { _body(range); }
41 
42 private:
43  std::function<void(const cv::Range &)> _body;
44 };
45 
46 } /* namespace ov_core */
47 
48 #endif /* OV_CORE_OPENCV_LAMBDA_BODY_H */
ov_core::LambdaBody::_body
std::function< void(const cv::Range &)> _body
Definition: opencv_lambda_body.h:43
ov_core::LambdaBody::operator()
void operator()(const cv::Range &range) const override
Definition: opencv_lambda_body.h:40
ov_core::LambdaBody
Definition: opencv_lambda_body.h:37
ov_core::LambdaBody::LambdaBody
LambdaBody(const std::function< void(const cv::Range &)> &body)
Definition: opencv_lambda_body.h:39
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Mon Dec 16 2024 03:06:46