Converted tabs to spaces.

pull/1318/head
Roman Donchenko 11 years ago
parent e9a28f66ee
commit 3c137f7a04
  1. 10
      cmake/checks/win32uitest.cpp
  2. 2
      cmake/checks/winrttest.cpp
  3. 10
      doc/opencv_cheatsheet.tex
  4. 156
      doc/tutorials/core/basic_geometric_drawing/basic_geometric_drawing.rst
  5. 16
      doc/tutorials/features2d/trackingmotion/corner_subpixeles/corner_subpixeles.rst
  6. 26
      doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.rst
  7. 44
      doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.rst
  8. 2
      doc/tutorials/imgproc/histograms/back_projection/back_projection.rst
  9. 84
      doc/tutorials/imgproc/imgtrans/remap/remap.rst
  10. 16
      doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.rst
  11. 18
      doc/tutorials/imgproc/threshold/threshold.rst
  12. 12
      doc/tutorials/introduction/windows_visual_studio_image_watch/windows_visual_studio_image_watch.rst
  13. 6
      doc/tutorials/ios/hello/hello.rst
  14. 166
      doc/tutorials/ios/video_processing/video_processing.rst
  15. 212
      modules/core/src/stat.cpp
  16. 6
      modules/highgui/src/cap_ffmpeg.cpp
  17. 14
      modules/highgui/src/cap_ffmpeg_impl.hpp
  18. 252
      modules/imgproc/src/morph.cpp
  19. 86
      modules/imgproc/src/sumpixels.cpp
  20. 2
      modules/java/android_test/AndroidManifest.xml
  21. 54
      modules/ocl/perf/perf_calib3d.cpp
  22. 48
      modules/ocl/perf/perf_precomp.hpp
  23. 2
      modules/ocl/src/interpolate_frames.cpp
  24. 72
      modules/ocl/src/opencl/objdetect_hog.cl
  25. 76
      modules/ocl/src/opencl/tvl1flow.cl
  26. 2
      modules/ocl/src/stereobp.cpp
  27. 28
      samples/MacOSX/FaceTracker/FaceTracker-Info.plist
  28. 22
      samples/c/build_all.sh
  29. 10
      samples/winrt/ImageManipulations/MediaExtensions/Common/CritSec.h
  30. 6
      samples/winrt/ImageManipulations/MediaExtensions/OcvTransform/OcvImageManipulations.idl
  31. 28
      samples/winrt/ImageManipulations/MediaExtensions/OcvTransform/OcvTransform.cpp
  32. 2
      samples/winrt/ImageManipulations/MediaExtensions/OcvTransform/dllmain.cpp
  33. 44
      samples/winrt/ImageManipulations/common/LayoutAwarePage.cpp

@ -2,10 +2,10 @@
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/, CreateWindow(NULL /*lpClassName*/, NULL /*lpWindowName*/, 0 /*dwStyle*/, 0 /*x*/,
0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/, 0 /*y*/, 0 /*nWidth*/, 0 /*nHeight*/, NULL /*hWndParent*/, NULL /*hMenu*/,
NULL /*hInstance*/, NULL /*lpParam*/); NULL /*hInstance*/, NULL /*lpParam*/);
DeleteDC(NULL); DeleteDC(NULL);
return 0; return 0;
} }

@ -2,5 +2,5 @@
int main(int, char**) int main(int, char**)
{ {
return 0; return 0;
} }

@ -75,11 +75,11 @@
% if using A4 paper. (This probably isn't strictly necessary.) % if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins. % If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}} \ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} } { \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}} {\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} } {\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} } {\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
} }
% Turn off header and footer % Turn off header and footer
% \pagestyle{empty} % \pagestyle{empty}

@ -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 );

@ -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.

@ -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)

@ -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: 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 .. 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*. 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. 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 .. 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). 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: 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 .. 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). 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 .. 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: 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 .. 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. 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: 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 .. 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 .. 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];
} }

@ -455,41 +455,41 @@ cv::Scalar cv::sum( InputArray _src )
int k, cn = src.channels(), depth = src.depth(); int k, cn = src.channels(), depth = src.depth();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total(); size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows); int rows = src.size[0], cols = (int)(total_size/rows);
if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
{ {
IppiSize sz = { cols, rows }; IppiSize sz = { cols, rows };
int type = src.type(); int type = src.type();
typedef IppStatus (CV_STDCALL* ippiSumFunc)(const void*, int, IppiSize, double *, int); typedef IppStatus (CV_STDCALL* ippiSumFunc)(const void*, int, IppiSize, double *, int);
ippiSumFunc ippFunc = ippiSumFunc ippFunc =
type == CV_8UC1 ? (ippiSumFunc)ippiSum_8u_C1R : type == CV_8UC1 ? (ippiSumFunc)ippiSum_8u_C1R :
type == CV_8UC3 ? (ippiSumFunc)ippiSum_8u_C3R : type == CV_8UC3 ? (ippiSumFunc)ippiSum_8u_C3R :
type == CV_8UC4 ? (ippiSumFunc)ippiSum_8u_C4R : type == CV_8UC4 ? (ippiSumFunc)ippiSum_8u_C4R :
type == CV_16UC1 ? (ippiSumFunc)ippiSum_16u_C1R : type == CV_16UC1 ? (ippiSumFunc)ippiSum_16u_C1R :
type == CV_16UC3 ? (ippiSumFunc)ippiSum_16u_C3R : type == CV_16UC3 ? (ippiSumFunc)ippiSum_16u_C3R :
type == CV_16UC4 ? (ippiSumFunc)ippiSum_16u_C4R : type == CV_16UC4 ? (ippiSumFunc)ippiSum_16u_C4R :
type == CV_16SC1 ? (ippiSumFunc)ippiSum_16s_C1R : type == CV_16SC1 ? (ippiSumFunc)ippiSum_16s_C1R :
type == CV_16SC3 ? (ippiSumFunc)ippiSum_16s_C3R : type == CV_16SC3 ? (ippiSumFunc)ippiSum_16s_C3R :
type == CV_16SC4 ? (ippiSumFunc)ippiSum_16s_C4R : type == CV_16SC4 ? (ippiSumFunc)ippiSum_16s_C4R :
type == CV_32FC1 ? (ippiSumFunc)ippiSum_32f_C1R : type == CV_32FC1 ? (ippiSumFunc)ippiSum_32f_C1R :
type == CV_32FC3 ? (ippiSumFunc)ippiSum_32f_C3R : type == CV_32FC3 ? (ippiSumFunc)ippiSum_32f_C3R :
type == CV_32FC4 ? (ippiSumFunc)ippiSum_32f_C4R : type == CV_32FC4 ? (ippiSumFunc)ippiSum_32f_C4R :
0; 0;
if( ippFunc ) if( ippFunc )
{ {
Ipp64f res[4]; Ipp64f res[4];
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 ) if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
{ {
Scalar sc; Scalar sc;
for( int i = 0; i < cn; i++ ) for( int i = 0; i < cn; i++ )
{ {
sc[i] = res[i]; sc[i] = res[i];
} }
return sc; return sc;
} }
} }
} }
#endif #endif
SumFunc func = getSumFunc(depth); SumFunc func = getSumFunc(depth);
@ -567,77 +567,77 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
int k, cn = src.channels(), depth = src.depth(); int k, cn = src.channels(), depth = src.depth();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total(); size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows); 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) ) if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
{ {
IppiSize sz = { cols, rows }; IppiSize sz = { cols, rows };
int type = src.type(); int type = src.type();
if( !mask.empty() ) if( !mask.empty() )
{ {
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *); typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *);
ippiMaskMeanFuncC1 ippFuncC1 = ippiMaskMeanFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR : type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR : type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR : type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
0; 0;
if( ippFuncC1 ) if( ippFuncC1 )
{ {
Ipp64f res; Ipp64f res;
if( ippFuncC1(src.data, src.step[0], mask.data, mask.step[0], sz, &res) >= 0 ) if( ippFuncC1(src.data, src.step[0], mask.data, mask.step[0], sz, &res) >= 0 )
{ {
return Scalar(res); return Scalar(res);
} }
} }
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *); typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *);
ippiMaskMeanFuncC3 ippFuncC3 = ippiMaskMeanFuncC3 ippFuncC3 =
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR : type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR : type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR : type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
0; 0;
if( ippFuncC3 ) if( ippFuncC3 )
{ {
Ipp64f res1, res2, res3; Ipp64f res1, res2, res3;
if( ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 1, &res1) >= 0 && 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, 2, &res2) >= 0 &&
ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 3, &res3) >= 0 ) ippFuncC3(src.data, src.step[0], mask.data, mask.step[0], sz, 3, &res3) >= 0 )
{ {
return Scalar(res1, res2, res3); return Scalar(res1, res2, res3);
} }
} }
} }
else else
{ {
typedef IppStatus (CV_STDCALL* ippiMeanFunc)(const void*, int, IppiSize, double *, int); typedef IppStatus (CV_STDCALL* ippiMeanFunc)(const void*, int, IppiSize, double *, int);
ippiMeanFunc ippFunc = ippiMeanFunc ippFunc =
type == CV_8UC1 ? (ippiMeanFunc)ippiMean_8u_C1R : type == CV_8UC1 ? (ippiMeanFunc)ippiMean_8u_C1R :
type == CV_8UC3 ? (ippiMeanFunc)ippiMean_8u_C3R : type == CV_8UC3 ? (ippiMeanFunc)ippiMean_8u_C3R :
type == CV_8UC4 ? (ippiMeanFunc)ippiMean_8u_C4R : type == CV_8UC4 ? (ippiMeanFunc)ippiMean_8u_C4R :
type == CV_16UC1 ? (ippiMeanFunc)ippiMean_16u_C1R : type == CV_16UC1 ? (ippiMeanFunc)ippiMean_16u_C1R :
type == CV_16UC3 ? (ippiMeanFunc)ippiMean_16u_C3R : type == CV_16UC3 ? (ippiMeanFunc)ippiMean_16u_C3R :
type == CV_16UC4 ? (ippiMeanFunc)ippiMean_16u_C4R : type == CV_16UC4 ? (ippiMeanFunc)ippiMean_16u_C4R :
type == CV_16SC1 ? (ippiMeanFunc)ippiMean_16s_C1R : type == CV_16SC1 ? (ippiMeanFunc)ippiMean_16s_C1R :
type == CV_16SC3 ? (ippiMeanFunc)ippiMean_16s_C3R : type == CV_16SC3 ? (ippiMeanFunc)ippiMean_16s_C3R :
type == CV_16SC4 ? (ippiMeanFunc)ippiMean_16s_C4R : type == CV_16SC4 ? (ippiMeanFunc)ippiMean_16s_C4R :
type == CV_32FC1 ? (ippiMeanFunc)ippiMean_32f_C1R : type == CV_32FC1 ? (ippiMeanFunc)ippiMean_32f_C1R :
type == CV_32FC3 ? (ippiMeanFunc)ippiMean_32f_C3R : type == CV_32FC3 ? (ippiMeanFunc)ippiMean_32f_C3R :
type == CV_32FC4 ? (ippiMeanFunc)ippiMean_32f_C4R : type == CV_32FC4 ? (ippiMeanFunc)ippiMean_32f_C4R :
0; 0;
if( ippFunc ) if( ippFunc )
{ {
Ipp64f res[4]; Ipp64f res[4];
if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 ) if( ippFunc(src.data, src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
{ {
Scalar sc; Scalar sc;
for( int i = 0; i < cn; i++ ) for( int i = 0; i < cn; i++ )
{ {
sc[i] = res[i]; sc[i] = res[i];
} }
return sc; return sc;
} }
} }
} }
} }
#endif #endif
SumFunc func = getSumFunc(depth); SumFunc func = getSumFunc(depth);

@ -161,7 +161,7 @@ private:
class CvCapture_FFMPEG_proxy : class CvCapture_FFMPEG_proxy :
public CvCapture public CvCapture
{ {
public: public:
CvCapture_FFMPEG_proxy() { ffmpegCapture = 0; } CvCapture_FFMPEG_proxy() { ffmpegCapture = 0; }
@ -186,7 +186,7 @@ public:
if (!ffmpegCapture || if (!ffmpegCapture ||
!icvRetrieveFrame_FFMPEG_p(ffmpegCapture, &data, &step, &width, &height, &cn)) !icvRetrieveFrame_FFMPEG_p(ffmpegCapture, &data, &step, &width, &height, &cn))
return 0; return 0;
cvInitImageHeader(&frame, cvSize(width, height), 8, cn); cvInitImageHeader(&frame, cvSize(width, height), 8, cn);
cvSetData(&frame, data, step); cvSetData(&frame, data, step);
return &frame; return &frame;
@ -225,7 +225,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
} }
class CvVideoWriter_FFMPEG_proxy : class CvVideoWriter_FFMPEG_proxy :
public CvVideoWriter public CvVideoWriter
{ {
public: public:
CvVideoWriter_FFMPEG_proxy() { ffmpegWriter = 0; } CvVideoWriter_FFMPEG_proxy() { ffmpegWriter = 0; }

@ -343,8 +343,8 @@ void CvCapture_FFMPEG::close()
class ImplMutex class ImplMutex
{ {
public: public:
ImplMutex() { init(); } ImplMutex() { init(); }
~ImplMutex() { destroy(); } ~ImplMutex() { destroy(); }
void init(); void init();
void destroy(); void destroy();
@ -447,14 +447,14 @@ struct ImplMutex::Impl
void ImplMutex::init() void ImplMutex::init()
{ {
impl = (Impl*)malloc(sizeof(Impl)); impl = (Impl*)malloc(sizeof(Impl));
impl->init(); impl->init();
} }
void ImplMutex::destroy() void ImplMutex::destroy()
{ {
impl->destroy(); impl->destroy();
free(impl); free(impl);
impl = NULL; impl = NULL;
} }
void ImplMutex::lock() { impl->lock(); } void ImplMutex::lock() { impl->lock(); }
void ImplMutex::unlock() { impl->unlock(); } void ImplMutex::unlock() { impl->unlock(); }

@ -1139,134 +1139,134 @@ private:
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel, const Point &anchor) static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel, const Point &anchor)
{ {
int type = src.type(); int type = src.type();
const Mat* _src = &src; const Mat* _src = &src;
Mat temp; Mat temp;
if( src.data == dst.data ) if( src.data == dst.data )
{ {
src.copyTo(temp); src.copyTo(temp);
_src = &temp; _src = &temp;
} }
//DEPRECATED. Allocates and initializes morphology state structure for erosion or dilation operation. //DEPRECATED. Allocates and initializes morphology state structure for erosion or dilation operation.
typedef IppStatus (CV_STDCALL* ippiMorphologyInitAllocFunc)(int, const void*, IppiSize, IppiPoint, IppiMorphState **); typedef IppStatus (CV_STDCALL* ippiMorphologyInitAllocFunc)(int, const void*, IppiSize, IppiPoint, IppiMorphState **);
ippiMorphologyInitAllocFunc ippInitAllocFunc = ippiMorphologyInitAllocFunc ippInitAllocFunc =
type == CV_8UC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C1R : type == CV_8UC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C1R :
type == CV_8UC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C3R : type == CV_8UC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C3R :
type == CV_8UC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C4R : type == CV_8UC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_8u_C4R :
type == CV_32FC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C1R : type == CV_32FC1 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C1R :
type == CV_32FC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C3R : type == CV_32FC3 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C3R :
type == CV_32FC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C4R : type == CV_32FC4 ? (ippiMorphologyInitAllocFunc)ippiMorphologyInitAlloc_32f_C4R :
0; 0;
typedef IppStatus (CV_STDCALL* ippiMorphologyBorderReplicateFunc)(const void*, int, void *, int, IppiSize, IppiBorderType, IppiMorphState *); typedef IppStatus (CV_STDCALL* ippiMorphologyBorderReplicateFunc)(const void*, int, void *, int, IppiSize, IppiBorderType, IppiMorphState *);
ippiMorphologyBorderReplicateFunc ippFunc = 0; ippiMorphologyBorderReplicateFunc ippFunc = 0;
switch( op ) switch( op )
{ {
case MORPH_DILATE: case MORPH_DILATE:
{ {
ippFunc = ippFunc =
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C1R : type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C1R :
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C3R : type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C3R :
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C4R : type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_8u_C4R :
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C1R : type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C1R :
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C3R : type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C3R :
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C4R : type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiDilateBorderReplicate_32f_C4R :
0; 0;
break; break;
} }
case MORPH_ERODE: case MORPH_ERODE:
{ {
ippFunc = ippFunc =
type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C1R : type == CV_8UC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C1R :
type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C3R : type == CV_8UC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C3R :
type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C4R : type == CV_8UC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_8u_C4R :
type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C1R : type == CV_32FC1 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C1R :
type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C3R : type == CV_32FC3 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C3R :
type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C4R : type == CV_32FC4 ? (ippiMorphologyBorderReplicateFunc)ippiErodeBorderReplicate_32f_C4R :
0; 0;
break; break;
} }
} }
if( ippFunc && ippInitAllocFunc) if( ippFunc && ippInitAllocFunc)
{ {
IppiMorphState* pState; IppiMorphState* pState;
IppiSize roiSize = {src.cols, src.rows}; IppiSize roiSize = {src.cols, src.rows};
IppiSize kernelSize = {kernel.cols, kernel.rows}; IppiSize kernelSize = {kernel.cols, kernel.rows};
IppiPoint point = {anchor.x, anchor.y}; IppiPoint point = {anchor.x, anchor.y};
if( ippInitAllocFunc( roiSize.width, kernel.data, kernelSize, point, &pState ) < 0 ) if( ippInitAllocFunc( roiSize.width, kernel.data, kernelSize, point, &pState ) < 0 )
return false; return false;
bool is_ok = ippFunc( _src->data, _src->step[0], dst.data, dst.step[0], roiSize, ippBorderRepl, pState ) >= 0; bool is_ok = ippFunc( _src->data, _src->step[0], dst.data, dst.step[0], roiSize, ippBorderRepl, pState ) >= 0;
ippiMorphologyFree(pState); ippiMorphologyFree(pState);
return is_ok; return is_ok;
} }
return false; return false;
} }
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst, static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
InputArray _kernel, InputArray _kernel,
const Point &anchor, int iterations, const Point &anchor, int iterations,
int borderType, const Scalar &borderValue) int borderType, const Scalar &borderValue)
{ {
Mat src = _src.getMat(), kernel = _kernel.getMat(); Mat src = _src.getMat(), kernel = _kernel.getMat();
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) || if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) ) !( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|| !( op == MORPH_DILATE || op == MORPH_ERODE) ) || !( op == MORPH_DILATE || op == MORPH_ERODE) )
return false; return false;
if( borderType == cv::BORDER_CONSTANT ) if( borderType == cv::BORDER_CONSTANT )
{ {
int x, y; int x, y;
for( y = 0; y < kernel.rows; y++ ) for( y = 0; y < kernel.rows; y++ )
{ {
if( kernel.at<uchar>(y, anchor.x) != 0 ) if( kernel.at<uchar>(y, anchor.x) != 0 )
continue; continue;
for( x = 0; x < kernel.cols; x++ ) for( x = 0; x < kernel.cols; x++ )
{ {
if( kernel.at<uchar>(y,x) != 0 ) if( kernel.at<uchar>(y,x) != 0 )
return false; return false;
} }
} }
for( x = 0; y < kernel.cols; x++ ) for( x = 0; y < kernel.cols; x++ )
{ {
if( kernel.at<uchar>(anchor.y, x) != 0 ) if( kernel.at<uchar>(anchor.y, x) != 0 )
continue; continue;
for( y = 0; y < kernel.rows; y++ ) for( y = 0; y < kernel.rows; y++ )
{ {
if( kernel.at<uchar>(y,x) != 0 ) if( kernel.at<uchar>(y,x) != 0 )
return false; return false;
} }
} }
} }
Size ksize = kernel.data ? kernel.size() : Size(3,3); Size ksize = kernel.data ? kernel.size() : Size(3,3);
Point normanchor = normalizeAnchor(anchor, ksize); 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() ); _dst.create( src.size(), src.type() );
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
if( iterations == 0 || kernel.rows*kernel.cols == 1 ) if( iterations == 0 || kernel.rows*kernel.cols == 1 )
{ {
src.copyTo(dst); src.copyTo(dst);
return true; return true;
} }
if( !kernel.data ) if( !kernel.data )
{ {
kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2)); kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2));
normanchor = Point(iterations, iterations); normanchor = Point(iterations, iterations);
iterations = 1; iterations = 1;
} }
else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols ) else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols )
{ {
normanchor = Point(normanchor.x*iterations, normanchor.y*iterations); normanchor = Point(normanchor.x*iterations, normanchor.y*iterations);
kernel = getStructuringElement(MORPH_RECT, kernel = getStructuringElement(MORPH_RECT,
Size(ksize.width + (iterations-1)*(ksize.width-1), Size(ksize.width + (iterations-1)*(ksize.width-1),
ksize.height + (iterations-1)*(ksize.height-1)), ksize.height + (iterations-1)*(ksize.height-1)),
normanchor); normanchor);
iterations = 1; iterations = 1;
} }
return IPPMorphReplicate( op, src, dst, kernel, normanchor ); return IPPMorphReplicate( op, src, dst, kernel, normanchor );
} }
#endif #endif
@ -1277,8 +1277,8 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
{ {
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if( IPPMorphOp(op, _src, _dst, _kernel, anchor, iterations, borderType, borderValue) ) if( IPPMorphOp(op, _src, _dst, _kernel, anchor, iterations, borderType, borderValue) )
return; return;
#endif #endif
Mat src = _src.getMat(), kernel = _kernel.getMat(); 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); sdepth = CV_MAT_DEPTH(sdepth);
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if( ( depth == CV_8U ) && ( !_tilted.needed() ) ) if( ( depth == CV_8U ) && ( !_tilted.needed() ) )
{ {
if( sdepth == CV_32F ) if( sdepth == CV_32F )
{ {
if( cn == 1 ) if( cn == 1 )
{ {
IppiSize srcRoiSize = ippiSize( src.cols, src.rows ); IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) ); _sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
sum = _sum.getMat(); sum = _sum.getMat();
if( _sqsum.needed() ) if( _sqsum.needed() )
{ {
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) ); _sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
sqsum = _sqsum.getMat(); 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 ); ippiSqrIntegral_8u32f64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
} }
else else
{ {
ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, srcRoiSize, 0 ); ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32f*)sum.data, sum.step, srcRoiSize, 0 );
} }
return; return;
} }
} }
if( sdepth == CV_32S ) if( sdepth == CV_32S )
{ {
if( cn == 1 ) if( cn == 1 )
{ {
IppiSize srcRoiSize = ippiSize( src.cols, src.rows ); IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
_sum.create( isize, CV_MAKETYPE( sdepth, cn ) ); _sum.create( isize, CV_MAKETYPE( sdepth, cn ) );
sum = _sum.getMat(); sum = _sum.getMat();
if( _sqsum.needed() ) if( _sqsum.needed() )
{ {
_sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) ); _sqsum.create( isize, CV_MAKETYPE( CV_64F, cn ) );
sqsum = _sqsum.getMat(); 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 ); ippiSqrIntegral_8u32s64f_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, (Ipp64f*)sqsum.data, sqsum.step, srcRoiSize, 0, 0 );
} }
else else
{ {
ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, srcRoiSize, 0 ); ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, src.step, (Ipp32s*)sum.data, sum.step, srcRoiSize, 0 );
} }
return; return;
} }
} }
} }
#endif #endif
_sum.create( isize, CV_MAKETYPE(sdepth, cn) ); _sum.create( isize, CV_MAKETYPE(sdepth, cn) );

@ -4,7 +4,7 @@
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> 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 <!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library, this package needs to link against the android.test library,

@ -48,45 +48,45 @@
///////////// StereoMatchBM //////////////////////// ///////////// StereoMatchBM ////////////////////////
PERFTEST(StereoMatchBM) PERFTEST(StereoMatchBM)
{ {
Mat left_image = imread(abspath("aloeL.jpg"), cv::IMREAD_GRAYSCALE); Mat left_image = imread(abspath("aloeL.jpg"), cv::IMREAD_GRAYSCALE);
Mat right_image = imread(abspath("aloeR.jpg"), cv::IMREAD_GRAYSCALE); Mat right_image = imread(abspath("aloeR.jpg"), cv::IMREAD_GRAYSCALE);
Mat disp,dst; Mat disp,dst;
ocl::oclMat d_left, d_right,d_disp; ocl::oclMat d_left, d_right,d_disp;
int n_disp= 128; int n_disp= 128;
int winSize =19; 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); StereoBM bm(0, n_disp, winSize);
bm(left_image, right_image, dst); bm(left_image, right_image, dst);
CPU_ON; CPU_ON;
bm(left_image, right_image, dst); bm(left_image, right_image, dst);
CPU_OFF; CPU_OFF;
d_left.upload(left_image); d_left.upload(left_image);
d_right.upload(right_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; WARMUP_ON;
d_bm(d_left, d_right, d_disp); d_bm(d_left, d_right, d_disp);
WARMUP_OFF; WARMUP_OFF;
cv::Mat ocl_mat; cv::Mat ocl_mat;
d_disp.download(ocl_mat); d_disp.download(ocl_mat);
ocl_mat.convertTo(ocl_mat, dst.type()); ocl_mat.convertTo(ocl_mat, dst.type());
GPU_ON; GPU_ON;
d_bm(d_left, d_right, d_disp); d_bm(d_left, d_right, d_disp);
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
d_left.upload(left_image); d_left.upload(left_image);
d_right.upload(right_image); d_right.upload(right_image);
d_bm(d_left, d_right, d_disp); d_bm(d_left, d_right, d_disp);
d_disp.download(disp); d_disp.download(disp);
GPU_FULL_OFF; GPU_FULL_OFF;
TestSystem::instance().setAccurate(-1, 0.); TestSystem::instance().setAccurate(-1, 0.);
} }

@ -463,51 +463,51 @@ private:
#define GLOBAL_INIT(name) \ #define GLOBAL_INIT(name) \
struct name##_init: Runnable { \ struct name##_init: Runnable { \
name##_init(): Runnable(#name) { \ name##_init(): Runnable(#name) { \
TestSystem::instance().addInit(this); \ TestSystem::instance().addInit(this); \
} \ } \
void run(); \ void run(); \
} name##_init_instance; \ } name##_init_instance; \
void name##_init::run() void name##_init::run()
#define PERFTEST(name) \ #define PERFTEST(name) \
struct name##_test: Runnable { \ struct name##_test: Runnable { \
name##_test(): Runnable(#name) { \ name##_test(): Runnable(#name) { \
TestSystem::instance().addTest(this); \ TestSystem::instance().addTest(this); \
} \ } \
void run(); \ void run(); \
} name##_test_instance; \ } name##_test_instance; \
void name##_test::run() void name##_test::run()
#define SUBTEST TestSystem::instance().startNewSubtest() #define SUBTEST TestSystem::instance().startNewSubtest()
#define CPU_ON \ #define CPU_ON \
while (!TestSystem::instance().cpu_stop()) { \ while (!TestSystem::instance().cpu_stop()) { \
TestSystem::instance().cpuOn() TestSystem::instance().cpuOn()
#define CPU_OFF \ #define CPU_OFF \
TestSystem::instance().cpuOff(); \ TestSystem::instance().cpuOff(); \
} TestSystem::instance().cpuComplete() } TestSystem::instance().cpuComplete()
#define GPU_ON \ #define GPU_ON \
while (!TestSystem::instance().stop()) { \ while (!TestSystem::instance().stop()) { \
TestSystem::instance().gpuOn() TestSystem::instance().gpuOn()
#define GPU_OFF \ #define GPU_OFF \
ocl::finish();\ ocl::finish();\
TestSystem::instance().gpuOff(); \ TestSystem::instance().gpuOff(); \
} TestSystem::instance().gpuComplete() } TestSystem::instance().gpuComplete()
#define GPU_FULL_ON \ #define GPU_FULL_ON \
while (!TestSystem::instance().stop()) { \ while (!TestSystem::instance().stop()) { \
TestSystem::instance().gpufullOn() TestSystem::instance().gpufullOn()
#define GPU_FULL_OFF \ #define GPU_FULL_OFF \
TestSystem::instance().gpufullOff(); \ TestSystem::instance().gpufullOff(); \
} TestSystem::instance().gpufullComplete() } TestSystem::instance().gpufullComplete()
#define WARMUP_ON \ #define WARMUP_ON \
while (!TestSystem::instance().warmupStop()) { while (!TestSystem::instance().warmupStop()) {
#define WARMUP_OFF \ #define WARMUP_OFF \
ocl::finish();\ ocl::finish();\
} TestSystem::instance().warmupComplete() } TestSystem::instance().warmupComplete()
#endif #endif

@ -234,5 +234,5 @@ void interpolate::bindImgTex(const oclMat &img, cl_mem &texture)
{ {
openCLFree(texture); openCLFree(texture);
} }
texture = bindTexture(img); texture = bindTexture(img);
} }

@ -318,15 +318,15 @@ __kernel void classify_hists_180_kernel(
volatile __local float* smem = products; volatile __local float* smem = products;
#ifdef CPU #ifdef CPU
if (tid < 13) smem[tid] = product = product + smem[tid + 32]; 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]; if (tid < 16) smem[tid] = product = product + smem[tid + 16];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<8) smem[tid] = product = product + smem[tid + 8]; if(tid<8) smem[tid] = product = product + smem[tid + 8];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<4) smem[tid] = product = product + smem[tid + 4]; if(tid<4) smem[tid] = product = product + smem[tid + 4];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<2) smem[tid] = product = product + smem[tid + 2]; if(tid<2) smem[tid] = product = product + smem[tid + 2];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#else #else
if (tid < 13) if (tid < 13)
{ {
@ -345,9 +345,9 @@ __kernel void classify_hists_180_kernel(
#endif #endif
if (tid == 0){ if (tid == 0){
product = product + smem[tid + 1]; product = product + smem[tid + 1];
labels[gidY * img_win_width + gidX] = (product + free_coef >= threshold); 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]; if (tid < 64) products[tid] = product = product + products[tid + 64];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
volatile __local float* smem = products; volatile __local float* smem = products;
#ifdef CPU #ifdef CPU
if(tid<32) smem[tid] = product = product + smem[tid + 32]; if(tid<32) 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]; if(tid<16) smem[tid] = product = product + smem[tid + 16];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<8) smem[tid] = product = product + smem[tid + 8]; if(tid<8) smem[tid] = product = product + smem[tid + 8];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<4) smem[tid] = product = product + smem[tid + 4]; if(tid<4) smem[tid] = product = product + smem[tid + 4];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<2) smem[tid] = product = product + smem[tid + 2]; if(tid<2) smem[tid] = product = product + smem[tid + 2];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#else #else
if (tid < 32) if (tid < 32)
{ {
@ -415,9 +415,9 @@ __kernel void classify_hists_252_kernel(
} }
#endif #endif
if (tid == 0){ if (tid == 0){
product = product + smem[tid + 1]; product = product + smem[tid + 1];
labels[gidY * img_win_width + gidX] = (product + free_coef >= threshold); 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]; if (tid < 64) products[tid] = product = product + products[tid + 64];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
volatile __local float* smem = products; volatile __local float* smem = products;
#ifdef CPU #ifdef CPU
if(tid<32) smem[tid] = product = product + smem[tid + 32]; if(tid<32) 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]; if(tid<16) smem[tid] = product = product + smem[tid + 16];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<8) smem[tid] = product = product + smem[tid + 8]; if(tid<8) smem[tid] = product = product + smem[tid + 8];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<4) smem[tid] = product = product + smem[tid + 4]; if(tid<4) smem[tid] = product = product + smem[tid + 4];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
if(tid<2) smem[tid] = product = product + smem[tid + 2]; if(tid<2) smem[tid] = product = product + smem[tid + 2];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#else #else
if (tid < 32) if (tid < 32)
{ {
@ -485,9 +485,9 @@ __kernel void classify_hists_kernel(
} }
#endif #endif
if (tid == 0){ 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); 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)) if((x < src_col)&&(y < src_row))
{ {
int src_x1 = (x + 1) < (src_col -1)? (x + 1) : (src_col - 1); int src_x1 = (x + 1) < (src_col -1)? (x + 1) : (src_col - 1);
int src_x2 = (x - 1) > 0 ? (x -1) : 0; int src_x2 = (x - 1) > 0 ? (x -1) : 0;
//if(src[y * src_step + src_x1] == src[y * src_step+ src_x2]) //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]); 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; 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]); 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, __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* u1, int u1_step,
__global const float* u2, __global const float* u2,
__global float* I1w, __global float* I1w,
__global float* I1wx, /*int I1wx_step,*/ __global float* I1wx, /*int I1wx_step,*/
__global float* I1wy, /*int I1wy_step,*/ __global float* I1wy, /*int I1wy_step,*/
__global float* grad, /*int grad_step,*/ __global float* grad, /*int grad_step,*/
__global float* rho, __global float* rho,
int I1w_step, int I1w_step,
int u2_step, int u2_step,
int u1_offset_x, int u1_offset_x,
int u1_offset_y, int u1_offset_y,
int u2_offset_x, int u2_offset_x,
int u2_offset_y) int u2_offset_y)
{ {
const int x = get_global_id(0); const int x = get_global_id(0);
const int y = get_global_id(1); 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); const float w = bicubicCoeff(wx - cx) * bicubicCoeff(wy - cy);
//sum += w * tex2D(tex_I1 , cx, 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; sum += w * read_imagef(tex_I1, sampleri, cood).x;
//sumx += w * tex2D(tex_I1x, cx, cy); //sumx += w * tex2D(tex_I1x, cx, cy);
sumx += w * read_imagef(tex_I1x, sampleri, cood).x; 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, __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* u1, int u1_step,
__global const float* u2, __global const float* u2,
__global float* I1w, __global float* I1w,
__global float* I1wx, /*int I1wx_step,*/ __global float* I1wx, /*int I1wx_step,*/
__global float* I1wy, /*int I1wy_step,*/ __global float* I1wy, /*int I1wy_step,*/
__global float* grad, /*int grad_step,*/ __global float* grad, /*int grad_step,*/
__global float* rho, __global float* rho,
int I1w_step, int I1w_step,
int u2_step, int u2_step,
int I1_step, int I1_step,
int I1x_step) int I1x_step)
{ {
const int x = get_global_id(0); const int x = get_global_id(0);
const int y = get_global_id(1); 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); 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); 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); 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); 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* p21,
__global float* p22, __global float* p22,
const float taut, const float taut,
int u2_step, int u2_step,
int u1_offset_x, int u1_offset_x,
int u1_offset_y, int u1_offset_y,
int u2_offset_x, int u2_offset_x,
int u2_offset_y) int u2_offset_y)
{ {
//const int x = blockIdx.x * blockDim.x + threadIdx.x; //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) 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]; 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]; 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]; 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 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); 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* u1, int u1_step,
__global float* u2, __global float* u2,
__global float* error, const float l_t, const float theta, int u2_step, __global float* error, const float l_t, const float theta, int u2_step,
int u1_offset_x, int u1_offset_x,
int u1_offset_y, int u1_offset_y,
int u2_offset_x, int u2_offset_x,
int u2_offset_y) int u2_offset_y)
{ {
//const int x = blockIdx.x * blockDim.x + threadIdx.x; //const int x = blockIdx.x * blockDim.x + threadIdx.x;

@ -112,7 +112,7 @@ namespace cv
///////////////////////////comp data//////////////////////////////////////// ///////////////////////////comp data////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
static void comp_data_call(const oclMat &left, const oclMat &right, oclMat &data, int /*disp*/, 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; Context *clCxt = left.clCxt;
int channels = left.oclchannels(); 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"> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>de.rwth-aachen.ient.FaceTracker</string> <string>de.rwth-aachen.ient.FaceTracker</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
</dict> </dict>
</plist> </plist>

@ -1,16 +1,16 @@
#!/bin/sh #!/bin/sh
if [ $# -gt 0 ] ; then if [ $# -gt 0 ] ; then
base=`basename $1 .c` base=`basename $1 .c`
echo "compiling $base" echo "compiling $base"
gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base
else else
for i in *.c; do for i in *.c; do
echo "compiling $i" echo "compiling $i"
gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`; gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
done done
for i in *.cpp; do for i in *.cpp; do
echo "compiling $i" echo "compiling $i"
g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`; g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
done done
fi fi

@ -20,13 +20,13 @@ public:
DeleteCriticalSection(&m_criticalSection); DeleteCriticalSection(&m_criticalSection);
} }
_Acquires_lock_(m_criticalSection) _Acquires_lock_(m_criticalSection)
void Lock() void Lock()
{ {
EnterCriticalSection(&m_criticalSection); EnterCriticalSection(&m_criticalSection);
} }
_Releases_lock_(m_criticalSection) _Releases_lock_(m_criticalSection)
void Unlock() void Unlock()
{ {
LeaveCriticalSection(&m_criticalSection); LeaveCriticalSection(&m_criticalSection);
@ -47,16 +47,16 @@ class AutoLock
private: private:
CritSec *m_pCriticalSection; CritSec *m_pCriticalSection;
public: public:
_Acquires_lock_(m_pCriticalSection) _Acquires_lock_(m_pCriticalSection)
AutoLock(CritSec& crit) AutoLock(CritSec& crit)
{ {
m_pCriticalSection = &crit; m_pCriticalSection = &crit;
m_pCriticalSection->Lock(); m_pCriticalSection->Lock();
} }
_Releases_lock_(m_pCriticalSection) _Releases_lock_(m_pCriticalSection)
~AutoLock() ~AutoLock()
{ {
m_pCriticalSection->Unlock(); m_pCriticalSection->Unlock();
} }
}; };

@ -4,8 +4,8 @@ import "Windows.Media.idl";
namespace OcvTransform namespace OcvTransform
{ {
[version(NTDDI_WIN8)] [version(NTDDI_WIN8)]
runtimeclass OcvImageManipulations 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. // 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 baseRabge[] = {0.f,256.f};
const float* ranges[] = {baseRabge}; const float* ranges[] = {baseRabge};
const cv::Scalar mColorsY[] = { cv::Scalar(76), cv::Scalar(149), cv::Scalar(29) }; 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 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 OutputY(m_imageHeightInPixels, m_imageWidthInPixels, CV_8UC1, pDest, lDestStride);
cv::Mat OutputUV(m_imageHeightInPixels/2, m_imageWidthInPixels/2, cv::Mat OutputUV(m_imageHeightInPixels/2, m_imageWidthInPixels/2,
CV_8UC2, pDest+m_imageHeightInPixels*lDestStride, lDestStride); CV_8UC2, pDest+m_imageHeightInPixels*lDestStride, lDestStride);
cv::Mat BgrFrame; cv::Mat BgrFrame;
InputFrame.copyTo(OutputFrame); InputFrame.copyTo(OutputFrame);
cv::cvtColor(InputFrame, BgrFrame, cv::COLOR_YUV420sp2BGR); cv::cvtColor(InputFrame, BgrFrame, cv::COLOR_YUV420sp2BGR);
int thikness = (int) (BgrFrame.cols / (mHistSizeNum + 10) / 5); 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); cv::normalize(hist, hist, BgrFrame.rows/2, 0, cv::NORM_INF);
for(int h=0; h<mHistSizeNum; h++) { for(int h=0; h<mHistSizeNum; h++) {
cv::Point mP1, mP2; cv::Point mP1, mP2;
// Draw on Y plane // Draw on Y plane
mP1.x = mP2.x = offset + (c * (mHistSizeNum + 10) + h) * thikness; mP1.x = mP2.x = offset + (c * (mHistSizeNum + 10) + h) * thikness;
mP1.y = BgrFrame.rows-1; mP1.y = BgrFrame.rows-1;
mP2.y = mP1.y - 2 - (int)hist.at<float>(h); 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.x /= 2;
mP1.y /= 2; mP1.y /= 2;
mP2.x /= 2; mP2.x /= 2;
mP2.y /= 2; mP2.y /= 2;
cv::line(OutputUV, mP1, mP2, mColorsUV[c], thikness/2); cv::line(OutputUV, mP1, mP2, mColorsUV[c], thikness/2);
} }
} }
} break; } break;
@ -1426,7 +1426,7 @@ HRESULT OcvImageManipulations::UpdateFormatInfo()
} }
// Calculate the image size for YUV NV12 image(not including padding) // 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: done:

@ -17,7 +17,7 @@
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
namespace Microsoft { namespace Samples { namespace Microsoft { namespace Samples {
ActivatableClass(OcvImageManipulations); ActivatableClass(OcvImageManipulations);
}} }}
BOOL WINAPI DllMain( _In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_opt_ LPVOID lpReserved ) 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> /// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 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 // Keyboard and mouse navigation only apply when occupying the entire window
if (this->ActualHeight == Window::Current->Bounds.Height && if (this->ActualHeight == Window::Current->Bounds.Height &&
this->ActualWidth == Window::Current->Bounds.Width) this->ActualWidth == Window::Current->Bounds.Width)
{ {
// Listen to the window directly so focus isn't required // Listen to the window directly so focus isn't required
_acceleratorKeyEventToken = Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated += _acceleratorKeyEventToken = Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated +=
ref new TypedEventHandler<CoreDispatcher^, AcceleratorKeyEventArgs^>(this, ref new TypedEventHandler<CoreDispatcher^, AcceleratorKeyEventArgs^>(this,
&LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated); &LayoutAwarePage::CoreDispatcher_AcceleratorKeyActivated);
_pointerPressedEventToken = Window::Current->CoreWindow->PointerPressed += _pointerPressedEventToken = Window::Current->CoreWindow->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this,
&LayoutAwarePage::CoreWindow_PointerPressed); &LayoutAwarePage::CoreWindow_PointerPressed);
_navigationShortcutsRegistered = true; _navigationShortcutsRegistered = true;
} }
} }
/// <summary> /// <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> /// <param name="e">Event data describing the conditions that led to the event.</param>
void LayoutAwarePage::OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) void LayoutAwarePage::OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{ {
if (_navigationShortcutsRegistered) if (_navigationShortcutsRegistered)
{ {
Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated -= _acceleratorKeyEventToken; Window::Current->CoreWindow->Dispatcher->AcceleratorKeyActivated -= _acceleratorKeyEventToken;
Window::Current->CoreWindow->PointerPressed -= _pointerPressedEventToken; Window::Current->CoreWindow->PointerPressed -= _pointerPressedEventToken;
_navigationShortcutsRegistered = false; _navigationShortcutsRegistered = false;
} }
StopLayoutUpdates(sender, e); StopLayoutUpdates(sender, e);
} }
#pragma region Navigation support #pragma region Navigation support

Loading…
Cancel
Save