mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-23 00:49:38 +08:00
lowResolutionDetection problems fixed
This commit is contained in:
@@ -170,7 +170,7 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
for ( int j = 0; j < test.cols; j++ )
|
for ( int j = 0; j < test.cols; j++ )
|
||||||
{
|
{
|
||||||
if( i < 6 && i >= 0 && j < 34 && j >= 28 )
|
if( i < 6 && i >= 0 && j < 6 && j >= 0 )
|
||||||
test.at < uchar > ( i, j ) = 255;
|
test.at < uchar > ( i, j ) = 255;
|
||||||
else
|
else
|
||||||
test.at < uchar > ( i, j ) = rand.uniform( 40, 60 );
|
test.at < uchar > ( i, j ) = rand.uniform( 40, 60 );
|
||||||
|
@@ -40,6 +40,8 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
//TODO delete highgui include
|
||||||
|
#include <opencv2/highgui.hpp>
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@@ -203,9 +205,15 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( const Mat& image, Mat
|
|||||||
lowResBFMask.setTo( 1 );
|
lowResBFMask.setTo( 1 );
|
||||||
|
|
||||||
// Scan all the ROI of original matrices
|
// Scan all the ROI of original matrices
|
||||||
for ( int i = 0; i < image.rows / N; i++ )
|
for ( int i = 0; i < ceil( (float) image.rows / N ); i++ )
|
||||||
{
|
{
|
||||||
for ( int j = 0; j < image.cols / N; j++ )
|
if( ( roi.y + ( N - 1 ) ) <= ( image.rows - 1 ) )
|
||||||
|
{
|
||||||
|
// Reset original ROI dimension
|
||||||
|
roi = Rect( Point( roi.x, roi.y ), Size( N, N ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int j = 0; j < ceil( (float) image.cols / N ); j++ )
|
||||||
{
|
{
|
||||||
// Compute the mean of image's block and epslonMatrix's block based on ROI
|
// Compute the mean of image's block and epslonMatrix's block based on ROI
|
||||||
Mat roiImage = image( roi );
|
Mat roiImage = image( roi );
|
||||||
@@ -238,17 +246,31 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( const Mat& image, Mat
|
|||||||
}
|
}
|
||||||
// Shift the ROI from left to right follow the block dimension
|
// Shift the ROI from left to right follow the block dimension
|
||||||
roi = roi + Point( N, 0 );
|
roi = roi + Point( N, 0 );
|
||||||
|
if( ( roi.x + ( roi.width - 1 ) ) > ( image.cols - 1 ) && ( roi.y + ( N - 1 ) ) <= ( image.rows - 1 ) )
|
||||||
|
{
|
||||||
|
roi = Rect( Point( roi.x, roi.y ), Size( abs( ( image.cols - 1 ) - roi.x )+1, N ) );
|
||||||
|
}
|
||||||
|
else if( ( roi.x + ( roi.width - 1 ) ) > ( image.cols - 1 ) && ( roi.y + ( N - 1 ) ) > ( image.rows - 1 ) )
|
||||||
|
{
|
||||||
|
roi = Rect( Point( roi.x, roi.y ), Size( abs( ( image.cols - 1 ) - roi.x )+1, abs( ( image.rows - 1 ) - roi.y )+1 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Shift the ROI from up to down follow the block dimension, also bringing it back to beginning of row
|
//Shift the ROI from up to down follow the block dimension, also bringing it back to beginning of row
|
||||||
roi.x = 0;
|
roi.x = 0;
|
||||||
roi.y += N;
|
roi.y += N;
|
||||||
|
if( ( roi.y + ( roi.height - 1 ) ) > ( image.rows - 1 ) )
|
||||||
|
{
|
||||||
|
roi = Rect( Point( roi.x, roi.y ), Size( N, abs( ( image.rows - 1 ) - roi.y )+1 ) );
|
||||||
|
}
|
||||||
|
cout << endl << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lowResBFMask.create( image.rows, image.cols, CV_8UC1 );
|
lowResBFMask.create( image.rows, image.cols, CV_8UC1 );
|
||||||
lowResBFMask.setTo( NAN );
|
lowResBFMask.setTo( 1 );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,6 +492,10 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
|
|||||||
Mat not_lowResBFMask;
|
Mat not_lowResBFMask;
|
||||||
Mat noisePixelsMask;
|
Mat noisePixelsMask;
|
||||||
|
|
||||||
|
/*Mat t( image.getMat().rows, image.getMat().cols, CV_32FC2 );
|
||||||
|
t.setTo( 50 );
|
||||||
|
backgroundModel.at( 0 ) = t; */
|
||||||
|
|
||||||
fullResolutionDetection( image.getMat(), highResBFMask );
|
fullResolutionDetection( image.getMat(), highResBFMask );
|
||||||
lowResolutionDetection( image.getMat(), lowResBFMask );
|
lowResolutionDetection( image.getMat(), lowResBFMask );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user