From 2c089f60ff18fe142c003201ffca1344be2d4d21 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Thu, 9 Mar 2017 18:23:14 +0900 Subject: [PATCH] Thread-safe vector insertion while using OpenMP --- modules/surface_matching/src/ppf_match_3d.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/surface_matching/src/ppf_match_3d.cpp b/modules/surface_matching/src/ppf_match_3d.cpp index 5c6361c8a..a15863c57 100644 --- a/modules/surface_matching/src/ppf_match_3d.cpp +++ b/modules/surface_matching/src/ppf_match_3d.cpp @@ -645,7 +645,12 @@ void PPF3DDetector::match(const Mat& pc, std::vector& results, const Pose3DPtr pose(new Pose3D(alpha, refIndMax, maxVotes)); pose->updatePose(rawPose); - poseList.push_back(pose); + #if defined (_OPENMP) + #pragma omp critical + #endif + { + poseList.push_back(pose); + } #if defined (_OPENMP) free(accumulator);