mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-22 07:31:26 +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++ )
|
||||
{
|
||||
if( i < 6 && i >= 0 && j < 34 && j >= 28 )
|
||||
if( i < 6 && i >= 0 && j < 6 && j >= 0 )
|
||||
test.at < uchar > ( i, j ) = 255;
|
||||
else
|
||||
test.at < uchar > ( i, j ) = rand.uniform( 40, 60 );
|
||||
|
@@ -40,6 +40,8 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
//TODO delete highgui include
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -203,9 +205,15 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( const Mat& image, Mat
|
||||
lowResBFMask.setTo( 1 );
|
||||
|
||||
// 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
|
||||
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
|
||||
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
|
||||
roi.x = 0;
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
lowResBFMask.create( image.rows, image.cols, CV_8UC1 );
|
||||
lowResBFMask.setTo( NAN );
|
||||
lowResBFMask.setTo( 1 );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -470,6 +492,10 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
|
||||
Mat not_lowResBFMask;
|
||||
Mat noisePixelsMask;
|
||||
|
||||
/*Mat t( image.getMat().rows, image.getMat().cols, CV_32FC2 );
|
||||
t.setTo( 50 );
|
||||
backgroundModel.at( 0 ) = t; */
|
||||
|
||||
fullResolutionDetection( image.getMat(), highResBFMask );
|
||||
lowResolutionDetection( image.getMat(), lowResBFMask );
|
||||
|
||||
|
Reference in New Issue
Block a user