oreillymedia/Learning-OpenCV-3_examples

example 2.5 in printed book

FOSSBOSS opened this issue · 1 comments

not having the source to fork is pretty BS but moving on, the source code in example 2.5, pages 31,32 is incomplete.

#include <opencv2/opencv.hpp>
using namespace cv;
void example2_5(cv::Mat & image){
	Mat out;
	namedWindow("input",WINDOW_AUTOSIZE);
	namedWindow("output",WINDOW_AUTOSIZE);
	imshow("input", image);
	GaussianBlur(image, out, Size(5,5) ,3, 3);
	GaussianBlur(  out, out, Size(5,5) ,3, 3);
	
	imshow("output",out);
	
	waitKey(0);
	}


int main(int argc, char **argv){
	Mat input;
	input = imread(argv[1]);
	example2_5(input);
	return 0;
	}

Your code is quite different from the book, the example 2-5 seems to exactly reflect what is in Learning OpenCV 3:

#include <opencv2/opencv.hpp>

int main( int argc, char** argv ) {

// Load an image specified on the command line.
//
cv::Mat image = cv::imread(argv[1],-1);

// Create some windows to show the input
// and output images in.
//
cv::namedWindow( "Example 2-5-in", cv::WINDOW_AUTOSIZE );
cv::namedWindow( "Example 2-5-out", cv::WINDOW_AUTOSIZE );

// Create a window to show our input image
//
cv::imshow( "Example 2-5-in", image );

// Create an image to hold the smoothed output
//
cv::Mat out;

// Do the smoothing
// ( Note: Could use GaussianBlur(), blur(), medianBlur() or
// bilateralFilter(). )
//
cv::GaussianBlur( image, out, cv::Size(5,5), 3, 3);
cv::GaussianBlur( out, out, cv::Size(5,5), 3, 3);

// Show the smoothed image in the output window
//
cv::imshow( "Example 2-5-out", out );

// Wait for the user to hit a key, windows will self destruct
//
cv::waitKey( 0 );

}