Build tutorial codes together with other samples

These codes should be included into regular builds.
This commit is contained in:
Andrey Kamaev
2012-11-07 18:21:20 +04:00
parent 6484732509
commit b131dfeecd
58 changed files with 420 additions and 354 deletions

View File

@@ -21,13 +21,13 @@ int lowThreshold;
int const max_lowThreshold = 100;
int ratio = 3;
int kernel_size = 3;
char* window_name = "Edge Map";
const char* window_name = "Edge Map";
/**
* @function CannyThreshold
* @brief Trackbar callback - Canny thresholds input with a ratio 1:3
*/
void CannyThreshold(int, void*)
static void CannyThreshold(int, void*)
{
/// Reduce noise with a kernel 3x3
blur( src_gray, detected_edges, Size(3,3) );
@@ -46,7 +46,7 @@ void CannyThreshold(int, void*)
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
/// Load an image
src = imread( argv[1] );

View File

@@ -13,14 +13,14 @@ using namespace cv;
using namespace std;
/// Global variables
char* source_window = "Source image";
char* warp_window = "Warp";
char* warp_rotate_window = "Warp + Rotate";
const char* source_window = "Source image";
const char* warp_window = "Warp";
const char* warp_rotate_window = "Warp + Rotate";
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
Point2f srcTri[3];
Point2f dstTri[3];
@@ -37,12 +37,12 @@ int main( int argc, char** argv )
/// Set your 3 points to calculate the Affine Transform
srcTri[0] = Point2f( 0,0 );
srcTri[1] = Point2f( src.cols - 1, 0 );
srcTri[2] = Point2f( 0, src.rows - 1 );
srcTri[1] = Point2f( src.cols - 1.f, 0 );
srcTri[2] = Point2f( 0, src.rows - 1.f );
dstTri[0] = Point2f( src.cols*0.0, src.rows*0.33 );
dstTri[1] = Point2f( src.cols*0.85, src.rows*0.25 );
dstTri[2] = Point2f( src.cols*0.15, src.rows*0.7 );
dstTri[0] = Point2f( src.cols*0.0f, src.rows*0.33f );
dstTri[1] = Point2f( src.cols*0.85f, src.rows*0.25f );
dstTri[2] = Point2f( src.cols*0.15f, src.rows*0.7f );
/// Get the Affine Transform
warp_mat = getAffineTransform( srcTri, dstTri );

View File

@@ -14,7 +14,7 @@ using namespace cv;
/**
* @function main
*/
int main(int argc, char** argv)
int main(int, char** argv)
{
Mat src, src_gray;

View File

@@ -21,8 +21,8 @@ Mat standard_hough, probabilistic_hough;
int min_threshold = 50;
int max_trackbar = 150;
char* standard_name = "Standard Hough Lines Demo";
char* probabilistic_name = "Probabilistic Hough Lines Demo";
const char* standard_name = "Standard Hough Lines Demo";
const char* probabilistic_name = "Probabilistic Hough Lines Demo";
int s_trackbar = max_trackbar;
int p_trackbar = max_trackbar;
@@ -35,7 +35,7 @@ void Probabilistic_Hough( int, void* );
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
/// Read the image
src = imread( argv[1], 1 );
@@ -91,7 +91,7 @@ void Standard_Hough( int, void* )
HoughLines( edges, s_lines, 1, CV_PI/180, min_threshold + s_trackbar, 0, 0 );
/// Show the result
for( int i = 0; i < s_lines.size(); i++ )
for( size_t i = 0; i < s_lines.size(); i++ )
{
float r = s_lines[i][0], t = s_lines[i][1];
double cos_t = cos(t), sin_t = sin(t);

View File

@@ -14,7 +14,7 @@ using namespace cv;
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
Mat src, src_gray, dst;
@@ -22,9 +22,7 @@ int main( int argc, char** argv )
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
char* window_name = "Laplace Demo";
int c;
const char* window_name = "Laplace Demo";
/// Load an image
src = imread( argv[1] );

View File

@@ -14,7 +14,7 @@ using namespace cv;
/// Global variables
Mat src, dst;
Mat map_x, map_y;
char* remap_window = "Remap demo";
const char* remap_window = "Remap demo";
int ind = 0;
/// Function Headers
@@ -23,7 +23,7 @@ void update_map( void );
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
/// Load the image
src = imread( argv[1], 1 );
@@ -37,7 +37,7 @@ int main( int argc, char** argv )
namedWindow( remap_window, CV_WINDOW_AUTOSIZE );
/// Loop
while( true )
for(;;)
{
/// Each 1 sec. Press ESC to exit the program
int c = waitKey( 1000 );
@@ -71,8 +71,8 @@ void update_map( void )
case 0:
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
{
map_x.at<float>(j,i) = 2*( i - src.cols*0.25 ) + 0.5 ;
map_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
map_x.at<float>(j,i) = 2*( i - src.cols*0.25f ) + 0.5f ;
map_y.at<float>(j,i) = 2*( j - src.rows*0.25f ) + 0.5f ;
}
else
{ map_x.at<float>(j,i) = 0 ;
@@ -80,16 +80,16 @@ void update_map( void )
}
break;
case 1:
map_x.at<float>(j,i) = i ;
map_y.at<float>(j,i) = src.rows - j ;
map_x.at<float>(j,i) = (float)i ;
map_y.at<float>(j,i) = (float)(src.rows - j) ;
break;
case 2:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = j ;
map_x.at<float>(j,i) = (float)(src.cols - i) ;
map_y.at<float>(j,i) = (float)j ;
break;
case 3:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = src.rows - j ;
map_x.at<float>(j,i) = (float)(src.cols - i) ;
map_y.at<float>(j,i) = (float)(src.rows - j) ;
break;
} // end of switch
}

View File

@@ -14,18 +14,16 @@ using namespace cv;
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
Mat src, src_gray;
Mat grad;
char* window_name = "Sobel Demo - Simple Edge Detector";
const char* window_name = "Sobel Demo - Simple Edge Detector";
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
int c;
/// Load an image
src = imread( argv[1] );

View File

@@ -16,13 +16,13 @@ Mat src, dst;
int top, bottom, left, right;
int borderType;
Scalar value;
char* window_name = "copyMakeBorder Demo";
const char* window_name = "copyMakeBorder Demo";
RNG rng(12345);
/**
* @function main
*/
int main( int argc, char** argv )
int main( int, char** argv )
{
int c;
@@ -31,8 +31,9 @@ int main( int argc, char** argv )
src = imread( argv[1] );
if( !src.data )
{ return -1;
{
printf(" No data entered, please enter the path to an image file \n");
return -1;
}
/// Brief how-to for this program
@@ -52,7 +53,7 @@ int main( int argc, char** argv )
imshow( window_name, dst );
while( true )
for(;;)
{
c = waitKey(500);

View File

@@ -14,7 +14,7 @@ using namespace cv;
/**
* @function main
*/
int main ( int argc, char** argv )
int main ( int, char** argv )
{
/// Declare variables
Mat src, dst;
@@ -24,7 +24,7 @@ int main ( int argc, char** argv )
double delta;
int ddepth;
int kernel_size;
char* window_name = "filter2D Demo";
const char* window_name = "filter2D Demo";
int c;
@@ -44,7 +44,7 @@ int main ( int argc, char** argv )
/// Loop - Will filter the image with different kernel sizes each 0.5 seconds
int ind = 0;
while( true )
for(;;)
{
c = waitKey(500);
/// Press 'ESC' to exit the program