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:
@@ -268,7 +268,7 @@ int main( int argc, char** argv )
|
||||
printf("%s\n", imageList[i*3+k].c_str());
|
||||
view = imread(imageList[i*3+k], 1);
|
||||
|
||||
if(view.data)
|
||||
if(!view.empty())
|
||||
{
|
||||
vector<Point2f> ptvec;
|
||||
imageSize = view.size();
|
||||
@@ -356,7 +356,7 @@ int main( int argc, char** argv )
|
||||
int k2 = k == 0 ? 1 : k == 1 ? 0 : 2;
|
||||
view = imread(imageList[i*3+k], 1);
|
||||
|
||||
if(!view.data)
|
||||
if(view.empty())
|
||||
continue;
|
||||
|
||||
Mat rview = canvas.colRange(k2*imageSize.width, (k2+1)*imageSize.width);
|
||||
|
@@ -448,7 +448,7 @@ int main( int argc, char** argv )
|
||||
else if( i < (int)imageList.size() )
|
||||
view = imread(imageList[i], 1);
|
||||
|
||||
if(!view.data)
|
||||
if(view.empty())
|
||||
{
|
||||
if( imagePoints.size() > 0 )
|
||||
runAndSave(outputFilename, imagePoints, imageSize,
|
||||
@@ -563,7 +563,7 @@ int main( int argc, char** argv )
|
||||
for( i = 0; i < (int)imageList.size(); i++ )
|
||||
{
|
||||
view = imread(imageList[i], 1);
|
||||
if(!view.data)
|
||||
if(view.empty())
|
||||
continue;
|
||||
//undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
|
||||
remap(view, rview, map1, map2, INTER_LINEAR);
|
||||
|
@@ -319,12 +319,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);
|
||||
@@ -367,7 +367,7 @@ int main()
|
||||
|
||||
img0 = imread(src);
|
||||
|
||||
if(!img0.data)
|
||||
if(img0.empty())
|
||||
{
|
||||
cout << "Source Image does not exist" << endl;
|
||||
exit(0);
|
||||
@@ -397,7 +397,7 @@ int main()
|
||||
|
||||
img0 = imread(src);
|
||||
|
||||
if(!img0.data)
|
||||
if(img0.empty())
|
||||
{
|
||||
cout << "Source Image does not exist" << endl;
|
||||
exit(0);
|
||||
@@ -430,7 +430,7 @@ int main()
|
||||
|
||||
img0 = imread(src);
|
||||
|
||||
if(!img0.data)
|
||||
if(img0.empty())
|
||||
{
|
||||
cout << "Source Image does not exist" << endl;
|
||||
exit(0);
|
||||
|
@@ -48,7 +48,7 @@ int main( int argc, char** argv )
|
||||
}
|
||||
#endif
|
||||
|
||||
if( !img.data ) // check if the image has been loaded properly
|
||||
if( img.empty() ) // check if the image has been loaded properly
|
||||
return -1;
|
||||
|
||||
Mat img_yuv;
|
||||
|
@@ -59,7 +59,7 @@ static void ErodeDilate(int, void*)
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
char* filename = argc == 2 ? argv[1] : (char*)"baboon.jpg";
|
||||
if( (src = imread(filename,1)).data == 0 )
|
||||
if( (src = imread(filename,1)).empty() )
|
||||
return -1;
|
||||
|
||||
help();
|
||||
|
@@ -38,7 +38,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);
|
||||
|
@@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
||||
Mat tmp_frame, bgmask, out_frame;
|
||||
|
||||
cap >> tmp_frame;
|
||||
if(!tmp_frame.data)
|
||||
if(tmp_frame.empty())
|
||||
{
|
||||
printf("can not read data from the video source\n");
|
||||
return -1;
|
||||
@@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
||||
for(;;)
|
||||
{
|
||||
cap >> tmp_frame;
|
||||
if( !tmp_frame.data )
|
||||
if( tmp_frame.empty() )
|
||||
break;
|
||||
bgsubtractor->apply(tmp_frame, bgmask, update_bg_model ? -1 : 0);
|
||||
refineSegments(tmp_frame, bgmask, out_frame);
|
||||
|
@@ -147,7 +147,7 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram
|
||||
|
||||
projectPoints(Mat(objpt), rvec, tvec, cameraMatrix, Mat(), imgpt);
|
||||
|
||||
if( shownFrame.data )
|
||||
if( !shownFrame.empty() )
|
||||
{
|
||||
if( nobjpt == 1 )
|
||||
circle(shownFrame, imgpt[0], 3, Scalar(0,255,0), -1, LINE_AA);
|
||||
@@ -534,9 +534,9 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
capture >> frame0;
|
||||
if( !frame0.data )
|
||||
if( frame0.empty() )
|
||||
break;
|
||||
if( !frame.data )
|
||||
if( frame.empty() )
|
||||
{
|
||||
if( frame0.size() != calibratedImageSize )
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ void get_svm_detector(const Ptr<SVM>& svm, vector< float > & hog_detector )
|
||||
hog_detector.clear();
|
||||
|
||||
hog_detector.resize(sv.cols + 1);
|
||||
memcpy(&hog_detector[0], sv.data, sv.cols*sizeof(hog_detector[0]));
|
||||
memcpy(&hog_detector[0], sv.ptr(), sv.cols*sizeof(hog_detector[0]));
|
||||
hog_detector[sv.cols] = (float)-rho;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void load_images( const string & prefix, const string & filename, vector< Mat >
|
||||
break;
|
||||
}
|
||||
Mat img = imread( (prefix+line).c_str() ); // load the image
|
||||
if( !img.data ) // invalid image, just skip it.
|
||||
if( img.empty() ) // invalid image, just skip it.
|
||||
continue;
|
||||
#ifdef _DEBUG
|
||||
imshow( "image", img );
|
||||
@@ -381,7 +381,7 @@ void test_it( const Size & size )
|
||||
while( !end_of_process )
|
||||
{
|
||||
video >> img;
|
||||
if( !img.data )
|
||||
if( img.empty() )
|
||||
break;
|
||||
|
||||
draw = img.clone();
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 )
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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; }
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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 );
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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];
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user