mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 17:24:28 +08:00
build: fix usage of unsupported cv::Mat types
This commit is contained in:
@@ -194,7 +194,7 @@ private:
|
||||
String name_;
|
||||
|
||||
Mat_<int> nfeatures_;
|
||||
Mat_<unsigned int> colors_;
|
||||
Mat_<int> colors_;
|
||||
Mat_<float> weights_;
|
||||
|
||||
Mat buf_;
|
||||
@@ -223,7 +223,7 @@ void BackgroundSubtractorGMGImpl::initialize(Size frameSize, double minVal, doub
|
||||
nfeatures_.setTo(Scalar::all(0));
|
||||
}
|
||||
|
||||
static float findFeature(unsigned int color, const unsigned int* colors, const float* weights, int nfeatures)
|
||||
static float findFeature(int color, const int* colors, const float* weights, int nfeatures)
|
||||
{
|
||||
for (int i = 0; i < nfeatures; ++i)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ static void normalizeHistogram(float* weights, int nfeatures)
|
||||
}
|
||||
}
|
||||
|
||||
static bool insertFeature(unsigned int color, float weight, unsigned int* colors, float* weights, int& nfeatures, int maxFeatures)
|
||||
static bool insertFeature(int color, float weight, int* colors, float* weights, int& nfeatures, int maxFeatures)
|
||||
{
|
||||
int idx = -1;
|
||||
for (int i = 0; i < nfeatures; ++i)
|
||||
@@ -266,7 +266,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
|
||||
{
|
||||
// move feature to beginning of list
|
||||
|
||||
::memmove(colors + 1, colors, idx * sizeof(unsigned int));
|
||||
::memmove(colors + 1, colors, idx * sizeof(int));
|
||||
::memmove(weights + 1, weights, idx * sizeof(float));
|
||||
|
||||
colors[0] = color;
|
||||
@@ -276,7 +276,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
|
||||
{
|
||||
// discard oldest feature
|
||||
|
||||
::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(unsigned int));
|
||||
::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(int));
|
||||
::memmove(weights + 1, weights, (nfeatures - 1) * sizeof(float));
|
||||
|
||||
colors[0] = color;
|
||||
@@ -297,7 +297,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
|
||||
|
||||
template <typename T> struct Quantization
|
||||
{
|
||||
static unsigned int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels)
|
||||
static int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels)
|
||||
{
|
||||
const T* src = static_cast<const T*>(src_);
|
||||
src += x * cn;
|
||||
@@ -313,7 +313,7 @@ template <typename T> struct Quantization
|
||||
class GMG_LoopBody : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<unsigned int>& colors, const Mat_<float>& weights,
|
||||
GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<int>& colors, const Mat_<float>& weights,
|
||||
int maxFeatures, double learningRate, int numInitializationFrames, int quantizationLevels, double backgroundPrior, double decisionThreshold,
|
||||
double maxVal, double minVal, int frameNum, bool updateBackgroundModel) :
|
||||
frame_(frame), fgmask_(fgmask), nfeatures_(nfeatures), colors_(colors), weights_(weights),
|
||||
@@ -331,7 +331,7 @@ private:
|
||||
mutable Mat_<uchar> fgmask_;
|
||||
|
||||
mutable Mat_<int> nfeatures_;
|
||||
mutable Mat_<unsigned int> colors_;
|
||||
mutable Mat_<int> colors_;
|
||||
mutable Mat_<float> weights_;
|
||||
|
||||
int maxFeatures_;
|
||||
@@ -349,7 +349,7 @@ private:
|
||||
|
||||
void GMG_LoopBody::operator() (const Range& range) const
|
||||
{
|
||||
typedef unsigned int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels);
|
||||
typedef int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
Quantization<uchar>::apply,
|
||||
@@ -375,10 +375,10 @@ void GMG_LoopBody::operator() (const Range& range) const
|
||||
for (int x = 0; x < frame_.cols; ++x, ++featureIdx)
|
||||
{
|
||||
int nfeatures = nfeatures_row[x];
|
||||
unsigned int* colors = colors_[featureIdx];
|
||||
int* colors = colors_[featureIdx];
|
||||
float* weights = weights_[featureIdx];
|
||||
|
||||
unsigned int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_);
|
||||
int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_);
|
||||
|
||||
bool isForeground = false;
|
||||
|
||||
|
@@ -47,19 +47,22 @@ namespace cv
|
||||
namespace saliency
|
||||
{
|
||||
|
||||
typedef int64_t TIG_TYPE;
|
||||
typedef double MAT_TIG_TYPE; // cv::Mat has no native support for int64/uint64
|
||||
|
||||
struct TIGbits
|
||||
{
|
||||
TIGbits() : bc0(0), bc1(0) {}
|
||||
inline void accumulate(int64_t tig, int64_t tigMask0, int64_t tigMask1, uchar shift)
|
||||
inline void accumulate(TIG_TYPE tig, TIG_TYPE tigMask0, TIG_TYPE tigMask1, uchar shift)
|
||||
{
|
||||
bc0 += ((POPCNT64(tigMask0 & tig) << 1) - POPCNT64(tig)) << shift;
|
||||
bc1 += ((POPCNT64(tigMask1 & tig) << 1) - POPCNT64(tig)) << shift;
|
||||
}
|
||||
int64_t bc0;
|
||||
int64_t bc1;
|
||||
TIG_TYPE bc0;
|
||||
TIG_TYPE bc1;
|
||||
};
|
||||
|
||||
float ObjectnessBING::FilterTIG::dot( int64_t tig1, int64_t tig2, int64_t tig4, int64_t tig8 )
|
||||
float ObjectnessBING::FilterTIG::dot( TIG_TYPE tig1, TIG_TYPE tig2, TIG_TYPE tig4, TIG_TYPE tig8 )
|
||||
{
|
||||
TIGbits x;
|
||||
x.accumulate(tig1, _bTIGs[0], _bTIGs[1], 0);
|
||||
@@ -111,22 +114,22 @@ Mat ObjectnessBING::FilterTIG::matchTemplate( const Mat &mag1u )
|
||||
{
|
||||
const int H = mag1u.rows, W = mag1u.cols;
|
||||
const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions
|
||||
Mat_<int64_t> Tig1 = Mat_<int64_t>::zeros( sz ), Tig2 = Mat_<int64_t>::zeros( sz );
|
||||
Mat_<int64_t> Tig4 = Mat_<int64_t>::zeros( sz ), Tig8 = Mat_<int64_t>::zeros( sz );
|
||||
Mat_<MAT_TIG_TYPE> Tig1 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig2 = Mat_<MAT_TIG_TYPE>::zeros( sz );
|
||||
Mat_<MAT_TIG_TYPE> Tig4 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig8 = Mat_<MAT_TIG_TYPE>::zeros( sz );
|
||||
Mat_<BYTE> Row1 = Mat_<BYTE>::zeros( sz ), Row2 = Mat_<BYTE>::zeros( sz );
|
||||
Mat_<BYTE> Row4 = Mat_<BYTE>::zeros( sz ), Row8 = Mat_<BYTE>::zeros( sz );
|
||||
Mat_<float> scores( sz );
|
||||
for ( int y = 1; y <= H; y++ )
|
||||
{
|
||||
const BYTE* G = mag1u.ptr<BYTE>( y - 1 );
|
||||
int64_t* T1 = Tig1.ptr<int64_t>( y ); // Binary TIG of current row
|
||||
int64_t* T2 = Tig2.ptr<int64_t>( y );
|
||||
int64_t* T4 = Tig4.ptr<int64_t>( y );
|
||||
int64_t* T8 = Tig8.ptr<int64_t>( y );
|
||||
int64_t* Tu1 = Tig1.ptr<int64_t>( y - 1 ); // Binary TIG of upper row
|
||||
int64_t* Tu2 = Tig2.ptr<int64_t>( y - 1 );
|
||||
int64_t* Tu4 = Tig4.ptr<int64_t>( y - 1 );
|
||||
int64_t* Tu8 = Tig8.ptr<int64_t>( y - 1 );
|
||||
TIG_TYPE* T1 = Tig1.ptr<TIG_TYPE>( y ); // Binary TIG of current row
|
||||
TIG_TYPE* T2 = Tig2.ptr<TIG_TYPE>( y );
|
||||
TIG_TYPE* T4 = Tig4.ptr<TIG_TYPE>( y );
|
||||
TIG_TYPE* T8 = Tig8.ptr<TIG_TYPE>( y );
|
||||
TIG_TYPE* Tu1 = Tig1.ptr<TIG_TYPE>( y - 1 ); // Binary TIG of upper row
|
||||
TIG_TYPE* Tu2 = Tig2.ptr<TIG_TYPE>( y - 1 );
|
||||
TIG_TYPE* Tu4 = Tig4.ptr<TIG_TYPE>( y - 1 );
|
||||
TIG_TYPE* Tu8 = Tig8.ptr<TIG_TYPE>( y - 1 );
|
||||
BYTE* R1 = Row1.ptr<BYTE>( y );
|
||||
BYTE* R2 = Row2.ptr<BYTE>( y );
|
||||
BYTE* R4 = Row4.ptr<BYTE>( y );
|
||||
|
Reference in New Issue
Block a user