10
10
#include < opencv2/imgproc.hpp>
11
11
#include " opencv2/core/private.hpp"
12
12
#include " opencv2/core/utils/logger.hpp"
13
- #include < opencv2/core/core_c.h>
14
13
#include < opencv2/fastcv.hpp>
15
14
#include < map>
16
15
#include < atomic>
@@ -83,14 +82,14 @@ namespace dsp {
83
82
(CV_Error(cv::Error::StsBadArg, cv::format(" Matrix '%s' not allocated with FastCV allocator. " \
84
83
" Please ensure that the matrix is created using " \
85
84
" cv::fastcv::getQcAllocator()." , #mat)), false ))
86
-
85
+
87
86
#define FASTCV_CHECK_DSP_INIT () \
88
87
if (!FastCvDspContext::getContext().isInitialized() && \
89
88
fcvdspinit () != 0) \
90
89
{ \
91
90
CV_Error (cv::Error::StsError, " Failed to initialize DSP" ); \
92
91
}
93
-
92
+
94
93
struct FastCvDspContext
95
94
{
96
95
private:
@@ -113,7 +112,7 @@ namespace dsp {
113
112
114
113
bool initialize () {
115
114
cv::AutoLock lock (initMutex);
116
-
115
+
117
116
if (isDspInitialized.load (std::memory_order_acquire)) {
118
117
CV_LOG_INFO (NULL , " FastCV DSP already initialized, skipping initialization" );
119
118
return true ;
@@ -124,33 +123,33 @@ namespace dsp {
124
123
if (fcvQ6Init () == 0 ) {
125
124
isDspInitialized.store (true , std::memory_order_release);
126
125
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)" ,
128
127
initializationCount.load (), deInitializationCount.load ()));
129
128
130
129
return true ;
131
130
}
132
-
131
+
133
132
CV_LOG_ERROR (NULL , " FastCV DSP initialization failed" );
134
133
return false ;
135
134
}
136
135
137
136
bool deinitialize () {
138
137
cv::AutoLock lock (initMutex);
139
-
138
+
140
139
if (!isDspInitialized.load (std::memory_order_acquire)) {
141
140
CV_LOG_DEBUG (NULL , " FastCV DSP already deinitialized, skipping deinitialization" );
142
141
return true ;
143
142
}
144
143
145
144
CV_LOG_INFO (NULL , " Deinitializing FastCV DSP" );
146
-
145
+
147
146
try {
148
147
fcvQ6DeInit ();
149
148
isDspInitialized.store (false , std::memory_order_release);
150
149
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)" ,
152
151
initializationCount.load (), deInitializationCount.load ()));
153
-
152
+
154
153
return true ;
155
154
}
156
155
catch (...) {
@@ -174,7 +173,7 @@ namespace dsp {
174
173
const cv::Mutex& getInitMutex () const {
175
174
return initMutex;
176
175
}
177
-
176
+
178
177
private:
179
178
FastCvDspContext () = default ;
180
179
};
0 commit comments