Commit 30c13c2c authored by jaco's avatar jaco

wip window compile error fixing

parent bc66cc27
......@@ -100,12 +100,13 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
MotionSaliencyBinWangApr2014();
~MotionSaliencyBinWangApr2014();
typedef Ptr<Size> (Algorithm::*SizeGetter)();
/*typedef Ptr<Size> (Algorithm::*SizeGetter)();
typedef void (Algorithm::*SizeSetter)( const Ptr<Size> & );
Ptr<Size> getWsize();
void setWsize( const Ptr<Size> &newSize );
void setWsize( const Ptr<Size> &newSize ); */
void setImagesize( int W, int H );
bool init();
protected:
......@@ -142,7 +143,9 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
//fixed parameter
bool neighborhoodCheck;
int N_DS; // Number of template to be downsampled and used in lowResolutionDetection function
Ptr<Size> imgSize; // Size of input image
//Ptr<Size> imgSize;
int imageWidth; // Width of input image
int imageHeight; //Height of input image
int K; // Number of background model template
int N; // NxN is the size of the block for downsampling in the lowlowResolutionDetection
float alpha; // Learning rate
......@@ -241,7 +244,7 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
bool filtersLoaded()
{
int n = (int)_svmSzIdxs.size();
int n = (int) _svmSzIdxs.size();
return n > 0 && _svmReW1f.size() == Size( 2, n ) && _svmFilter.size() == Size( _W, _W );
}
void predictBBoxSI( CMat &mag3u, ValStructVec<float, Vec4i> &valBoxes, vecI &sz, int NUM_WIN_PSZ = 100, bool fast = true );
......
......@@ -157,18 +157,18 @@ int main( int argc, char** argv )
else if( saliency_algorithm.find( "BinWangApr2014" ) == 0 )
{
Ptr<Size> size = Ptr<Size>( new Size( image.cols, image.rows ) );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setWsize( size );
//Ptr<Size> size = Ptr<Size>( new Size( image.cols, image.rows ) );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( image.cols, image.rows );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
bool paused=false;
bool paused = false;
while ( true )
{
if( !paused )
{
cap >> frame;
cvtColor(frame, frame, COLOR_BGR2GRAY);
cvtColor( frame, frame, COLOR_BGR2GRAY );
Mat saliencyMap;
if( saliencyAlgorithm->computeSaliency( frame, saliencyMap ) )
......
......@@ -41,7 +41,6 @@
#include "CmFile.h"
bool CmFile::MkDir( CStr &_path )
{
if( _path.size() == 0 )
......@@ -58,7 +57,9 @@ bool CmFile::MkDir( CStr &_path )
buffer[i] = '/';
}
}
return CreateDirectoryA(_S(_path), 0);
CreateDirectoryA(_S(_path), 0);
return true;
#else
for ( int i = 0; buffer[i] != 0; i++ )
{
......@@ -69,6 +70,7 @@ bool CmFile::MkDir( CStr &_path )
buffer[i] = '/';
}
}
return mkdir( _S( _path ), 0 );
mkdir( _S( _path ), 0 );
return true;
#endif
}
......@@ -116,7 +116,7 @@ int ObjectnessBING::loadTrainedModel( std::string modelName ) // Return -1, 0,
CV_Assert( _svmSzIdxs.size() > 1 && filters1f.size() == Size(_W, _W) && filters1f.type() == CV_32F );
_svmFilter = filters1f;
if( !matRead( s2, _svmReW1f ) || _svmReW1f.size() != Size( 2, _svmSzIdxs.size() ) )
if( !matRead( s2, _svmReW1f ) || _svmReW1f.size() != Size( 2, (int)_svmSzIdxs.size() ) )
{
_svmReW1f = Mat();
return -1;
......@@ -126,7 +126,7 @@ int ObjectnessBING::loadTrainedModel( std::string modelName ) // Return -1, 0,
void ObjectnessBING::predictBBoxSI( CMat &img3u, ValStructVec<float, Vec4i> &valBoxes, vecI &sz, int NUM_WIN_PSZ, bool fast )
{
const int numSz = _svmSzIdxs.size();
const int numSz =(int) _svmSzIdxs.size();
const int imgW = img3u.cols, imgH = img3u.rows;
valBoxes.reserve( 10000 );
sz.clear();
......@@ -374,7 +374,7 @@ void ObjectnessBING::gradientXY( CMat &x1i, CMat &y1i, Mat &mag1u )
const int *x = x1i.ptr<int>( r ), *y = y1i.ptr<int>( r );
BYTE* m = mag1u.ptr<BYTE>( r );
for ( int c = 0; c < W; c++ )
m[c] = min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
m[c] = (BYTE)min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
}
}
......@@ -491,7 +491,7 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
Mat( sortedBB ).copyTo( objectnessBoundingBox );
// List of the rectangles' objectness value
unsigned long int valIdxesSize = finalBoxes.getvalIdxes().size();
unsigned long int valIdxesSize = (unsigned long int)finalBoxes.getvalIdxes().size();
objectnessValues.resize( valIdxesSize );
for ( uint i = 0; i < valIdxesSize; i++ )
objectnessValues[i] = finalBoxes.getvalIdxes()[i].first;
......
......@@ -49,13 +49,19 @@
namespace cv
{
cv::Ptr<Size> MotionSaliencyBinWangApr2014::getWsize()
{
/* cv::Ptr<Size> MotionSaliencyBinWangApr2014::getWsize()
{
return imgSize;
}
void MotionSaliencyBinWangApr2014::setWsize( const cv::Ptr<Size>& newSize )
{
}
void MotionSaliencyBinWangApr2014::setWsize( const cv::Ptr<Size>& newSize )
{
imgSize = newSize;
} */
void MotionSaliencyBinWangApr2014::setImagesize( int W, int H )
{
imageWidth = W;
imageHeight = H;
}
MotionSaliencyBinWangApr2014::MotionSaliencyBinWangApr2014()
......@@ -63,7 +69,7 @@ MotionSaliencyBinWangApr2014::MotionSaliencyBinWangApr2014()
N_DS = 2; // Number of template to be downsampled and used in lowResolutionDetection function
K = 3; // Number of background model template
N = 4; // NxN is the size of the block for downsampling in the lowlowResolutionDetection
alpha = 0.01; // Learning rate
alpha = (float) 0.01; // Learning rate
L0 = 300; // Upper-bound values for C0 (efficacy of the first template (matrices) of backgroundModel
L1 = 200; // Upper-bound values for C1 (efficacy of the second template (matrices) of backgroundModel
thetaL = thetaL_VAL; // T0, T1 swap threshold
......@@ -76,13 +82,13 @@ MotionSaliencyBinWangApr2014::MotionSaliencyBinWangApr2014()
bool MotionSaliencyBinWangApr2014::init()
{
epslonPixelsValue = Mat( imgSize->height, imgSize->width, CV_32F, Scalar( 20 ) );
Size imgSize( imageWidth, imageHeight );
epslonPixelsValue = Mat( imgSize.height, imgSize.width, CV_32F, Scalar( 20 ) );
// Median of range [18, 80] advised in reference paper.
// Since data is even, the median is estimated using two values ​​that occupy
// the position (n / 2) and ((n / 2) +1) (choose their arithmetic mean).
potentialBackground = Mat( imgSize->height, imgSize->width, CV_32FC2, Scalar( NAN, 0 ) );
potentialBackground = Mat( imgSize.height, imgSize.width, CV_32FC2, Scalar( NAN, 0 ) );
//backgroundModel = std::vector<Mat>( K + 1, Mat::zeros( imgSize->height, imgSize->width, CV_32FC2 ) );
backgroundModel.resize( K + 1 );
......@@ -90,7 +96,7 @@ bool MotionSaliencyBinWangApr2014::init()
for ( int i = 0; i < K + 1; i++ )
{
Mat* tmpm = new Mat;
tmpm->create( imgSize->height, imgSize->width, CV_32FC2 );
tmpm->create( imgSize.height, imgSize.width, CV_32FC2 );
tmpm->setTo( Scalar( NAN, 0 ) );
Ptr<Mat> tmp = Ptr<Mat>( tmpm );
backgroundModel[i] = tmp;
......@@ -114,7 +120,7 @@ bool MotionSaliencyBinWangApr2014::fullResolutionDetection( const Mat& image2, M
float currentEpslonValue;
bool backgFlag = false;
/* for ( int i = 0; i <= K; i++ )
/* for ( int i = 0; i <= K; i++ )
{
vector<Mat> spl;
split( * ( backgroundModel[i] ), spl );
......@@ -243,8 +249,8 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( const Mat& image, Mat
// Compute the mean of image's block and epslonMatrix's block based on ROI
Mat roiImage = image( roi );
Mat roiEpslon = epslonPixelsValue( roi );
currentPixelValue = mean( roiImage ).val[0];
currentEpslonValue = mean( roiEpslon ).val[0];
currentPixelValue = (float) mean( roiImage ).val[0];
currentEpslonValue = (float) mean( roiEpslon ).val[0];
// scan background model vector
for ( int z = 0; z < N_DS; z++ )
......@@ -252,8 +258,8 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( const Mat& image, Mat
// Select the current template 2 channel matrix, select ROI and compute the mean for each channel separately
Mat roiTemplate = ( * ( backgroundModel[z] ) )( roi );
Scalar templateMean = mean( roiTemplate );
currentB = templateMean[0];
currentC = templateMean[1];
currentB = (float) templateMean[0];
currentC = (float) templateMean[1];
if( ( currentC ) > 0 ) //The current template is active
{
......@@ -348,7 +354,7 @@ bool MotionSaliencyBinWangApr2014::templateOrdering()
// set new C0 value for current model)
swap( bgModel_0P[j][1], bgModel_1P[j][1] );
bgModel_0P[j][1] = gamma * thetaL;
bgModel_0P[j][1] = (float) gamma * thetaL;
}
......@@ -388,12 +394,12 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
neighborhoodCheck = true;
}
float roiSize = 3; // FIXED ROI SIZE, not change until you first appropriately adjust the following controls in the EVALUATION section!
int roiSize = 3; // FIXED ROI SIZE, not change until you first appropriately adjust the following controls in the EVALUATION section!
int countNonZeroElements = 0;
std::vector<Mat> mv;
Mat replicateCurrentBAMat( roiSize, roiSize, CV_32FC1 );
Mat backgroundModelROI( roiSize, roiSize, CV_32FC1 );
Mat diffResult( roiSize, roiSize, CV_32FC1 );
Mat replicateCurrentBAMat( roiSize, roiSize, CV_32F );
Mat backgroundModelROI( roiSize, roiSize, CV_32F );
Mat diffResult( roiSize, roiSize, CV_32F );
// Scan all pixels of finalBFMask and all pixels of others models (the dimension are the same)
const float* finalBFMaskP;
......@@ -449,9 +455,9 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
if( i > 0 && j > 0 && i < ( backgroundModel[z]->rows - 1 ) && j < ( backgroundModel[z]->cols - 1 ) )
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i - floor( roiSize / 2 ), roiSize, roiSize ) );
backgroundModelROI = mv[0]( Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), roiSize, roiSize ) );
}
else if( i == 0 && j == 0 ) // upper left
else if( i == 0 && j == 0 ) // upper leftt
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i, ceil( roiSize / 2 ), ceil( roiSize / 2 ) ) );
......@@ -459,37 +465,40 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
else if( j == 0 && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle left
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i - floor( roiSize / 2 ), ceil( roiSize / 2 ), roiSize ) );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), ceil( roiSize / 2 ), roiSize ) );
}
else if( i == ( backgroundModel[z]->rows - 1 ) && j == 0 ) //down left
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i - floor( roiSize / 2 ), ceil( roiSize / 2 ), ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), ceil( roiSize / 2 ), ceil( roiSize / 2 ) ) );
}
else if( i == 0 && j > 0 && j < ( backgroundModel[z]->cols - 1 ) ) // upper - middle
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( ( j - floor( roiSize / 2 ) ), i, roiSize, ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( ( j - (int) floor( roiSize / 2 ) ), i, roiSize, (int) ceil( roiSize / 2 ) ) );
}
else if( i == ( backgroundModel[z]->rows - 1 ) && j > 0 && j < ( backgroundModel[z]->cols - 1 ) ) //down middle
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i - floor( roiSize / 2 ), roiSize, ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0](
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), roiSize, (int) ceil( roiSize / 2 ) ) );
}
else if( i == 0 && j == ( backgroundModel[z]->cols - 1 ) ) // upper right
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i, ceil( roiSize / 2 ), ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
}
else if( j == ( backgroundModel[z]->cols - 1 ) && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle - right
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i - floor( roiSize / 2 ), ceil( roiSize / 2 ), roiSize ) );
backgroundModelROI = mv[0](
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), roiSize ) );
}
else if( i == ( backgroundModel[z]->rows - 1 ) && j == ( backgroundModel[z]->cols - 1 ) ) // down right
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - floor( roiSize / 2 ), i - floor( roiSize / 2 ), ceil( roiSize / 2 ), ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0](
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
}
/* Check if the value of current pixel BA in potentialBackground model is already contained in at least one of its neighbors'
......@@ -541,7 +550,7 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
/*imshow( "highResBFMask", highResBFMask * 255 );
imshow( "lowResBFMask", lowResBFMask * 255 );
*/
*/
// Compute the final background-foreground mask. One pixel is marked as foreground if and only if it is
// foreground in both masks (full and low)
......
......@@ -45,11 +45,8 @@
namespace cv
{
CV_INIT_ALGORITHM(
StaticSaliencySpectralResidual,
"SALIENCY.SPECTRAL_RESIDUAL",
obj.info()->addParam( obj, "resImWidth", obj.resImWidth);
obj.info()->addParam( obj, "resImHeight", obj.resImHeight));
CV_INIT_ALGORITHM( StaticSaliencySpectralResidual, "SALIENCY.SPECTRAL_RESIDUAL",
obj.info()->addParam( obj, "resImWidth", obj.resImWidth); obj.info()->addParam( obj, "resImHeight", obj.resImHeight) );
//CV_INIT_ALGORITHM( MotionSaliencySuBSENSE, "SALIENCY.SuBSENSE", );
......@@ -57,19 +54,15 @@ CV_INIT_ALGORITHM(
ObjectnessBING, "SALIENCY.BING",
obj.info()->addParam(obj, "_base", obj._base); obj.info()->addParam(obj, "_NSS", obj._NSS); obj.info()->addParam(obj, "_W", obj._W) );
CV_INIT_ALGORITHM(
MotionSaliencyBinWangApr2014,
"SALIENCY.BinWangApr2014",
obj.info()->addParam( obj, "imgSize", obj.imgSize, false,
reinterpret_cast<SizeGetter>( &MotionSaliencyBinWangApr2014::getWsize ),
reinterpret_cast<SizeSetter>( &MotionSaliencyBinWangApr2014::setWsize ) ) );
CV_INIT_ALGORITHM( MotionSaliencyBinWangApr2014, "SALIENCY.BinWangApr2014",
obj.info()->addParam( obj, "imageWidth", obj.imageWidth); obj.info()->addParam( obj, "imageHeight", obj.imageHeight) );
bool initModule_saliency( void )
{
bool all = true;
all &= !StaticSaliencySpectralResidual_info_auto.name().empty();
//all &= !MotionSaliencySuBSENSE_info_auto.name().empty();
all &= !MotionSaliencyBinWangApr2014_info_auto.name().empty();
all &= !MotionSaliencyBinWangApr2014_info_auto.name().empty();
all &= !ObjectnessBING_info_auto.name().empty();
return all;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment