Normalize whitespace in documentation and text files
This commit is contained in:
parent
9337246867
commit
0e7ca71dcc
@ -5,10 +5,10 @@ INSTRUCTIONS TO BUILD WIN32 PACKAGES WITH CMAKE+CPACK
|
|||||||
- Install NSIS.
|
- Install NSIS.
|
||||||
- Generate OpenCV solutions for MSVC using CMake as usual.
|
- Generate OpenCV solutions for MSVC using CMake as usual.
|
||||||
- In cmake-gui:
|
- In cmake-gui:
|
||||||
- Mark BUILD_PACKAGE
|
- Mark BUILD_PACKAGE
|
||||||
- Mark BUILD_EXAMPLES (If examples are desired to be shipped as binaries...)
|
- Mark BUILD_EXAMPLES (If examples are desired to be shipped as binaries...)
|
||||||
- Unmark ENABLE_OPENMP, since this feature seems to have some issues yet...
|
- Unmark ENABLE_OPENMP, since this feature seems to have some issues yet...
|
||||||
- Mark INSTALL_*_EXAMPLES
|
- Mark INSTALL_*_EXAMPLES
|
||||||
- Open the OpenCV solution and build ALL in Debug and Release.
|
- Open the OpenCV solution and build ALL in Debug and Release.
|
||||||
- Build PACKAGE, from the Release configuration. An NSIS installer package will be
|
- Build PACKAGE, from the Release configuration. An NSIS installer package will be
|
||||||
created with both release and debug LIBs and DLLs.
|
created with both release and debug LIBs and DLLs.
|
||||||
|
@ -99,11 +99,11 @@ Explanation
|
|||||||
|
|
||||||
/// 2.b. Creating rectangles
|
/// 2.b. Creating rectangles
|
||||||
rectangle( rook_image,
|
rectangle( rook_image,
|
||||||
Point( 0, 7*w/8.0 ),
|
Point( 0, 7*w/8.0 ),
|
||||||
Point( w, w),
|
Point( w, w),
|
||||||
Scalar( 0, 255, 255 ),
|
Scalar( 0, 255, 255 ),
|
||||||
-1,
|
-1,
|
||||||
8 );
|
8 );
|
||||||
|
|
||||||
/// 2.c. Create a few lines
|
/// 2.c. Create a few lines
|
||||||
MyLine( rook_image, Point( 0, 15*w/16 ), Point( w, 15*w/16 ) );
|
MyLine( rook_image, Point( 0, 15*w/16 ), Point( w, 15*w/16 ) );
|
||||||
@ -118,16 +118,16 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
void MyLine( Mat img, Point start, Point end )
|
void MyLine( Mat img, Point start, Point end )
|
||||||
{
|
{
|
||||||
int thickness = 2;
|
int thickness = 2;
|
||||||
int lineType = 8;
|
int lineType = 8;
|
||||||
line( img,
|
line( img,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
Scalar( 0, 0, 0 ),
|
Scalar( 0, 0, 0 ),
|
||||||
thickness,
|
thickness,
|
||||||
lineType );
|
lineType );
|
||||||
}
|
}
|
||||||
|
|
||||||
As we can see, *MyLine* just call the function :line:`line <>`, which does the following:
|
As we can see, *MyLine* just call the function :line:`line <>`, which does the following:
|
||||||
|
|
||||||
@ -145,18 +145,18 @@ Explanation
|
|||||||
|
|
||||||
void MyEllipse( Mat img, double angle )
|
void MyEllipse( Mat img, double angle )
|
||||||
{
|
{
|
||||||
int thickness = 2;
|
int thickness = 2;
|
||||||
int lineType = 8;
|
int lineType = 8;
|
||||||
|
|
||||||
ellipse( img,
|
ellipse( img,
|
||||||
Point( w/2.0, w/2.0 ),
|
Point( w/2.0, w/2.0 ),
|
||||||
Size( w/4.0, w/16.0 ),
|
Size( w/4.0, w/16.0 ),
|
||||||
angle,
|
angle,
|
||||||
0,
|
0,
|
||||||
360,
|
360,
|
||||||
Scalar( 255, 0, 0 ),
|
Scalar( 255, 0, 0 ),
|
||||||
thickness,
|
thickness,
|
||||||
lineType );
|
lineType );
|
||||||
}
|
}
|
||||||
|
|
||||||
From the code above, we can observe that the function :ellipse:`ellipse <>` draws an ellipse such that:
|
From the code above, we can observe that the function :ellipse:`ellipse <>` draws an ellipse such that:
|
||||||
@ -176,17 +176,17 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
void MyFilledCircle( Mat img, Point center )
|
void MyFilledCircle( Mat img, Point center )
|
||||||
{
|
{
|
||||||
int thickness = -1;
|
int thickness = -1;
|
||||||
int lineType = 8;
|
int lineType = 8;
|
||||||
|
|
||||||
circle( img,
|
circle( img,
|
||||||
center,
|
center,
|
||||||
w/32.0,
|
w/32.0,
|
||||||
Scalar( 0, 0, 255 ),
|
Scalar( 0, 0, 255 ),
|
||||||
thickness,
|
thickness,
|
||||||
lineType );
|
lineType );
|
||||||
}
|
}
|
||||||
|
|
||||||
Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
||||||
|
|
||||||
@ -203,41 +203,41 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
void MyPolygon( Mat img )
|
void MyPolygon( Mat img )
|
||||||
{
|
{
|
||||||
int lineType = 8;
|
int lineType = 8;
|
||||||
|
|
||||||
/** Create some points */
|
/** Create some points */
|
||||||
Point rook_points[1][20];
|
Point rook_points[1][20];
|
||||||
rook_points[0][0] = Point( w/4.0, 7*w/8.0 );
|
rook_points[0][0] = Point( w/4.0, 7*w/8.0 );
|
||||||
rook_points[0][1] = Point( 3*w/4.0, 7*w/8.0 );
|
rook_points[0][1] = Point( 3*w/4.0, 7*w/8.0 );
|
||||||
rook_points[0][2] = Point( 3*w/4.0, 13*w/16.0 );
|
rook_points[0][2] = Point( 3*w/4.0, 13*w/16.0 );
|
||||||
rook_points[0][3] = Point( 11*w/16.0, 13*w/16.0 );
|
rook_points[0][3] = Point( 11*w/16.0, 13*w/16.0 );
|
||||||
rook_points[0][4] = Point( 19*w/32.0, 3*w/8.0 );
|
rook_points[0][4] = Point( 19*w/32.0, 3*w/8.0 );
|
||||||
rook_points[0][5] = Point( 3*w/4.0, 3*w/8.0 );
|
rook_points[0][5] = Point( 3*w/4.0, 3*w/8.0 );
|
||||||
rook_points[0][6] = Point( 3*w/4.0, w/8.0 );
|
rook_points[0][6] = Point( 3*w/4.0, w/8.0 );
|
||||||
rook_points[0][7] = Point( 26*w/40.0, w/8.0 );
|
rook_points[0][7] = Point( 26*w/40.0, w/8.0 );
|
||||||
rook_points[0][8] = Point( 26*w/40.0, w/4.0 );
|
rook_points[0][8] = Point( 26*w/40.0, w/4.0 );
|
||||||
rook_points[0][9] = Point( 22*w/40.0, w/4.0 );
|
rook_points[0][9] = Point( 22*w/40.0, w/4.0 );
|
||||||
rook_points[0][10] = Point( 22*w/40.0, w/8.0 );
|
rook_points[0][10] = Point( 22*w/40.0, w/8.0 );
|
||||||
rook_points[0][11] = Point( 18*w/40.0, w/8.0 );
|
rook_points[0][11] = Point( 18*w/40.0, w/8.0 );
|
||||||
rook_points[0][12] = Point( 18*w/40.0, w/4.0 );
|
rook_points[0][12] = Point( 18*w/40.0, w/4.0 );
|
||||||
rook_points[0][13] = Point( 14*w/40.0, w/4.0 );
|
rook_points[0][13] = Point( 14*w/40.0, w/4.0 );
|
||||||
rook_points[0][14] = Point( 14*w/40.0, w/8.0 );
|
rook_points[0][14] = Point( 14*w/40.0, w/8.0 );
|
||||||
rook_points[0][15] = Point( w/4.0, w/8.0 );
|
rook_points[0][15] = Point( w/4.0, w/8.0 );
|
||||||
rook_points[0][16] = Point( w/4.0, 3*w/8.0 );
|
rook_points[0][16] = Point( w/4.0, 3*w/8.0 );
|
||||||
rook_points[0][17] = Point( 13*w/32.0, 3*w/8.0 );
|
rook_points[0][17] = Point( 13*w/32.0, 3*w/8.0 );
|
||||||
rook_points[0][18] = Point( 5*w/16.0, 13*w/16.0 );
|
rook_points[0][18] = Point( 5*w/16.0, 13*w/16.0 );
|
||||||
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
||||||
|
|
||||||
const Point* ppt[1] = { rook_points[0] };
|
const Point* ppt[1] = { rook_points[0] };
|
||||||
int npt[] = { 20 };
|
int npt[] = { 20 };
|
||||||
|
|
||||||
fillPoly( img,
|
fillPoly( img,
|
||||||
ppt,
|
ppt,
|
||||||
npt,
|
npt,
|
||||||
1,
|
1,
|
||||||
Scalar( 255, 255, 255 ),
|
Scalar( 255, 255, 255 ),
|
||||||
lineType );
|
lineType );
|
||||||
}
|
}
|
||||||
|
|
||||||
To draw a filled polygon we use the function :fill_poly:`fillPoly <>`. We note that:
|
To draw a filled polygon we use the function :fill_poly:`fillPoly <>`. We note that:
|
||||||
@ -255,11 +255,11 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
rectangle( rook_image,
|
rectangle( rook_image,
|
||||||
Point( 0, 7*w/8.0 ),
|
Point( 0, 7*w/8.0 ),
|
||||||
Point( w, w),
|
Point( w, w),
|
||||||
Scalar( 0, 255, 255 ),
|
Scalar( 0, 255, 255 ),
|
||||||
-1,
|
-1,
|
||||||
8 );
|
8 );
|
||||||
|
|
||||||
Finally we have the :rectangle:`rectangle <>` function (we did not create a special function for this guy). We note that:
|
Finally we have the :rectangle:`rectangle <>` function (we did not create a special function for this guy). We note that:
|
||||||
|
|
||||||
|
@ -87,14 +87,14 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
|
|
||||||
/// Apply corner detection
|
/// Apply corner detection
|
||||||
goodFeaturesToTrack( src_gray,
|
goodFeaturesToTrack( src_gray,
|
||||||
corners,
|
corners,
|
||||||
maxCorners,
|
maxCorners,
|
||||||
qualityLevel,
|
qualityLevel,
|
||||||
minDistance,
|
minDistance,
|
||||||
Mat(),
|
Mat(),
|
||||||
blockSize,
|
blockSize,
|
||||||
useHarrisDetector,
|
useHarrisDetector,
|
||||||
k );
|
k );
|
||||||
|
|
||||||
|
|
||||||
/// Draw corners detected
|
/// Draw corners detected
|
||||||
|
@ -98,16 +98,16 @@ How does it work?
|
|||||||
u & v
|
u & v
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
\left (
|
\left (
|
||||||
\displaystyle \sum_{x,y}
|
\displaystyle \sum_{x,y}
|
||||||
w(x,y)
|
w(x,y)
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
I_x^{2} & I_{x}I_{y} \\
|
I_x^{2} & I_{x}I_{y} \\
|
||||||
I_xI_{y} & I_{y}^{2}
|
I_xI_{y} & I_{y}^{2}
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
\right )
|
\right )
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
u \\
|
u \\
|
||||||
v
|
v
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
|
|
||||||
* Let's denote:
|
* Let's denote:
|
||||||
@ -115,11 +115,11 @@ How does it work?
|
|||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
M = \displaystyle \sum_{x,y}
|
M = \displaystyle \sum_{x,y}
|
||||||
w(x,y)
|
w(x,y)
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
I_x^{2} & I_{x}I_{y} \\
|
I_x^{2} & I_{x}I_{y} \\
|
||||||
I_xI_{y} & I_{y}^{2}
|
I_xI_{y} & I_{y}^{2}
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
|
|
||||||
* So, our equation now is:
|
* So, our equation now is:
|
||||||
|
|
||||||
@ -128,10 +128,10 @@ How does it work?
|
|||||||
E(u,v) \approx \begin{bmatrix}
|
E(u,v) \approx \begin{bmatrix}
|
||||||
u & v
|
u & v
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
M
|
M
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
u \\
|
u \\
|
||||||
v
|
v
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,21 +112,21 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
|
|
||||||
/// Create Erosion Trackbar
|
/// Create Erosion Trackbar
|
||||||
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
|
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
|
||||||
&erosion_elem, max_elem,
|
&erosion_elem, max_elem,
|
||||||
Erosion );
|
Erosion );
|
||||||
|
|
||||||
createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
|
createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
|
||||||
&erosion_size, max_kernel_size,
|
&erosion_size, max_kernel_size,
|
||||||
Erosion );
|
Erosion );
|
||||||
|
|
||||||
/// Create Dilation Trackbar
|
/// Create Dilation Trackbar
|
||||||
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
|
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
|
||||||
&dilation_elem, max_elem,
|
&dilation_elem, max_elem,
|
||||||
Dilation );
|
Dilation );
|
||||||
|
|
||||||
createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
|
createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
|
||||||
&dilation_size, max_kernel_size,
|
&dilation_size, max_kernel_size,
|
||||||
Dilation );
|
Dilation );
|
||||||
|
|
||||||
/// Default start
|
/// Default start
|
||||||
Erosion( 0, 0 );
|
Erosion( 0, 0 );
|
||||||
@ -145,8 +145,8 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
|
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
|
||||||
|
|
||||||
Mat element = getStructuringElement( erosion_type,
|
Mat element = getStructuringElement( erosion_type,
|
||||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||||
Point( erosion_size, erosion_size ) );
|
Point( erosion_size, erosion_size ) );
|
||||||
|
|
||||||
/// Apply the erosion operation
|
/// Apply the erosion operation
|
||||||
erode( src, erosion_dst, element );
|
erode( src, erosion_dst, element );
|
||||||
@ -162,8 +162,8 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
|
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
|
||||||
|
|
||||||
Mat element = getStructuringElement( dilation_type,
|
Mat element = getStructuringElement( dilation_type,
|
||||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||||
Point( dilation_size, dilation_size ) );
|
Point( dilation_size, dilation_size ) );
|
||||||
/// Apply the dilation operation
|
/// Apply the dilation operation
|
||||||
dilate( src, dilation_dst, element );
|
dilate( src, dilation_dst, element );
|
||||||
imshow( "Dilation Demo", dilation_dst );
|
imshow( "Dilation Demo", dilation_dst );
|
||||||
@ -201,8 +201,8 @@ Explanation
|
|||||||
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
|
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
|
||||||
|
|
||||||
Mat element = getStructuringElement( erosion_type,
|
Mat element = getStructuringElement( erosion_type,
|
||||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||||
Point( erosion_size, erosion_size ) );
|
Point( erosion_size, erosion_size ) );
|
||||||
/// Apply the erosion operation
|
/// Apply the erosion operation
|
||||||
erode( src, erosion_dst, element );
|
erode( src, erosion_dst, element );
|
||||||
imshow( "Erosion Demo", erosion_dst );
|
imshow( "Erosion Demo", erosion_dst );
|
||||||
@ -216,17 +216,17 @@ Explanation
|
|||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
Mat element = getStructuringElement( erosion_type,
|
Mat element = getStructuringElement( erosion_type,
|
||||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||||
Point( erosion_size, erosion_size ) );
|
Point( erosion_size, erosion_size ) );
|
||||||
|
|
||||||
We can choose any of three shapes for our kernel:
|
We can choose any of three shapes for our kernel:
|
||||||
|
|
||||||
.. container:: enumeratevisibleitemswithsquare
|
.. container:: enumeratevisibleitemswithsquare
|
||||||
|
|
||||||
+ Rectangular box: MORPH_RECT
|
+ Rectangular box: MORPH_RECT
|
||||||
+ Cross: MORPH_CROSS
|
+ Cross: MORPH_CROSS
|
||||||
+ Ellipse: MORPH_ELLIPSE
|
+ Ellipse: MORPH_ELLIPSE
|
||||||
|
|
||||||
Then, we just have to specify the size of our kernel and the *anchor point*. If not specified, it is assumed to be in the center.
|
Then, we just have to specify the size of our kernel and the *anchor point*. If not specified, it is assumed to be in the center.
|
||||||
|
|
||||||
@ -251,8 +251,8 @@ The code is below. As you can see, it is completely similar to the snippet of co
|
|||||||
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
|
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
|
||||||
|
|
||||||
Mat element = getStructuringElement( dilation_type,
|
Mat element = getStructuringElement( dilation_type,
|
||||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||||
Point( dilation_size, dilation_size ) );
|
Point( dilation_size, dilation_size ) );
|
||||||
/// Apply the dilation operation
|
/// Apply the dilation operation
|
||||||
dilate( src, dilation_dst, element );
|
dilate( src, dilation_dst, element );
|
||||||
imshow( "Dilation Demo", dilation_dst );
|
imshow( "Dilation Demo", dilation_dst );
|
||||||
|
@ -159,35 +159,35 @@ Code
|
|||||||
if( display_caption( "Homogeneous Blur" ) != 0 ) { return 0; }
|
if( display_caption( "Homogeneous Blur" ) != 0 ) { return 0; }
|
||||||
|
|
||||||
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
||||||
{ blur( src, dst, Size( i, i ), Point(-1,-1) );
|
{ blur( src, dst, Size( i, i ), Point(-1,-1) );
|
||||||
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
||||||
|
|
||||||
/// Applying Gaussian blur
|
/// Applying Gaussian blur
|
||||||
if( display_caption( "Gaussian Blur" ) != 0 ) { return 0; }
|
if( display_caption( "Gaussian Blur" ) != 0 ) { return 0; }
|
||||||
|
|
||||||
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
||||||
{ GaussianBlur( src, dst, Size( i, i ), 0, 0 );
|
{ GaussianBlur( src, dst, Size( i, i ), 0, 0 );
|
||||||
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
||||||
|
|
||||||
/// Applying Median blur
|
/// Applying Median blur
|
||||||
if( display_caption( "Median Blur" ) != 0 ) { return 0; }
|
if( display_caption( "Median Blur" ) != 0 ) { return 0; }
|
||||||
|
|
||||||
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
||||||
{ medianBlur ( src, dst, i );
|
{ medianBlur ( src, dst, i );
|
||||||
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
||||||
|
|
||||||
/// Applying Bilateral Filter
|
/// Applying Bilateral Filter
|
||||||
if( display_caption( "Bilateral Blur" ) != 0 ) { return 0; }
|
if( display_caption( "Bilateral Blur" ) != 0 ) { return 0; }
|
||||||
|
|
||||||
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
|
||||||
{ bilateralFilter ( src, dst, i, i*2, i/2 );
|
{ bilateralFilter ( src, dst, i, i*2, i/2 );
|
||||||
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } }
|
||||||
|
|
||||||
/// Wait until user press a key
|
/// Wait until user press a key
|
||||||
display_caption( "End: Press a key!" );
|
display_caption( "End: Press a key!" );
|
||||||
|
|
||||||
waitKey(0);
|
waitKey(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int display_caption( char* caption )
|
int display_caption( char* caption )
|
||||||
|
@ -94,7 +94,7 @@ Code
|
|||||||
* Loads an image
|
* Loads an image
|
||||||
* Convert the original to HSV format and separate only *Hue* channel to be used for the Histogram (using the OpenCV function :mix_channels:`mixChannels <>`)
|
* Convert the original to HSV format and separate only *Hue* channel to be used for the Histogram (using the OpenCV function :mix_channels:`mixChannels <>`)
|
||||||
* Let the user to enter the number of bins to be used in the calculation of the histogram.
|
* Let the user to enter the number of bins to be used in the calculation of the histogram.
|
||||||
* Calculate the histogram (and update it if the bins change) and the backprojection of the same image.
|
* Calculate the histogram (and update it if the bins change) and the backprojection of the same image.
|
||||||
* Display the backprojection and the histogram in windows.
|
* Display the backprojection and the histogram in windows.
|
||||||
|
|
||||||
* **Downloadable code**:
|
* **Downloadable code**:
|
||||||
|
@ -124,34 +124,34 @@ Code
|
|||||||
|
|
||||||
for( int j = 0; j < src.rows; j++ )
|
for( int j = 0; j < src.rows; j++ )
|
||||||
{ for( int i = 0; i < src.cols; i++ )
|
{ for( int i = 0; i < src.cols; i++ )
|
||||||
{
|
{
|
||||||
switch( ind )
|
switch( ind )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
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_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_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ map_x.at<float>(j,i) = 0 ;
|
{ map_x.at<float>(j,i) = 0 ;
|
||||||
map_y.at<float>(j,i) = 0 ;
|
map_y.at<float>(j,i) = 0 ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
map_x.at<float>(j,i) = i ;
|
map_x.at<float>(j,i) = i ;
|
||||||
map_y.at<float>(j,i) = src.rows - j ;
|
map_y.at<float>(j,i) = src.rows - j ;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
map_x.at<float>(j,i) = src.cols - i ;
|
map_x.at<float>(j,i) = src.cols - i ;
|
||||||
map_y.at<float>(j,i) = j ;
|
map_y.at<float>(j,i) = j ;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
map_x.at<float>(j,i) = src.cols - i ;
|
map_x.at<float>(j,i) = src.cols - i ;
|
||||||
map_y.at<float>(j,i) = src.rows - j ;
|
map_y.at<float>(j,i) = src.rows - j ;
|
||||||
break;
|
break;
|
||||||
} // end of switch
|
} // end of switch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ind++;
|
ind++;
|
||||||
}
|
}
|
||||||
@ -241,34 +241,34 @@ Explanation
|
|||||||
|
|
||||||
for( int j = 0; j < src.rows; j++ )
|
for( int j = 0; j < src.rows; j++ )
|
||||||
{ for( int i = 0; i < src.cols; i++ )
|
{ for( int i = 0; i < src.cols; i++ )
|
||||||
{
|
{
|
||||||
switch( ind )
|
switch( ind )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
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_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_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ map_x.at<float>(j,i) = 0 ;
|
{ map_x.at<float>(j,i) = 0 ;
|
||||||
map_y.at<float>(j,i) = 0 ;
|
map_y.at<float>(j,i) = 0 ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
map_x.at<float>(j,i) = i ;
|
map_x.at<float>(j,i) = i ;
|
||||||
map_y.at<float>(j,i) = src.rows - j ;
|
map_y.at<float>(j,i) = src.rows - j ;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
map_x.at<float>(j,i) = src.cols - i ;
|
map_x.at<float>(j,i) = src.cols - i ;
|
||||||
map_y.at<float>(j,i) = j ;
|
map_y.at<float>(j,i) = j ;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
map_x.at<float>(j,i) = src.cols - i ;
|
map_x.at<float>(j,i) = src.cols - i ;
|
||||||
map_y.at<float>(j,i) = src.rows - j ;
|
map_y.at<float>(j,i) = src.rows - j ;
|
||||||
break;
|
break;
|
||||||
} // end of switch
|
} // end of switch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ind++;
|
ind++;
|
||||||
}
|
}
|
||||||
|
@ -154,13 +154,13 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
|
|
||||||
/// Create Trackbar to select kernel type
|
/// Create Trackbar to select kernel type
|
||||||
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
||||||
&morph_elem, max_elem,
|
&morph_elem, max_elem,
|
||||||
Morphology_Operations );
|
Morphology_Operations );
|
||||||
|
|
||||||
/// Create Trackbar to choose kernel size
|
/// Create Trackbar to choose kernel size
|
||||||
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
||||||
&morph_size, max_kernel_size,
|
&morph_size, max_kernel_size,
|
||||||
Morphology_Operations );
|
Morphology_Operations );
|
||||||
|
|
||||||
/// Default start
|
/// Default start
|
||||||
Morphology_Operations( 0, 0 );
|
Morphology_Operations( 0, 0 );
|
||||||
@ -211,16 +211,16 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
||||||
&morph_elem, max_elem,
|
&morph_elem, max_elem,
|
||||||
Morphology_Operations );
|
Morphology_Operations );
|
||||||
|
|
||||||
* The final trackbar **"Kernel Size"** returns the size of the kernel to be used (**morph_size**)
|
* The final trackbar **"Kernel Size"** returns the size of the kernel to be used (**morph_size**)
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
||||||
&morph_size, max_kernel_size,
|
&morph_size, max_kernel_size,
|
||||||
Morphology_Operations );
|
Morphology_Operations );
|
||||||
|
|
||||||
|
|
||||||
* Every time we move any slider, the user's function **Morphology_Operations** will be called to effectuate a new morphology operation and it will update the output image based on the current trackbar values.
|
* Every time we move any slider, the user's function **Morphology_Operations** will be called to effectuate a new morphology operation and it will update the output image based on the current trackbar values.
|
||||||
|
@ -129,7 +129,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
|||||||
c = waitKey(10);
|
c = waitKey(10);
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( (char)c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
if( (char)c == 'u' )
|
if( (char)c == 'u' )
|
||||||
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
||||||
printf( "** Zoom In: Image x 2 \n" );
|
printf( "** Zoom In: Image x 2 \n" );
|
||||||
@ -188,7 +188,7 @@ Explanation
|
|||||||
c = waitKey(10);
|
c = waitKey(10);
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( (char)c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
if( (char)c == 'u' )
|
if( (char)c == 'u' )
|
||||||
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
||||||
printf( "** Zoom In: Image x 2 \n" );
|
printf( "** Zoom In: Image x 2 \n" );
|
||||||
|
@ -174,12 +174,12 @@ The tutorial code's is shown lines below. You can also download it from `here <h
|
|||||||
|
|
||||||
/// Create Trackbar to choose type of Threshold
|
/// Create Trackbar to choose type of Threshold
|
||||||
createTrackbar( trackbar_type,
|
createTrackbar( trackbar_type,
|
||||||
window_name, &threshold_type,
|
window_name, &threshold_type,
|
||||||
max_type, Threshold_Demo );
|
max_type, Threshold_Demo );
|
||||||
|
|
||||||
createTrackbar( trackbar_value,
|
createTrackbar( trackbar_value,
|
||||||
window_name, &threshold_value,
|
window_name, &threshold_value,
|
||||||
max_value, Threshold_Demo );
|
max_value, Threshold_Demo );
|
||||||
|
|
||||||
/// Call the function to initialize
|
/// Call the function to initialize
|
||||||
Threshold_Demo( 0, 0 );
|
Threshold_Demo( 0, 0 );
|
||||||
@ -190,7 +190,7 @@ The tutorial code's is shown lines below. You can also download it from `here <h
|
|||||||
int c;
|
int c;
|
||||||
c = waitKey( 20 );
|
c = waitKey( 20 );
|
||||||
if( (char)c == 27 )
|
if( (char)c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -245,12 +245,12 @@ Explanation
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
createTrackbar( trackbar_type,
|
createTrackbar( trackbar_type,
|
||||||
window_name, &threshold_type,
|
window_name, &threshold_type,
|
||||||
max_type, Threshold_Demo );
|
max_type, Threshold_Demo );
|
||||||
|
|
||||||
createTrackbar( trackbar_value,
|
createTrackbar( trackbar_value,
|
||||||
window_name, &threshold_value,
|
window_name, &threshold_value,
|
||||||
max_value, Threshold_Demo );
|
max_value, Threshold_Demo );
|
||||||
|
|
||||||
* Wait until the user enters the threshold value, the type of thresholding (or until the program exits)
|
* Wait until the user enters the threshold value, the type of thresholding (or until the program exits)
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ Now we will learn how to write a simple Hello World Application in Xcode using O
|
|||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#import <opencv2/opencv.hpp>
|
#import <opencv2/opencv.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
.. image:: images/header_directive.png
|
.. image:: images/header_directive.png
|
||||||
:alt: header
|
:alt: header
|
||||||
|
@ -17,32 +17,32 @@ Including OpenCV library in your iOS project
|
|||||||
|
|
||||||
The OpenCV library comes as a so-called framework, which you can directly drag-and-drop into your XCode project. Download the latest binary from <http://sourceforge.net/projects/opencvlibrary/files/opencv-ios/>. Alternatively follow this guide :ref:`iOS-Installation` to compile the framework manually. Once you have the framework, just drag-and-drop into XCode:
|
The OpenCV library comes as a so-called framework, which you can directly drag-and-drop into your XCode project. Download the latest binary from <http://sourceforge.net/projects/opencvlibrary/files/opencv-ios/>. Alternatively follow this guide :ref:`iOS-Installation` to compile the framework manually. Once you have the framework, just drag-and-drop into XCode:
|
||||||
|
|
||||||
.. image:: images/xcode_hello_ios_framework_drag_and_drop.png
|
.. image:: images/xcode_hello_ios_framework_drag_and_drop.png
|
||||||
|
|
||||||
|
|
||||||
Also you have to locate the prefix header that is used for all header files in the project. The file is typically located at "ProjectName/Supporting Files/ProjectName-Prefix.pch". There, you have add an include statement to import the opencv library. However, make sure you include opencv before you include UIKit and Foundation, because else you will get some weird compile errors that some macros like min and max are defined multiple times. For example the prefix header could look like the following:
|
Also you have to locate the prefix header that is used for all header files in the project. The file is typically located at "ProjectName/Supporting Files/ProjectName-Prefix.pch". There, you have add an include statement to import the opencv library. However, make sure you include opencv before you include UIKit and Foundation, because else you will get some weird compile errors that some macros like min and max are defined multiple times. For example the prefix header could look like the following:
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prefix header for all source files of the 'VideoFilters' target in the 'VideoFilters' project
|
// Prefix header for all source files of the 'VideoFilters' target in the 'VideoFilters' project
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <Availability.h>
|
#import <Availability.h>
|
||||||
|
|
||||||
#ifndef __IPHONE_4_0
|
#ifndef __IPHONE_4_0
|
||||||
#warning "This project uses features only available in iOS SDK 4.0 and later."
|
#warning "This project uses features only available in iOS SDK 4.0 and later."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#import <opencv2/opencv.hpp>
|
#import <opencv2/opencv.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -53,23 +53,23 @@ User Interface
|
|||||||
|
|
||||||
First, we create a simple iOS project, for example Single View Application. Then, we create and add an UIImageView and UIButton to start the camera and display the video frames. The storyboard could look like that:
|
First, we create a simple iOS project, for example Single View Application. Then, we create and add an UIImageView and UIButton to start the camera and display the video frames. The storyboard could look like that:
|
||||||
|
|
||||||
.. image:: images/xcode_hello_ios_viewcontroller_layout.png
|
.. image:: images/xcode_hello_ios_viewcontroller_layout.png
|
||||||
|
|
||||||
|
|
||||||
Make sure to add and connect the IBOutlets and IBActions to the corresponding ViewController:
|
Make sure to add and connect the IBOutlets and IBActions to the corresponding ViewController:
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
@interface ViewController : UIViewController
|
@interface ViewController : UIViewController
|
||||||
{
|
{
|
||||||
IBOutlet UIImageView* imageView;
|
IBOutlet UIImageView* imageView;
|
||||||
IBOutlet UIButton* button;
|
IBOutlet UIButton* button;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)actionStart:(id)sender;
|
- (IBAction)actionStart:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
Adding the Camera
|
Adding the Camera
|
||||||
@ -78,37 +78,37 @@ Adding the Camera
|
|||||||
We add a camera controller to the view controller and initialize it when the view has loaded:
|
We add a camera controller to the view controller and initialize it when the view has loaded:
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
#import <opencv2/highgui/cap_ios.h>
|
#import <opencv2/highgui/cap_ios.h>
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
|
||||||
@interface ViewController : UIViewController
|
@interface ViewController : UIViewController
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
CvVideoCamera* videoCamera;
|
CvVideoCamera* videoCamera;
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
@property (nonatomic, retain) CvVideoCamera* videoCamera;
|
@property (nonatomic, retain) CvVideoCamera* videoCamera;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad
|
||||||
{
|
{
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
// Do any additional setup after loading the view, typically from a nib.
|
// Do any additional setup after loading the view, typically from a nib.
|
||||||
|
|
||||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||||
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
|
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
|
||||||
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
|
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
|
||||||
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
|
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
|
||||||
self.videoCamera.defaultFPS = 30;
|
self.videoCamera.defaultFPS = 30;
|
||||||
self.videoCamera.grayscale = NO;
|
self.videoCamera.grayscale = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
In this case, we initialize the camera and provide the imageView as a target for rendering each frame. CvVideoCamera is basically a wrapper around AVFoundation, so we provie as properties some of the AVFoundation camera options. For example we want to use the front camera, set the video size to 352x288 and a video orientation (the video camera normally outputs in landscape mode, which results in transposed data when you design a portrait application).
|
In this case, we initialize the camera and provide the imageView as a target for rendering each frame. CvVideoCamera is basically a wrapper around AVFoundation, so we provie as properties some of the AVFoundation camera options. For example we want to use the front camera, set the video size to 352x288 and a video orientation (the video camera normally outputs in landscape mode, which results in transposed data when you design a portrait application).
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ Additionally, we have to manually add framework dependencies of the opencv frame
|
|||||||
* Foundation
|
* Foundation
|
||||||
|
|
||||||
|
|
||||||
.. image:: images/xcode_hello_ios_frameworks_add_dependencies.png
|
.. image:: images/xcode_hello_ios_frameworks_add_dependencies.png
|
||||||
|
|
||||||
|
|
||||||
Processing frames
|
Processing frames
|
||||||
@ -152,35 +152,35 @@ Processing frames
|
|||||||
We follow the delegation pattern, which is very common in iOS, to provide access to each camera frame. Basically, the View Controller has to implement the CvVideoCameraDelegate protocol and has to be set as delegate to the video camera:
|
We follow the delegation pattern, which is very common in iOS, to provide access to each camera frame. Basically, the View Controller has to implement the CvVideoCameraDelegate protocol and has to be set as delegate to the video camera:
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
@interface ViewController : UIViewController<CvVideoCameraDelegate>
|
@interface ViewController : UIViewController<CvVideoCameraDelegate>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||||
self.videoCamera.delegate = self;
|
self.videoCamera.delegate = self;
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
#pragma mark - Protocol CvVideoCameraDelegate
|
#pragma mark - Protocol CvVideoCameraDelegate
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
- (void)processImage:(Mat&)image;
|
- (void)processImage:(Mat&)image;
|
||||||
{
|
{
|
||||||
// Do some OpenCV stuff with the image
|
// Do some OpenCV stuff with the image
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Note that we are using C++ here (cv::Mat).
|
Note that we are using C++ here (cv::Mat).
|
||||||
Important: You have to rename the view controller's extension .m into .mm, so that the compiler compiles it under the assumption of Objective-C++ (Objective-C and C++ mixed). Then, __cplusplus is defined when the compiler is processing the file for C++ code. Therefore, we put our code within a block where __cplusplus is defined.
|
Important: You have to rename the view controller's extension .m into .mm, so that the compiler compiles it under the assumption of Objective-C++ (Objective-C and C++ mixed). Then, __cplusplus is defined when the compiler is processing the file for C++ code. Therefore, we put our code within a block where __cplusplus is defined.
|
||||||
@ -193,18 +193,18 @@ From here you can start processing video frames. For example the following snipp
|
|||||||
|
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
- (void)processImage:(Mat&)image;
|
- (void)processImage:(Mat&)image;
|
||||||
{
|
{
|
||||||
// Do some OpenCV stuff with the image
|
// Do some OpenCV stuff with the image
|
||||||
Mat image_copy;
|
Mat image_copy;
|
||||||
cvtColor(image, image_copy, CV_BGRA2BGR);
|
cvtColor(image, image_copy, CV_BGRA2BGR);
|
||||||
|
|
||||||
// invert image
|
// invert image
|
||||||
bitwise_not(image_copy, image_copy);
|
bitwise_not(image_copy, image_copy);
|
||||||
cvtColor(image_copy, image, CV_BGR2BGRA);
|
cvtColor(image_copy, image, CV_BGR2BGRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Start!
|
Start!
|
||||||
@ -213,14 +213,14 @@ Start!
|
|||||||
Finally, we have to tell the camera to actually start/stop working. The following code will start the camera when you press the button, assuming you connected the UI properly:
|
Finally, we have to tell the camera to actually start/stop working. The following code will start the camera when you press the button, assuming you connected the UI properly:
|
||||||
|
|
||||||
.. code-block:: objc
|
.. code-block:: objc
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
#pragma mark - UI Actions
|
#pragma mark - UI Actions
|
||||||
|
|
||||||
- (IBAction)actionStart:(id)sender;
|
- (IBAction)actionStart:(id)sender;
|
||||||
{
|
{
|
||||||
[self.videoCamera start];
|
[self.videoCamera start];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
0
samples/c/example_cmake/README.txt
Executable file → Normal file
0
samples/c/example_cmake/README.txt
Executable file → Normal file
0
samples/cpp/matching_to_many_images/train/trainImages.txt
Executable file → Normal file
0
samples/cpp/matching_to_many_images/train/trainImages.txt
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user