Skip to content

Commit 62e77e9

Browse files
committed
build: fix usage of unsupported cv::Mat types
1 parent e7547d6 commit 62e77e9

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

modules/bgsegm/src/bgfg_gmg.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class BackgroundSubtractorGMGImpl : public BackgroundSubtractorGMG
194194
String name_;
195195

196196
Mat_<int> nfeatures_;
197-
Mat_<unsigned int> colors_;
197+
Mat_<int> colors_;
198198
Mat_<float> weights_;
199199

200200
Mat buf_;
@@ -223,7 +223,7 @@ void BackgroundSubtractorGMGImpl::initialize(Size frameSize, double minVal, doub
223223
nfeatures_.setTo(Scalar::all(0));
224224
}
225225

226-
static float findFeature(unsigned int color, const unsigned int* colors, const float* weights, int nfeatures)
226+
static float findFeature(int color, const int* colors, const float* weights, int nfeatures)
227227
{
228228
for (int i = 0; i < nfeatures; ++i)
229229
{
@@ -248,7 +248,7 @@ static void normalizeHistogram(float* weights, int nfeatures)
248248
}
249249
}
250250

251-
static bool insertFeature(unsigned int color, float weight, unsigned int* colors, float* weights, int& nfeatures, int maxFeatures)
251+
static bool insertFeature(int color, float weight, int* colors, float* weights, int& nfeatures, int maxFeatures)
252252
{
253253
int idx = -1;
254254
for (int i = 0; i < nfeatures; ++i)
@@ -266,7 +266,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
266266
{
267267
// move feature to beginning of list
268268

269-
::memmove(colors + 1, colors, idx * sizeof(unsigned int));
269+
::memmove(colors + 1, colors, idx * sizeof(int));
270270
::memmove(weights + 1, weights, idx * sizeof(float));
271271

272272
colors[0] = color;
@@ -276,7 +276,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
276276
{
277277
// discard oldest feature
278278

279-
::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(unsigned int));
279+
::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(int));
280280
::memmove(weights + 1, weights, (nfeatures - 1) * sizeof(float));
281281

282282
colors[0] = color;
@@ -297,7 +297,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
297297

298298
template <typename T> struct Quantization
299299
{
300-
static unsigned int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels)
300+
static int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels)
301301
{
302302
const T* src = static_cast<const T*>(src_);
303303
src += x * cn;
@@ -313,7 +313,7 @@ template <typename T> struct Quantization
313313
class GMG_LoopBody : public ParallelLoopBody
314314
{
315315
public:
316-
GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<unsigned int>& colors, const Mat_<float>& weights,
316+
GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<int>& colors, const Mat_<float>& weights,
317317
int maxFeatures, double learningRate, int numInitializationFrames, int quantizationLevels, double backgroundPrior, double decisionThreshold,
318318
double maxVal, double minVal, int frameNum, bool updateBackgroundModel) :
319319
frame_(frame), fgmask_(fgmask), nfeatures_(nfeatures), colors_(colors), weights_(weights),
@@ -331,7 +331,7 @@ class GMG_LoopBody : public ParallelLoopBody
331331
mutable Mat_<uchar> fgmask_;
332332

333333
mutable Mat_<int> nfeatures_;
334-
mutable Mat_<unsigned int> colors_;
334+
mutable Mat_<int> colors_;
335335
mutable Mat_<float> weights_;
336336

337337
int maxFeatures_;
@@ -349,7 +349,7 @@ class GMG_LoopBody : public ParallelLoopBody
349349

350350
void GMG_LoopBody::operator() (const Range& range) const
351351
{
352-
typedef unsigned int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels);
352+
typedef int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels);
353353
static const func_t funcs[] =
354354
{
355355
Quantization<uchar>::apply,
@@ -375,10 +375,10 @@ void GMG_LoopBody::operator() (const Range& range) const
375375
for (int x = 0; x < frame_.cols; ++x, ++featureIdx)
376376
{
377377
int nfeatures = nfeatures_row[x];
378-
unsigned int* colors = colors_[featureIdx];
378+
int* colors = colors_[featureIdx];
379379
float* weights = weights_[featureIdx];
380380

381-
unsigned int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_);
381+
int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_);
382382

383383
bool isForeground = false;
384384

modules/saliency/src/BING/FilterTIG.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,22 @@ namespace cv
4747
namespace saliency
4848
{
4949

50+
typedef int64_t TIG_TYPE;
51+
typedef double MAT_TIG_TYPE; // cv::Mat has no native support for int64/uint64
52+
5053
struct TIGbits
5154
{
5255
TIGbits() : bc0(0), bc1(0) {}
53-
inline void accumulate(int64_t tig, int64_t tigMask0, int64_t tigMask1, uchar shift)
56+
inline void accumulate(TIG_TYPE tig, TIG_TYPE tigMask0, TIG_TYPE tigMask1, uchar shift)
5457
{
5558
bc0 += ((POPCNT64(tigMask0 & tig) << 1) - POPCNT64(tig)) << shift;
5659
bc1 += ((POPCNT64(tigMask1 & tig) << 1) - POPCNT64(tig)) << shift;
5760
}
58-
int64_t bc0;
59-
int64_t bc1;
61+
TIG_TYPE bc0;
62+
TIG_TYPE bc1;
6063
};
6164

62-
float ObjectnessBING::FilterTIG::dot( int64_t tig1, int64_t tig2, int64_t tig4, int64_t tig8 )
65+
float ObjectnessBING::FilterTIG::dot( TIG_TYPE tig1, TIG_TYPE tig2, TIG_TYPE tig4, TIG_TYPE tig8 )
6366
{
6467
TIGbits x;
6568
x.accumulate(tig1, _bTIGs[0], _bTIGs[1], 0);
@@ -111,22 +114,22 @@ Mat ObjectnessBING::FilterTIG::matchTemplate( const Mat &mag1u )
111114
{
112115
const int H = mag1u.rows, W = mag1u.cols;
113116
const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions
114-
Mat_<int64_t> Tig1 = Mat_<int64_t>::zeros( sz ), Tig2 = Mat_<int64_t>::zeros( sz );
115-
Mat_<int64_t> Tig4 = Mat_<int64_t>::zeros( sz ), Tig8 = Mat_<int64_t>::zeros( sz );
117+
Mat_<MAT_TIG_TYPE> Tig1 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig2 = Mat_<MAT_TIG_TYPE>::zeros( sz );
118+
Mat_<MAT_TIG_TYPE> Tig4 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig8 = Mat_<MAT_TIG_TYPE>::zeros( sz );
116119
Mat_<BYTE> Row1 = Mat_<BYTE>::zeros( sz ), Row2 = Mat_<BYTE>::zeros( sz );
117120
Mat_<BYTE> Row4 = Mat_<BYTE>::zeros( sz ), Row8 = Mat_<BYTE>::zeros( sz );
118121
Mat_<float> scores( sz );
119122
for ( int y = 1; y <= H; y++ )
120123
{
121124
const BYTE* G = mag1u.ptr<BYTE>( y - 1 );
122-
int64_t* T1 = Tig1.ptr<int64_t>( y ); // Binary TIG of current row
123-
int64_t* T2 = Tig2.ptr<int64_t>( y );
124-
int64_t* T4 = Tig4.ptr<int64_t>( y );
125-
int64_t* T8 = Tig8.ptr<int64_t>( y );
126-
int64_t* Tu1 = Tig1.ptr<int64_t>( y - 1 ); // Binary TIG of upper row
127-
int64_t* Tu2 = Tig2.ptr<int64_t>( y - 1 );
128-
int64_t* Tu4 = Tig4.ptr<int64_t>( y - 1 );
129-
int64_t* Tu8 = Tig8.ptr<int64_t>( y - 1 );
125+
TIG_TYPE* T1 = Tig1.ptr<TIG_TYPE>( y ); // Binary TIG of current row
126+
TIG_TYPE* T2 = Tig2.ptr<TIG_TYPE>( y );
127+
TIG_TYPE* T4 = Tig4.ptr<TIG_TYPE>( y );
128+
TIG_TYPE* T8 = Tig8.ptr<TIG_TYPE>( y );
129+
TIG_TYPE* Tu1 = Tig1.ptr<TIG_TYPE>( y - 1 ); // Binary TIG of upper row
130+
TIG_TYPE* Tu2 = Tig2.ptr<TIG_TYPE>( y - 1 );
131+
TIG_TYPE* Tu4 = Tig4.ptr<TIG_TYPE>( y - 1 );
132+
TIG_TYPE* Tu8 = Tig8.ptr<TIG_TYPE>( y - 1 );
130133
BYTE* R1 = Row1.ptr<BYTE>( y );
131134
BYTE* R2 = Row2.ptr<BYTE>( y );
132135
BYTE* R4 = Row4.ptr<BYTE>( y );

0 commit comments

Comments
 (0)