Several type of formal refactoring:

1. someMatrix.data -> someMatrix.prt()
2. someMatrix.data + someMatrix.step * lineIndex -> someMatrix.ptr( lineIndex )
3. (SomeType*) someMatrix.data -> someMatrix.ptr<SomeType>()
4. someMatrix.data -> !someMatrix.empty() ( or !someMatrix.data -> someMatrix.empty() ) in logical expressions
This commit is contained in:
Adil Ibragimov
2014-08-13 15:08:27 +04:00
parent 30111a786a
commit 8a4a1bb018
134 changed files with 988 additions and 986 deletions

View File

@@ -47,8 +47,8 @@ int main( void )
src1 = imread("../images/LinuxLogo.jpg");
src2 = imread("../images/WindowsLogo.jpg");
if( !src1.data ) { printf("Error loading src1 \n"); return -1; }
if( !src2.data ) { printf("Error loading src2 \n"); return -1; }
if( src1.empty() ) { printf("Error loading src1 \n"); return -1; }
if( src2.empty() ) { printf("Error loading src2 \n"); return -1; }
/// Initialize values
alpha_slider = 0;

View File

@@ -26,7 +26,7 @@ int main( int, char** argv )
/// Load image
src = imread( argv[1], 1 );
if( !src.data )
if( src.empty() )
{ cout<<"Usage: ./Histogram_Demo <path_to_image>"<<endl;
return -1;
}

View File

@@ -23,7 +23,7 @@ int main( int, char** argv )
/// Load image
src = imread( argv[1], 1 );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Separate the image in 3 places ( B, G and R )

View File

@@ -35,8 +35,8 @@ int main( void )
src1 = imread("../images/LinuxLogo.jpg");
src2 = imread("../images/WindowsLogo.jpg");
if( !src1.data ) { std::cout<< "Error loading src1"<<std::endl; return -1; }
if( !src2.data ) { std::cout<< "Error loading src2"<<std::endl; return -1; }
if( src1.empty() ) { std::cout<< "Error loading src1"<<std::endl; return -1; }
if( src2.empty() ) { std::cout<< "Error loading src2"<<std::endl; return -1; }
/// Create Windows
namedWindow("Linear Blend", 1);

View File

@@ -34,7 +34,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Create windows

View File

@@ -36,7 +36,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Create window

View File

@@ -33,7 +33,7 @@ int main( void )
/// Test image - Make sure it s divisible by 2^{n}
src = imread( "../images/chicky_512.png" );
if( !src.data )
if( src.empty() )
{ printf(" No data! -- Exiting the program \n");
return -1; }

View File

@@ -52,7 +52,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Create a matrix of the same type and size as src (for dst)

View File

@@ -65,7 +65,7 @@ int main(int argc, char** argv)
// Read the image
src = imread( argv[1], 1 );
if( !src.data )
if( src.empty() )
{
std::cerr<<"Invalid input image\n";
std::cout<<usage;

View File

@@ -28,7 +28,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Remove noise by blurring with a Gaussian filter

View File

@@ -28,7 +28,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );

View File

@@ -30,7 +30,7 @@ int main( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{
printf(" No data entered, please enter the path to an image file \n");
return -1;

View File

@@ -32,7 +32,7 @@ int main ( int, char** argv )
/// Load an image
src = imread( argv[1] );
if( !src.data )
if( src.empty() )
{ return -1; }
/// Create window

View File

@@ -33,7 +33,7 @@ int main( int argc, char** argv )
Mat imgDisparity16S = Mat( imgLeft.rows, imgLeft.cols, CV_16S );
Mat imgDisparity8U = Mat( imgLeft.rows, imgLeft.cols, CV_8UC1 );
if( !imgLeft.data || !imgRight.data )
if( imgLeft.empty() || imgRight.empty() )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
//-- 2. Call the constructor for StereoBM

View File

@@ -41,7 +41,7 @@ int main( int argc, char* argv[])
else
I = imread(argv[1], IMREAD_COLOR);
if (!I.data)
if (I.empty())
{
cout << "The image" << argv[1] << " could not be loaded." << endl;
return -1;
@@ -107,7 +107,7 @@ int main( int argc, char* argv[])
<< times << " runs): " << t << " milliseconds."<< endl;
Mat lookUpTable(1, 256, CV_8U);
uchar* p = lookUpTable.data;
uchar* p = lookUpTable.ptr();
for( int i = 0; i < 256; ++i)
p[i] = table[i];

View File

@@ -17,7 +17,7 @@ int main( int argc, char** argv )
Mat image;
image = imread(argv[1], IMREAD_COLOR); // Read the file
if(! image.data ) // Check for invalid input
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;

View File

@@ -17,7 +17,7 @@ int main( int argc, char** argv )
Mat image;
image = imread(argv[1], IMREAD_COLOR); // Read the file
if(! image.data ) // Check for invalid input
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;

View File

@@ -37,7 +37,7 @@ int main(int argc, char* argv[])
Mat I = imread(argv[1]);
if(!I.data)
if(I.empty())
{
cout << "Image not found" << endl;
exit(0);

View File

@@ -318,12 +318,12 @@ int main()
img2 = imread(dest);
if(!img0.data)
if(img0.empty())
{
cout << "Source Image does not exist" << endl;
exit(0);
}
if(!img2.data)
if(img2.empty())
{
cout << "Destination Image does not exist" << endl;
exit(0);
@@ -366,7 +366,7 @@ int main()
img0 = imread(src);
if(!img0.data)
if(img0.empty())
{
cout << "Source Image does not exist" << endl;
exit(0);
@@ -396,7 +396,7 @@ int main()
img0 = imread(src);
if(!img0.data)
if(img0.empty())
{
cout << "Source Image does not exist" << endl;
exit(0);
@@ -429,7 +429,7 @@ int main()
img0 = imread(src);
if(!img0.data)
if(img0.empty())
{
cout << "Source Image does not exist" << endl;
exit(0);

View File

@@ -130,7 +130,7 @@ void processVideo(char* videoFilename) {
void processImages(char* fistFrameFilename) {
//read the first file of the sequence
frame = imread(fistFrameFilename);
if(!frame.data){
if(frame.empty()){
//error in opening the first image
cerr << "Unable to open first image frame: " << fistFrameFilename << endl;
exit(EXIT_FAILURE);
@@ -169,7 +169,7 @@ void processImages(char* fistFrameFilename) {
string nextFrameFilename = prefix + nextFrameNumberString + suffix;
//read the next frame
frame = imread(nextFrameFilename);
if(!frame.data){
if(frame.empty()){
//error in opening the next image in the sequence
cerr << "Unable to open image frame: " << nextFrameFilename << endl;
exit(EXIT_FAILURE);