From e1c541f93e41d351ee1a89ec549ef261fd6988e0 Mon Sep 17 00:00:00 2001 From: mathnathan Date: Tue, 27 Jul 2010 11:39:24 -0400 Subject: [PATCH] More updates for the website --- examples/CMakeLists.txt | 8 ++++++++ examples/alphablend.cpp | 31 +++++++++++++++++++++++++++++++ examples/example2-2.cpp | 3 ++- examples/example2-5.cpp | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 examples/alphablend.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fbb11c0..1125f2f 100755 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,10 +8,18 @@ add_executable(example1 example2-1.cpp) add_executable(example2 example2-2.cpp) add_executable(example3 example2-3.cpp) add_executable(example4 example2-4.cpp) +add_executable(example5 example2-5.cpp) +add_executable(example6 example2-6.cpp) +add_executable(example6debug example2-6debug.cpp) +add_executable(alphablend alphablend.cpp) target_link_libraries(example1 ${OpenCV_LIBS}) target_link_libraries(example2 ${OpenCV_LIBS}) target_link_libraries(example3 ${OpenCV_LIBS}) target_link_libraries(example4 ${OpenCV_LIBS}) +target_link_libraries(example5 ${OpenCV_LIBS}) +target_link_libraries(example6 ${OpenCV_LIBS}) +target_link_libraries(example6debug ${OpenCV_LIBS}) +target_link_libraries(alphablend ${OpenCV_LIBS}) diff --git a/examples/alphablend.cpp b/examples/alphablend.cpp new file mode 100644 index 0000000..2ddd74b --- /dev/null +++ b/examples/alphablend.cpp @@ -0,0 +1,31 @@ +/* This program takes in 8 arguments, argv[1] and argv[2] are the images being blended. * + * The ROI of argv[2] is blended into the ROI of argv[1]. argv[3] and argv[4] are the * + * x and y coordinates respectively of the top left or bottom left corner of the ROI in * + * the argv[1] image. argv[5] and argv[6] are the width and height of the ROI from the * + * x,y coordinate. arg[7] is the weighted alph value of image argv[1], and argv[8] is * + * the weighted beta value of the image argv[2] to be blended. */ + +# include +# include + +int main( int argc, char** argv ) { + IplImage *src1, *src2; + if( argc == 9 && ((src1=cvLoadImage(argv[1],1)) != 0 + )&&((src2=cvLoadImage(argv[2],1)) != 0)) + { + int x = atoi(argv[3]); + int y = atoi(argv[4]); + int width = atoi(argv[5]); + int height = atoi(argv[6]); + double alpha = (double)atof(argv[7]); + double beta = (double)atof(argv[8]); + cvSetImageROI(src1, cvRect(x,y,width,height)); + cvSetImageROI(src2, cvRect(x,y,width,height)); + cvAddWeighted(src1, alpha, src2, beta, 0.0, src1); + cvResetImageROI(src1); + cvNamedWindow( "Alpha_blend", 1 ); + cvShowImage( "Alpha_blend", src1 ); + cvWaitKey(); + } + return 0; +} diff --git a/examples/example2-2.cpp b/examples/example2-2.cpp index 111ff6a..e56ca79 100644 --- a/examples/example2-2.cpp +++ b/examples/example2-2.cpp @@ -13,11 +13,12 @@ int main( int argc, char** argv ) { cvMoveWindow( "Example2", 100, 100); CvCapture* capture = cvCreateFileCapture( argv[1] ); + double fps = cvGetCaptureProperty( capture, CV_CAP_PROP_FPS ); while(1) { frame = cvQueryFrame( capture ); if( !frame) break; cvShowImage( "Example2", frame ); - char c = cvWaitKey(73); + char c = cvWaitKey( 33 ); if( c == 27 ) break; } diff --git a/examples/example2-5.cpp b/examples/example2-5.cpp index 801cebc..ee1e881 100755 --- a/examples/example2-5.cpp +++ b/examples/example2-5.cpp @@ -21,7 +21,7 @@ int main( int argc, char** argv ) { frame = cvQueryFrame( capture ); if( !frame) break; augframe = cvCreateImage( cvGetSize( frame ), IPL_DEPTH_8U, 3 ); - cvSmooth( frame, augframe, CV_BLUR, 3, 3 ); + cvSmooth( frame, augframe, CV_BILATERAL, 3, 3 ); cvShowImage( "Example2", frame ); cvShowImage( "output", augframe ); char c = cvWaitKey(73);