Вы находитесь на странице: 1из 8

/ , OpenCV

2. Visual Studio.
OpenCV

http://www.lisperati.com/haskell/hello_world.png

:
www.uralvision.blogspot.com


perevalovds@gmail.com

/ 2011

1.
, OpenCV2.1 .
1. VS2008
2.
File - New - Project - Win32 Console Application,
Name Project1, .
3.
Alt+F7 -
Configuration Properties - C/C++ - General - Additional Include Directories,
"C:\Program Files\OpenCV2.1\include\opencv";
Linker - General - Additional Library Directories,
C:\Program Files\OpenCV2.1\lib\
Linker - Input - Additional Dependencies cv210.lib cvaux210.lib cxcore210.lib cxts210.lib highgui210.lib
Release,
cv210d.lib cvaux210d.lib cxcore210d.lib cxts210.lib highgui210d.lib
Debug

2.

1. :
http://www.fitseniors.org/wp-content/uploads/2008/04/green_apple.jpg
C:\green_apple.jpg
2. Project1.cpp:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
using namespace cv;
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" ); //
imshow( "image", image );
//
waitKey( 0 );
//
return 0;
}
3. F7 - , F5 - .
,
.

3.

main :
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//image1 0.3*image
Mat image1 = 0.3 * image;
imshow( "image", image );
imshow( "image1", image1 );
waitKey( 0 );
return 0;
}

4.
, ,
main :
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//
// - channels[0], channels[1], channels[2]
vector<Mat> channels;
split( image, channels );
//
// , - 2, 0.
imshow( "Red", channels[2] );
imshow( "Green", channels[1] );
imshow( "Blue", channels[0] );
waitKey( 0 );
return 0;
}

4.
main :
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//
// - channels[0], channels[1], channels[2]
vector<Mat> channels;
split( image, channels );
//
Mat image2;
threshold( channels[0], image2,
100, //
255, //. , 0 255
CV_THRESH_BINARY // , (value > 100) ? 255 : 0;
);
imshow( "Thresholded", image2 );
waitKey( 0 );
return 0;
}

5.

main :
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//
Rect rect = Rect(100, 100, 200, 200); //
Mat image3;
image( rect ).copyTo( image3 );
// image
imshow( "image3", image3 );
//
image( rect ) *= 2;
imshow( "image changed", image );
waitKey( 0 );
return 0;
}


1. ,
(image) (image_orange)
image3 = 0.5 * image + 0.5 * image_orange;
,
-
(Photoshop Paint).
2. (Project.cpp +
) perevalovds@gmail.com

Вам также может понравиться