|
| 1 | +diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in |
| 2 | +index c5a82c0..3ce4719 100644 |
| 3 | +--- a/cmake/Config.cmake.in |
| 4 | ++++ b/cmake/Config.cmake.in |
| 5 | +@@ -42,6 +42,7 @@ |
| 6 | + include(CMakeFindDependencyMacro) |
| 7 | + |
| 8 | + set(OpenCV_DIR @OpenCV_DIR@) |
| 9 | ++find_dependency(TBB) |
| 10 | + find_dependency(OpenCV) |
| 11 | + find_dependency(Eigen3 @CCTAG_EIGEN_REQUIRED_VERSION@) |
| 12 | + find_dependency(Boost 1.66 REQUIRED COMPONENTS @BOOST_REQUIRED_COMPONENTS@) |
| 13 | +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt |
| 14 | +index 7b64b83..5398ed4 100644 |
| 15 | +--- a/src/CMakeLists.txt |
| 16 | ++++ b/src/CMakeLists.txt |
| 17 | +@@ -176,7 +176,8 @@ if(CCTAG_WITH_CUDA) |
| 18 | + ${OpenCV_LIBS} |
| 19 | + Boost::date_time Boost::chrono Boost::thread Boost::serialization Boost::system Boost::filesystem Boost::atomic Boost::program_options Boost::timer Boost::math_c99 |
| 20 | + Eigen3::Eigen |
| 21 | +- ${TBB_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY}) |
| 22 | ++ TBB::tbb |
| 23 | ++ ${CUDA_CUDADEVRT_LIBRARY}) |
| 24 | + |
| 25 | + if(NOT MSVC) |
| 26 | + target_link_libraries(CCTag pthread dl) |
| 27 | +@@ -184,7 +185,7 @@ if(CCTAG_WITH_CUDA) |
| 28 | + |
| 29 | + target_compile_definitions(CCTag |
| 30 | + PUBLIC -DCCTAG_WITH_CUDA |
| 31 | +- PRIVATE ${TBB_DEFINITIONS}) |
| 32 | ++) |
| 33 | + |
| 34 | + if(CCTAG_HAVE_SHFL_DOWN_SYNC) |
| 35 | + target_compile_definitions(CCTag PRIVATE "-DCCTAG_HAVE_SHFL_DOWN_SYNC") |
| 36 | +@@ -220,16 +221,13 @@ else() # without CUDA |
| 37 | + # get_target_property(testprop CCTag INTERFACE_INCLUDE_DIRECTORIES ) |
| 38 | + # message(STATUS "testprop: ${testprop}") |
| 39 | + |
| 40 | +- target_compile_definitions(CCTag |
| 41 | +- PRIVATE ${TBB_DEFINITIONS}) |
| 42 | + |
| 43 | + target_link_libraries(CCTag |
| 44 | + PUBLIC |
| 45 | + ${OpenCV_LIBS} |
| 46 | + Eigen3::Eigen |
| 47 | + Boost::atomic Boost::chrono Boost::date_time Boost::filesystem Boost::serialization Boost::system Boost::thread Boost::timer Boost::math_c99 |
| 48 | +- PRIVATE |
| 49 | +- ${TBB_LIBRARIES}) |
| 50 | ++ TBB::tbb) |
| 51 | + |
| 52 | + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |
| 53 | + target_link_libraries(CCTag PRIVATE pthread dl) |
| 54 | +diff --git a/src/applications/CMakeLists.txt b/src/applications/CMakeLists.txt |
| 55 | +index 506d19b..c7154fc 100644 |
| 56 | +--- a/src/applications/CMakeLists.txt |
| 57 | ++++ b/src/applications/CMakeLists.txt |
| 58 | +@@ -86,7 +86,7 @@ target_include_directories(detection PUBLIC |
| 59 | + ) |
| 60 | + target_link_libraries(detection PUBLIC |
| 61 | + CCTag::CCTag |
| 62 | +- ${TBB_LIBRARIES} |
| 63 | ++ TBB::tbb |
| 64 | + ${OpenCV_LIBS} |
| 65 | + Boost::filesystem Boost::program_options Boost::timer |
| 66 | + ) |
| 67 | +diff --git a/src/cctag/Detection.cpp b/src/cctag/Detection.cpp |
| 68 | +index 21c47bf..a800fbc 100644 |
| 69 | +--- a/src/cctag/Detection.cpp |
| 70 | ++++ b/src/cctag/Detection.cpp |
| 71 | +@@ -44,6 +44,7 @@ |
| 72 | + #include <list> |
| 73 | + #include <utility> |
| 74 | + #include <memory> |
| 75 | ++#include <mutex> |
| 76 | + #ifdef CCTAG_WITH_CUDA |
| 77 | + #include <cctag/cuda/cctag_cuda_runtime.h> // only for debugging |
| 78 | + #endif // CCTAG_WITH_CUDA |
| 79 | +@@ -71,7 +72,7 @@ static void constructFlowComponentFromSeed( |
| 80 | + std::vector<CandidatePtr> & vCandidateLoopOne, |
| 81 | + const Parameters & params) |
| 82 | + { |
| 83 | +- static tbb::mutex G_SortMutex; |
| 84 | ++ static std::mutex G_SortMutex; |
| 85 | + |
| 86 | + assert( seed ); |
| 87 | + // Check if the seed has already been processed, i.e. belongs to an already |
| 88 | +@@ -102,7 +103,7 @@ static void constructFlowComponentFromSeed( |
| 89 | + } |
| 90 | + |
| 91 | + { |
| 92 | +- tbb::mutex::scoped_lock lock(G_SortMutex); |
| 93 | ++ std::lock_guard<std::mutex> lock(G_SortMutex); |
| 94 | + candidate->_averageReceivedVote = (float) (nReceivedVote*nReceivedVote) / (float) nVotedPoints; |
| 95 | + auto it = std::lower_bound(vCandidateLoopOne.begin(), vCandidateLoopOne.end(), candidate, |
| 96 | + [](const CandidatePtr& c1, const CandidatePtr& c2) { return c1->_averageReceivedVote > c2->_averageReceivedVote; }); |
| 97 | +@@ -119,8 +120,8 @@ static void completeFlowComponent( |
| 98 | + std::size_t runId, |
| 99 | + const Parameters & params) |
| 100 | + { |
| 101 | +- static tbb::spin_mutex G_UpdateMutex; |
| 102 | +- static tbb::mutex G_InsertMutex; |
| 103 | ++ static std::mutex G_UpdateMutex; |
| 104 | ++ static std::mutex G_InsertMutex; |
| 105 | + |
| 106 | + try |
| 107 | + { |
| 108 | +@@ -171,7 +172,7 @@ static void completeFlowComponent( |
| 109 | + if (nSegmentCommon == -1) |
| 110 | + { |
| 111 | + { |
| 112 | +- tbb::spin_mutex::scoped_lock lock(G_UpdateMutex); |
| 113 | ++ std::lock_guard<std::mutex> lock(G_UpdateMutex); |
| 114 | + nLabel = nSegmentOut; |
| 115 | + ++nSegmentOut; |
| 116 | + } |
| 117 | +@@ -239,7 +240,7 @@ static void completeFlowComponent( |
| 118 | + } |
| 119 | + |
| 120 | + { |
| 121 | +- tbb::mutex::scoped_lock lock(G_InsertMutex); |
| 122 | ++ std::lock_guard<std::mutex> lock(G_InsertMutex); |
| 123 | + vCandidateLoopTwo.push_back(candidate); |
| 124 | + } |
| 125 | + |
| 126 | +@@ -384,7 +385,7 @@ static void cctagDetectionFromEdgesLoopTwoIteration( |
| 127 | + float scale, |
| 128 | + const Parameters& params) |
| 129 | + { |
| 130 | +- static tbb::mutex G_InsertMutex; |
| 131 | ++ static std::mutex G_InsertMutex; |
| 132 | + |
| 133 | + const Candidate& candidate = vCandidateLoopTwo[iCandidate]; |
| 134 | + |
| 135 | +@@ -543,7 +544,7 @@ static void cctagDetectionFromEdgesLoopTwoIteration( |
| 136 | + #endif |
| 137 | + |
| 138 | + { |
| 139 | +- tbb::mutex::scoped_lock lock(G_InsertMutex); |
| 140 | ++ std::lock_guard<std::mutex> lock(G_InsertMutex); |
| 141 | + markers.push_back( tag ); // markers takes responsibility for delete |
| 142 | + } |
| 143 | + #ifdef CCTAG_SERIALIZE |
| 144 | +diff --git a/src/cctag/Identification.cpp b/src/cctag/Identification.cpp |
| 145 | +index 15c9d9b..99b616a 100644 |
| 146 | +--- a/src/cctag/Identification.cpp |
| 147 | ++++ b/src/cctag/Identification.cpp |
| 148 | +@@ -29,6 +29,7 @@ |
| 149 | + |
| 150 | + #include <cmath> |
| 151 | + #include <vector> |
| 152 | ++#include <mutex> |
| 153 | + |
| 154 | + #include <tbb/tbb.h> |
| 155 | + |
| 156 | +@@ -71,7 +72,7 @@ bool orazioDistanceRobust( |
| 157 | + #endif // GRIFF_DEBUG |
| 158 | + |
| 159 | + const size_t cut_count = cuts.size(); |
| 160 | +- static tbb::mutex vscore_mutex; |
| 161 | ++ static std::mutex vscore_mutex; |
| 162 | + |
| 163 | + tbb::parallel_for(size_t(0), cut_count, [&](size_t i) { |
| 164 | + const cctag::ImageCut& cut = cuts[i]; |
| 165 | +@@ -183,7 +184,7 @@ bool orazioDistanceRobust( |
| 166 | + #endif // GRIFF_DEBUG |
| 167 | + |
| 168 | + { |
| 169 | +- tbb::mutex::scoped_lock lock(vscore_mutex); |
| 170 | ++ std::lock_guard<std::mutex> lock(vscore_mutex); |
| 171 | + vScore[idSet.front().first].push_back(idSet.front().second); |
| 172 | + } |
| 173 | + } |
0 commit comments