1010#include < opencv2/imgproc.hpp>
1111#include " opencv2/core/private.hpp"
1212#include " opencv2/core/utils/logger.hpp"
13- #include < opencv2/core/core_c.h>
1413#include < opencv2/fastcv.hpp>
1514#include < map>
1615#include < atomic>
@@ -83,14 +82,14 @@ namespace dsp {
8382 (CV_Error(cv::Error::StsBadArg, cv::format(" Matrix '%s' not allocated with FastCV allocator. " \
8483 " Please ensure that the matrix is created using " \
8584 " cv::fastcv::getQcAllocator()." , #mat)), false ))
86-
85+
8786 #define FASTCV_CHECK_DSP_INIT () \
8887 if (!FastCvDspContext::getContext().isInitialized() && \
8988 fcvdspinit () != 0) \
9089 { \
9190 CV_Error (cv::Error::StsError, " Failed to initialize DSP" ); \
9291 }
93-
92+
9493 struct FastCvDspContext
9594 {
9695 private:
@@ -113,7 +112,7 @@ namespace dsp {
113112
114113 bool initialize () {
115114 cv::AutoLock lock (initMutex);
116-
115+
117116 if (isDspInitialized.load (std::memory_order_acquire)) {
118117 CV_LOG_INFO (NULL , " FastCV DSP already initialized, skipping initialization" );
119118 return true ;
@@ -124,33 +123,33 @@ namespace dsp {
124123 if (fcvQ6Init () == 0 ) {
125124 isDspInitialized.store (true , std::memory_order_release);
126125 initializationCount++;
127- CV_LOG_DEBUG (NULL , cv::format (" FastCV DSP initialized (init count: %lu, deinit count: %lu)" ,
126+ CV_LOG_DEBUG (NULL , cv::format (" FastCV DSP initialized (init count: %lu, deinit count: %lu)" ,
128127 initializationCount.load (), deInitializationCount.load ()));
129128
130129 return true ;
131130 }
132-
131+
133132 CV_LOG_ERROR (NULL , " FastCV DSP initialization failed" );
134133 return false ;
135134 }
136135
137136 bool deinitialize () {
138137 cv::AutoLock lock (initMutex);
139-
138+
140139 if (!isDspInitialized.load (std::memory_order_acquire)) {
141140 CV_LOG_DEBUG (NULL , " FastCV DSP already deinitialized, skipping deinitialization" );
142141 return true ;
143142 }
144143
145144 CV_LOG_INFO (NULL , " Deinitializing FastCV DSP" );
146-
145+
147146 try {
148147 fcvQ6DeInit ();
149148 isDspInitialized.store (false , std::memory_order_release);
150149 deInitializationCount++;
151- CV_LOG_DEBUG (NULL , cv::format (" FastCV DSP deinitialized (init count: %lu, deinit count: %lu)" ,
150+ CV_LOG_DEBUG (NULL , cv::format (" FastCV DSP deinitialized (init count: %lu, deinit count: %lu)" ,
152151 initializationCount.load (), deInitializationCount.load ()));
153-
152+
154153 return true ;
155154 }
156155 catch (...) {
@@ -174,7 +173,7 @@ namespace dsp {
174173 const cv::Mutex& getInitMutex () const {
175174 return initMutex;
176175 }
177-
176+
178177 private:
179178 FastCvDspContext () = default ;
180179};
0 commit comments