mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
Converted tabs to spaces.
This commit is contained in:
parent
e9a28f66ee
commit
3c137f7a04
@ -2,10 +2,10 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/,
|
||||
0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/,
|
||||
NULL /*hInstance*/, NULL /*lpParam*/);
|
||||
DeleteDC(NULL);
|
||||
CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/,
|
||||
0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/,
|
||||
NULL /*hInstance*/, NULL /*lpParam*/);
|
||||
DeleteDC(NULL);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -75,11 +75,11 @@
|
||||
% if using A4 paper. (This probably isn't strictly necessary.)
|
||||
% If using another size paper, use default 1cm margins.
|
||||
\ifthenelse{\lengthtest { \paperwidth = 11in}}
|
||||
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
|
||||
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
}
|
||||
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
|
||||
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
|
||||
}
|
||||
|
||||
% Turn off header and footer
|
||||
% \pagestyle{empty}
|
||||
|
@ -99,11 +99,11 @@ Explanation
|
||||
|
||||
/// 2.b. Creating rectangles
|
||||
rectangle( rook_image,
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
|
||||
/// 2.c. Create a few lines
|
||||
MyLine( rook_image, Point( 0, 15*w/16 ), Point( w, 15*w/16 ) );
|
||||
@ -118,16 +118,16 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
void MyLine( Mat img, Point start, Point end )
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
line( img,
|
||||
start,
|
||||
end,
|
||||
Scalar( 0, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
line( img,
|
||||
start,
|
||||
end,
|
||||
Scalar( 0, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
int thickness = 2;
|
||||
int lineType = 8;
|
||||
|
||||
ellipse( img,
|
||||
Point( w/2.0, w/2.0 ),
|
||||
Size( w/4.0, w/16.0 ),
|
||||
angle,
|
||||
0,
|
||||
360,
|
||||
Scalar( 255, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
ellipse( img,
|
||||
Point( w/2.0, w/2.0 ),
|
||||
Size( w/4.0, w/16.0 ),
|
||||
angle,
|
||||
0,
|
||||
360,
|
||||
Scalar( 255, 0, 0 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
void MyFilledCircle( Mat img, Point center )
|
||||
{
|
||||
int thickness = -1;
|
||||
int lineType = 8;
|
||||
{
|
||||
int thickness = -1;
|
||||
int lineType = 8;
|
||||
|
||||
circle( img,
|
||||
center,
|
||||
w/32.0,
|
||||
Scalar( 0, 0, 255 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
circle( img,
|
||||
center,
|
||||
w/32.0,
|
||||
Scalar( 0, 0, 255 ),
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
||||
|
||||
@ -203,41 +203,41 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
void MyPolygon( Mat img )
|
||||
{
|
||||
int lineType = 8;
|
||||
{
|
||||
int lineType = 8;
|
||||
|
||||
/** Create some points */
|
||||
Point rook_points[1][20];
|
||||
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][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][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][6] = Point( 3*w/4.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][9] = Point( 22*w/40.0, w/4.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][12] = Point( 18*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][15] = Point( w/4.0, 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][18] = Point( 5*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
||||
/** Create some points */
|
||||
Point rook_points[1][20];
|
||||
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][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][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][6] = Point( 3*w/4.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][9] = Point( 22*w/40.0, w/4.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][12] = Point( 18*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][15] = Point( w/4.0, 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][18] = Point( 5*w/16.0, 13*w/16.0 );
|
||||
rook_points[0][19] = Point( w/4.0, 13*w/16.0) ;
|
||||
|
||||
const Point* ppt[1] = { rook_points[0] };
|
||||
int npt[] = { 20 };
|
||||
const Point* ppt[1] = { rook_points[0] };
|
||||
int npt[] = { 20 };
|
||||
|
||||
fillPoly( img,
|
||||
ppt,
|
||||
npt,
|
||||
1,
|
||||
Scalar( 255, 255, 255 ),
|
||||
lineType );
|
||||
fillPoly( img,
|
||||
ppt,
|
||||
npt,
|
||||
1,
|
||||
Scalar( 255, 255, 255 ),
|
||||
lineType );
|
||||
}
|
||||
|
||||
To draw a filled polygon we use the function :fill_poly:`fillPoly <>`. We note that:
|
||||
@ -255,11 +255,11 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
rectangle( rook_image,
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
Point( 0, 7*w/8.0 ),
|
||||
Point( w, w),
|
||||
Scalar( 0, 255, 255 ),
|
||||
-1,
|
||||
8 );
|
||||
|
||||
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
|
||||
goodFeaturesToTrack( src_gray,
|
||||
corners,
|
||||
maxCorners,
|
||||
qualityLevel,
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
corners,
|
||||
maxCorners,
|
||||
qualityLevel,
|
||||
minDistance,
|
||||
Mat(),
|
||||
blockSize,
|
||||
useHarrisDetector,
|
||||
k );
|
||||
|
||||
|
||||
/// Draw corners detected
|
||||
|
@ -98,16 +98,16 @@ How does it work?
|
||||
u & v
|
||||
\end{bmatrix}
|
||||
\left (
|
||||
\displaystyle \sum_{x,y}
|
||||
\displaystyle \sum_{x,y}
|
||||
w(x,y)
|
||||
\begin{bmatrix}
|
||||
I_x^{2} & I_{x}I_{y} \\
|
||||
I_xI_{y} & I_{y}^{2}
|
||||
\end{bmatrix}
|
||||
\right )
|
||||
\begin{bmatrix}
|
||||
\end{bmatrix}
|
||||
\right )
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v
|
||||
v
|
||||
\end{bmatrix}
|
||||
|
||||
* Let's denote:
|
||||
@ -115,11 +115,11 @@ How does it work?
|
||||
.. math::
|
||||
|
||||
M = \displaystyle \sum_{x,y}
|
||||
w(x,y)
|
||||
\begin{bmatrix}
|
||||
I_x^{2} & I_{x}I_{y} \\
|
||||
I_xI_{y} & I_{y}^{2}
|
||||
\end{bmatrix}
|
||||
w(x,y)
|
||||
\begin{bmatrix}
|
||||
I_x^{2} & I_{x}I_{y} \\
|
||||
I_xI_{y} & I_{y}^{2}
|
||||
\end{bmatrix}
|
||||
|
||||
* So, our equation now is:
|
||||
|
||||
@ -128,10 +128,10 @@ How does it work?
|
||||
E(u,v) \approx \begin{bmatrix}
|
||||
u & v
|
||||
\end{bmatrix}
|
||||
M
|
||||
\begin{bmatrix}
|
||||
M
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v
|
||||
v
|
||||
\end{bmatrix}
|
||||
|
||||
|
||||
|
@ -112,21 +112,21 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
|
||||
/// Create Erosion Trackbar
|
||||
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
|
||||
&erosion_elem, max_elem,
|
||||
Erosion );
|
||||
&erosion_elem, max_elem,
|
||||
Erosion );
|
||||
|
||||
createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
|
||||
&erosion_size, max_kernel_size,
|
||||
Erosion );
|
||||
&erosion_size, max_kernel_size,
|
||||
Erosion );
|
||||
|
||||
/// Create Dilation Trackbar
|
||||
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
|
||||
&dilation_elem, max_elem,
|
||||
Dilation );
|
||||
&dilation_elem, max_elem,
|
||||
Dilation );
|
||||
|
||||
createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
|
||||
&dilation_size, max_kernel_size,
|
||||
Dilation );
|
||||
&dilation_size, max_kernel_size,
|
||||
Dilation );
|
||||
|
||||
/// Default start
|
||||
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; }
|
||||
|
||||
Mat element = getStructuringElement( erosion_type,
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
|
||||
/// Apply the erosion operation
|
||||
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; }
|
||||
|
||||
Mat element = getStructuringElement( dilation_type,
|
||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||
Point( dilation_size, dilation_size ) );
|
||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||
Point( dilation_size, dilation_size ) );
|
||||
/// Apply the dilation operation
|
||||
dilate( src, dilation_dst, element );
|
||||
imshow( "Dilation Demo", dilation_dst );
|
||||
@ -201,8 +201,8 @@ Explanation
|
||||
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
|
||||
|
||||
Mat element = getStructuringElement( erosion_type,
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
/// Apply the erosion operation
|
||||
erode( src, erosion_dst, element );
|
||||
imshow( "Erosion Demo", erosion_dst );
|
||||
@ -216,17 +216,17 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat element = getStructuringElement( erosion_type,
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
Mat element = getStructuringElement( erosion_type,
|
||||
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
|
||||
Point( erosion_size, erosion_size ) );
|
||||
|
||||
We can choose any of three shapes for our kernel:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ Rectangular box: MORPH_RECT
|
||||
+ Cross: MORPH_CROSS
|
||||
+ Ellipse: MORPH_ELLIPSE
|
||||
+ Rectangular box: MORPH_RECT
|
||||
+ Cross: MORPH_CROSS
|
||||
+ 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.
|
||||
|
||||
@ -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; }
|
||||
|
||||
Mat element = getStructuringElement( dilation_type,
|
||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||
Point( dilation_size, dilation_size ) );
|
||||
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
|
||||
Point( dilation_size, dilation_size ) );
|
||||
/// Apply the dilation operation
|
||||
dilate( src, dilation_dst, element );
|
||||
imshow( "Dilation Demo", dilation_dst );
|
||||
|
@ -94,7 +94,7 @@ Code
|
||||
* 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 <>`)
|
||||
* 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.
|
||||
|
||||
* **Downloadable code**:
|
||||
|
@ -124,34 +124,34 @@ Code
|
||||
|
||||
for( int j = 0; j < src.rows; j++ )
|
||||
{ for( int i = 0; i < src.cols; i++ )
|
||||
{
|
||||
{
|
||||
switch( ind )
|
||||
{
|
||||
case 0:
|
||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
||||
{
|
||||
case 0:
|
||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
||||
{
|
||||
map_x.at<float>(j,i) = 2*( i - src.cols*0.25 ) + 0.5 ;
|
||||
map_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
|
||||
}
|
||||
else
|
||||
{ map_x.at<float>(j,i) = 0 ;
|
||||
map_y.at<float>(j,i) = 0 ;
|
||||
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 ;
|
||||
}
|
||||
else
|
||||
{ map_x.at<float>(j,i) = 0 ;
|
||||
map_y.at<float>(j,i) = 0 ;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
map_x.at<float>(j,i) = i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
case 1:
|
||||
map_x.at<float>(j,i) = i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
case 2:
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = j ;
|
||||
break;
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = j ;
|
||||
break;
|
||||
case 3:
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
} // end of switch
|
||||
}
|
||||
}
|
||||
}
|
||||
ind++;
|
||||
}
|
||||
@ -241,34 +241,34 @@ Explanation
|
||||
|
||||
for( int j = 0; j < src.rows; j++ )
|
||||
{ for( int i = 0; i < src.cols; i++ )
|
||||
{
|
||||
{
|
||||
switch( ind )
|
||||
{
|
||||
case 0:
|
||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
||||
{
|
||||
case 0:
|
||||
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
|
||||
{
|
||||
map_x.at<float>(j,i) = 2*( i - src.cols*0.25 ) + 0.5 ;
|
||||
map_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
|
||||
}
|
||||
else
|
||||
{ map_x.at<float>(j,i) = 0 ;
|
||||
map_y.at<float>(j,i) = 0 ;
|
||||
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 ;
|
||||
}
|
||||
else
|
||||
{ map_x.at<float>(j,i) = 0 ;
|
||||
map_y.at<float>(j,i) = 0 ;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
map_x.at<float>(j,i) = i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
case 1:
|
||||
map_x.at<float>(j,i) = i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
case 2:
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = j ;
|
||||
break;
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = j ;
|
||||
break;
|
||||
case 3:
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
map_x.at<float>(j,i) = src.cols - i ;
|
||||
map_y.at<float>(j,i) = src.rows - j ;
|
||||
break;
|
||||
} // end of switch
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
||||
&morph_elem, max_elem,
|
||||
Morphology_Operations );
|
||||
&morph_elem, max_elem,
|
||||
Morphology_Operations );
|
||||
|
||||
/// Create Trackbar to choose kernel size
|
||||
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
||||
&morph_size, max_kernel_size,
|
||||
Morphology_Operations );
|
||||
&morph_size, max_kernel_size,
|
||||
Morphology_Operations );
|
||||
|
||||
/// Default start
|
||||
Morphology_Operations( 0, 0 );
|
||||
@ -211,16 +211,16 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
createTrackbar( "Element:\n 0: Rect - 1: Cross - 2: Ellipse", window_name,
|
||||
&morph_elem, max_elem,
|
||||
Morphology_Operations );
|
||||
&morph_elem, max_elem,
|
||||
Morphology_Operations );
|
||||
|
||||
* The final trackbar **"Kernel Size"** returns the size of the kernel to be used (**morph_size**)
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
createTrackbar( "Kernel size:\n 2n +1", window_name,
|
||||
&morph_size, max_kernel_size,
|
||||
Morphology_Operations );
|
||||
&morph_size, max_kernel_size,
|
||||
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.
|
||||
|
@ -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
|
||||
createTrackbar( trackbar_type,
|
||||
window_name, &threshold_type,
|
||||
max_type, Threshold_Demo );
|
||||
window_name, &threshold_type,
|
||||
max_type, Threshold_Demo );
|
||||
|
||||
createTrackbar( trackbar_value,
|
||||
window_name, &threshold_value,
|
||||
max_value, Threshold_Demo );
|
||||
window_name, &threshold_value,
|
||||
max_value, Threshold_Demo );
|
||||
|
||||
/// Call the function to initialize
|
||||
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;
|
||||
c = waitKey( 20 );
|
||||
if( (char)c == 27 )
|
||||
{ break; }
|
||||
{ break; }
|
||||
}
|
||||
|
||||
}
|
||||
@ -245,12 +245,12 @@ Explanation
|
||||
.. code-block:: cpp
|
||||
|
||||
createTrackbar( trackbar_type,
|
||||
window_name, &threshold_type,
|
||||
max_type, Threshold_Demo );
|
||||
window_name, &threshold_type,
|
||||
max_type, Threshold_Demo );
|
||||
|
||||
createTrackbar( trackbar_value,
|
||||
window_name, &threshold_value,
|
||||
max_value, Threshold_Demo );
|
||||
window_name, &threshold_value,
|
||||
max_value, Threshold_Demo );
|
||||
|
||||
* Wait until the user enters the threshold value, the type of thresholding (or until the program exits)
|
||||
|
||||
|
@ -97,14 +97,14 @@ Now you can inspect the state of you program. For example, you can bring up the
|
||||
Note that the built-in *Locals* window will display text only. This is where the Image Watch plug-in comes in. Image Watch is like another *Locals* window, but with an image viewer built into it. To bring up Image Watch, select :menuselection:`View --> Other Windows --> Image Watch`. Like Visual Studio's *Locals* window, Image Watch can dock to the Visual Studio IDE. Also, Visual Studio will remember whether you had Image Watch open, and where it was located between debugging sessions. This means you only have to do this once--the next time you start debugging, Image Watch will be back where you left it. Here's what the docked Image Watch window looks like at our breakpoint:
|
||||
|
||||
.. image:: images/toolwindow.jpg
|
||||
:height: 320pt
|
||||
:height: 320pt
|
||||
|
||||
The radio button at the top left (*Locals/Watch*) selects what is shown in the *Image List* below: *Locals* lists all OpenCV image objects in the current scope (this list is automatically populated). *Watch* shows image expressions that have been pinned for continuous inspection (not described here, see `Image Watch documentation <http://go.microsoft.com/fwlink/?LinkId=285461>`_ for details). The image list shows basic information such as width, height, number of channels, and, if available, a thumbnail. In our example, the image list contains our two local image variables, *input* and *edges*.
|
||||
|
||||
If an image has a thumbnail, left-clicking on that image will select it for detailed viewing in the *Image Viewer* on the right. The viewer lets you pan (drag mouse) and zoom (mouse wheel). It also displays the pixel coordinate and value at the current mouse position.
|
||||
|
||||
.. image:: images/viewer.jpg
|
||||
:height: 160pt
|
||||
:height: 160pt
|
||||
|
||||
Note that the second image in the list, *edges*, is shown as "invalid". This indicates that some data members of this image object have corrupt or invalid values (for example, a negative image width). This is expected at this point in the program, since the C++ constructor for *edges* has not run yet, and so its members have undefined values (in debug mode they are usually filled with "0xCD" bytes).
|
||||
|
||||
@ -113,17 +113,17 @@ From here you can single-step through your code (:menuselection:`Debug->Step Ove
|
||||
Now assume you want to do a visual sanity check of the *cv::Canny()* implementation. Bring the *edges* image into the viewer by selecting it in the *Image List* and zoom into a region with a clearly defined edge:
|
||||
|
||||
.. image:: images/edges_zoom.png
|
||||
:height: 160pt
|
||||
:height: 160pt
|
||||
|
||||
Right-click on the *Image Viewer* to bring up the view context menu and enable :menuselection:`Link Views` (a check box next to the menu item indicates whether the option is enabled).
|
||||
|
||||
.. image:: images/viewer_context_menu.png
|
||||
:height: 120pt
|
||||
:height: 120pt
|
||||
|
||||
The :menuselection:`Link Views` feature keeps the view region fixed when flipping between images of the same size. To see how this works, select the input image from the image list--you should now see the corresponding zoomed-in region in the input image:
|
||||
|
||||
.. image:: images/input_zoom.png
|
||||
:height: 160pt
|
||||
:height: 160pt
|
||||
|
||||
You may also switch back and forth between viewing input and edges with your up/down cursor keys. That way you can easily verify that the detected edges line up nicely with the data in the input image.
|
||||
|
||||
@ -141,4 +141,4 @@ Image watch has a number of more advanced features, such as
|
||||
Please refer to the online `Image Watch Documentation <http://go.microsoft.com/fwlink/?LinkId=285461>`_ for details--you also can get to the documentation page by clicking on the *Help* link in the Image Watch window:
|
||||
|
||||
.. image:: images/help_button.jpg
|
||||
:height: 80pt
|
||||
:height: 80pt
|
||||
|
@ -43,9 +43,9 @@ Now we will learn how to write a simple Hello World Application in Xcode using O
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import <opencv2/opencv.hpp>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#import <opencv2/opencv.hpp>
|
||||
#endif
|
||||
|
||||
.. image:: images/header_directive.png
|
||||
: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:
|
||||
|
||||
.. 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:
|
||||
|
||||
.. 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
|
||||
#warning "This project uses features only available in iOS SDK 4.0 and later."
|
||||
#endif
|
||||
#ifndef __IPHONE_4_0
|
||||
#warning "This project uses features only available in iOS SDK 4.0 and later."
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import <opencv2/opencv.hpp>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#import <opencv2/opencv.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#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:
|
||||
|
||||
.. 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:
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
{
|
||||
IBOutlet UIImageView* imageView;
|
||||
IBOutlet UIButton* button;
|
||||
}
|
||||
@interface ViewController : UIViewController
|
||||
{
|
||||
IBOutlet UIImageView* imageView;
|
||||
IBOutlet UIButton* button;
|
||||
}
|
||||
|
||||
- (IBAction)actionStart:(id)sender;
|
||||
- (IBAction)actionStart:(id)sender;
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
|
||||
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:
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
#import <opencv2/highgui/cap_ios.h>
|
||||
using namespace cv;
|
||||
#import <opencv2/highgui/cap_ios.h>
|
||||
using namespace cv;
|
||||
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
{
|
||||
...
|
||||
CvVideoCamera* videoCamera;
|
||||
}
|
||||
...
|
||||
@property (nonatomic, retain) CvVideoCamera* videoCamera;
|
||||
@interface ViewController : UIViewController
|
||||
{
|
||||
...
|
||||
CvVideoCamera* videoCamera;
|
||||
}
|
||||
...
|
||||
@property (nonatomic, retain) CvVideoCamera* videoCamera;
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
|
||||
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
|
||||
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
|
||||
self.videoCamera.defaultFPS = 30;
|
||||
self.videoCamera.grayscale = NO;
|
||||
}
|
||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
|
||||
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
|
||||
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
|
||||
self.videoCamera.defaultFPS = 30;
|
||||
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).
|
||||
|
||||
@ -143,7 +143,7 @@ Additionally, we have to manually add framework dependencies of the opencv frame
|
||||
* Foundation
|
||||
|
||||
|
||||
.. image:: images/xcode_hello_ios_frameworks_add_dependencies.png
|
||||
.. image:: images/xcode_hello_ios_frameworks_add_dependencies.png
|
||||
|
||||
|
||||
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:
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
@interface ViewController : UIViewController<CvVideoCameraDelegate>
|
||||
@interface ViewController : UIViewController<CvVideoCameraDelegate>
|
||||
|
||||
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
...
|
||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||
self.videoCamera.delegate = self;
|
||||
...
|
||||
}
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
...
|
||||
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
|
||||
self.videoCamera.delegate = self;
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
#pragma mark - Protocol CvVideoCameraDelegate
|
||||
#pragma mark - Protocol CvVideoCameraDelegate
|
||||
|
||||
#ifdef __cplusplus
|
||||
- (void)processImage:(Mat&)image;
|
||||
{
|
||||
// Do some OpenCV stuff with the image
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
- (void)processImage:(Mat&)image;
|
||||
{
|
||||
// Do some OpenCV stuff with the image
|
||||
}
|
||||
#endif
|
||||
|
||||
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.
|
||||
@ -193,18 +193,18 @@ From here you can start processing video frames. For example the following snipp
|
||||
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
- (void)processImage:(Mat&)image;
|
||||
{
|
||||
// Do some OpenCV stuff with the image
|
||||
Mat image_copy;
|
||||
cvtColor(image, image_copy, CV_BGRA2BGR);
|
||||
- (void)processImage:(Mat&)image;
|
||||
{
|
||||
// Do some OpenCV stuff with the image
|
||||
Mat image_copy;
|
||||
cvtColor(image, image_copy, CV_BGRA2BGR);
|
||||
|
||||
// invert image
|
||||
bitwise_not(image_copy, image_copy);
|
||||
cvtColor(image_copy, image, CV_BGR2BGRA);
|
||||
}
|
||||
// invert image
|
||||
bitwise_not(image_copy, image_copy);
|
||||
cvtColor(image_copy, image, CV_BGR2BGRA);
|
||||
}
|
||||
|
||||
|
||||
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:
|
||||
|
||||
.. code-block:: objc
|
||||
:linenos:
|
||||
:linenos:
|
||||
|
||||
#pragma mark - UI Actions
|
||||
#pragma mark - UI Actions
|
||||
|
||||
- (IBAction)actionStart:(id)sender;
|
||||
{
|
||||
[self.videoCamera start];
|
||||
}
|
||||
- (IBAction)actionStart:(id)sender;
|
||||
{
|
||||
[self.videoCamera start];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -455,41 +455,41 @@ cv::Scalar cv::sum( InputArray _src )
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = (int)(total_size/rows);
|
||||
if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
typedef IppStatus (CV_STDCALL* ippiSumFunc)(const void*, int, IppiSize, double *, int);
|
||||
ippiSumFunc ippFunc =
|
||||
type == CV_8UC1 ? (ippiSumFunc)ippiSum_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiSumFunc)ippiSum_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiSumFunc)ippiSum_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiSumFunc)ippiSum_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiSumFunc)ippiSum_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiSumFunc)ippiSum_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiSumFunc)ippiSum_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiSumFunc)ippiSum_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiSumFunc)ippiSum_16s_C4R :
|
||||
type == CV_32FC1 ? (ippiSumFunc)ippiSum_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiSumFunc)ippiSum_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiSumFunc)ippiSum_32f_C4R :
|
||||
0;
|
||||
if( ippFunc )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
{
|
||||
sc[i] = res[i];
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = (int)(total_size/rows);
|
||||
if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
typedef IppStatus (CV_STDCALL* ippiSumFunc)(const void*, int, IppiSize, double *, int);
|
||||
ippiSumFunc ippFunc =
|
||||
type == CV_8UC1 ? (ippiSumFunc)ippiSum_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiSumFunc)ippiSum_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiSumFunc)ippiSum_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiSumFunc)ippiSum_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiSumFunc)ippiSum_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiSumFunc)ippiSum_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiSumFunc)ippiSum_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiSumFunc)ippiSum_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiSumFunc)ippiSum_16s_C4R :
|
||||
type == CV_32FC1 ? (ippiSumFunc)ippiSum_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiSumFunc)ippiSum_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiSumFunc)ippiSum_32f_C4R :
|
||||
0;
|
||||
if( ippFunc )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
{
|
||||
sc[i] = res[i];
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SumFunc func = getSumFunc(depth);
|
||||
@ -567,77 +567,77 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = (int)(total_size/rows);
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.data, src.step[0], mask.data, mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
return Scalar(res);
|
||||
}
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 1, &res1) >= 0 &&
|
||||
ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 2, &res2) >= 0 &&
|
||||
ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
return Scalar(res1, res2, res3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFunc)(const void*, int, IppiSize, double *, int);
|
||||
ippiMeanFunc ippFunc =
|
||||
type == CV_8UC1 ? (ippiMeanFunc)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFunc)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFunc)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFunc)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFunc)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFunc)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFunc)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFunc)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFunc)ippiMean_16s_C4R :
|
||||
type == CV_32FC1 ? (ippiMeanFunc)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFunc)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFunc)ippiMean_32f_C4R :
|
||||
0;
|
||||
if( ippFunc )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
{
|
||||
sc[i] = res[i];
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = (int)(total_size/rows);
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.data, src.step[0], mask.data, mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
return Scalar(res);
|
||||
}
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 1, &res1) >= 0 &&
|
||||
ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 2, &res2) >= 0 &&
|
||||
ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
return Scalar(res1, res2, res3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFunc)(const void*, int, IppiSize, double *, int);
|
||||
ippiMeanFunc ippFunc =
|
||||
type == CV_8UC1 ? (ippiMeanFunc)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFunc)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFunc)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFunc)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFunc)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFunc)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFunc)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFunc)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFunc)ippiMean_16s_C4R :
|
||||
type == CV_32FC1 ? (ippiMeanFunc)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFunc)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFunc)ippiMean_32f_C4R :
|
||||
0;
|
||||
if( ippFunc )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
{
|
||||
sc[i] = res[i];
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SumFunc func = getSumFunc(depth);
|
||||
|
@ -161,7 +161,7 @@ private:
|
||||
|
||||
|
||||
class CvCapture_FFMPEG_proxy :
|
||||
public CvCapture
|
||||
public CvCapture
|
||||
{
|
||||
public:
|
||||
CvCapture_FFMPEG_proxy() { ffmpegCapture = 0; }
|
||||
@ -186,7 +186,7 @@ public:
|
||||
|
||||
if (!ffmpegCapture ||
|
||||
!icvRetrieveFrame_FFMPEG_p(ffmpegCapture, &data, &step, &width, &height, &cn))
|
||||
return 0;
|
||||
return 0;
|
||||
cvInitImageHeader(&frame, cvSize(width, height), 8, cn);
|
||||
cvSetData(&frame, data, step);
|
||||
return &frame;
|
||||
@ -225,7 +225,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
|
||||
}
|
||||
|
||||
class CvVideoWriter_FFMPEG_proxy :
|
||||
public CvVideoWriter
|
||||
public CvVideoWriter
|
||||
{
|
||||
public:
|
||||
CvVideoWriter_FFMPEG_proxy() { ffmpegWriter = 0; }
|
||||
|
@ -343,8 +343,8 @@ void CvCapture_FFMPEG::close()
|
||||
class ImplMutex
|
||||
{
|
||||
public:
|
||||
ImplMutex() { init(); }
|
||||
~ImplMutex() { destroy(); }
|
||||
ImplMutex() { init(); }
|
||||
~ImplMutex() { destroy(); }
|
||||
|
||||
void init();
|
||||
void destroy();
|
||||
@ -447,14 +447,14 @@ struct ImplMutex::Impl
|
||||
|
||||
void ImplMutex::init()
|
||||
{
|
||||
impl = (Impl*)malloc(sizeof(Impl));
|
||||
impl->init();
|
||||
impl = (Impl*)malloc(sizeof(Impl));
|
||||
impl->init();
|
||||
}
|
||||
void ImplMutex::destroy()
|
||||
{
|
||||
impl->destroy();
|
||||
free(impl);
|
||||
impl = NULL;
|
||||
impl->destroy();
|
||||
free(impl);
|
||||
impl = NULL;
|
||||
}
|
||||
void ImplMutex::lock() { impl->lock(); }
|
||||
void ImplMutex::unlock() { impl->unlock(); }
|
||||
|
@ -1139,134 +1139,134 @@ private:
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel, const Point &anchor)
|
||||
{
|
||||
int type = src.type();
|
||||
const Mat* _src = &src;
|
||||
Mat temp;
|
||||
if( src.data == dst.data )
|
||||
{
|
||||
src.copyTo(temp);
|
||||
_src = &temp;
|
||||
}
|
||||
//DEPRECATED. Allocates and initializes morphology state structure for erosion or dilation operation.
|
||||
typedef IppStatus (CV_STDCALL* ippiMorphologyInitAllocFunc)(int, const void*, IppiSize, IppiPoint, IppiMorphState **);
|
||||
ippiMorphologyInitAllocFunc ippInitAllocFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C4R :
|
||||
0;
|
||||
typedef IppStatus (CV_STDCALL* ippiMorphologyBorderReplicateFunc)(const void*, int, void *, int, IppiSize, IppiBorderType, IppiMorphState *);
|
||||
ippiMorphologyBorderReplicateFunc ippFunc = 0;
|
||||
switch( op )
|
||||
{
|
||||
case MORPH_DILATE:
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C4R :
|
||||
0;
|
||||
break;
|
||||
}
|
||||
case MORPH_ERODE:
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C4R :
|
||||
0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ippFunc && ippInitAllocFunc)
|
||||
{
|
||||
IppiMorphState* pState;
|
||||
IppiSize roiSize = {src.cols, src.rows};
|
||||
IppiSize kernelSize = {kernel.cols, kernel.rows};
|
||||
IppiPoint point = {anchor.x, anchor.y};
|
||||
if( ippInitAllocFunc( roiSize.width, kernel.data, kernelSize, point, &pState ) < 0 )
|
||||
return false;
|
||||
bool is_ok = ippFunc( _src->data, _src->step[0], dst.data, dst.step[0], roiSize, ippBorderRepl, pState ) >= 0;
|
||||
ippiMorphologyFree(pState);
|
||||
return is_ok;
|
||||
}
|
||||
return false;
|
||||
int type = src.type();
|
||||
const Mat* _src = &src;
|
||||
Mat temp;
|
||||
if( src.data == dst.data )
|
||||
{
|
||||
src.copyTo(temp);
|
||||
_src = &temp;
|
||||
}
|
||||
//DEPRECATED. Allocates and initializes morphology state structure for erosion or dilation operation.
|
||||
typedef IppStatus (CV_STDCALL* ippiMorphologyInitAllocFunc)(int, const void*, IppiSize, IppiPoint, IppiMorphState **);
|
||||
ippiMorphologyInitAllocFunc ippInitAllocFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C4R :
|
||||
0;
|
||||
typedef IppStatus (CV_STDCALL* ippiMorphologyBorderReplicateFunc)(const void*, int, void *, int, IppiSize, IppiBorderType, IppiMorphState *);
|
||||
ippiMorphologyBorderReplicateFunc ippFunc = 0;
|
||||
switch( op )
|
||||
{
|
||||
case MORPH_DILATE:
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C4R :
|
||||
0;
|
||||
break;
|
||||
}
|
||||
case MORPH_ERODE:
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C4R :
|
||||
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C4R :
|
||||
0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ippFunc && ippInitAllocFunc)
|
||||
{
|
||||
IppiMorphState* pState;
|
||||
IppiSize roiSize = {src.cols, src.rows};
|
||||
IppiSize kernelSize = {kernel.cols, kernel.rows};
|
||||
IppiPoint point = {anchor.x, anchor.y};
|
||||
if( ippInitAllocFunc( roiSize.width, kernel.data, kernelSize, point, &pState ) < 0 )
|
||||
return false;
|
||||
bool is_ok = ippFunc( _src->data, _src->step[0], dst.data, dst.step[0], roiSize, ippBorderRepl, pState ) >= 0;
|
||||
ippiMorphologyFree(pState);
|
||||
return is_ok;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
InputArray _kernel,
|
||||
const Point &anchor, int iterations,
|
||||
int borderType, const Scalar &borderValue)
|
||||
InputArray _kernel,
|
||||
const Point &anchor, int iterations,
|
||||
int borderType, const Scalar &borderValue)
|
||||
{
|
||||
Mat src = _src.getMat(), kernel = _kernel.getMat();
|
||||
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
|
||||
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|
||||
|| !( op == MORPH_DILATE || op == MORPH_ERODE) )
|
||||
return false;
|
||||
if( borderType == cv::BORDER_CONSTANT )
|
||||
{
|
||||
int x, y;
|
||||
for( y = 0; y < kernel.rows; y++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y, anchor.x) != 0 )
|
||||
continue;
|
||||
for( x = 0; x < kernel.cols; x++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y,x) != 0 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for( x = 0; y < kernel.cols; x++ )
|
||||
{
|
||||
if( kernel.at<uchar>(anchor.y, x) != 0 )
|
||||
continue;
|
||||
for( y = 0; y < kernel.rows; y++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y,x) != 0 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Mat src = _src.getMat(), kernel = _kernel.getMat();
|
||||
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
|
||||
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|
||||
|| !( op == MORPH_DILATE || op == MORPH_ERODE) )
|
||||
return false;
|
||||
if( borderType == cv::BORDER_CONSTANT )
|
||||
{
|
||||
int x, y;
|
||||
for( y = 0; y < kernel.rows; y++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y, anchor.x) != 0 )
|
||||
continue;
|
||||
for( x = 0; x < kernel.cols; x++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y,x) != 0 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for( x = 0; y < kernel.cols; x++ )
|
||||
{
|
||||
if( kernel.at<uchar>(anchor.y, x) != 0 )
|
||||
continue;
|
||||
for( y = 0; y < kernel.rows; y++ )
|
||||
{
|
||||
if( kernel.at<uchar>(y,x) != 0 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
||||
Point normanchor = normalizeAnchor(anchor, ksize);
|
||||
}
|
||||
Size ksize = kernel.data ? kernel.size() : Size(3,3);
|
||||
Point normanchor = normalizeAnchor(anchor, ksize);
|
||||
|
||||
CV_Assert( normanchor.inside(Rect(0, 0, ksize.width, ksize.height)) );
|
||||
CV_Assert( normanchor.inside(Rect(0, 0, ksize.width, ksize.height)) );
|
||||
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
_dst.create( src.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
if( iterations == 0 || kernel.rows*kernel.cols == 1 )
|
||||
{
|
||||
src.copyTo(dst);
|
||||
return true;
|
||||
}
|
||||
if( iterations == 0 || kernel.rows*kernel.cols == 1 )
|
||||
{
|
||||
src.copyTo(dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !kernel.data )
|
||||
{
|
||||
kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2));
|
||||
normanchor = Point(iterations, iterations);
|
||||
iterations = 1;
|
||||
}
|
||||
else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols )
|
||||
{
|
||||
normanchor = Point(normanchor.x*iterations, normanchor.y*iterations);
|
||||
kernel = getStructuringElement(MORPH_RECT,
|
||||
Size(ksize.width + (iterations-1)*(ksize.width-1),
|
||||
ksize.height + (iterations-1)*(ksize.height-1)),
|
||||
normanchor);
|
||||
iterations = 1;
|
||||
}
|
||||
if( !kernel.data )
|
||||
{
|
||||
kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2));
|
||||
normanchor = Point(iterations, iterations);
|
||||
iterations = 1;
|
||||
}
|
||||
else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols )
|
||||
{
|
||||
normanchor = Point(normanchor.x*iterations, normanchor.y*iterations);
|
||||
kernel = getStructuringElement(MORPH_RECT,
|
||||
Size(ksize.width + (iterations-1)*(ksize.width-1),
|
||||
ksize.height + (iterations-1)*(ksize.height-1)),
|
||||
normanchor);
|
||||
iterations = 1;
|
||||
}
|
||||
|
||||
return IPPMorphReplicate( op, src, dst, kernel, normanchor );
|
||||
return IPPMorphReplicate( op, src, dst, kernel, normanchor );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1277,8 +1277,8 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
|
||||
{
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
if( IPPMorphOp(op, _src, _dst, _kernel, anchor, iterations, borderType, borderValue) )
|
||||
return;
|
||||
if( IPPMorphOp(op, _src, _dst, _kernel, anchor, iterations, borderType, borderValue) )
|
||||
return;
|
||||
#endif
|
||||
|
||||
Mat src = _src.getMat(), kernel = _kernel.getMat();
|
||||
|
@ -239,49 +239,49 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
|
||||
sdepth = CV_MAT_DEPTH(sdepth);
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
if( ( depth == CV_8U ) && ( !_tilted.needed() ) )
|
||||
{
|
||||
if( sdepth == CV_32F )
|
||||
{
|
||||
if( cn == 1 )
|
||||
{
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
|
||||
sum = _sum.getMat();
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
|
||||
sqsum = _sqsum.getMat();
|
||||
ippiSqrIntegral_8u32f64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( sdepth == CV_32S )
|
||||
{
|
||||
if( cn == 1 )
|
||||
{
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
|
||||
sum = _sum.getMat();
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
|
||||
sqsum = _sqsum.getMat();
|
||||
ippiSqrIntegral_8u32s64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ( depth == CV_8U ) && ( !_tilted.needed() ) )
|
||||
{
|
||||
if( sdepth == CV_32F )
|
||||
{
|
||||
if( cn == 1 )
|
||||
{
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
|
||||
sum = _sum.getMat();
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
|
||||
sqsum = _sqsum.getMat();
|
||||
ippiSqrIntegral_8u32f64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( sdepth == CV_32S )
|
||||
{
|
||||
if( cn == 1 )
|
||||
{
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
|
||||
sum = _sum.getMat();
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
|
||||
sqsum = _sqsum.getMat();
|
||||
ippiSqrIntegral_8u32s64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_sum.create( isize, CV_MAKETYPE(sdepth, cn) );
|
||||
|
@ -4,7 +4,7 @@
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
|
||||
<!-- We add an application tag here just so that we can indicate that
|
||||
this package needs to link against the android.test library,
|
||||
|
@ -48,45 +48,45 @@
|
||||
///////////// StereoMatchBM ////////////////////////
|
||||
PERFTEST(StereoMatchBM)
|
||||
{
|
||||
Mat left_image = imread(abspath("aloeL.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat right_image = imread(abspath("aloeR.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat disp,dst;
|
||||
ocl::oclMat d_left, d_right,d_disp;
|
||||
int n_disp= 128;
|
||||
int winSize =19;
|
||||
Mat left_image = imread(abspath("aloeL.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat right_image = imread(abspath("aloeR.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat disp,dst;
|
||||
ocl::oclMat d_left, d_right,d_disp;
|
||||
int n_disp= 128;
|
||||
int winSize =19;
|
||||
|
||||
SUBTEST << left_image.cols << 'x' << left_image.rows << "; aloeL.jpg ;"<< right_image.cols << 'x' << right_image.rows << "; aloeR.jpg ";
|
||||
SUBTEST << left_image.cols << 'x' << left_image.rows << "; aloeL.jpg ;"<< right_image.cols << 'x' << right_image.rows << "; aloeR.jpg ";
|
||||
|
||||
StereoBM bm(0, n_disp, winSize);
|
||||
bm(left_image, right_image, dst);
|
||||
StereoBM bm(0, n_disp, winSize);
|
||||
bm(left_image, right_image, dst);
|
||||
|
||||
CPU_ON;
|
||||
bm(left_image, right_image, dst);
|
||||
CPU_OFF;
|
||||
CPU_ON;
|
||||
bm(left_image, right_image, dst);
|
||||
CPU_OFF;
|
||||
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
|
||||
ocl::StereoBM_OCL d_bm(0, n_disp, winSize);
|
||||
ocl::StereoBM_OCL d_bm(0, n_disp, winSize);
|
||||
|
||||
WARMUP_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
WARMUP_OFF;
|
||||
WARMUP_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
WARMUP_OFF;
|
||||
|
||||
cv::Mat ocl_mat;
|
||||
d_disp.download(ocl_mat);
|
||||
ocl_mat.convertTo(ocl_mat, dst.type());
|
||||
|
||||
GPU_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
GPU_OFF;
|
||||
GPU_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
d_disp.download(disp);
|
||||
GPU_FULL_OFF;
|
||||
GPU_FULL_ON;
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
d_disp.download(disp);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().setAccurate(-1, 0.);
|
||||
}
|
||||
|
@ -463,51 +463,51 @@ private:
|
||||
|
||||
#define GLOBAL_INIT(name) \
|
||||
struct name##_init: Runnable { \
|
||||
name##_init(): Runnable(#name) { \
|
||||
TestSystem::instance().addInit(this); \
|
||||
name##_init(): Runnable(#name) { \
|
||||
TestSystem::instance().addInit(this); \
|
||||
} \
|
||||
void run(); \
|
||||
void run(); \
|
||||
} name##_init_instance; \
|
||||
void name##_init::run()
|
||||
void name##_init::run()
|
||||
|
||||
|
||||
#define PERFTEST(name) \
|
||||
struct name##_test: Runnable { \
|
||||
name##_test(): Runnable(#name) { \
|
||||
TestSystem::instance().addTest(this); \
|
||||
name##_test(): Runnable(#name) { \
|
||||
TestSystem::instance().addTest(this); \
|
||||
} \
|
||||
void run(); \
|
||||
void run(); \
|
||||
} name##_test_instance; \
|
||||
void name##_test::run()
|
||||
void name##_test::run()
|
||||
|
||||
#define SUBTEST TestSystem::instance().startNewSubtest()
|
||||
|
||||
#define CPU_ON \
|
||||
while (!TestSystem::instance().cpu_stop()) { \
|
||||
TestSystem::instance().cpuOn()
|
||||
while (!TestSystem::instance().cpu_stop()) { \
|
||||
TestSystem::instance().cpuOn()
|
||||
#define CPU_OFF \
|
||||
TestSystem::instance().cpuOff(); \
|
||||
} TestSystem::instance().cpuComplete()
|
||||
TestSystem::instance().cpuOff(); \
|
||||
} TestSystem::instance().cpuComplete()
|
||||
|
||||
#define GPU_ON \
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpuOn()
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpuOn()
|
||||
#define GPU_OFF \
|
||||
ocl::finish();\
|
||||
TestSystem::instance().gpuOff(); \
|
||||
} TestSystem::instance().gpuComplete()
|
||||
ocl::finish();\
|
||||
TestSystem::instance().gpuOff(); \
|
||||
} TestSystem::instance().gpuComplete()
|
||||
|
||||
#define GPU_FULL_ON \
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpufullOn()
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpufullOn()
|
||||
#define GPU_FULL_OFF \
|
||||
TestSystem::instance().gpufullOff(); \
|
||||
} TestSystem::instance().gpufullComplete()
|
||||
TestSystem::instance().gpufullOff(); \
|
||||
} TestSystem::instance().gpufullComplete()
|
||||
|
||||
#define WARMUP_ON \
|
||||
while (!TestSystem::instance().warmupStop()) {
|
||||
while (!TestSystem::instance().warmupStop()) {
|
||||
#define WARMUP_OFF \
|
||||
ocl::finish();\
|
||||
} TestSystem::instance().warmupComplete()
|
||||
ocl::finish();\
|
||||
} TestSystem::instance().warmupComplete()
|
||||
|
||||
#endif
|
||||
|
@ -234,5 +234,5 @@ void interpolate::bindImgTex(const oclMat &img, cl_mem &texture)
|
||||
{
|
||||
openCLFree(texture);
|
||||
}
|
||||
texture = bindTexture(img);
|
||||
texture = bindTexture(img);
|
||||
}
|
||||
|
@ -318,15 +318,15 @@ __kernel void classify_hists_180_kernel(
|
||||
volatile __local float* smem = products;
|
||||
#ifdef CPU
|
||||
if (tid < 13) smem[tid] = product = product + smem[tid + 32];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if (tid < 16) smem[tid] = product = product + smem[tid + 16];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
#else
|
||||
if (tid < 13)
|
||||
{
|
||||
@ -345,9 +345,9 @@ __kernel void classify_hists_180_kernel(
|
||||
#endif
|
||||
|
||||
if (tid == 0){
|
||||
product = product + smem[tid + 1];
|
||||
product = product + smem[tid + 1];
|
||||
labels[gidY * img_win_width + gidX] = (product + free_coef >= threshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -388,18 +388,18 @@ __kernel void classify_hists_252_kernel(
|
||||
if (tid < 64) products[tid] = product = product + products[tid + 64];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
volatile __local float* smem = products;
|
||||
volatile __local float* smem = products;
|
||||
#ifdef CPU
|
||||
if(tid<32) smem[tid] = product = product + smem[tid + 32];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<16) smem[tid] = product = product + smem[tid + 16];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<32) smem[tid] = product = product + smem[tid + 32];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<16) smem[tid] = product = product + smem[tid + 16];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
#else
|
||||
if (tid < 32)
|
||||
{
|
||||
@ -415,9 +415,9 @@ __kernel void classify_hists_252_kernel(
|
||||
}
|
||||
#endif
|
||||
if (tid == 0){
|
||||
product = product + smem[tid + 1];
|
||||
product = product + smem[tid + 1];
|
||||
labels[gidY * img_win_width + gidX] = (product + free_coef >= threshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -458,18 +458,18 @@ __kernel void classify_hists_kernel(
|
||||
if (tid < 64) products[tid] = product = product + products[tid + 64];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
volatile __local float* smem = products;
|
||||
volatile __local float* smem = products;
|
||||
#ifdef CPU
|
||||
if(tid<32) smem[tid] = product = product + smem[tid + 32];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<16) smem[tid] = product = product + smem[tid + 16];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<32) smem[tid] = product = product + smem[tid + 32];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<16) smem[tid] = product = product + smem[tid + 16];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<8) smem[tid] = product = product + smem[tid + 8];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<4) smem[tid] = product = product + smem[tid + 4];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
if(tid<2) smem[tid] = product = product + smem[tid + 2];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
#else
|
||||
if (tid < 32)
|
||||
{
|
||||
@ -485,9 +485,9 @@ __kernel void classify_hists_kernel(
|
||||
}
|
||||
#endif
|
||||
if (tid == 0){
|
||||
smem[tid] = product = product + smem[tid + 1];
|
||||
smem[tid] = product = product + smem[tid + 1];
|
||||
labels[gidY * img_win_width + gidX] = (product + free_coef >= threshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -51,8 +51,8 @@ __global float* dx, __global float* dy, int dx_step)
|
||||
|
||||
if((x < src_col)&&(y < src_row))
|
||||
{
|
||||
int src_x1 = (x + 1) < (src_col -1)? (x + 1) : (src_col - 1);
|
||||
int src_x2 = (x - 1) > 0 ? (x -1) : 0;
|
||||
int src_x1 = (x + 1) < (src_col -1)? (x + 1) : (src_col - 1);
|
||||
int src_x2 = (x - 1) > 0 ? (x -1) : 0;
|
||||
|
||||
//if(src[y * src_step + src_x1] == src[y * src_step+ src_x2])
|
||||
//{
|
||||
@ -62,7 +62,7 @@ __global float* dx, __global float* dy, int dx_step)
|
||||
//}
|
||||
dx[y * dx_step+ x] = 0.5f * (src[y * src_step + src_x1] - src[y * src_step+ src_x2]);
|
||||
|
||||
int src_y1 = (y+1) < (src_row - 1) ? (y + 1) : (src_row - 1);
|
||||
int src_y1 = (y+1) < (src_row - 1) ? (y + 1) : (src_row - 1);
|
||||
int src_y2 = (y - 1) > 0 ? (y - 1) : 0;
|
||||
dy[y * dx_step+ x] = 0.5f * (src[src_y1 * src_step + x] - src[src_y2 * src_step+ x]);
|
||||
}
|
||||
@ -89,20 +89,20 @@ float bicubicCoeff(float x_)
|
||||
}
|
||||
|
||||
__kernel void warpBackwardKernel(__global const float* I0, int I0_step, int I0_col, int I0_row,
|
||||
image2d_t tex_I1, image2d_t tex_I1x, image2d_t tex_I1y,
|
||||
image2d_t tex_I1, image2d_t tex_I1x, image2d_t tex_I1y,
|
||||
__global const float* u1, int u1_step,
|
||||
__global const float* u2,
|
||||
__global float* I1w,
|
||||
__global float* I1wx, /*int I1wx_step,*/
|
||||
__global float* I1wy, /*int I1wy_step,*/
|
||||
__global float* grad, /*int grad_step,*/
|
||||
__global float* rho,
|
||||
int I1w_step,
|
||||
int u2_step,
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
__global float* I1wx, /*int I1wx_step,*/
|
||||
__global float* I1wy, /*int I1wy_step,*/
|
||||
__global float* grad, /*int grad_step,*/
|
||||
__global float* rho,
|
||||
int I1w_step,
|
||||
int u2_step,
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
{
|
||||
const int x = get_global_id(0);
|
||||
const int y = get_global_id(1);
|
||||
@ -136,7 +136,7 @@ __kernel void warpBackwardKernel(__global const float* I0, int I0_step, int I0_c
|
||||
const float w = bicubicCoeff(wx - cx) * bicubicCoeff(wy - cy);
|
||||
|
||||
//sum += w * tex2D(tex_I1 , cx, cy);
|
||||
int2 cood = (int2)(cx, cy);
|
||||
int2 cood = (int2)(cx, cy);
|
||||
sum += w * read_imagef(tex_I1, sampleri, cood).x;
|
||||
//sumx += w * tex2D(tex_I1x, cx, cy);
|
||||
sumx += w * read_imagef(tex_I1x, sampleri, cood).x;
|
||||
@ -181,18 +181,18 @@ float readImage(__global const float *image, const int x, const int y, const
|
||||
}
|
||||
|
||||
__kernel void warpBackwardKernelNoImage2d(__global const float* I0, int I0_step, int I0_col, int I0_row,
|
||||
__global const float* tex_I1, __global const float* tex_I1x, __global const float* tex_I1y,
|
||||
__global const float* tex_I1, __global const float* tex_I1x, __global const float* tex_I1y,
|
||||
__global const float* u1, int u1_step,
|
||||
__global const float* u2,
|
||||
__global float* I1w,
|
||||
__global float* I1wx, /*int I1wx_step,*/
|
||||
__global float* I1wy, /*int I1wy_step,*/
|
||||
__global float* grad, /*int grad_step,*/
|
||||
__global float* rho,
|
||||
int I1w_step,
|
||||
int u2_step,
|
||||
int I1_step,
|
||||
int I1x_step)
|
||||
__global float* I1wx, /*int I1wx_step,*/
|
||||
__global float* I1wy, /*int I1wy_step,*/
|
||||
__global float* grad, /*int grad_step,*/
|
||||
__global float* rho,
|
||||
int I1w_step,
|
||||
int u2_step,
|
||||
int I1_step,
|
||||
int I1x_step)
|
||||
{
|
||||
const int x = get_global_id(0);
|
||||
const int y = get_global_id(1);
|
||||
@ -224,7 +224,7 @@ __kernel void warpBackwardKernelNoImage2d(__global const float* I0, int I0_step,
|
||||
{
|
||||
const float w = bicubicCoeff(wx - cx) * bicubicCoeff(wy - cy);
|
||||
|
||||
int2 cood = (int2)(cx, cy);
|
||||
int2 cood = (int2)(cx, cy);
|
||||
sum += w * readImage(tex_I1, cood.x, cood.y, I0_col, I0_row, I1_step);
|
||||
sumx += w * readImage(tex_I1x, cood.x, cood.y, I0_col, I0_row, I1x_step);
|
||||
sumy += w * readImage(tex_I1y, cood.x, cood.y, I0_col, I0_row, I1x_step);
|
||||
@ -263,11 +263,11 @@ __kernel void estimateDualVariablesKernel(__global const float* u1, int u1_col,
|
||||
__global float* p21,
|
||||
__global float* p22,
|
||||
const float taut,
|
||||
int u2_step,
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
int u2_step,
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
{
|
||||
|
||||
//const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
@ -277,16 +277,16 @@ __kernel void estimateDualVariablesKernel(__global const float* u1, int u1_col,
|
||||
|
||||
if(x < u1_col && y < u1_row)
|
||||
{
|
||||
int src_x1 = (x + 1) < (u1_col - 1) ? (x + 1) : (u1_col - 1);
|
||||
int src_x1 = (x + 1) < (u1_col - 1) ? (x + 1) : (u1_col - 1);
|
||||
const float u1x = u1[(y + u1_offset_y) * u1_step + src_x1 + u1_offset_x] - u1[(y + u1_offset_y) * u1_step + x + u1_offset_x];
|
||||
|
||||
int src_y1 = (y + 1) < (u1_row - 1) ? (y + 1) : (u1_row - 1);
|
||||
int src_y1 = (y + 1) < (u1_row - 1) ? (y + 1) : (u1_row - 1);
|
||||
const float u1y = u1[(src_y1 + u1_offset_y) * u1_step + x + u1_offset_x] - u1[(y + u1_offset_y) * u1_step + x + u1_offset_x];
|
||||
|
||||
int src_x2 = (x + 1) < (u1_col - 1) ? (x + 1) : (u1_col - 1);
|
||||
int src_x2 = (x + 1) < (u1_col - 1) ? (x + 1) : (u1_col - 1);
|
||||
const float u2x = u2[(y + u2_offset_y) * u2_step + src_x2 + u2_offset_x] - u2[(y + u2_offset_y) * u2_step + x + u2_offset_x];
|
||||
|
||||
int src_y2 = (y + 1) < (u1_row - 1) ? (y + 1) : (u1_row - 1);
|
||||
int src_y2 = (y + 1) < (u1_row - 1) ? (y + 1) : (u1_row - 1);
|
||||
const float u2y = u2[(src_y2 + u2_offset_y) * u2_step + x + u2_offset_x] - u2[(y + u2_offset_y) * u2_step + x + u2_offset_x];
|
||||
|
||||
const float g1 = hypot(u1x, u1y);
|
||||
@ -338,10 +338,10 @@ __kernel void estimateUKernel(__global const float* I1wx, int I1wx_col, int I1wx
|
||||
__global float* u1, int u1_step,
|
||||
__global float* u2,
|
||||
__global float* error, const float l_t, const float theta, int u2_step,
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
int u1_offset_x,
|
||||
int u1_offset_y,
|
||||
int u2_offset_x,
|
||||
int u2_offset_y)
|
||||
{
|
||||
|
||||
//const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
|
@ -112,7 +112,7 @@ namespace cv
|
||||
///////////////////////////comp data////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
static void comp_data_call(const oclMat &left, const oclMat &right, oclMat &data, int /*disp*/,
|
||||
float /*cmax_data_term*/, float /*cdata_weight*/)
|
||||
float /*cmax_data_term*/, float /*cdata_weight*/)
|
||||
{
|
||||
Context *clCxt = left.clCxt;
|
||||
int channels = left.oclchannels();
|
||||
|
@ -2,19 +2,19 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>de.rwth-aachen.ient.FaceTracker</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>de.rwth-aachen.ient.FaceTracker</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
22
samples/c/build_all.sh
Executable file → Normal file
22
samples/c/build_all.sh
Executable file → Normal file
@ -1,16 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -gt 0 ] ; then
|
||||
base=`basename $1 .c`
|
||||
echo "compiling $base"
|
||||
gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base
|
||||
base=`basename $1 .c`
|
||||
echo "compiling $base"
|
||||
gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base
|
||||
else
|
||||
for i in *.c; do
|
||||
echo "compiling $i"
|
||||
gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
|
||||
done
|
||||
for i in *.cpp; do
|
||||
echo "compiling $i"
|
||||
g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
|
||||
done
|
||||
for i in *.c; do
|
||||
echo "compiling $i"
|
||||
gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
|
||||
done
|
||||
for i in *.cpp; do
|
||||
echo "compiling $i"
|
||||
g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
|
||||
done
|
||||
fi
|
||||
|
@ -20,13 +20,13 @@ public:
|
||||
DeleteCriticalSection(&m_criticalSection);
|
||||
}
|
||||
|
||||
_Acquires_lock_(m_criticalSection)
|
||||
_Acquires_lock_(m_criticalSection)
|
||||
void Lock()
|
||||
{
|
||||
EnterCriticalSection(&m_criticalSection);
|
||||
}
|
||||
|
||||
_Releases_lock_(m_criticalSection)
|
||||
_Releases_lock_(m_criticalSection)
|
||||
void Unlock()
|
||||
{
|
||||
LeaveCriticalSection(&m_criticalSection);
|
||||
@ -47,16 +47,16 @@ class AutoLock
|
||||
private:
|
||||
CritSec *m_pCriticalSection;
|
||||
public:
|
||||
_Acquires_lock_(m_pCriticalSection)
|
||||
_Acquires_lock_(m_pCriticalSection)
|
||||
AutoLock(CritSec& crit)
|
||||
{
|
||||
m_pCriticalSection = &crit;
|
||||
m_pCriticalSection->Lock();
|
||||
}
|
||||
|
||||
_Releases_lock_(m_pCriticalSection)
|
||||
_Releases_lock_(m_pCriticalSection)
|
||||
~AutoLock()
|
||||
{
|
||||
m_pCriticalSection->Unlock();
|
||||
m_pCriticalSection->Unlock();
|
||||
}
|
||||
};
|
||||
|
@ -4,8 +4,8 @@ import "Windows.Media.idl";
|
||||
|
||||
namespace OcvTransform
|
||||
{
|
||||
[version(NTDDI_WIN8)]
|
||||
runtimeclass OcvImageManipulations
|
||||
[version(NTDDI_WIN8)]
|
||||
runtimeclass OcvImageManipulations
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ HRESULT OcvImageManipulations::SetProperties(ABI::Windows::Foundation::Collectio
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
return hr;
|
||||
}
|
||||
|
||||
// IMFTransform methods. Refer to the Media Foundation SDK documentation for details.
|
||||
@ -1334,15 +1334,15 @@ HRESULT OcvImageManipulations::OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuff
|
||||
const float baseRabge[] = {0.f,256.f};
|
||||
const float* ranges[] = {baseRabge};
|
||||
|
||||
const cv::Scalar mColorsY[] = { cv::Scalar(76), cv::Scalar(149), cv::Scalar(29) };
|
||||
const cv::Scalar mColorsUV[] = { cv::Scalar(84, 255), cv::Scalar(43, 21), cv::Scalar(255, 107) };
|
||||
const cv::Scalar mColorsY[] = { cv::Scalar(76), cv::Scalar(149), cv::Scalar(29) };
|
||||
const cv::Scalar mColorsUV[] = { cv::Scalar(84, 255), cv::Scalar(43, 21), cv::Scalar(255, 107) };
|
||||
|
||||
cv::Mat OutputY(m_imageHeightInPixels, m_imageWidthInPixels, CV_8UC1, pDest, lDestStride);
|
||||
cv::Mat OutputUV(m_imageHeightInPixels/2, m_imageWidthInPixels/2,
|
||||
CV_8UC2, pDest+m_imageHeightInPixels*lDestStride, lDestStride);
|
||||
cv::Mat OutputY(m_imageHeightInPixels, m_imageWidthInPixels, CV_8UC1, pDest, lDestStride);
|
||||
cv::Mat OutputUV(m_imageHeightInPixels/2, m_imageWidthInPixels/2,
|
||||
CV_8UC2, pDest+m_imageHeightInPixels*lDestStride, lDestStride);
|
||||
cv::Mat BgrFrame;
|
||||
|
||||
InputFrame.copyTo(OutputFrame);
|
||||
InputFrame.copyTo(OutputFrame);
|
||||
|
||||
cv::cvtColor(InputFrame, BgrFrame, cv::COLOR_YUV420sp2BGR);
|
||||
int thikness = (int) (BgrFrame.cols / (mHistSizeNum + 10) / 5);
|
||||
@ -1357,18 +1357,18 @@ HRESULT OcvImageManipulations::OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuff
|
||||
cv::normalize(hist, hist, BgrFrame.rows/2, 0, cv::NORM_INF);
|
||||
for(int h=0; h<mHistSizeNum; h++) {
|
||||
cv::Point mP1, mP2;
|
||||
// Draw on Y plane
|
||||
mP1.x = mP2.x = offset + (c * (mHistSizeNum + 10) + h) * thikness;
|
||||
// Draw on Y plane
|
||||
mP1.x = mP2.x = offset + (c * (mHistSizeNum + 10) + h) * thikness;
|
||||
mP1.y = BgrFrame.rows-1;
|
||||
mP2.y = mP1.y - 2 - (int)hist.at<float>(h);
|
||||
cv::line(OutputY, mP1, mP2, mColorsY[c], thikness);
|
||||
cv::line(OutputY, mP1, mP2, mColorsY[c], thikness);
|
||||
|
||||
// Draw on UV planes
|
||||
// Draw on UV planes
|
||||
mP1.x /= 2;
|
||||
mP1.y /= 2;
|
||||
mP2.x /= 2;
|
||||
mP2.x /= 2;
|
||||
mP2.y /= 2;
|
||||
cv::line(OutputUV, mP1, mP2, mColorsUV[c], thikness/2);
|
||||
cv::line(OutputUV, mP1, mP2, mColorsUV[c], thikness/2);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
@ -1426,7 +1426,7 @@ HRESULT OcvImageManipulations::UpdateFormatInfo()
|
||||
}
|
||||
|
||||
// Calculate the image size for YUV NV12 image(not including padding)
|
||||
m_cbImageSize = (m_imageHeightInPixels + m_imageHeightInPixels/2)*m_imageWidthInPixels;
|
||||
m_cbImageSize = (m_imageHeightInPixels + m_imageHeightInPixels/2)*m_imageWidthInPixels;
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -17,7 +17,7 @@
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
namespace Microsoft { namespace Samples {
|
||||
ActivatableClass(OcvImageManipulations);
|
||||
ActivatableClass(OcvImageManipulations);
|
||||
}}
|
||||
|
||||
BOOL WINAPI DllMain( _In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_opt_ LPVOID lpReserved )
|
||||
|
@ -85,21 +85,21 @@ void LayoutAwarePage::DefaultViewModel::set(IObservableMap<String^, Object^>^ va
|
||||
/// <param name="e">Event data describing the conditions that led to the event.</param>
|
||||
void LayoutAwarePage::OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
{
|
||||
this->StartLayoutUpdates(sender, e);
|
||||
this->StartLayoutUpdates(sender, e);
|
||||
|
||||
// Keyboard and mouse navigation only apply when occupying the entire window
|
||||
if (this->ActualHeight == Window::Current->Bounds.Height &&
|
||||
this->ActualWidth == Window::Current->Bounds.Width)
|
||||
{
|
||||
// Listen to the window directly so focus isn't required
|
||||
_acceleratorKeyEventToken = Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated +=
|
||||
ref new TypedEventHandler<CoreDispatcher^, AcceleratorKeyEventArgs^>(this,
|
||||
&LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated);
|
||||
_pointerPressedEventToken = Window::Current->CoreWindow->PointerPressed +=
|
||||
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this,
|
||||
&LayoutAwarePage::CoreWindow_PointerPressed);
|
||||
_navigationShortcutsRegistered = true;
|
||||
}
|
||||
// Keyboard and mouse navigation only apply when occupying the entire window
|
||||
if (this->ActualHeight == Window::Current->Bounds.Height &&
|
||||
this->ActualWidth == Window::Current->Bounds.Width)
|
||||
{
|
||||
// Listen to the window directly so focus isn't required
|
||||
_acceleratorKeyEventToken = Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated +=
|
||||
ref new TypedEventHandler<CoreDispatcher^, AcceleratorKeyEventArgs^>(this,
|
||||
&LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated);
|
||||
_pointerPressedEventToken = Window::Current->CoreWindow->PointerPressed +=
|
||||
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this,
|
||||
&LayoutAwarePage::CoreWindow_PointerPressed);
|
||||
_navigationShortcutsRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -109,13 +109,13 @@ void LayoutAwarePage::OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArg
|
||||
/// <param name="e">Event data describing the conditions that led to the event.</param>
|
||||
void LayoutAwarePage::OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
{
|
||||
if (_navigationShortcutsRegistered)
|
||||
{
|
||||
Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated -= _acceleratorKeyEventToken;
|
||||
Window::Current->CoreWindow->PointerPressed -= _pointerPressedEventToken;
|
||||
_navigationShortcutsRegistered = false;
|
||||
}
|
||||
StopLayoutUpdates(sender, e);
|
||||
if (_navigationShortcutsRegistered)
|
||||
{
|
||||
Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated -= _acceleratorKeyEventToken;
|
||||
Window::Current->CoreWindow->PointerPressed -= _pointerPressedEventToken;
|
||||
_navigationShortcutsRegistered = false;
|
||||
}
|
||||
StopLayoutUpdates(sender, e);
|
||||
}
|
||||
|
||||
#pragma region Navigation support
|
||||
|
Loading…
Reference in New Issue
Block a user