注:
tbb::parallel_for( 0, no_of_configs, 1, [&](int i) {
cv::Mat affine = configs[i].getAffineMatrix();
/* Check if our affine transformed rectangle still fits within our boundary */
cv::Mat affine_corners = (affine * corners).t();
affine_corners = affine_corners + transl;
if( WITHIN( affine_corners.at<cv::Point2f>(0), top_left, bottom_right) &&
WITHIN( affine_corners.at<cv::Point2f>(1), top_left, bottom_right) &&
WITHIN( affine_corners.at<cv::Point2f>(2), top_left, bottom_right) &&
WITHIN( affine_corners.at<cv::Point2f>(3), top_left, bottom_right) ) {
affines[i] = affine;
insiders[i] = true;
}
});
auto func = [&](int i) {
cv::Mat affine = configs[i].getAffineMatrix();
/* Check if our affine transformed rectangle still fits within our boundary */
cv::Mat affine_corners = (affine * corners).t();
affine_corners = affine_corners + transl;
cv::Point2f point0, point1, point2, point3;
point0.x = affine_corners.at<float>(0, 0);
point0.y = affine_corners.at<float>(0, 1);
point1.x = affine_corners.at<float>(1, 0);
point1.y = affine_corners.at<float>(1, 1);
point2.x = affine_corners.at<float>(2, 0);
point2.y = affine_corners.at<float>(2, 1);
point3.x = affine_corners.at<float>(3, 0);
point3.y = affine_corners.at<float>(3, 1);
if (WITHIN(point0, top_left, bottom_right) &&
WITHIN(point1, top_left, bottom_right) &&
WITHIN(point2, top_left, bottom_right) &&
WITHIN(point3, top_left, bottom_right)) {
affines[i] = affine;
insiders[i] = true;
}
};
// tbb::parallel_for(0, no_of_configs, 1, func);
for (int i = 0; i < no_of_configs; ++i)
{
func(i);
}