mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Merge pull request #3302 from berak:doc_fix_constants_30
This commit is contained in:
commit
bc7ab6c2df
@ -136,7 +136,7 @@ Explanation
|
||||
{
|
||||
case Settings::CHESSBOARD:
|
||||
found = findChessboardCorners( view, s.boardSize, pointBuf,
|
||||
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE);
|
||||
CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FAST_CHECK | CALIB_CB_NORMALIZE_IMAGE);
|
||||
break;
|
||||
case Settings::CIRCLES_GRID:
|
||||
found = findCirclesGrid( view, s.boardSize, pointBuf );
|
||||
@ -158,9 +158,9 @@ Explanation
|
||||
if( s.calibrationPattern == Settings::CHESSBOARD)
|
||||
{
|
||||
Mat viewGray;
|
||||
cvtColor(view, viewGray, CV_BGR2GRAY);
|
||||
cvtColor(view, viewGray, COLOR_BGR2GRAY);
|
||||
cornerSubPix( viewGray, pointBuf, Size(11,11),
|
||||
Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 ));
|
||||
Size(-1,-1), TermCriteria( TermCriteria::EPS+TermCriteria::MAX_ITER, 30, 0.1 ));
|
||||
}
|
||||
|
||||
if( mode == CAPTURING && // For camera only take new samples after delay time
|
||||
@ -327,7 +327,7 @@ We do the calibration with the help of the :calib3d:`calibrateCamera <calibratec
|
||||
.. code-block:: cpp
|
||||
|
||||
cameraMatrix = Mat::eye(3, 3, CV_64F);
|
||||
if( s.flag & CV_CALIB_FIX_ASPECT_RATIO )
|
||||
if( s.flag & CALIB_FIX_ASPECT_RATIO )
|
||||
cameraMatrix.at<double>(0,0) = 1.0;
|
||||
|
||||
+ The distortion coefficient matrix. Initialize with zero.
|
||||
@ -364,7 +364,7 @@ We do the calibration with the help of the :calib3d:`calibrateCamera <calibratec
|
||||
{
|
||||
projectPoints( Mat(objectPoints[i]), rvecs[i], tvecs[i], cameraMatrix, // project
|
||||
distCoeffs, imagePoints2);
|
||||
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), CV_L2); // difference
|
||||
err = norm(Mat(imagePoints[i]), Mat(imagePoints2), NORM_L2); // difference
|
||||
|
||||
int n = (int)objectPoints[i].size();
|
||||
perViewErrors[i] = (float) std::sqrt(err*err/n); // save for this view
|
||||
|
@ -28,12 +28,12 @@ Now, let us write a code that detects a chessboard in a new image and finds its
|
||||
#.
|
||||
Create an empty console project. Load a test image: ::
|
||||
|
||||
Mat img = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img = imread(argv[1], IMREAD_GRAYSCALE);
|
||||
|
||||
#.
|
||||
Detect a chessboard in this image using findChessboard function. ::
|
||||
|
||||
bool found = findChessboardCorners( img, boardSize, ptvec, CV_CALIB_CB_ADAPTIVE_THRESH );
|
||||
bool found = findChessboardCorners( img, boardSize, ptvec, CALIB_CB_ADAPTIVE_THRESH );
|
||||
|
||||
#.
|
||||
Now, write a function that generates a ``vector<Point3f>`` array of 3d coordinates of a chessboard in any coordinate system. For simplicity, let us choose a system such that one of the chessboard corners is in the origin and the board is in the plane *z = 0*.
|
||||
|
@ -120,8 +120,8 @@ In this sample I'll show how to calculate and show the *magnitude* image of a Fo
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
normalize(magI, magI, 0, 1, CV_MINMAX); // Transform the matrix with float values into a
|
||||
// viewable image form (float between values 0 and 1).
|
||||
normalize(magI, magI, 0, 1, NORM_MINMAX); // Transform the matrix with float values into a
|
||||
// viewable image form (float between values 0 and 1).
|
||||
|
||||
Result
|
||||
======
|
||||
|
@ -32,8 +32,8 @@ To tackle this issue OpenCV uses a reference counting system. The idea is that e
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
|
||||
Mat A, C; // creates just the header parts
|
||||
A = imread(argv[1], CV_LOAD_IMAGE_COLOR); // here we'll know the method used (allocate matrix)
|
||||
Mat A, C; // creates just the header parts
|
||||
A = imread(argv[1], IMREAD_COLOR); // here we'll know the method used (allocate matrix)
|
||||
|
||||
Mat B(A); // Use the copy constructor
|
||||
|
||||
|
@ -194,7 +194,7 @@ Explanation
|
||||
|
||||
int Displaying_Big_End( Mat image, char* window_name, RNG rng )
|
||||
{
|
||||
Size textsize = getTextSize("OpenCV forever!", CV_FONT_HERSHEY_COMPLEX, 3, 5, 0);
|
||||
Size textsize = getTextSize("OpenCV forever!", FONT_HERSHEY_COMPLEX, 3, 5, 0);
|
||||
Point org((window_width - textsize.width)/2, (window_height - textsize.height)/2);
|
||||
int lineType = 8;
|
||||
|
||||
@ -203,7 +203,7 @@ Explanation
|
||||
for( int i = 0; i < 255; i += 2 )
|
||||
{
|
||||
image2 = image - Scalar::all(i);
|
||||
putText( image2, "OpenCV forever!", org, CV_FONT_HERSHEY_COMPLEX, 3,
|
||||
putText( image2, "OpenCV forever!", org, FONT_HERSHEY_COMPLEX, 3,
|
||||
Scalar(i, i, 255), 5, lineType );
|
||||
|
||||
imshow( window_name, image2 );
|
||||
|
@ -12,8 +12,8 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu
|
||||
#.
|
||||
Create a new console project. Read two input images. ::
|
||||
|
||||
Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img1 = imread(argv[1], IMREAD_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], IMREAD_GRAYSCALE);
|
||||
|
||||
#.
|
||||
Detect keypoints in both images. ::
|
||||
@ -59,7 +59,7 @@ The goal of this tutorial is to learn how to use *features2d* and *calib3d* modu
|
||||
vector<Point2f> points1, points2;
|
||||
// fill the arrays with the points
|
||||
....
|
||||
Mat H = findHomography(Mat(points1), Mat(points2), CV_RANSAC, ransacReprojThreshold);
|
||||
Mat H = findHomography(Mat(points1), Mat(points2), RANSAC, ransacReprojThreshold);
|
||||
|
||||
|
||||
#.
|
||||
|
@ -45,8 +45,8 @@ This tutorial code's is shown lines below.
|
||||
if( argc != 3 )
|
||||
{ return -1; }
|
||||
|
||||
Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_1 = imread( argv[1], IMREAD_GRAYSCALE );
|
||||
Mat img_2 = imread( argv[2], IMREAD_GRAYSCALE );
|
||||
|
||||
if( !img_1.data || !img_2.data )
|
||||
{ return -1; }
|
||||
|
@ -44,8 +44,8 @@ This tutorial code's is shown lines below.
|
||||
if( argc != 3 )
|
||||
{ readme(); return -1; }
|
||||
|
||||
Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_1 = imread( argv[1], IMREAD_GRAYSCALE );
|
||||
Mat img_2 = imread( argv[2], IMREAD_GRAYSCALE );
|
||||
|
||||
if( !img_1.data || !img_2.data )
|
||||
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
|
||||
|
@ -43,8 +43,8 @@ This tutorial code's is shown lines below.
|
||||
if( argc != 3 )
|
||||
{ readme(); return -1; }
|
||||
|
||||
Mat img_object = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
|
||||
Mat img_object = imread( argv[1], IMREAD_GRAYSCALE );
|
||||
Mat img_scene = imread( argv[2], IMREAD_GRAYSCALE );
|
||||
|
||||
if( !img_object.data || !img_scene.data )
|
||||
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
|
||||
@ -108,7 +108,7 @@ This tutorial code's is shown lines below.
|
||||
scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
|
||||
}
|
||||
|
||||
Mat H = findHomography( obj, scene, CV_RANSAC );
|
||||
Mat H = findHomography( obj, scene, RANSAC );
|
||||
|
||||
//-- Get the corners from the image_1 ( the object to be "detected" )
|
||||
std::vector<Point2f> obj_corners(4);
|
||||
|
@ -49,10 +49,10 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
{
|
||||
/// Load source image and convert it to gray
|
||||
src = imread( argv[1], 1 );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
/// Create Window
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create Trackbar to set the number of corners
|
||||
createTrackbar( "Max corners:", source_window, &maxCorners, maxTrackbar, goodFeaturesToTrack_Demo);
|
||||
@ -105,13 +105,13 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
rng.uniform(0,255)), -1, 8, 0 ); }
|
||||
|
||||
/// Show what you got
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, copy );
|
||||
|
||||
/// Set the neeed parameters to find the refined corners
|
||||
Size winSize = Size( 5, 5 );
|
||||
Size zeroZone = Size( -1, -1 );
|
||||
TermCriteria criteria = TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 40, 0.001 );
|
||||
TermCriteria criteria = TermCriteria( TermCriteria::EPS + TermCriteria::MAX_ITER, 40, 0.001 );
|
||||
|
||||
/// Calculate the refined corner locations
|
||||
cornerSubPix( src_gray, corners, winSize, zeroZone, criteria );
|
||||
|
@ -50,10 +50,10 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
{
|
||||
/// Load source image and convert it to gray
|
||||
src = imread( argv[1], 1 );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
/// Create Window
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create Trackbar to set the number of corners
|
||||
createTrackbar( "Max corners:", source_window, &maxCorners, maxTrackbar, goodFeaturesToTrack_Demo );
|
||||
@ -106,7 +106,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
rng.uniform(0,255)), -1, 8, 0 ); }
|
||||
|
||||
/// Show what you got
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, copy );
|
||||
}
|
||||
|
||||
|
@ -180,10 +180,10 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
{
|
||||
/// Load source image and convert it to gray
|
||||
src = imread( argv[1], 1 );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
/// Create a window and a trackbar
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
createTrackbar( "Threshold: ", source_window, &thresh, max_thresh, cornerHarris_demo );
|
||||
imshow( source_window, src );
|
||||
|
||||
@ -223,7 +223,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
}
|
||||
/// Showing the result
|
||||
namedWindow( corners_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( corners_window, WINDOW_AUTOSIZE );
|
||||
imshow( corners_window, dst_norm_scaled );
|
||||
}
|
||||
|
||||
|
@ -79,18 +79,18 @@ Videos have many-many information attached to them besides the content of the fr
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Size refS = Size((int) captRefrnc.get(CV_CAP_PROP_FRAME_WIDTH),
|
||||
(int) captRefrnc.get(CV_CAP_PROP_FRAME_HEIGHT)),
|
||||
Size refS = Size((int) captRefrnc.get(CAP_PROP_FRAME_WIDTH),
|
||||
(int) captRefrnc.get(CAP_PROP_FRAME_HEIGHT)),
|
||||
|
||||
cout << "Reference frame resolution: Width=" << refS.width << " Height=" << refS.height
|
||||
<< " of nr#: " << captRefrnc.get(CV_CAP_PROP_FRAME_COUNT) << endl;
|
||||
<< " of nr#: " << captRefrnc.get(CAP_PROP_FRAME_COUNT) << endl;
|
||||
|
||||
When you are working with videos you may often want to control these values yourself. To do this there is a :hgvideo:`set <videocapture-set>` function. Its first argument remains the name of the property you want to change and there is a second of double type containing the value to be set. It will return true if it succeeds and false otherwise. Good examples for this is seeking in a video file to a given time or frame:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
captRefrnc.set(CV_CAP_PROP_POS_MSEC, 1.2); // go to the 1.2 second in the video
|
||||
captRefrnc.set(CV_CAP_PROP_POS_FRAMES, 10); // go to the 10th frame of the video
|
||||
captRefrnc.set(CAP_PROP_POS_MSEC, 1.2); // go to the 1.2 second in the video
|
||||
captRefrnc.set(CAP_PROP_POS_FRAMES, 10); // go to the 10th frame of the video
|
||||
// now a read operation would read the frame at the set position
|
||||
|
||||
For properties you can read and change look into the documentation of the :hgvideo:`get <videocapture-get>` and :hgvideo:`set <videocapture-set>` functions.
|
||||
@ -122,7 +122,7 @@ Here the :math:`MAX_I^2` is the maximum valid value for a pixel. In case of the
|
||||
s1.convertTo(s1, CV_32F); // cannot make a square on 8 bits
|
||||
s1 = s1.mul(s1); // |I1 - I2|^2
|
||||
|
||||
Scalar s = sum(s1); // sum elements per channel
|
||||
Scalar s = sum(s1); // sum elements per channel
|
||||
|
||||
double sse = s.val[0] + s.val[1] + s.val[2]; // sum channels
|
||||
|
||||
|
@ -62,8 +62,8 @@ To create a video file you just need to create an instance of the :hgvideo:`Vide
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
VideoCapture inputVideo(source); // Open input
|
||||
int ex = static_cast<int>(inputVideo.get(CV_CAP_PROP_FOURCC)); // Get Codec Type- Int form
|
||||
VideoCapture inputVideo(source); // Open input
|
||||
int ex = static_cast<int>(inputVideo.get(CAP_PROP_FOURCC)); // Get Codec Type- Int form
|
||||
|
||||
OpenCV internally works with this integer type and expect this as its second parameter. Now to convert from the integer form to string we may use two methods: a bitwise operator and a union method. The first one extracting from an int the characters looks like (an "and" operation, some shifting and adding a 0 at the end to close the string):
|
||||
|
||||
@ -100,9 +100,9 @@ Here it is, how I use it in the sample:
|
||||
.. code-block:: cpp
|
||||
|
||||
VideoWriter outputVideo;
|
||||
Size S = Size((int) inputVideo.get(CV_CAP_PROP_FRAME_WIDTH), //Acquire input size
|
||||
(int) inputVideo.get(CV_CAP_PROP_FRAME_HEIGHT));
|
||||
outputVideo.open(NAME , ex, inputVideo.get(CV_CAP_PROP_FPS),S, true);
|
||||
Size S = Size((int) inputVideo.get(CAP_PROP_FRAME_WIDTH), //Acquire input size
|
||||
(int) inputVideo.get(CAP_PROP_FRAME_HEIGHT));
|
||||
outputVideo.open(NAME , ex, inputVideo.get(CAP_PROP_FPS),S, true);
|
||||
|
||||
Afterwards, you use the :hgvideo:`isOpened() <videowriter-isopened>` function to find out if the open operation succeeded or not. The video file automatically closes when the *VideoWriter* object is destroyed. After you open the object with success you can send the frames of the video in a sequential order by using the :hgvideo:`write<videowriter-write>` function of the class. Alternatively, you can use its overloaded operator << :
|
||||
|
||||
|
@ -106,8 +106,8 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
{ return -1; }
|
||||
|
||||
/// Create windows
|
||||
namedWindow( "Erosion Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Erosion Demo", WINDOW_AUTOSIZE );
|
||||
namedWindow( "Dilation Demo", WINDOW_AUTOSIZE );
|
||||
cvMoveWindow( "Dilation Demo", src.cols, 0 );
|
||||
|
||||
/// Create Erosion Trackbar
|
||||
|
@ -145,7 +145,7 @@ Code
|
||||
*/
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Load the source image
|
||||
src = imread( "../images/lena.jpg", 1 );
|
||||
@ -195,7 +195,7 @@ Code
|
||||
dst = Mat::zeros( src.size(), src.type() );
|
||||
putText( dst, caption,
|
||||
Point( src.cols/4, src.rows/2),
|
||||
CV_FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255) );
|
||||
FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255) );
|
||||
|
||||
imshow( window_name, dst );
|
||||
int c = waitKey( DELAY_CAPTION );
|
||||
|
@ -128,7 +128,7 @@ Code
|
||||
/// Read the image
|
||||
src = imread( argv[1], 1 );
|
||||
/// Transform it to HSV
|
||||
cvtColor( src, hsv, CV_BGR2HSV );
|
||||
cvtColor( src, hsv, COLOR_BGR2HSV );
|
||||
|
||||
/// Use only the Hue value
|
||||
hue.create( hsv.size(), hsv.depth() );
|
||||
@ -137,7 +137,7 @@ Code
|
||||
|
||||
/// Create Trackbar to enter the number of bins
|
||||
char* window_image = "Source image";
|
||||
namedWindow( window_image, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_image, WINDOW_AUTOSIZE );
|
||||
createTrackbar("* Hue bins: ", window_image, &bins, 180, Hist_and_Backproj );
|
||||
Hist_and_Backproj(0, 0);
|
||||
|
||||
@ -198,7 +198,7 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
src = imread( argv[1], 1 );
|
||||
cvtColor( src, hsv, CV_BGR2HSV );
|
||||
cvtColor( src, hsv, COLOR_BGR2HSV );
|
||||
|
||||
#. For this tutorial, we will use only the Hue value for our 1-D histogram (check out the fancier code in the links above if you want to use the more standard H-S histogram, which yields better results):
|
||||
|
||||
@ -224,7 +224,7 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
char* window_image = "Source image";
|
||||
namedWindow( window_image, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_image, WINDOW_AUTOSIZE );
|
||||
createTrackbar("* Hue bins: ", window_image, &bins, 180, Hist_and_Backproj );
|
||||
Hist_and_Backproj(0, 0);
|
||||
|
||||
|
@ -155,7 +155,7 @@ Code
|
||||
}
|
||||
|
||||
/// Display
|
||||
namedWindow("calcHist Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow("calcHist Demo", WINDOW_AUTOSIZE );
|
||||
imshow("calcHist Demo", histImage );
|
||||
|
||||
waitKey(0);
|
||||
@ -309,7 +309,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow("calcHist Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow("calcHist Demo", WINDOW_AUTOSIZE );
|
||||
imshow("calcHist Demo", histImage );
|
||||
|
||||
waitKey(0);
|
||||
|
@ -119,9 +119,9 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src_base, hsv_base, CV_BGR2HSV );
|
||||
cvtColor( src_test1, hsv_test1, CV_BGR2HSV );
|
||||
cvtColor( src_test2, hsv_test2, CV_BGR2HSV );
|
||||
cvtColor( src_base, hsv_base, COLOR_BGR2HSV );
|
||||
cvtColor( src_test1, hsv_test1, COLOR_BGR2HSV );
|
||||
cvtColor( src_test2, hsv_test2, COLOR_BGR2HSV );
|
||||
|
||||
#. Also, create an image of half the base image (in HSV format):
|
||||
|
||||
|
@ -113,14 +113,14 @@ Code
|
||||
return -1;}
|
||||
|
||||
/// Convert to grayscale
|
||||
cvtColor( src, src, CV_BGR2GRAY );
|
||||
cvtColor( src, src, COLOR_BGR2GRAY );
|
||||
|
||||
/// Apply Histogram Equalization
|
||||
equalizeHist( src, dst );
|
||||
|
||||
/// Display results
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( equalized_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
namedWindow( equalized_window, WINDOW_AUTOSIZE );
|
||||
|
||||
imshow( source_window, src );
|
||||
imshow( equalized_window, dst );
|
||||
@ -157,7 +157,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src, CV_BGR2GRAY );
|
||||
cvtColor( src, src, COLOR_BGR2GRAY );
|
||||
|
||||
#. Apply histogram equalization with the function :equalize_hist:`equalizeHist <>` :
|
||||
|
||||
@ -171,8 +171,8 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( equalized_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
namedWindow( equalized_window, WINDOW_AUTOSIZE );
|
||||
|
||||
imshow( source_window, src );
|
||||
imshow( equalized_window, dst );
|
||||
|
@ -158,8 +158,8 @@ Code
|
||||
templ = imread( argv[2], 1 );
|
||||
|
||||
/// Create windows
|
||||
namedWindow( image_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( result_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( image_window, WINDOW_AUTOSIZE );
|
||||
namedWindow( result_window, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create Trackbar
|
||||
char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
|
||||
@ -239,8 +239,8 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( image_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( result_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( image_window, WINDOW_AUTOSIZE );
|
||||
namedWindow( result_window, WINDOW_AUTOSIZE );
|
||||
|
||||
#. Create the Trackbar to enter the kind of matching method to be used. When a change is detected the callback function **MatchingMethod** is called.
|
||||
|
||||
@ -306,11 +306,11 @@ Explanation
|
||||
+ **Mat():** Optional mask
|
||||
|
||||
|
||||
#. For the first two methods ( CV\_SQDIFF and CV\_SQDIFF\_NORMED ) the best match are the lowest values. For all the others, higher values represent better matches. So, we save the corresponding value in the **matchLoc** variable:
|
||||
#. For the first two methods ( TM\_SQDIFF and MT\_SQDIFF\_NORMED ) the best match are the lowest values. For all the others, higher values represent better matches. So, we save the corresponding value in the **matchLoc** variable:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
if( match_method == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED )
|
||||
if( match_method == TM_SQDIFF || match_method == TM_SQDIFF_NORMED )
|
||||
{ matchLoc = minLoc; }
|
||||
else
|
||||
{ matchLoc = maxLoc; }
|
||||
|
@ -142,10 +142,10 @@ Code
|
||||
dst.create( src.size(), src.type() );
|
||||
|
||||
/// Convert the image to grayscale
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
/// Create a window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create a Trackbar for user to enter threshold
|
||||
createTrackbar( "Min Threshold:", window_name, &lowThreshold, max_lowThreshold, CannyThreshold );
|
||||
@ -203,13 +203,13 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
#. Create a window to display the results
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
#. Create a Trackbar for the user to enter the lower threshold for our Canny detector:
|
||||
|
||||
|
@ -89,7 +89,7 @@ Code
|
||||
printf( " ** Press 'ESC' to exit the program \n");
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Initialize arguments for the filter
|
||||
top = (int) (0.05*src.rows); bottom = (int) (0.05*src.rows);
|
||||
@ -150,7 +150,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
#. Now we initialize the argument that defines the size of the borders (*top*, *bottom*, *left* and *right*). We give them a value of 5% the size of *src*.
|
||||
|
||||
|
@ -106,7 +106,7 @@ Code
|
||||
{ return -1; }
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Initialize arguments for the filter
|
||||
anchor = Point( -1, -1 );
|
||||
@ -151,7 +151,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
#. Initialize the arguments for the linear filter
|
||||
|
||||
|
@ -67,7 +67,7 @@ Code
|
||||
{ return -1; }
|
||||
|
||||
/// Convert it to gray
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
/// Reduce the noise so we avoid false circle detection
|
||||
GaussianBlur( src_gray, src_gray, Size(9, 9), 2, 2 );
|
||||
@ -75,7 +75,7 @@ Code
|
||||
vector<Vec3f> circles;
|
||||
|
||||
/// Apply the Hough Transform to find the circles
|
||||
HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );
|
||||
HoughCircles( src_gray, circles, HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );
|
||||
|
||||
/// Draw the circles detected
|
||||
for( size_t i = 0; i < circles.size(); i++ )
|
||||
@ -89,7 +89,7 @@ Code
|
||||
}
|
||||
|
||||
/// Show your results
|
||||
namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Hough Circle Transform Demo", WINDOW_AUTOSIZE );
|
||||
imshow( "Hough Circle Transform Demo", src );
|
||||
|
||||
waitKey(0);
|
||||
@ -114,7 +114,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
|
||||
#. Apply a Gaussian blur to reduce noise and avoid false circle detection:
|
||||
|
||||
@ -128,13 +128,13 @@ Explanation
|
||||
|
||||
vector<Vec3f> circles;
|
||||
|
||||
HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );
|
||||
HoughCircles( src_gray, circles, HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );
|
||||
|
||||
with the arguments:
|
||||
|
||||
* *src_gray*: Input image (grayscale).
|
||||
* *circles*: A vector that stores sets of 3 values: :math:`x_{c}, y_{c}, r` for each detected circle.
|
||||
* *CV_HOUGH_GRADIENT*: Define the detection method. Currently this is the only one available in OpenCV.
|
||||
* *HOUGH_GRADIENT*: Define the detection method. Currently this is the only one available in OpenCV.
|
||||
* *dp = 1*: The inverse ratio of resolution.
|
||||
* *min_dist = src_gray.rows/8*: Minimum distance between detected centers.
|
||||
* *param_1 = 200*: Upper threshold for the internal Canny edge detector.
|
||||
@ -162,7 +162,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Hough Circle Transform Demo", WINDOW_AUTOSIZE );
|
||||
imshow( "Hough Circle Transform Demo", src );
|
||||
|
||||
#. Wait for the user to exit the program
|
||||
|
@ -133,7 +133,7 @@ Code
|
||||
|
||||
Mat dst, cdst;
|
||||
Canny(src, dst, 50, 200, 3);
|
||||
cvtColor(dst, cdst, CV_GRAY2BGR);
|
||||
cvtColor(dst, cdst, COLOR_GRAY2BGR);
|
||||
|
||||
#if 0
|
||||
vector<Vec2f> lines;
|
||||
@ -149,7 +149,7 @@ Code
|
||||
pt1.y = cvRound(y0 + 1000*(a));
|
||||
pt2.x = cvRound(x0 - 1000*(-b));
|
||||
pt2.y = cvRound(y0 - 1000*(a));
|
||||
line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
|
||||
line( cdst, pt1, pt2, Scalar(0,0,255), 3, LINE_AA);
|
||||
}
|
||||
#else
|
||||
vector<Vec4i> lines;
|
||||
@ -223,7 +223,7 @@ Explanation
|
||||
pt1.y = cvRound(y0 + 1000*(a));
|
||||
pt2.x = cvRound(x0 - 1000*(-b));
|
||||
pt2.y = cvRound(y0 - 1000*(a));
|
||||
line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
|
||||
line( cdst, pt1, pt2, Scalar(0,0,255), 3, LINE_AA);
|
||||
}
|
||||
|
||||
#. **Probabilistic Hough Line Transform**
|
||||
@ -252,7 +252,7 @@ Explanation
|
||||
for( size_t i = 0; i < lines.size(); i++ )
|
||||
{
|
||||
Vec4i l = lines[i];
|
||||
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
|
||||
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, LINE_AA);
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,10 +88,10 @@ Code
|
||||
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
|
||||
|
||||
/// Convert the image to grayscale
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Apply Laplace function
|
||||
Mat abs_dst;
|
||||
@ -141,7 +141,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
#. Apply the Laplacian operator to the grayscale image:
|
||||
|
||||
|
@ -93,7 +93,7 @@ Code
|
||||
map_y.create( src.size(), CV_32FC1 );
|
||||
|
||||
/// Create window
|
||||
namedWindow( remap_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( remap_window, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Loop
|
||||
while( true )
|
||||
@ -106,7 +106,7 @@ Code
|
||||
|
||||
/// Update map_x & map_y. Then apply remap
|
||||
update_map();
|
||||
remap( src, dst, map_x, map_y, CV_INTER_LINEAR, BORDER_CONSTANT, Scalar(0,0, 0) );
|
||||
remap( src, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0,0, 0) );
|
||||
|
||||
/// Display results
|
||||
imshow( remap_window, dst );
|
||||
@ -186,7 +186,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( remap_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( remap_window, WINDOW_AUTOSIZE );
|
||||
|
||||
#. Establish a loop. Each 1000 ms we update our mapping matrices (*mat_x* and *mat_y*) and apply them to our source image:
|
||||
|
||||
@ -202,7 +202,7 @@ Explanation
|
||||
|
||||
/// Update map_x & map_y. Then apply remap
|
||||
update_map();
|
||||
remap( src, dst, map_x, map_y, CV_INTER_LINEAR, BORDER_CONSTANT, Scalar(0,0, 0) );
|
||||
remap( src, dst, map_x, map_y, INTER_LINEAR, BORDER_CONSTANT, Scalar(0,0, 0) );
|
||||
|
||||
/// Display results
|
||||
imshow( remap_window, dst );
|
||||
@ -214,7 +214,7 @@ Explanation
|
||||
* **dst**: Destination image of same size as *src*
|
||||
* **map_x**: The mapping function in the x direction. It is equivalent to the first component of :math:`h(i,j)`
|
||||
* **map_y**: Same as above, but in y direction. Note that *map_y* and *map_x* are both of the same size as *src*
|
||||
* **CV_INTER_LINEAR**: The type of interpolation to use for non-integer pixels. This is by default.
|
||||
* **INTER_LINEAR**: The type of interpolation to use for non-integer pixels. This is by default.
|
||||
* **BORDER_CONSTANT**: Default
|
||||
|
||||
How do we update our mapping matrices *mat_x* and *mat_y*? Go on reading:
|
||||
|
@ -154,10 +154,10 @@ Code
|
||||
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
|
||||
|
||||
/// Convert it to gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Generate grad_x and grad_y
|
||||
Mat grad_x, grad_y;
|
||||
@ -217,7 +217,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
#. Second, we calculate the "*derivatives*" in *x* and *y* directions. For this, we use the function :sobel:`Sobel <>` as shown below:
|
||||
|
||||
|
@ -155,13 +155,13 @@ Code
|
||||
warpAffine( warp_dst, warp_rotate_dst, rot_mat, warp_dst.size() );
|
||||
|
||||
/// Show what you got
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
namedWindow( warp_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( warp_window, WINDOW_AUTOSIZE );
|
||||
imshow( warp_window, warp_dst );
|
||||
|
||||
namedWindow( warp_rotate_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( warp_rotate_window, WINDOW_AUTOSIZE );
|
||||
imshow( warp_rotate_window, warp_rotate_dst );
|
||||
|
||||
/// Wait until user exits the program
|
||||
@ -265,13 +265,13 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
namedWindow( warp_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( warp_window, WINDOW_AUTOSIZE );
|
||||
imshow( warp_window, warp_dst );
|
||||
|
||||
namedWindow( warp_rotate_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( warp_rotate_window, WINDOW_AUTOSIZE );
|
||||
imshow( warp_rotate_window, warp_rotate_dst );
|
||||
|
||||
|
||||
|
@ -147,7 +147,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
{ return -1; }
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create Trackbar to select Morphology operation
|
||||
createTrackbar("Operator:\n 0: Opening - 1: Closing \n 2: Gradient - 3: Top Hat \n 4: Black Hat", window_name, &morph_operator, max_operator, Morphology_Operations );
|
||||
|
@ -119,7 +119,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
dst = tmp;
|
||||
|
||||
/// Create window
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
imshow( window_name, dst );
|
||||
|
||||
/// Loop
|
||||
@ -175,7 +175,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
imshow( window_name, dst );
|
||||
|
||||
* Perform an infinite loop waiting for user input.
|
||||
|
@ -49,12 +49,12 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert image to gray and blur it
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
blur( src_gray, src_gray, Size(3,3) );
|
||||
|
||||
/// Create Window
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
createTrackbar( " Threshold:", "Source", &thresh, max_thresh, thresh_callback );
|
||||
@ -74,7 +74,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
/// Detect edges using Threshold
|
||||
threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );
|
||||
/// Find contours
|
||||
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
findContours( threshold_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
|
||||
/// Approximate contours to polygons + get bounding rects and circles
|
||||
vector<vector<Point> > contours_poly( contours.size() );
|
||||
@ -100,7 +100,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
|
||||
/// Show in a window
|
||||
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Contours", WINDOW_AUTOSIZE );
|
||||
imshow( "Contours", drawing );
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,12 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert image to gray and blur it
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
blur( src_gray, src_gray, Size(3,3) );
|
||||
|
||||
/// Create Window
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
createTrackbar( " Threshold:", "Source", &thresh, max_thresh, thresh_callback );
|
||||
@ -74,7 +74,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
/// Detect edges using Threshold
|
||||
threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );
|
||||
/// Find contours
|
||||
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
findContours( threshold_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
|
||||
/// Find the rotated rectangles and ellipses for each contour
|
||||
vector<RotatedRect> minRect( contours.size() );
|
||||
@ -102,7 +102,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
|
||||
/// Show in a window
|
||||
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Contours", WINDOW_AUTOSIZE );
|
||||
imshow( "Contours", drawing );
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,12 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert image to gray and blur it
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
blur( src_gray, src_gray, Size(3,3) );
|
||||
|
||||
/// Create Window
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
createTrackbar( " Canny thresh:", "Source", &thresh, max_thresh, thresh_callback );
|
||||
@ -72,7 +72,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
/// Detect edges using canny
|
||||
Canny( src_gray, canny_output, thresh, thresh*2, 3 );
|
||||
/// Find contours
|
||||
findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
|
||||
/// Draw contours
|
||||
Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );
|
||||
@ -83,7 +83,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
|
||||
/// Show in a window
|
||||
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Contours", WINDOW_AUTOSIZE );
|
||||
imshow( "Contours", drawing );
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,12 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert image to gray and blur it
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
blur( src_gray, src_gray, Size(3,3) );
|
||||
|
||||
/// Create Window
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
createTrackbar( " Threshold:", "Source", &thresh, max_thresh, thresh_callback );
|
||||
@ -74,7 +74,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );
|
||||
|
||||
/// Find contours
|
||||
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
findContours( threshold_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
|
||||
/// Find the convex hull object for each contour
|
||||
vector<vector<Point> >hull( contours.size() );
|
||||
@ -91,7 +91,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
|
||||
/// Show in a window
|
||||
namedWindow( "Hull demo", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Hull demo", WINDOW_AUTOSIZE );
|
||||
imshow( "Hull demo", drawing );
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,12 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert image to gray and blur it
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
||||
blur( src_gray, src_gray, Size(3,3) );
|
||||
|
||||
/// Create Window
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
|
||||
createTrackbar( " Canny thresh:", "Source", &thresh, max_thresh, thresh_callback );
|
||||
@ -74,7 +74,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
/// Detect edges using canny
|
||||
Canny( src_gray, canny_output, thresh, thresh*2, 3 );
|
||||
/// Find contours
|
||||
findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
|
||||
|
||||
/// Get the moments
|
||||
vector<Moments> mu(contours.size() );
|
||||
@ -96,7 +96,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
}
|
||||
|
||||
/// Show in a window
|
||||
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Contours", WINDOW_AUTOSIZE );
|
||||
imshow( "Contours", drawing );
|
||||
|
||||
/// Calculate the area with the moments 00 and compare with the result of the OpenCV function
|
||||
|
@ -88,9 +88,9 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
|
||||
/// Create Window and show your results
|
||||
char* source_window = "Source";
|
||||
namedWindow( source_window, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, src );
|
||||
namedWindow( "Distance", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Distance", WINDOW_AUTOSIZE );
|
||||
imshow( "Distance", drawing );
|
||||
|
||||
waitKey(0);
|
||||
|
@ -167,10 +167,10 @@ The tutorial code's is shown lines below. You can also download it from `here <h
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert the image to Gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
/// Create a window to display results
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
/// Create Trackbar to choose type of Threshold
|
||||
createTrackbar( trackbar_type,
|
||||
@ -228,14 +228,14 @@ Explanation
|
||||
src = imread( argv[1], 1 );
|
||||
|
||||
/// Convert the image to Gray
|
||||
cvtColor( src, src_gray, CV_RGB2GRAY );
|
||||
cvtColor( src, src_gray, COLOR_RGB2GRAY );
|
||||
|
||||
|
||||
* Create a window to display the result
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( window_name, WINDOW_AUTOSIZE );
|
||||
|
||||
* Create :math:`2` trackbars for the user to enter user input:
|
||||
|
||||
|
@ -66,9 +66,9 @@ Now we call the :imread:`imread <>` function which loads the image name specifie
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
|
||||
+ CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one
|
||||
+ CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format
|
||||
+ IMREAD_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
|
||||
+ IMREAD_GRAYSCALE ( 0) loads the image as an intensity one
|
||||
+ IMREAD_COLOR (>0) loads the image in the RGB format
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
@ -83,8 +83,8 @@ After checking that the image data was loaded correctly, we want to display our
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ *CV_WINDOW_AUTOSIZE* is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!
|
||||
+ *CV_WINDOW_NORMAL* on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if you would like the image to keep its aspect ratio (*CV_WINDOW_KEEPRATIO*) or not (*CV_WINDOW_FREERATIO*).
|
||||
+ *WINDOW_AUTOSIZE* is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!
|
||||
+ *WINDOW_NORMAL* on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if you would like the image to keep its aspect ratio (*WINDOW_KEEPRATIO*) or not (*WINDOW_FREERATIO*).
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
|
@ -68,7 +68,7 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( image, gray_image, CV_BGR2GRAY );
|
||||
cvtColor( image, gray_image, COLOR_BGR2GRAY );
|
||||
|
||||
As you can see, :miscellaneous_transformations:`cvtColor <cvtcolor>` takes as arguments:
|
||||
|
||||
@ -76,7 +76,7 @@ Explanation
|
||||
|
||||
* a source image (*image*)
|
||||
* a destination image (*gray_image*), in which we will save the converted image.
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **CV_BGR2GRAY** (because of :readwriteimage:`imread <imread>` has BGR default channel order in case of color images).
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **COLOR_BGR2GRAY** (because of :readwriteimage:`imread <imread>` has BGR default channel order in case of color images).
|
||||
|
||||
#. So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost after the program ends). To save it, we will use a function analagous to :readwriteimage:`imread <imread>`: :readwriteimage:`imwrite <imwrite>`
|
||||
|
||||
@ -90,8 +90,8 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
namedWindow( imageName, CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow( imageName, WINDOW_AUTOSIZE );
|
||||
namedWindow( "Gray image", WINDOW_AUTOSIZE );
|
||||
|
||||
imshow( imageName, image );
|
||||
imshow( "Gray image", gray_image );
|
||||
|
@ -65,7 +65,7 @@ Image Watch works with any existing project that uses OpenCV image objects (for
|
||||
|
||||
cout << "Loading input image: " << argv[1] << endl;
|
||||
Mat input;
|
||||
input = imread(argv[1], CV_LOAD_IMAGE_COLOR);
|
||||
input = imread(argv[1], IMREAD_COLOR);
|
||||
|
||||
cout << "Detecting edges in input image" << endl;
|
||||
Mat edges;
|
||||
|
@ -70,7 +70,7 @@ After the processing we need to convert it back to UIImage. The code below can h
|
||||
.. code-block:: cpp
|
||||
|
||||
cv::Mat greyMat;
|
||||
cv::cvtColor(inputMat, greyMat, CV_BGR2GRAY);
|
||||
cv::cvtColor(inputMat, greyMat, COLOR_BGR2GRAY);
|
||||
|
||||
After the processing we need to convert it back to UIImage.
|
||||
|
||||
|
@ -114,16 +114,16 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
CvSVMParams params;
|
||||
params.svm_type = CvSVM::C_SVC;
|
||||
params.kernel_type = CvSVM::LINEAR;
|
||||
params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);
|
||||
ml::SVM::Params params;
|
||||
params.svmType = ml::SVM::C_SVC;
|
||||
params.kernelType = ml::SVM::LINEAR;
|
||||
params.termCrit = TermCriteria(TermCriteria::MAX_ITER, 100, 1e-6);
|
||||
|
||||
* *Type of SVM*. We choose here the type **CvSVM::C_SVC** that can be used for n-class classification (n :math:`\geq` 2). This parameter is defined in the attribute *CvSVMParams.svm_type*.
|
||||
* *Type of SVM*. We choose here the type **ml::SVM::C_SVC** that can be used for n-class classification (n :math:`\geq` 2). This parameter is defined in the attribute *ml::SVM::Params.svmType*.
|
||||
|
||||
.. note:: The important feature of the type of SVM **CvSVM::C_SVC** deals with imperfect separation of classes (i.e. when the training data is non-linearly separable). This feature is not important here since the data is linearly separable and we chose this SVM type only for being the most commonly used.
|
||||
|
||||
* *Type of SVM kernel*. We have not talked about kernel functions since they are not interesting for the training data we are dealing with. Nevertheless, let's explain briefly now the main idea behind a kernel function. It is a mapping done to the training data to improve its resemblance to a linearly separable set of data. This mapping consists of increasing the dimensionality of the data and is done efficiently using a kernel function. We choose here the type **CvSVM::LINEAR** which means that no mapping is done. This parameter is defined in the attribute *CvSVMParams.kernel_type*.
|
||||
* *Type of SVM kernel*. We have not talked about kernel functions since they are not interesting for the training data we are dealing with. Nevertheless, let's explain briefly now the main idea behind a kernel function. It is a mapping done to the training data to improve its resemblance to a linearly separable set of data. This mapping consists of increasing the dimensionality of the data and is done efficiently using a kernel function. We choose here the type **ml::SVM::LINEAR** which means that no mapping is done. This parameter is defined in the attribute *ml::SVMParams.kernel_type*.
|
||||
|
||||
* *Termination criteria of the algorithm*. The SVM training procedure is implemented solving a constrained quadratic optimization problem in an **iterative** fashion. Here we specify a maximum number of iterations and a tolerance error so we allow the algorithm to finish in less number of steps even if the optimal hyperplane has not been computed yet. This parameter is defined in a structure :oldbasicstructures:`cvTermCriteria <cvtermcriteria>`.
|
||||
|
||||
|
@ -131,7 +131,7 @@ Explanation
|
||||
params.svm_type = SVM::C_SVC;
|
||||
params.C = 0.1;
|
||||
params.kernel_type = SVM::LINEAR;
|
||||
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);
|
||||
params.term_crit = TermCriteria(TermCriteria::ITER, (int)1e7, 1e-6);
|
||||
|
||||
There are just two differences between the configuration we do here and the one that was done in the :ref:`previous tutorial <introductiontosvms>` that we use as reference.
|
||||
|
||||
|
@ -17,8 +17,8 @@ The code
|
||||
--------
|
||||
We will start with a short sample ``opencv/samples/cpp/matcher_simple.cpp``: ::
|
||||
|
||||
Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img1 = imread(argv[1], IMREAD_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], IMREAD_GRAYSCALE);
|
||||
if(img1.empty() || img2.empty())
|
||||
{
|
||||
printf("Can't read one of the images\n");
|
||||
@ -54,8 +54,8 @@ The code explained
|
||||
|
||||
Let us break the code down. ::
|
||||
|
||||
Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img1 = imread(argv[1], IMREAD_GRAYSCALE);
|
||||
Mat img2 = imread(argv[2], IMREAD_GRAYSCALE);
|
||||
if(img1.empty() || img2.empty())
|
||||
{
|
||||
printf("Can't read one of the images\n");
|
||||
|
@ -41,19 +41,19 @@ VideoCapture can retrieve the following data:
|
||||
|
||||
#.
|
||||
data given from depth generator:
|
||||
* ``CV_CAP_OPENNI_DEPTH_MAP`` - depth values in mm (CV_16UC1)
|
||||
* ``CV_CAP_OPENNI_POINT_CLOUD_MAP`` - XYZ in meters (CV_32FC3)
|
||||
* ``CV_CAP_OPENNI_DISPARITY_MAP`` - disparity in pixels (CV_8UC1)
|
||||
* ``CV_CAP_OPENNI_DISPARITY_MAP_32F`` - disparity in pixels (CV_32FC1)
|
||||
* ``CV_CAP_OPENNI_VALID_DEPTH_MASK`` - mask of valid pixels (not ocluded, not shaded etc.) (CV_8UC1)
|
||||
* ``CAP_OPENNI_DEPTH_MAP`` - depth values in mm (CV_16UC1)
|
||||
* ``CAP_OPENNI_POINT_CLOUD_MAP`` - XYZ in meters (CV_32FC3)
|
||||
* ``CAP_OPENNI_DISPARITY_MAP`` - disparity in pixels (CV_8UC1)
|
||||
* ``CAP_OPENNI_DISPARITY_MAP_32F`` - disparity in pixels (CV_32FC1)
|
||||
* ``CAP_OPENNI_VALID_DEPTH_MASK`` - mask of valid pixels (not ocluded, not shaded etc.) (CV_8UC1)
|
||||
#.
|
||||
data given from RGB image generator:
|
||||
* ``CV_CAP_OPENNI_BGR_IMAGE`` - color image (CV_8UC3)
|
||||
* ``CV_CAP_OPENNI_GRAY_IMAGE`` - gray image (CV_8UC1)
|
||||
* ``CAP_OPENNI_BGR_IMAGE`` - color image (CV_8UC3)
|
||||
* ``CAP_OPENNI_GRAY_IMAGE`` - gray image (CV_8UC1)
|
||||
|
||||
In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e. g. ::
|
||||
|
||||
VideoCapture capture( CV_CAP_OPENNI );
|
||||
VideoCapture capture( CAP_OPENNI );
|
||||
for(;;)
|
||||
{
|
||||
Mat depthMap;
|
||||
@ -65,7 +65,7 @@ In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e
|
||||
|
||||
For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::retrieve``, e.g. ::
|
||||
|
||||
VideoCapture capture(0); // or CV_CAP_OPENNI
|
||||
VideoCapture capture(0); // or CAP_OPENNI
|
||||
for(;;)
|
||||
{
|
||||
Mat depthMap;
|
||||
@ -73,8 +73,8 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret
|
||||
|
||||
capture.grab();
|
||||
|
||||
capture.retrieve( depthMap, CV_CAP_OPENNI_DEPTH_MAP );
|
||||
capture.retrieve( bgrImage, CV_CAP_OPENNI_BGR_IMAGE );
|
||||
capture.retrieve( depthMap, CAP_OPENNI_DEPTH_MAP );
|
||||
capture.retrieve( bgrImage, CAP_OPENNI_BGR_IMAGE );
|
||||
|
||||
if( waitKey( 30 ) >= 0 )
|
||||
break;
|
||||
@ -82,20 +82,20 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret
|
||||
|
||||
For setting and getting some property of sensor` data generators use ``VideoCapture::set`` and ``VideoCapture::get`` methods respectively, e.g. ::
|
||||
|
||||
VideoCapture capture( CV_CAP_OPENNI );
|
||||
capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ );
|
||||
cout << "FPS " << capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FPS ) << endl;
|
||||
VideoCapture capture( CAP_OPENNI );
|
||||
capture.set( CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CAP_OPENNI_VGA_30HZ );
|
||||
cout << "FPS " << capture.get( CAP_OPENNI_IMAGE_GENERATOR+CAP_PROP_FPS ) << endl;
|
||||
|
||||
Since two types of sensor's data generators are supported (image generator and depth generator), there are two flags that should be used to set/get property of the needed generator:
|
||||
|
||||
* CV_CAP_OPENNI_IMAGE_GENERATOR -- A flag for access to the image generator properties.
|
||||
* CAP_OPENNI_IMAGE_GENERATOR -- A flag for access to the image generator properties.
|
||||
|
||||
* CV_CAP_OPENNI_DEPTH_GENERATOR -- A flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is not set.
|
||||
* CAP_OPENNI_DEPTH_GENERATOR -- A flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is not set.
|
||||
|
||||
Some depth sensors (for example XtionPRO) do not have image generator. In order to check it you can get ``CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT`` property.
|
||||
Some depth sensors (for example XtionPRO) do not have image generator. In order to check it you can get ``CAP_OPENNI_IMAGE_GENERATOR_PRESENT`` property.
|
||||
::
|
||||
|
||||
bool isImageGeneratorPresent = capture.get( CV_CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT ) != 0; // or == 1
|
||||
bool isImageGeneratorPresent = capture.get( CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT ) != 0; // or == 1
|
||||
|
||||
|
||||
Flags specifing the needed generator type must be used in combination with particular generator property. The following properties of cameras available through OpenNI interfaces are supported:
|
||||
@ -103,30 +103,30 @@ Flags specifing the needed generator type must be used in combination with parti
|
||||
*
|
||||
For image generator:
|
||||
|
||||
- ``CV_CAP_PROP_OPENNI_OUTPUT_MODE`` -- Three output modes are supported: ``CV_CAP_OPENNI_VGA_30HZ`` used by default (image generator returns images in VGA resolution with 30 FPS), ``CV_CAP_OPENNI_SXGA_15HZ`` (image generator returns images in SXGA resolution with 15 FPS) and ``CV_CAP_OPENNI_SXGA_30HZ`` (image generator returns images in SXGA resolution with 30 FPS, the mode is supported by XtionPRO Live); depth generator's maps are always in VGA resolution.
|
||||
- ``CAP_PROP_OPENNI_OUTPUT_MODE`` -- Three output modes are supported: ``CAP_OPENNI_VGA_30HZ`` used by default (image generator returns images in VGA resolution with 30 FPS), ``CAP_OPENNI_SXGA_15HZ`` (image generator returns images in SXGA resolution with 15 FPS) and ``CAP_OPENNI_SXGA_30HZ`` (image generator returns images in SXGA resolution with 30 FPS, the mode is supported by XtionPRO Live); depth generator's maps are always in VGA resolution.
|
||||
|
||||
|
||||
*
|
||||
For depth generator:
|
||||
|
||||
- ``CV_CAP_PROP_OPENNI_REGISTRATION`` -- Flag that registers the remapping depth map to image map by changing depth generator's view point (if the flag is ``"on"``) or sets this view point to its normal one (if the flag is ``"off"``). The registration process’s resulting images are pixel-aligned,which means that every pixel in the image is aligned to a pixel in the depth image.
|
||||
- ``CAP_PROP_OPENNI_REGISTRATION`` -- Flag that registers the remapping depth map to image map by changing depth generator's view point (if the flag is ``"on"``) or sets this view point to its normal one (if the flag is ``"off"``). The registration process’s resulting images are pixel-aligned,which means that every pixel in the image is aligned to a pixel in the depth image.
|
||||
|
||||
Next properties are available for getting only:
|
||||
|
||||
- ``CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH`` -- A maximum supported depth of Kinect in mm.
|
||||
- ``CV_CAP_PROP_OPENNI_BASELINE`` -- Baseline value in mm.
|
||||
- ``CV_CAP_PROP_OPENNI_FOCAL_LENGTH`` -- A focal length in pixels.
|
||||
- ``CV_CAP_PROP_FRAME_WIDTH`` -- Frame width in pixels.
|
||||
- ``CV_CAP_PROP_FRAME_HEIGHT`` -- Frame height in pixels.
|
||||
- ``CV_CAP_PROP_FPS`` -- Frame rate in FPS.
|
||||
- ``CAP_PROP_OPENNI_FRAME_MAX_DEPTH`` -- A maximum supported depth of Kinect in mm.
|
||||
- ``CAP_PROP_OPENNI_BASELINE`` -- Baseline value in mm.
|
||||
- ``CAP_PROP_OPENNI_FOCAL_LENGTH`` -- A focal length in pixels.
|
||||
- ``CAP_PROP_FRAME_WIDTH`` -- Frame width in pixels.
|
||||
- ``CAP_PROP_FRAME_HEIGHT`` -- Frame height in pixels.
|
||||
- ``CAP_PROP_FPS`` -- Frame rate in FPS.
|
||||
|
||||
*
|
||||
Some typical flags combinations "generator type + property" are defined as single flags:
|
||||
|
||||
- ``CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE``
|
||||
- ``CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE``
|
||||
- ``CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH``
|
||||
- ``CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION``
|
||||
- ``CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE``
|
||||
- ``CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE``
|
||||
- ``CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH``
|
||||
- ``CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION``
|
||||
|
||||
For more information please refer to the example of usage openni_capture.cpp_ in ``opencv/samples/cpp`` folder.
|
||||
|
||||
|
@ -24,16 +24,16 @@ VideoCapture can retrieve the following data:
|
||||
|
||||
#.
|
||||
data given from depth generator:
|
||||
* ``CV_CAP_INTELPERC_DEPTH_MAP`` - each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. (CV_16UC1)
|
||||
* ``CV_CAP_INTELPERC_UVDEPTH_MAP`` - each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. (CV_32FC2)
|
||||
* ``CV_CAP_INTELPERC_IR_MAP`` - each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. (CV_16UC1)
|
||||
* ``CAP_INTELPERC_DEPTH_MAP`` - each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. (CV_16UC1)
|
||||
* ``CAP_INTELPERC_UVDEPTH_MAP`` - each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. (CV_32FC2)
|
||||
* ``CAP_INTELPERC_IR_MAP`` - each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. (CV_16UC1)
|
||||
#.
|
||||
data given from RGB image generator:
|
||||
* ``CV_CAP_INTELPERC_IMAGE`` - color image. (CV_8UC3)
|
||||
* ``CAP_INTELPERC_IMAGE`` - color image. (CV_8UC3)
|
||||
|
||||
In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e. g. ::
|
||||
|
||||
VideoCapture capture( CV_CAP_INTELPERC );
|
||||
VideoCapture capture( CAP_INTELPERC );
|
||||
for(;;)
|
||||
{
|
||||
Mat depthMap;
|
||||
@ -45,7 +45,7 @@ In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e
|
||||
|
||||
For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::retrieve``, e.g. ::
|
||||
|
||||
VideoCapture capture(CV_CAP_INTELPERC);
|
||||
VideoCapture capture(CAP_INTELPERC);
|
||||
for(;;)
|
||||
{
|
||||
Mat depthMap;
|
||||
@ -54,9 +54,9 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret
|
||||
|
||||
capture.grab();
|
||||
|
||||
capture.retrieve( depthMap, CV_CAP_INTELPERC_DEPTH_MAP );
|
||||
capture.retrieve( image, CV_CAP_INTELPERC_IMAGE );
|
||||
capture.retrieve( irImage, CV_CAP_INTELPERC_IR_MAP);
|
||||
capture.retrieve( depthMap, CAP_INTELPERC_DEPTH_MAP );
|
||||
capture.retrieve( image, CAP_INTELPERC_IMAGE );
|
||||
capture.retrieve( irImage, CAP_INTELPERC_IR_MAP);
|
||||
|
||||
if( waitKey( 30 ) >= 0 )
|
||||
break;
|
||||
@ -64,16 +64,16 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret
|
||||
|
||||
For setting and getting some property of sensor` data generators use ``VideoCapture::set`` and ``VideoCapture::get`` methods respectively, e.g. ::
|
||||
|
||||
VideoCapture capture( CV_CAP_INTELPERC );
|
||||
capture.set( CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0 );
|
||||
cout << "FPS " << capture.get( CV_CAP_INTELPERC_DEPTH_GENERATOR+CV_CAP_PROP_FPS ) << endl;
|
||||
VideoCapture capture( CAP_INTELPERC );
|
||||
capture.set( CAP_INTELPERC_DEPTH_GENERATOR | CAP_PROP_INTELPERC_PROFILE_IDX, 0 );
|
||||
cout << "FPS " << capture.get( CAP_INTELPERC_DEPTH_GENERATOR+CAP_PROP_FPS ) << endl;
|
||||
|
||||
Since two types of sensor's data generators are supported (image generator and depth generator), there are two flags that should be used to set/get property of the needed generator:
|
||||
|
||||
* CV_CAP_INTELPERC_IMAGE_GENERATOR -- a flag for access to the image generator properties.
|
||||
* CAP_INTELPERC_IMAGE_GENERATOR -- a flag for access to the image generator properties.
|
||||
|
||||
* CV_CAP_INTELPERC_DEPTH_GENERATOR -- a flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is set.
|
||||
* CAP_INTELPERC_DEPTH_GENERATOR -- a flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is set.
|
||||
|
||||
For more information please refer to the example of usage intelperc_capture.cpp_ in ``opencv/samples/cpp`` folder.
|
||||
|
||||
.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp
|
||||
.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp
|
||||
|
@ -123,7 +123,7 @@ Conversion from color to grey scale: ::
|
||||
|
||||
Mat img = imread("image.jpg"); // loading a 8UC3 image
|
||||
Mat grey;
|
||||
cvtColor(img, grey, CV_BGR2GRAY);
|
||||
cvtColor(img, grey, COLOR_BGR2GRAY);
|
||||
|
||||
Change image type from 8UC1 to 32FC1: ::
|
||||
|
||||
@ -136,7 +136,7 @@ It is very useful to see intermediate results of your algorithm during developme
|
||||
|
||||
Mat img = imread("image.jpg");
|
||||
|
||||
namedWindow("image", CV_WINDOW_AUTOSIZE);
|
||||
namedWindow("image", WINDOW_AUTOSIZE);
|
||||
imshow("image", img);
|
||||
waitKey();
|
||||
|
||||
@ -144,7 +144,7 @@ A call to ``waitKey()`` starts a message passing cycle that waits for a key stro
|
||||
|
||||
Mat img = imread("image.jpg");
|
||||
Mat grey;
|
||||
cvtColor(img, grey, CV_BGR2GRAY);
|
||||
cvtColor(img, grey, COLOR_BGR2GRAY);
|
||||
|
||||
Mat sobelx;
|
||||
Sobel(grey, sobelx, CV_32F, 1, 0);
|
||||
@ -154,6 +154,6 @@ A call to ``waitKey()`` starts a message passing cycle that waits for a key stro
|
||||
Mat draw;
|
||||
sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal));
|
||||
|
||||
namedWindow("image", CV_WINDOW_AUTOSIZE);
|
||||
namedWindow("image", WINDOW_AUTOSIZE);
|
||||
imshow("image", draw);
|
||||
waitKey();
|
||||
|
Loading…
Reference in New Issue
Block a user