Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin 2018-08-20 19:29:39 +03:00
commit 7d4bb9428b
83 changed files with 1428 additions and 990 deletions

View File

@ -1,6 +1,9 @@
Changing the contrast and brightness of an image! {#tutorial_basic_linear_transform}
=================================================
@prev_tutorial{tutorial_adding_images}
@next_tutorial{tutorial_discrete_fourier_transform}
Goal
----

View File

@ -1,7 +1,7 @@
Discrete Fourier Transform {#tutorial_discrete_fourier_transform}
==========================
@prev_tutorial{tutorial_random_generator_and_text}
@prev_tutorial{tutorial_basic_linear_transform}
@next_tutorial{tutorial_file_input_output_with_xml_yml}
Goal

View File

@ -1,6 +1,9 @@
File Input and Output using XML and YAML files {#tutorial_file_input_output_with_xml_yml}
==============================================
@prev_tutorial{tutorial_discrete_fourier_transform}
@next_tutorial{tutorial_interoperability_with_OpenCV_1}
Goal
----

View File

@ -1,6 +1,9 @@
How to scan images, lookup tables and time measurement with OpenCV {#tutorial_how_to_scan_images}
==================================================================
@prev_tutorial{tutorial_mat_the_basic_image_container}
@next_tutorial{tutorial_mat_mask_operations}
Goal
----

View File

@ -1,6 +1,8 @@
How to use the OpenCV parallel_for_ to parallelize your code {#tutorial_how_to_use_OpenCV_parallel_for_}
==================================================================
@prev_tutorial{tutorial_how_to_use_ippa_conversion}
Goal
----

View File

@ -1,6 +1,9 @@
Intel® IPP Asynchronous C/C++ library in OpenCV {#tutorial_how_to_use_ippa_conversion}
===============================================
@prev_tutorial{tutorial_interoperability_with_OpenCV_1}
@next_tutorial{tutorial_how_to_use_OpenCV_parallel_for_}
Goal
----

View File

@ -1,6 +1,9 @@
Interoperability with OpenCV 1 {#tutorial_interoperability_with_OpenCV_1}
==============================
@prev_tutorial{tutorial_file_input_output_with_xml_yml}
@next_tutorial{tutorial_how_to_use_ippa_conversion}
Goal
----

View File

@ -1,6 +1,9 @@
Operations with images {#tutorial_mat_operations}
======================
@prev_tutorial{tutorial_mat_mask_operations}
@next_tutorial{tutorial_adding_images}
Input/Output
------------

View File

@ -1,6 +1,8 @@
Mat - The Basic Image Container {#tutorial_mat_the_basic_image_container}
===============================
@next_tutorial{tutorial_how_to_scan_images}
Goal
----

View File

@ -62,24 +62,6 @@ understanding how to manipulate the images on a pixel level.
We will learn how to change our image appearance!
- @subpage tutorial_basic_geometric_drawing
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will learn how to draw simple geometry with OpenCV!
- @subpage tutorial_random_generator_and_text
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will draw some *fancy-looking* stuff using OpenCV!
- @subpage tutorial_discrete_fourier_transform
*Languages:* C++, Java, Python

View File

@ -1,7 +1,6 @@
Basic Drawing {#tutorial_basic_geometric_drawing}
=============
@prev_tutorial{tutorial_basic_linear_transform}
@next_tutorial{tutorial_random_generator_and_text}
Goals
@ -82,20 +81,20 @@ Code
@add_toggle_cpp
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp)
@include samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp)
@include samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp
@end_toggle
@add_toggle_java
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java)
@include samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java)
@include samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java
@end_toggle
@add_toggle_python
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py)
@include samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py)
@include samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py
@end_toggle
Explanation
@ -104,42 +103,42 @@ Explanation
Since we plan to draw two examples (an atom and a rook), we have to create two images and two
windows to display them.
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp create_images
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp create_images
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java create_images
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java create_images
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py create_images
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py create_images
@end_toggle
We created functions to draw different geometric shapes. For instance, to draw the atom we used
**MyEllipse** and **MyFilledCircle**:
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp draw_atom
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp draw_atom
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java draw_atom
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java draw_atom
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py draw_atom
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py draw_atom
@end_toggle
And to draw the rook we employed **MyLine**, **rectangle** and a **MyPolygon**:
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp draw_rook
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp draw_rook
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java draw_rook
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java draw_rook
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py draw_rook
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py draw_rook
@end_toggle
@ -149,15 +148,15 @@ Let's check what is inside each of these functions:
<H4>MyLine</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_line
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_line
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_line
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_line
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_line
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_line
@end_toggle
- As we can see, **MyLine** just call the function **line()** , which does the following:
@ -170,15 +169,15 @@ Let's check what is inside each of these functions:
<H4>MyEllipse</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_ellipse
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_ellipse
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_ellipse
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_ellipse
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_ellipse
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_ellipse
@end_toggle
- From the code above, we can observe that the function **ellipse()** draws an ellipse such
@ -194,15 +193,15 @@ Let's check what is inside each of these functions:
<H4>MyFilledCircle</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_filled_circle
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_filled_circle
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_filled_circle
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_filled_circle
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_filled_circle
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_filled_circle
@end_toggle
- Similar to the ellipse function, we can observe that *circle* receives as arguments:
@ -215,15 +214,15 @@ Let's check what is inside each of these functions:
<H4>MyPolygon</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_polygon
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_polygon
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_polygon
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_polygon
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_polygon
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_polygon
@end_toggle
- To draw a filled polygon we use the function **fillPoly()** . We note that:
@ -235,15 +234,15 @@ Let's check what is inside each of these functions:
<H4>rectangle</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp rectangle
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp rectangle
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py rectangle
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py rectangle
@end_toggle
- Finally we have the @ref cv::rectangle function (we did not create a special function for

View File

@ -1,6 +1,9 @@
Eroding and Dilating {#tutorial_erosion_dilatation}
====================
@prev_tutorial{tutorial_gausian_median_blur_bilateral_filter}
@next_tutorial{tutorial_opening_closing_hats}
Goal
----

View File

@ -1,6 +1,7 @@
Smoothing Images {#tutorial_gausian_median_blur_bilateral_filter}
================
@prev_tutorial{tutorial_random_generator_and_text}
@next_tutorial{tutorial_erosion_dilatation}
Goal

View File

@ -1,6 +1,9 @@
Back Projection {#tutorial_back_projection}
===============
@prev_tutorial{tutorial_histogram_comparison}
@next_tutorial{tutorial_template_matching}
Goal
----

View File

@ -1,6 +1,9 @@
Histogram Calculation {#tutorial_histogram_calculation}
=====================
@prev_tutorial{tutorial_histogram_equalization}
@next_tutorial{tutorial_histogram_comparison}
Goal
----

View File

@ -1,6 +1,9 @@
Histogram Comparison {#tutorial_histogram_comparison}
====================
@prev_tutorial{tutorial_histogram_calculation}
@next_tutorial{tutorial_back_projection}
Goal
----

View File

@ -1,6 +1,9 @@
Histogram Equalization {#tutorial_histogram_equalization}
======================
@prev_tutorial{tutorial_warp_affine}
@next_tutorial{tutorial_histogram_calculation}
Goal
----

View File

@ -1,6 +1,9 @@
Canny Edge Detector {#tutorial_canny_detector}
===================
@prev_tutorial{tutorial_laplace_operator}
@next_tutorial{tutorial_hough_lines}
Goal
----

View File

@ -1,6 +1,9 @@
Image Segmentation with Distance Transform and Watershed Algorithm {#tutorial_distance_transform}
=============
@prev_tutorial{tutorial_point_polygon_test}
@next_tutorial{tutorial_out_of_focus_deblur_filter}
Goal
----

View File

@ -1,6 +1,9 @@
Remapping {#tutorial_remap}
=========
@prev_tutorial{tutorial_hough_circle}
@next_tutorial{tutorial_warp_affine}
Goal
----

View File

@ -1,6 +1,9 @@
Affine Transformations {#tutorial_warp_affine}
======================
@prev_tutorial{tutorial_remap}
@next_tutorial{tutorial_histogram_equalization}
Goal
----

View File

@ -1,6 +1,9 @@
More Morphology Transformations {#tutorial_opening_closing_hats}
===============================
@prev_tutorial{tutorial_erosion_dilatation}
@next_tutorial{tutorial_hitOrMiss}
Goal
----

View File

@ -1,6 +1,8 @@
Out-of-focus Deblur Filter {#tutorial_out_of_focus_deblur_filter}
==========================
@prev_tutorial{tutorial_distance_transform}
Goal
----

View File

@ -1,6 +1,9 @@
Random generator and text with OpenCV {#tutorial_random_generator_and_text}
=====================================
@prev_tutorial{tutorial_basic_geometric_drawing}
@next_tutorial{tutorial_gausian_median_blur_bilateral_filter}
Goals
-----

View File

@ -1,6 +1,9 @@
Creating Bounding boxes and circles for contours {#tutorial_bounding_rects_circles}
================================================
@prev_tutorial{tutorial_hull}
@next_tutorial{tutorial_bounding_rotated_ellipses}
Goal
----

View File

@ -1,6 +1,9 @@
Creating Bounding rotated boxes and ellipses for contours {#tutorial_bounding_rotated_ellipses}
=========================================================
@prev_tutorial{tutorial_bounding_rects_circles}
@next_tutorial{tutorial_moments}
Goal
----

View File

@ -1,6 +1,9 @@
Finding contours in your image {#tutorial_find_contours}
==============================
@prev_tutorial{tutorial_template_matching}
@next_tutorial{tutorial_hull}
Goal
----

View File

@ -1,6 +1,9 @@
Convex Hull {#tutorial_hull}
===========
@prev_tutorial{tutorial_find_contours}
@next_tutorial{tutorial_bounding_rects_circles}
Goal
----

View File

@ -1,6 +1,9 @@
Image Moments {#tutorial_moments}
=============
@prev_tutorial{tutorial_bounding_rotated_ellipses}
@next_tutorial{tutorial_point_polygon_test}
Goal
----

View File

@ -1,6 +1,9 @@
Point Polygon Test {#tutorial_point_polygon_test}
==================
@prev_tutorial{tutorial_moments}
@next_tutorial{tutorial_distance_transform}
Goal
----

View File

@ -3,6 +3,24 @@ Image Processing (imgproc module) {#tutorial_table_of_content_imgproc}
In this section you will learn about the image processing (manipulation) functions inside OpenCV.
- @subpage tutorial_basic_geometric_drawing
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will learn how to draw simple geometry with OpenCV!
- @subpage tutorial_random_generator_and_text
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will draw some *fancy-looking* stuff using OpenCV!
- @subpage tutorial_gausian_median_blur_bilateral_filter
*Languages:* C++, Java, Python

View File

@ -1,6 +1,9 @@
Basic Thresholding Operations {#tutorial_threshold}
=============================
@prev_tutorial{tutorial_pyramids}
@next_tutorial{tutorial_threshold_inRange}
Goal
----

View File

@ -1,6 +1,9 @@
Thresholding Operations using inRange {#tutorial_threshold_inRange}
=====================================
@prev_tutorial{tutorial_threshold}
@next_tutorial{tutorial_filter_2d}
Goal
----

View File

@ -24,17 +24,7 @@ Explanation
The most important code part is:
@code{.cpp}
Mat pano;
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
@endcode
@snippet cpp/stitching.cpp stitching
A new instance of stitcher is created and the @ref cv::Stitcher::stitch will
do all the hard work.

View File

@ -15,7 +15,7 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_core
Here you will learn
the about the basic building blocks of this library. A must read for understanding how
about the basic building blocks of this library. A must read for understanding how
to manipulate the images on a pixel level.
- @subpage tutorial_table_of_content_imgproc

View File

@ -118,7 +118,7 @@ v = f_y*y'' + c_y
tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
coefficients. Higher-order coefficients are not considered in OpenCV.
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$ and pincushion distortion (typically \f$ k_1 < 0 \f$).
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$) and pincushion distortion (typically \f$ k_1 < 0 \f$).
![](pics/distortion_examples.png)
@ -307,11 +307,11 @@ optimization procedures like calibrateCamera, stereoCalibrate, or solvePnP .
*/
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
/** @example pose_from_homography.cpp
An example program about pose estimation from coplanar points
/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp
An example program about pose estimation from coplanar points
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
/** @brief Finds a perspective transformation between two planes.
@ -526,11 +526,11 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
OutputArray jacobian = noArray(),
double aspectRatio = 0 );
/** @example homography_from_camera_displacement.cpp
An example program about homography from the camera displacement
/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp
An example program about homography from the camera displacement
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
/** @brief Finds an object pose from 3D-2D point correspondences.
@ -1959,11 +1959,11 @@ CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, Out
size_t maxIters = 2000, double confidence = 0.99,
size_t refineIters = 10);
/** @example decompose_homography.cpp
An example program with homography decomposition.
/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp
An example program with homography decomposition.
Check @ref tutorial_homography "the corresponding tutorial" for more details.
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details.
*/
/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

View File

@ -33,9 +33,14 @@ if(CV_TRACE AND HAVE_ITT AND BUILD_ITT)
add_definitions(-DOPENCV_WITH_ITT=1)
endif()
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
file(GLOB_RECURSE module_opencl_hdrs "include/opencv2/${name}/opencl/*")
file(GLOB lib_cuda_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.h")
file(GLOB lib_cuda_hdrs_detail
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.h")
file(GLOB_RECURSE module_opencl_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/opencl/*")
source_group("Include\\Cuda Headers" FILES ${lib_cuda_hdrs})
source_group("Include\\Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})

View File

@ -273,9 +273,11 @@ of p and len.
*/
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
/** @example copyMakeBorder_demo.cpp
An example using copyMakeBorder function
*/
/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
An example using copyMakeBorder function.
Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details
*/
/** @brief Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the
@ -474,9 +476,10 @@ The function can also be emulated with a matrix expression, for example:
*/
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
/** @example AddingImagesTrackbar.cpp
/** @example samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp
Check @ref tutorial_trackbar "the corresponding tutorial" for more details
*/
*/
/** @brief Calculates the weighted sum of two arrays.
The function addWeighted calculates the weighted sum of two arrays as follows:
@ -2530,14 +2533,18 @@ public:
Mat mean; //!< mean value subtracted before the projection and added after the back projection
};
/** @example pca.cpp
An example using %PCA for dimensionality reduction while maintaining an amount of variance
*/
/** @example samples/cpp/pca.cpp
An example using %PCA for dimensionality reduction while maintaining an amount of variance
*/
/** @example samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
Check @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details
*/
/**
@brief Linear Discriminant Analysis
@todo document this class
*/
@brief Linear Discriminant Analysis
@todo document this class
*/
class CV_EXPORTS LDA
{
public:
@ -2852,7 +2859,7 @@ public:
use explicit type cast operators, as in the a1 initialization above.
@param a lower inclusive boundary of the returned random number.
@param b upper non-inclusive boundary of the returned random number.
*/
*/
int uniform(int a, int b);
/** @overload */
float uniform(float a, float b);
@ -2914,7 +2921,7 @@ public:
Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
@todo document
*/
*/
class CV_EXPORTS RNG_MT19937
{
public:
@ -2932,17 +2939,11 @@ public:
unsigned operator ()(unsigned N);
unsigned operator ()();
/** @brief returns uniformly distributed integer random number from [a,b) range
*/
/** @brief returns uniformly distributed integer random number from [a,b) range*/
int uniform(int a, int b);
/** @brief returns uniformly distributed floating-point random number from [a,b) range
*/
/** @brief returns uniformly distributed floating-point random number from [a,b) range*/
float uniform(float a, float b);
/** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range
*/
/** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range*/
double uniform(double a, double b);
private:
@ -2956,8 +2957,8 @@ private:
//! @addtogroup core_cluster
//! @{
/** @example kmeans.cpp
An example on K-means clustering
/** @example samples/cpp/kmeans.cpp
An example on K-means clustering
*/
/** @brief Finds centers of clusters and groups input samples around the clusters.
@ -3069,7 +3070,7 @@ etc.).
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
@snippet snippets/core_various.cpp Algorithm
*/
*/
class CV_EXPORTS_W Algorithm
{
public:
@ -3085,8 +3086,8 @@ public:
virtual void write(FileStorage& fs) const { (void)fs; }
/** @brief simplified API for language bindings
* @overload
*/
* @overload
*/
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
/** @brief Reads algorithm parameters from a file storage
@ -3094,20 +3095,20 @@ public:
CV_WRAP virtual void read(const FileNode& fn) { (void)fn; }
/** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
*/
*/
CV_WRAP virtual bool empty() const { return false; }
/** @brief Reads algorithm from the file node
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn) and also have static create() method without parameters
(or with all the optional parameters)
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn) and also have static create() method without parameters
(or with all the optional parameters)
*/
template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
{
Ptr<_Tp> obj = _Tp::create();
@ -3117,16 +3118,16 @@ public:
/** @brief Loads algorithm from the file
@param filename Name of the file to read.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
@param filename Name of the file to read.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn).
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn).
*/
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
{
FileStorage fs(filename, FileStorage::READ);
@ -3140,14 +3141,14 @@ public:
/** @brief Loads algorithm from a String
@param strModel The string variable containing the model you want to load.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
@param strModel The string variable containing the model you want to load.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
@endcode
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
@endcode
*/
template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
{
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
@ -3158,11 +3159,11 @@ public:
}
/** Saves the algorithm to a file.
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
CV_WRAP virtual void save(const String& filename) const;
/** Returns the algorithm string identifier.
This string is used as top level xml/yml node tag when the object is saved to a file or string. */
This string is used as top level xml/yml node tag when the object is saved to a file or string. */
CV_WRAP virtual String getDefaultName() const;
protected:

View File

@ -571,7 +571,7 @@ protected:
MatStep& operator = (const MatStep&);
};
/** @example cout_mat.cpp
/** @example samples/cpp/cout_mat.cpp
An example demonstrating the serial out capabilities of cv::Mat
*/

View File

@ -287,12 +287,12 @@ element is a structure of 2 integers, followed by a single-precision floating-po
equivalent notations of the above specification are `iif`, `2i1f` and so forth. Other examples: `u`
means that the array consists of bytes, and `2d` means the array consists of pairs of doubles.
@see @ref filestorage.cpp
@see @ref samples/cpp/filestorage.cpp
*/
//! @{
/** @example filestorage.cpp
/** @example samples/cpp/filestorage.cpp
A complete example using the FileStorage interface
*/

View File

@ -4,11 +4,9 @@ namespace opencv_test
{
using namespace perf;
#define TYPICAL_MAT_SIZES_CORE_ARITHM szVGA, sz720p, sz1080p
#define TYPICAL_MAT_TYPES_CORE_ARITHM CV_8UC1, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_8UC4, CV_32SC1, CV_32FC1
#define TYPICAL_MATS_CORE_ARITHM testing::Combine( testing::Values( TYPICAL_MAT_SIZES_CORE_ARITHM ), testing::Values( TYPICAL_MAT_TYPES_CORE_ARITHM ) )
typedef Size_MatType BinaryOpTest;
PERF_TEST_P(Size_MatType, min, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, min)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -20,10 +18,10 @@ PERF_TEST_P(Size_MatType, min, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::min(a, b, c);
SANITY_CHECK(c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, minScalar, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, minScalarDouble)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -35,10 +33,34 @@ PERF_TEST_P(Size_MatType, minScalar, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::min(a, b, c);
SANITY_CHECK(c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, max, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, minScalarSameType)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Scalar b;
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) < CV_32S)
{
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
}
else if (CV_MAT_DEPTH(type) == CV_32S)
{
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
}
TEST_CYCLE() cv::min(a, b, c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, max)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -50,10 +72,10 @@ PERF_TEST_P(Size_MatType, max, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::max(a, b, c);
SANITY_CHECK(c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, maxScalar, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, maxScalarDouble)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -65,34 +87,10 @@ PERF_TEST_P(Size_MatType, maxScalar, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::max(a, b, c);
SANITY_CHECK(c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, absdiff, TYPICAL_MATS_CORE_ARITHM)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Mat b = Mat(sz, type);
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: absdiff can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::absdiff(a, b, c);
SANITY_CHECK(c, eps);
}
PERF_TEST_P(Size_MatType, absdiffScalar, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, maxScalarSameType)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -102,21 +100,91 @@ PERF_TEST_P(Size_MatType, absdiffScalar, TYPICAL_MATS_CORE_ARITHM)
declare.in(a, b, WARMUP_RNG).out(c);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) < CV_32S)
{
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
}
else if (CV_MAT_DEPTH(type) == CV_32S)
{
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
}
TEST_CYCLE() cv::max(a, b, c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, absdiff)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Mat b = Mat(sz, type);
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: absdiff can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::absdiff(a, b, c);
SANITY_CHECK(c, eps);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, add, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, absdiffScalarDouble)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Scalar b;
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: absdiff can be without saturation on 32S
a /= 2;
b /= 2;
}
TEST_CYCLE() cv::absdiff(a, b, c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, absdiffScalarSameType)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Scalar b;
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) < CV_32S)
{
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
}
else if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: absdiff can be without saturation on 32S
a /= 2;
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
}
TEST_CYCLE() cv::absdiff(a, b, c);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, add)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -127,21 +195,19 @@ PERF_TEST_P(Size_MatType, add, TYPICAL_MATS_CORE_ARITHM)
declare.in(a, b, WARMUP_RNG).out(c);
declare.time(50);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: add can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::add(a, b, c);
SANITY_CHECK(c, eps);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, addScalar, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, addScalarDouble)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -151,21 +217,45 @@ PERF_TEST_P(Size_MatType, addScalar, TYPICAL_MATS_CORE_ARITHM)
declare.in(a, b, WARMUP_RNG).out(c);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: add can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::add(a, b, c);
SANITY_CHECK(c, eps);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, subtract, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, addScalarSameType)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Scalar b;
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) < CV_32S)
{
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
}
else if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: add can be without saturation on 32S
a /= 2;
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
}
TEST_CYCLE() cv::add(a, b, c, noArray(), type);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, subtract)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -175,21 +265,19 @@ PERF_TEST_P(Size_MatType, subtract, TYPICAL_MATS_CORE_ARITHM)
declare.in(a, b, WARMUP_RNG).out(c);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: subtract can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::subtract(a, b, c);
SANITY_CHECK(c, eps);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, subtractScalar, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, subtractScalarDouble)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -199,21 +287,45 @@ PERF_TEST_P(Size_MatType, subtractScalar, TYPICAL_MATS_CORE_ARITHM)
declare.in(a, b, WARMUP_RNG).out(c);
double eps = 1e-8;
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: subtract can be without saturation on 32S
a /= 2;
b /= 2;
eps = 1;
}
TEST_CYCLE() cv::subtract(a, b, c);
SANITY_CHECK(c, eps);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, multiply, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, subtractScalarSameType)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
cv::Mat a = Mat(sz, type);
cv::Scalar b;
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
if (CV_MAT_DEPTH(type) < CV_32S)
{
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
}
else if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: subtract can be without saturation on 32S
a /= 2;
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
}
TEST_CYCLE() cv::subtract(a, b, c, noArray(), type);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BinaryOpTest, multiply)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -229,10 +341,10 @@ PERF_TEST_P(Size_MatType, multiply, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::multiply(a, b, c);
SANITY_CHECK(c, 1e-8);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, multiplyScale, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, multiplyScale)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -250,10 +362,10 @@ PERF_TEST_P(Size_MatType, multiplyScale, TYPICAL_MATS_CORE_ARITHM)
TEST_CYCLE() cv::multiply(a, b, c, scale);
SANITY_CHECK(c, 1e-8);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, divide, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, divide)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -267,7 +379,7 @@ PERF_TEST_P(Size_MatType, divide, TYPICAL_MATS_CORE_ARITHM)
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Size_MatType, reciprocal, TYPICAL_MATS_CORE_ARITHM)
PERF_TEST_P_(BinaryOpTest, reciprocal)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
@ -281,4 +393,11 @@ PERF_TEST_P(Size_MatType, reciprocal, TYPICAL_MATS_CORE_ARITHM)
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(/*nothing*/ , BinaryOpTest,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1)
)
);
} // namespace

View File

@ -45,6 +45,7 @@
#include "opencl_kernels_core.hpp"
#include <limits>
#include <iostream>
#include "mathfuncs.hpp"
namespace cv
{
@ -2023,4 +2024,382 @@ void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int)
}
// Common constants for dispatched code
namespace cv { namespace details {
#define EXPTAB_SCALE 6
#define EXPTAB_MASK ((1 << EXPTAB_SCALE) - 1)
#define EXPPOLY_32F_A0 .9670371139572337719125840413672004409288e-2
static const double CV_DECL_ALIGNED(64) expTab[EXPTAB_MASK + 1] = {
1.0 * EXPPOLY_32F_A0,
1.0108892860517004600204097905619 * EXPPOLY_32F_A0,
1.0218971486541166782344801347833 * EXPPOLY_32F_A0,
1.0330248790212284225001082839705 * EXPPOLY_32F_A0,
1.0442737824274138403219664787399 * EXPPOLY_32F_A0,
1.0556451783605571588083413251529 * EXPPOLY_32F_A0,
1.0671404006768236181695211209928 * EXPPOLY_32F_A0,
1.0787607977571197937406800374385 * EXPPOLY_32F_A0,
1.0905077326652576592070106557607 * EXPPOLY_32F_A0,
1.1023825833078409435564142094256 * EXPPOLY_32F_A0,
1.1143867425958925363088129569196 * EXPPOLY_32F_A0,
1.126521618608241899794798643787 * EXPPOLY_32F_A0,
1.1387886347566916537038302838415 * EXPPOLY_32F_A0,
1.151189229952982705817759635202 * EXPPOLY_32F_A0,
1.1637248587775775138135735990922 * EXPPOLY_32F_A0,
1.1763969916502812762846457284838 * EXPPOLY_32F_A0,
1.1892071150027210667174999705605 * EXPPOLY_32F_A0,
1.2021567314527031420963969574978 * EXPPOLY_32F_A0,
1.2152473599804688781165202513388 * EXPPOLY_32F_A0,
1.2284805361068700056940089577928 * EXPPOLY_32F_A0,
1.2418578120734840485936774687266 * EXPPOLY_32F_A0,
1.2553807570246910895793906574423 * EXPPOLY_32F_A0,
1.2690509571917332225544190810323 * EXPPOLY_32F_A0,
1.2828700160787782807266697810215 * EXPPOLY_32F_A0,
1.2968395546510096659337541177925 * EXPPOLY_32F_A0,
1.3109612115247643419229917863308 * EXPPOLY_32F_A0,
1.3252366431597412946295370954987 * EXPPOLY_32F_A0,
1.3396675240533030053600306697244 * EXPPOLY_32F_A0,
1.3542555469368927282980147401407 * EXPPOLY_32F_A0,
1.3690024229745906119296011329822 * EXPPOLY_32F_A0,
1.3839098819638319548726595272652 * EXPPOLY_32F_A0,
1.3989796725383111402095281367152 * EXPPOLY_32F_A0,
1.4142135623730950488016887242097 * EXPPOLY_32F_A0,
1.4296133383919700112350657782751 * EXPPOLY_32F_A0,
1.4451808069770466200370062414717 * EXPPOLY_32F_A0,
1.4609177941806469886513028903106 * EXPPOLY_32F_A0,
1.476826145939499311386907480374 * EXPPOLY_32F_A0,
1.4929077282912648492006435314867 * EXPPOLY_32F_A0,
1.5091644275934227397660195510332 * EXPPOLY_32F_A0,
1.5255981507445383068512536895169 * EXPPOLY_32F_A0,
1.5422108254079408236122918620907 * EXPPOLY_32F_A0,
1.5590044002378369670337280894749 * EXPPOLY_32F_A0,
1.5759808451078864864552701601819 * EXPPOLY_32F_A0,
1.5931421513422668979372486431191 * EXPPOLY_32F_A0,
1.6104903319492543081795206673574 * EXPPOLY_32F_A0,
1.628027421857347766848218522014 * EXPPOLY_32F_A0,
1.6457554781539648445187567247258 * EXPPOLY_32F_A0,
1.6636765803267364350463364569764 * EXPPOLY_32F_A0,
1.6817928305074290860622509524664 * EXPPOLY_32F_A0,
1.7001063537185234695013625734975 * EXPPOLY_32F_A0,
1.7186192981224779156293443764563 * EXPPOLY_32F_A0,
1.7373338352737062489942020818722 * EXPPOLY_32F_A0,
1.7562521603732994831121606193753 * EXPPOLY_32F_A0,
1.7753764925265212525505592001993 * EXPPOLY_32F_A0,
1.7947090750031071864277032421278 * EXPPOLY_32F_A0,
1.8142521755003987562498346003623 * EXPPOLY_32F_A0,
1.8340080864093424634870831895883 * EXPPOLY_32F_A0,
1.8539791250833855683924530703377 * EXPPOLY_32F_A0,
1.8741676341102999013299989499544 * EXPPOLY_32F_A0,
1.8945759815869656413402186534269 * EXPPOLY_32F_A0,
1.9152065613971472938726112702958 * EXPPOLY_32F_A0,
1.9360617934922944505980559045667 * EXPPOLY_32F_A0,
1.9571441241754002690183222516269 * EXPPOLY_32F_A0,
1.9784560263879509682582499181312 * EXPPOLY_32F_A0,
};
const double* getExpTab64f()
{
return expTab;
}
const float* getExpTab32f()
{
static float CV_DECL_ALIGNED(64) expTab_f[EXPTAB_MASK+1];
static volatile bool expTab_f_initialized = false;
if (!expTab_f_initialized)
{
for( int j = 0; j <= EXPTAB_MASK; j++ )
expTab_f[j] = (float)expTab[j];
expTab_f_initialized = true;
}
return expTab_f;
}
#define LOGTAB_SCALE 8
#define LOGTAB_MASK ((1 << LOGTAB_SCALE) - 1)
static const double CV_DECL_ALIGNED(64) logTab[(LOGTAB_MASK+1)*2] = {
0.0000000000000000000000000000000000000000, 1.000000000000000000000000000000000000000,
.00389864041565732288852075271279318258166, .9961089494163424124513618677042801556420,
.00778214044205494809292034119607706088573, .9922480620155038759689922480620155038760,
.01165061721997527263705585198749759001657, .9884169884169884169884169884169884169884,
.01550418653596525274396267235488267033361, .9846153846153846153846153846153846153846,
.01934296284313093139406447562578250654042, .9808429118773946360153256704980842911877,
.02316705928153437593630670221500622574241, .9770992366412213740458015267175572519084,
.02697658769820207233514075539915211265906, .9733840304182509505703422053231939163498,
.03077165866675368732785500469617545604706, .9696969696969696969696969696969696969697,
.03455238150665972812758397481047722976656, .9660377358490566037735849056603773584906,
.03831886430213659461285757856785494368522, .9624060150375939849624060150375939849624,
.04207121392068705056921373852674150839447, .9588014981273408239700374531835205992509,
.04580953603129420126371940114040626212953, .9552238805970149253731343283582089552239,
.04953393512227662748292900118940451648088, .9516728624535315985130111524163568773234,
.05324451451881227759255210685296333394944, .9481481481481481481481481481481481481481,
.05694137640013842427411105973078520037234, .9446494464944649446494464944649446494465,
.06062462181643483993820353816772694699466, .9411764705882352941176470588235294117647,
.06429435070539725460836422143984236754475, .9377289377289377289377289377289377289377,
.06795066190850773679699159401934593915938, .9343065693430656934306569343065693430657,
.07159365318700880442825962290953611955044, .9309090909090909090909090909090909090909,
.07522342123758751775142172846244648098944, .9275362318840579710144927536231884057971,
.07884006170777602129362549021607264876369, .9241877256317689530685920577617328519856,
.08244366921107458556772229485432035289706, .9208633093525179856115107913669064748201,
.08603433734180314373940490213499288074675, .9175627240143369175627240143369175627240,
.08961215868968712416897659522874164395031, .9142857142857142857142857142857142857143,
.09317722485418328259854092721070628613231, .9110320284697508896797153024911032028470,
.09672962645855109897752299730200320482256, .9078014184397163120567375886524822695035,
.10026945316367513738597949668474029749630, .9045936395759717314487632508833922261484,
.10379679368164355934833764649738441221420, .9014084507042253521126760563380281690141,
.10731173578908805021914218968959175981580, .8982456140350877192982456140350877192982,
.11081436634029011301105782649756292812530, .8951048951048951048951048951048951048951,
.11430477128005862852422325204315711744130, .8919860627177700348432055749128919860627,
.11778303565638344185817487641543266363440, .8888888888888888888888888888888888888889,
.12124924363286967987640707633545389398930, .8858131487889273356401384083044982698962,
.12470347850095722663787967121606925502420, .8827586206896551724137931034482758620690,
.12814582269193003360996385708858724683530, .8797250859106529209621993127147766323024,
.13157635778871926146571524895989568904040, .8767123287671232876712328767123287671233,
.13499516453750481925766280255629681050780, .8737201365187713310580204778156996587031,
.13840232285911913123754857224412262439730, .8707482993197278911564625850340136054422,
.14179791186025733629172407290752744302150, .8677966101694915254237288135593220338983,
.14518200984449788903951628071808954700830, .8648648648648648648648648648648648648649,
.14855469432313711530824207329715136438610, .8619528619528619528619528619528619528620,
.15191604202584196858794030049466527998450, .8590604026845637583892617449664429530201,
.15526612891112392955683674244937719777230, .8561872909698996655518394648829431438127,
.15860503017663857283636730244325008243330, .8533333333333333333333333333333333333333,
.16193282026931324346641360989451641216880, .8504983388704318936877076411960132890365,
.16524957289530714521497145597095368430010, .8476821192052980132450331125827814569536,
.16855536102980664403538924034364754334090, .8448844884488448844884488448844884488449,
.17185025692665920060697715143760433420540, .8421052631578947368421052631578947368421,
.17513433212784912385018287750426679849630, .8393442622950819672131147540983606557377,
.17840765747281828179637841458315961062910, .8366013071895424836601307189542483660131,
.18167030310763465639212199675966985523700, .8338762214983713355048859934853420195440,
.18492233849401198964024217730184318497780, .8311688311688311688311688311688311688312,
.18816383241818296356839823602058459073300, .8284789644012944983818770226537216828479,
.19139485299962943898322009772527962923050, .8258064516129032258064516129032258064516,
.19461546769967164038916962454095482826240, .8231511254019292604501607717041800643087,
.19782574332991986754137769821682013571260, .8205128205128205128205128205128205128205,
.20102574606059073203390141770796617493040, .8178913738019169329073482428115015974441,
.20421554142869088876999228432396193966280, .8152866242038216560509554140127388535032,
.20739519434607056602715147164417430758480, .8126984126984126984126984126984126984127,
.21056476910734961416338251183333341032260, .8101265822784810126582278481012658227848,
.21372432939771812687723695489694364368910, .8075709779179810725552050473186119873817,
.21687393830061435506806333251006435602900, .8050314465408805031446540880503144654088,
.22001365830528207823135744547471404075630, .8025078369905956112852664576802507836991,
.22314355131420973710199007200571941211830, .8000000000000000000000000000000000000000,
.22626367865045338145790765338460914790630, .7975077881619937694704049844236760124611,
.22937410106484582006380890106811420992010, .7950310559006211180124223602484472049689,
.23247487874309405442296849741978803649550, .7925696594427244582043343653250773993808,
.23556607131276688371634975283086532726890, .7901234567901234567901234567901234567901,
.23864773785017498464178231643018079921600, .7876923076923076923076923076923076923077,
.24171993688714515924331749374687206000090, .7852760736196319018404907975460122699387,
.24478272641769091566565919038112042471760, .7828746177370030581039755351681957186544,
.24783616390458124145723672882013488560910, .7804878048780487804878048780487804878049,
.25088030628580937353433455427875742316250, .7781155015197568389057750759878419452888,
.25391520998096339667426946107298135757450, .7757575757575757575757575757575757575758,
.25694093089750041913887912414793390780680, .7734138972809667673716012084592145015106,
.25995752443692604627401010475296061486000, .7710843373493975903614457831325301204819,
.26296504550088134477547896494797896593800, .7687687687687687687687687687687687687688,
.26596354849713793599974565040611196309330, .7664670658682634730538922155688622754491,
.26895308734550393836570947314612567424780, .7641791044776119402985074626865671641791,
.27193371548364175804834985683555714786050, .7619047619047619047619047619047619047619,
.27490548587279922676529508862586226314300, .7596439169139465875370919881305637982196,
.27786845100345625159121709657483734190480, .7573964497041420118343195266272189349112,
.28082266290088775395616949026589281857030, .7551622418879056047197640117994100294985,
.28376817313064456316240580235898960381750, .7529411764705882352941176470588235294118,
.28670503280395426282112225635501090437180, .7507331378299120234604105571847507331378,
.28963329258304265634293983566749375313530, .7485380116959064327485380116959064327485,
.29255300268637740579436012922087684273730, .7463556851311953352769679300291545189504,
.29546421289383584252163927885703742504130, .7441860465116279069767441860465116279070,
.29836697255179722709783618483925238251680, .7420289855072463768115942028985507246377,
.30126133057816173455023545102449133992200, .7398843930635838150289017341040462427746,
.30414733546729666446850615102448500692850, .7377521613832853025936599423631123919308,
.30702503529491181888388950937951449304830, .7356321839080459770114942528735632183908,
.30989447772286465854207904158101882785550, .7335243553008595988538681948424068767908,
.31275571000389684739317885942000430077330, .7314285714285714285714285714285714285714,
.31560877898630329552176476681779604405180, .7293447293447293447293447293447293447293,
.31845373111853458869546784626436419785030, .7272727272727272727272727272727272727273,
.32129061245373424782201254856772720813750, .7252124645892351274787535410764872521246,
.32411946865421192853773391107097268104550, .7231638418079096045197740112994350282486,
.32694034499585328257253991068864706903700, .7211267605633802816901408450704225352113,
.32975328637246797969240219572384376078850, .7191011235955056179775280898876404494382,
.33255833730007655635318997155991382896900, .7170868347338935574229691876750700280112,
.33535554192113781191153520921943709254280, .7150837988826815642458100558659217877095,
.33814494400871636381467055798566434532400, .7130919220055710306406685236768802228412,
.34092658697059319283795275623560883104800, .7111111111111111111111111111111111111111,
.34370051385331840121395430287520866841080, .7091412742382271468144044321329639889197,
.34646676734620857063262633346312213689100, .7071823204419889502762430939226519337017,
.34922538978528827602332285096053965389730, .7052341597796143250688705234159779614325,
.35197642315717814209818925519357435405250, .7032967032967032967032967032967032967033,
.35471990910292899856770532096561510115850, .7013698630136986301369863013698630136986,
.35745588892180374385176833129662554711100, .6994535519125683060109289617486338797814,
.36018440357500774995358483465679455548530, .6975476839237057220708446866485013623978,
.36290549368936841911903457003063522279280, .6956521739130434782608695652173913043478,
.36561919956096466943762379742111079394830, .6937669376693766937669376693766937669377,
.36832556115870762614150635272380895912650, .6918918918918918918918918918918918918919,
.37102461812787262962487488948681857436900, .6900269541778975741239892183288409703504,
.37371640979358405898480555151763837784530, .6881720430107526881720430107526881720430,
.37640097516425302659470730759494472295050, .6863270777479892761394101876675603217158,
.37907835293496944251145919224654790014030, .6844919786096256684491978609625668449198,
.38174858149084833769393299007788300514230, .6826666666666666666666666666666666666667,
.38441169891033200034513583887019194662580, .6808510638297872340425531914893617021277,
.38706774296844825844488013899535872042180, .6790450928381962864721485411140583554377,
.38971675114002518602873692543653305619950, .6772486772486772486772486772486772486772,
.39235876060286384303665840889152605086580, .6754617414248021108179419525065963060686,
.39499380824086893770896722344332374632350, .6736842105263157894736842105263157894737,
.39762193064713846624158577469643205404280, .6719160104986876640419947506561679790026,
.40024316412701266276741307592601515352730, .6701570680628272251308900523560209424084,
.40285754470108348090917615991202183067800, .6684073107049608355091383812010443864230,
.40546510810816432934799991016916465014230, .6666666666666666666666666666666666666667,
.40806588980822172674223224930756259709600, .6649350649350649350649350649350649350649,
.41065992498526837639616360320360399782650, .6632124352331606217616580310880829015544,
.41324724855021932601317757871584035456180, .6614987080103359173126614987080103359173,
.41582789514371093497757669865677598863850, .6597938144329896907216494845360824742268,
.41840189913888381489925905043492093682300, .6580976863753213367609254498714652956298,
.42096929464412963239894338585145305842150, .6564102564102564102564102564102564102564,
.42353011550580327293502591601281892508280, .6547314578005115089514066496163682864450,
.42608439531090003260516141381231136620050, .6530612244897959183673469387755102040816,
.42863216738969872610098832410585600882780, .6513994910941475826972010178117048346056,
.43117346481837132143866142541810404509300, .6497461928934010152284263959390862944162,
.43370832042155937902094819946796633303180, .6481012658227848101265822784810126582278,
.43623676677491801667585491486534010618930, .6464646464646464646464646464646464646465,
.43875883620762790027214350629947148263450, .6448362720403022670025188916876574307305,
.44127456080487520440058801796112675219780, .6432160804020100502512562814070351758794,
.44378397241030093089975139264424797147500, .6416040100250626566416040100250626566416,
.44628710262841947420398014401143882423650, .6400000000000000000000000000000000000000,
.44878398282700665555822183705458883196130, .6384039900249376558603491271820448877805,
.45127464413945855836729492693848442286250, .6368159203980099502487562189054726368159,
.45375911746712049854579618113348260521900, .6352357320099255583126550868486352357320,
.45623743348158757315857769754074979573500, .6336633663366336633663366336633663366337,
.45870962262697662081833982483658473938700, .6320987654320987654320987654320987654321,
.46117571512217014895185229761409573256980, .6305418719211822660098522167487684729064,
.46363574096303250549055974261136725544930, .6289926289926289926289926289926289926290,
.46608972992459918316399125615134835243230, .6274509803921568627450980392156862745098,
.46853771156323925639597405279346276074650, .6259168704156479217603911980440097799511,
.47097971521879100631480241645476780831830, .6243902439024390243902439024390243902439,
.47341577001667212165614273544633761048330, .6228710462287104622871046228710462287105,
.47584590486996386493601107758877333253630, .6213592233009708737864077669902912621359,
.47827014848147025860569669930555392056700, .6198547215496368038740920096852300242131,
.48068852934575190261057286988943815231330, .6183574879227053140096618357487922705314,
.48310107575113581113157579238759353756900, .6168674698795180722891566265060240963855,
.48550781578170076890899053978500887751580, .6153846153846153846153846153846153846154,
.48790877731923892879351001283794175833480, .6139088729016786570743405275779376498801,
.49030398804519381705802061333088204264650, .6124401913875598086124401913875598086124,
.49269347544257524607047571407747454941280, .6109785202863961813842482100238663484487,
.49507726679785146739476431321236304938800, .6095238095238095238095238095238095238095,
.49745538920281889838648226032091770321130, .6080760095011876484560570071258907363420,
.49982786955644931126130359189119189977650, .6066350710900473933649289099526066350711,
.50219473456671548383667413872899487614650, .6052009456264775413711583924349881796690,
.50455601075239520092452494282042607665050, .6037735849056603773584905660377358490566,
.50691172444485432801997148999362252652650, .6023529411764705882352941176470588235294,
.50926190178980790257412536448100581765150, .6009389671361502347417840375586854460094,
.51160656874906207391973111953120678663250, .5995316159250585480093676814988290398126,
.51394575110223428282552049495279788970950, .5981308411214953271028037383177570093458,
.51627947444845445623684554448118433356300, .5967365967365967365967365967365967365967,
.51860776420804555186805373523384332656850, .5953488372093023255813953488372093023256,
.52093064562418522900344441950437612831600, .5939675174013921113689095127610208816705,
.52324814376454775732838697877014055848100, .5925925925925925925925925925925925925926,
.52556028352292727401362526507000438869000, .5912240184757505773672055427251732101617,
.52786708962084227803046587723656557500350, .5898617511520737327188940092165898617512,
.53016858660912158374145519701414741575700, .5885057471264367816091954022988505747126,
.53246479886947173376654518506256863474850, .5871559633027522935779816513761467889908,
.53475575061602764748158733709715306758900, .5858123569794050343249427917620137299771,
.53704146589688361856929077475797384977350, .5844748858447488584474885844748858447489,
.53932196859560876944783558428753167390800, .5831435079726651480637813211845102505695,
.54159728243274429804188230264117009937750, .5818181818181818181818181818181818181818,
.54386743096728351609669971367111429572100, .5804988662131519274376417233560090702948,
.54613243759813556721383065450936555862450, .5791855203619909502262443438914027149321,
.54839232556557315767520321969641372561450, .5778781038374717832957110609480812641084,
.55064711795266219063194057525834068655950, .5765765765765765765765765765765765765766,
.55289683768667763352766542084282264113450, .5752808988764044943820224719101123595506,
.55514150754050151093110798683483153581600, .5739910313901345291479820627802690582960,
.55738115013400635344709144192165695130850, .5727069351230425055928411633109619686801,
.55961578793542265941596269840374588966350, .5714285714285714285714285714285714285714,
.56184544326269181269140062795486301183700, .5701559020044543429844097995545657015590,
.56407013828480290218436721261241473257550, .5688888888888888888888888888888888888889,
.56628989502311577464155334382667206227800, .5676274944567627494456762749445676274945,
.56850473535266865532378233183408156037350, .5663716814159292035398230088495575221239,
.57071468100347144680739575051120482385150, .5651214128035320088300220750551876379691,
.57291975356178548306473885531886480748650, .5638766519823788546255506607929515418502,
.57511997447138785144460371157038025558000, .5626373626373626373626373626373626373626,
.57731536503482350219940144597785547375700, .5614035087719298245614035087719298245614,
.57950594641464214795689713355386629700650, .5601750547045951859956236323851203501094,
.58169173963462239562716149521293118596100, .5589519650655021834061135371179039301310,
.58387276558098266665552955601015128195300, .5577342047930283224400871459694989106754,
.58604904500357812846544902640744112432000, .5565217391304347826086956521739130434783,
.58822059851708596855957011939608491957200, .5553145336225596529284164859002169197397,
.59038744660217634674381770309992134571100, .5541125541125541125541125541125541125541,
.59254960960667157898740242671919986605650, .5529157667386609071274298056155507559395,
.59470710774669277576265358220553025603300, .5517241379310344827586206896551724137931,
.59685996110779382384237123915227130055450, .5505376344086021505376344086021505376344,
.59900818964608337768851242799428291618800, .5493562231759656652360515021459227467811,
.60115181318933474940990890900138765573500, .5481798715203426124197002141327623126338,
.60329085143808425240052883964381180703650, .5470085470085470085470085470085470085470,
.60542532396671688843525771517306566238400, .5458422174840085287846481876332622601279,
.60755525022454170969155029524699784815300, .5446808510638297872340425531914893617021,
.60968064953685519036241657886421307921400, .5435244161358811040339702760084925690021,
.61180154110599282990534675263916142284850, .5423728813559322033898305084745762711864,
.61391794401237043121710712512140162289150, .5412262156448202959830866807610993657505,
.61602987721551394351138242200249806046500, .5400843881856540084388185654008438818565,
.61813735955507864705538167982012964785100, .5389473684210526315789473684210526315789,
.62024040975185745772080281312810257077200, .5378151260504201680672268907563025210084,
.62233904640877868441606324267922900617100, .5366876310272536687631027253668763102725,
.62443328801189346144440150965237990021700, .5355648535564853556485355648535564853556,
.62652315293135274476554741340805776417250, .5344467640918580375782881002087682672234,
.62860865942237409420556559780379757285100, .5333333333333333333333333333333333333333,
.63068982562619868570408243613201193511500, .5322245322245322245322245322245322245322,
.63276666957103777644277897707070223987100, .5311203319502074688796680497925311203320,
.63483920917301017716738442686619237065300, .5300207039337474120082815734989648033126,
.63690746223706917739093569252872839570050, .5289256198347107438016528925619834710744,
.63897144645792069983514238629140891134750, .5278350515463917525773195876288659793814,
.64103117942093124081992527862894348800200, .5267489711934156378600823045267489711934,
.64308667860302726193566513757104985415950, .5256673511293634496919917864476386036961,
.64513796137358470073053240412264131009600, .5245901639344262295081967213114754098361,
.64718504499530948859131740391603671014300, .5235173824130879345603271983640081799591,
.64922794662510974195157587018911726772800, .5224489795918367346938775510204081632653,
.65126668331495807251485530287027359008800, .5213849287169042769857433808553971486762,
.65330127201274557080523663898929953575150, .5203252032520325203252032520325203252033,
.65533172956312757406749369692988693714150, .5192697768762677484787018255578093306288,
.65735807270835999727154330685152672231200, .5182186234817813765182186234817813765182,
.65938031808912778153342060249997302889800, .5171717171717171717171717171717171717172,
.66139848224536490484126716182800009846700, .5161290322580645161290322580645161290323,
.66341258161706617713093692145776003599150, .5150905432595573440643863179074446680080,
.66542263254509037562201001492212526500250, .5140562248995983935742971887550200803213,
.66742865127195616370414654738851822912700, .5130260521042084168336673346693386773547,
.66943065394262923906154583164607174694550, .5120000000000000000000000000000000000000,
.67142865660530226534774556057527661323550, .5109780439121756487025948103792415169661,
.67342267521216669923234121597488410770900, .5099601593625498007968127490039840637450,
.67541272562017662384192817626171745359900, .5089463220675944333996023856858846918489,
.67739882359180603188519853574689477682100, .5079365079365079365079365079365079365079,
.67938098479579733801614338517538271844400, .5069306930693069306930693069306930693069,
.68135922480790300781450241629499942064300, .5059288537549407114624505928853754940711,
.68333355911162063645036823800182901322850, .5049309664694280078895463510848126232742,
.68530400309891936760919861626462079584600, .5039370078740157480314960629921259842520,
.68727057207096020619019327568821609020250, .5029469548133595284872298624754420432220,
.68923328123880889251040571252815425395950, .5019607843137254901960784313725490196078,
.69314718055994530941723212145818, 5.0e-01,
};
const double* getLogTab64f()
{
return logTab;
}
const float* getLogTab32f()
{
static float CV_DECL_ALIGNED(64) logTab_f[(LOGTAB_MASK+1)*2];
static volatile bool logTab_f_initialized = false;
if (!logTab_f_initialized)
{
for (int j = 0; j < (LOGTAB_MASK+1)*2; j++)
logTab_f[j] = (float)logTab[j];
logTab_f_initialized = true;
}
return logTab_f;
}
}} // namespace
/* End of file. */

View File

@ -0,0 +1,15 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CORE_SRC_MATHFUNCS_HPP
#define OPENCV_CORE_SRC_MATHFUNCS_HPP
namespace cv { namespace details {
const double* getExpTab64f();
const float* getExpTab32f();
const double* getLogTab64f();
const float* getLogTab32f();
}} // namespace
#endif // OPENCV_CORE_SRC_MATHFUNCS_HPP

View File

@ -2,6 +2,8 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "mathfuncs.hpp"
namespace cv { namespace hal {
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
@ -409,76 +411,6 @@ void log64f(const double *src, double *dst, int n)
#define EXPPOLY_32F_A0 .9670371139572337719125840413672004409288e-2
static const double expTab[] = {
1.0 * EXPPOLY_32F_A0,
1.0108892860517004600204097905619 * EXPPOLY_32F_A0,
1.0218971486541166782344801347833 * EXPPOLY_32F_A0,
1.0330248790212284225001082839705 * EXPPOLY_32F_A0,
1.0442737824274138403219664787399 * EXPPOLY_32F_A0,
1.0556451783605571588083413251529 * EXPPOLY_32F_A0,
1.0671404006768236181695211209928 * EXPPOLY_32F_A0,
1.0787607977571197937406800374385 * EXPPOLY_32F_A0,
1.0905077326652576592070106557607 * EXPPOLY_32F_A0,
1.1023825833078409435564142094256 * EXPPOLY_32F_A0,
1.1143867425958925363088129569196 * EXPPOLY_32F_A0,
1.126521618608241899794798643787 * EXPPOLY_32F_A0,
1.1387886347566916537038302838415 * EXPPOLY_32F_A0,
1.151189229952982705817759635202 * EXPPOLY_32F_A0,
1.1637248587775775138135735990922 * EXPPOLY_32F_A0,
1.1763969916502812762846457284838 * EXPPOLY_32F_A0,
1.1892071150027210667174999705605 * EXPPOLY_32F_A0,
1.2021567314527031420963969574978 * EXPPOLY_32F_A0,
1.2152473599804688781165202513388 * EXPPOLY_32F_A0,
1.2284805361068700056940089577928 * EXPPOLY_32F_A0,
1.2418578120734840485936774687266 * EXPPOLY_32F_A0,
1.2553807570246910895793906574423 * EXPPOLY_32F_A0,
1.2690509571917332225544190810323 * EXPPOLY_32F_A0,
1.2828700160787782807266697810215 * EXPPOLY_32F_A0,
1.2968395546510096659337541177925 * EXPPOLY_32F_A0,
1.3109612115247643419229917863308 * EXPPOLY_32F_A0,
1.3252366431597412946295370954987 * EXPPOLY_32F_A0,
1.3396675240533030053600306697244 * EXPPOLY_32F_A0,
1.3542555469368927282980147401407 * EXPPOLY_32F_A0,
1.3690024229745906119296011329822 * EXPPOLY_32F_A0,
1.3839098819638319548726595272652 * EXPPOLY_32F_A0,
1.3989796725383111402095281367152 * EXPPOLY_32F_A0,
1.4142135623730950488016887242097 * EXPPOLY_32F_A0,
1.4296133383919700112350657782751 * EXPPOLY_32F_A0,
1.4451808069770466200370062414717 * EXPPOLY_32F_A0,
1.4609177941806469886513028903106 * EXPPOLY_32F_A0,
1.476826145939499311386907480374 * EXPPOLY_32F_A0,
1.4929077282912648492006435314867 * EXPPOLY_32F_A0,
1.5091644275934227397660195510332 * EXPPOLY_32F_A0,
1.5255981507445383068512536895169 * EXPPOLY_32F_A0,
1.5422108254079408236122918620907 * EXPPOLY_32F_A0,
1.5590044002378369670337280894749 * EXPPOLY_32F_A0,
1.5759808451078864864552701601819 * EXPPOLY_32F_A0,
1.5931421513422668979372486431191 * EXPPOLY_32F_A0,
1.6104903319492543081795206673574 * EXPPOLY_32F_A0,
1.628027421857347766848218522014 * EXPPOLY_32F_A0,
1.6457554781539648445187567247258 * EXPPOLY_32F_A0,
1.6636765803267364350463364569764 * EXPPOLY_32F_A0,
1.6817928305074290860622509524664 * EXPPOLY_32F_A0,
1.7001063537185234695013625734975 * EXPPOLY_32F_A0,
1.7186192981224779156293443764563 * EXPPOLY_32F_A0,
1.7373338352737062489942020818722 * EXPPOLY_32F_A0,
1.7562521603732994831121606193753 * EXPPOLY_32F_A0,
1.7753764925265212525505592001993 * EXPPOLY_32F_A0,
1.7947090750031071864277032421278 * EXPPOLY_32F_A0,
1.8142521755003987562498346003623 * EXPPOLY_32F_A0,
1.8340080864093424634870831895883 * EXPPOLY_32F_A0,
1.8539791250833855683924530703377 * EXPPOLY_32F_A0,
1.8741676341102999013299989499544 * EXPPOLY_32F_A0,
1.8945759815869656413402186534269 * EXPPOLY_32F_A0,
1.9152065613971472938726112702958 * EXPPOLY_32F_A0,
1.9360617934922944505980559045667 * EXPPOLY_32F_A0,
1.9571441241754002690183222516269 * EXPPOLY_32F_A0,
1.9784560263879509682582499181312 * EXPPOLY_32F_A0,
};
static float expTab_f[EXPTAB_MASK+1];
static volatile bool extTab_f_initialized = false;
// the code below uses _mm_cast* intrinsics, which are not avialable on VS2005
#if (defined _MSC_VER && _MSC_VER < 1500) || \
(!defined __APPLE__ && defined __GNUC__ && __GNUC__*100 + __GNUC_MINOR__ < 402)
@ -494,14 +426,9 @@ void exp32f( const float *_x, float *y, int n )
{
CV_INSTRUMENT_REGION()
if( !extTab_f_initialized )
{
for( int j = 0; j <= EXPTAB_MASK; j++ )
expTab_f[j] = (float)expTab[j];
extTab_f_initialized = true;
}
const float* const expTab_f = cv::details::getExpTab32f();
static const float
const float
A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
A2 = (float)(.2402265109513301490103372422686535526573 / EXPPOLY_32F_A0),
@ -612,7 +539,9 @@ void exp64f( const double *_x, double *y, int n )
{
CV_INSTRUMENT_REGION()
static const double
const double* const expTab = cv::details::getExpTab64f();
const double
A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
A3 = .24022650695886477918181338054308 / EXPPOLY_32F_A0,
@ -737,268 +666,6 @@ void exp64f( const double *_x, double *y, int n )
#define LOGTAB_SCALE 8
#define LOGTAB_MASK ((1 << LOGTAB_SCALE) - 1)
static const double CV_DECL_ALIGNED(16) logTab[] = {
0.0000000000000000000000000000000000000000, 1.000000000000000000000000000000000000000,
.00389864041565732288852075271279318258166, .9961089494163424124513618677042801556420,
.00778214044205494809292034119607706088573, .9922480620155038759689922480620155038760,
.01165061721997527263705585198749759001657, .9884169884169884169884169884169884169884,
.01550418653596525274396267235488267033361, .9846153846153846153846153846153846153846,
.01934296284313093139406447562578250654042, .9808429118773946360153256704980842911877,
.02316705928153437593630670221500622574241, .9770992366412213740458015267175572519084,
.02697658769820207233514075539915211265906, .9733840304182509505703422053231939163498,
.03077165866675368732785500469617545604706, .9696969696969696969696969696969696969697,
.03455238150665972812758397481047722976656, .9660377358490566037735849056603773584906,
.03831886430213659461285757856785494368522, .9624060150375939849624060150375939849624,
.04207121392068705056921373852674150839447, .9588014981273408239700374531835205992509,
.04580953603129420126371940114040626212953, .9552238805970149253731343283582089552239,
.04953393512227662748292900118940451648088, .9516728624535315985130111524163568773234,
.05324451451881227759255210685296333394944, .9481481481481481481481481481481481481481,
.05694137640013842427411105973078520037234, .9446494464944649446494464944649446494465,
.06062462181643483993820353816772694699466, .9411764705882352941176470588235294117647,
.06429435070539725460836422143984236754475, .9377289377289377289377289377289377289377,
.06795066190850773679699159401934593915938, .9343065693430656934306569343065693430657,
.07159365318700880442825962290953611955044, .9309090909090909090909090909090909090909,
.07522342123758751775142172846244648098944, .9275362318840579710144927536231884057971,
.07884006170777602129362549021607264876369, .9241877256317689530685920577617328519856,
.08244366921107458556772229485432035289706, .9208633093525179856115107913669064748201,
.08603433734180314373940490213499288074675, .9175627240143369175627240143369175627240,
.08961215868968712416897659522874164395031, .9142857142857142857142857142857142857143,
.09317722485418328259854092721070628613231, .9110320284697508896797153024911032028470,
.09672962645855109897752299730200320482256, .9078014184397163120567375886524822695035,
.10026945316367513738597949668474029749630, .9045936395759717314487632508833922261484,
.10379679368164355934833764649738441221420, .9014084507042253521126760563380281690141,
.10731173578908805021914218968959175981580, .8982456140350877192982456140350877192982,
.11081436634029011301105782649756292812530, .8951048951048951048951048951048951048951,
.11430477128005862852422325204315711744130, .8919860627177700348432055749128919860627,
.11778303565638344185817487641543266363440, .8888888888888888888888888888888888888889,
.12124924363286967987640707633545389398930, .8858131487889273356401384083044982698962,
.12470347850095722663787967121606925502420, .8827586206896551724137931034482758620690,
.12814582269193003360996385708858724683530, .8797250859106529209621993127147766323024,
.13157635778871926146571524895989568904040, .8767123287671232876712328767123287671233,
.13499516453750481925766280255629681050780, .8737201365187713310580204778156996587031,
.13840232285911913123754857224412262439730, .8707482993197278911564625850340136054422,
.14179791186025733629172407290752744302150, .8677966101694915254237288135593220338983,
.14518200984449788903951628071808954700830, .8648648648648648648648648648648648648649,
.14855469432313711530824207329715136438610, .8619528619528619528619528619528619528620,
.15191604202584196858794030049466527998450, .8590604026845637583892617449664429530201,
.15526612891112392955683674244937719777230, .8561872909698996655518394648829431438127,
.15860503017663857283636730244325008243330, .8533333333333333333333333333333333333333,
.16193282026931324346641360989451641216880, .8504983388704318936877076411960132890365,
.16524957289530714521497145597095368430010, .8476821192052980132450331125827814569536,
.16855536102980664403538924034364754334090, .8448844884488448844884488448844884488449,
.17185025692665920060697715143760433420540, .8421052631578947368421052631578947368421,
.17513433212784912385018287750426679849630, .8393442622950819672131147540983606557377,
.17840765747281828179637841458315961062910, .8366013071895424836601307189542483660131,
.18167030310763465639212199675966985523700, .8338762214983713355048859934853420195440,
.18492233849401198964024217730184318497780, .8311688311688311688311688311688311688312,
.18816383241818296356839823602058459073300, .8284789644012944983818770226537216828479,
.19139485299962943898322009772527962923050, .8258064516129032258064516129032258064516,
.19461546769967164038916962454095482826240, .8231511254019292604501607717041800643087,
.19782574332991986754137769821682013571260, .8205128205128205128205128205128205128205,
.20102574606059073203390141770796617493040, .8178913738019169329073482428115015974441,
.20421554142869088876999228432396193966280, .8152866242038216560509554140127388535032,
.20739519434607056602715147164417430758480, .8126984126984126984126984126984126984127,
.21056476910734961416338251183333341032260, .8101265822784810126582278481012658227848,
.21372432939771812687723695489694364368910, .8075709779179810725552050473186119873817,
.21687393830061435506806333251006435602900, .8050314465408805031446540880503144654088,
.22001365830528207823135744547471404075630, .8025078369905956112852664576802507836991,
.22314355131420973710199007200571941211830, .8000000000000000000000000000000000000000,
.22626367865045338145790765338460914790630, .7975077881619937694704049844236760124611,
.22937410106484582006380890106811420992010, .7950310559006211180124223602484472049689,
.23247487874309405442296849741978803649550, .7925696594427244582043343653250773993808,
.23556607131276688371634975283086532726890, .7901234567901234567901234567901234567901,
.23864773785017498464178231643018079921600, .7876923076923076923076923076923076923077,
.24171993688714515924331749374687206000090, .7852760736196319018404907975460122699387,
.24478272641769091566565919038112042471760, .7828746177370030581039755351681957186544,
.24783616390458124145723672882013488560910, .7804878048780487804878048780487804878049,
.25088030628580937353433455427875742316250, .7781155015197568389057750759878419452888,
.25391520998096339667426946107298135757450, .7757575757575757575757575757575757575758,
.25694093089750041913887912414793390780680, .7734138972809667673716012084592145015106,
.25995752443692604627401010475296061486000, .7710843373493975903614457831325301204819,
.26296504550088134477547896494797896593800, .7687687687687687687687687687687687687688,
.26596354849713793599974565040611196309330, .7664670658682634730538922155688622754491,
.26895308734550393836570947314612567424780, .7641791044776119402985074626865671641791,
.27193371548364175804834985683555714786050, .7619047619047619047619047619047619047619,
.27490548587279922676529508862586226314300, .7596439169139465875370919881305637982196,
.27786845100345625159121709657483734190480, .7573964497041420118343195266272189349112,
.28082266290088775395616949026589281857030, .7551622418879056047197640117994100294985,
.28376817313064456316240580235898960381750, .7529411764705882352941176470588235294118,
.28670503280395426282112225635501090437180, .7507331378299120234604105571847507331378,
.28963329258304265634293983566749375313530, .7485380116959064327485380116959064327485,
.29255300268637740579436012922087684273730, .7463556851311953352769679300291545189504,
.29546421289383584252163927885703742504130, .7441860465116279069767441860465116279070,
.29836697255179722709783618483925238251680, .7420289855072463768115942028985507246377,
.30126133057816173455023545102449133992200, .7398843930635838150289017341040462427746,
.30414733546729666446850615102448500692850, .7377521613832853025936599423631123919308,
.30702503529491181888388950937951449304830, .7356321839080459770114942528735632183908,
.30989447772286465854207904158101882785550, .7335243553008595988538681948424068767908,
.31275571000389684739317885942000430077330, .7314285714285714285714285714285714285714,
.31560877898630329552176476681779604405180, .7293447293447293447293447293447293447293,
.31845373111853458869546784626436419785030, .7272727272727272727272727272727272727273,
.32129061245373424782201254856772720813750, .7252124645892351274787535410764872521246,
.32411946865421192853773391107097268104550, .7231638418079096045197740112994350282486,
.32694034499585328257253991068864706903700, .7211267605633802816901408450704225352113,
.32975328637246797969240219572384376078850, .7191011235955056179775280898876404494382,
.33255833730007655635318997155991382896900, .7170868347338935574229691876750700280112,
.33535554192113781191153520921943709254280, .7150837988826815642458100558659217877095,
.33814494400871636381467055798566434532400, .7130919220055710306406685236768802228412,
.34092658697059319283795275623560883104800, .7111111111111111111111111111111111111111,
.34370051385331840121395430287520866841080, .7091412742382271468144044321329639889197,
.34646676734620857063262633346312213689100, .7071823204419889502762430939226519337017,
.34922538978528827602332285096053965389730, .7052341597796143250688705234159779614325,
.35197642315717814209818925519357435405250, .7032967032967032967032967032967032967033,
.35471990910292899856770532096561510115850, .7013698630136986301369863013698630136986,
.35745588892180374385176833129662554711100, .6994535519125683060109289617486338797814,
.36018440357500774995358483465679455548530, .6975476839237057220708446866485013623978,
.36290549368936841911903457003063522279280, .6956521739130434782608695652173913043478,
.36561919956096466943762379742111079394830, .6937669376693766937669376693766937669377,
.36832556115870762614150635272380895912650, .6918918918918918918918918918918918918919,
.37102461812787262962487488948681857436900, .6900269541778975741239892183288409703504,
.37371640979358405898480555151763837784530, .6881720430107526881720430107526881720430,
.37640097516425302659470730759494472295050, .6863270777479892761394101876675603217158,
.37907835293496944251145919224654790014030, .6844919786096256684491978609625668449198,
.38174858149084833769393299007788300514230, .6826666666666666666666666666666666666667,
.38441169891033200034513583887019194662580, .6808510638297872340425531914893617021277,
.38706774296844825844488013899535872042180, .6790450928381962864721485411140583554377,
.38971675114002518602873692543653305619950, .6772486772486772486772486772486772486772,
.39235876060286384303665840889152605086580, .6754617414248021108179419525065963060686,
.39499380824086893770896722344332374632350, .6736842105263157894736842105263157894737,
.39762193064713846624158577469643205404280, .6719160104986876640419947506561679790026,
.40024316412701266276741307592601515352730, .6701570680628272251308900523560209424084,
.40285754470108348090917615991202183067800, .6684073107049608355091383812010443864230,
.40546510810816432934799991016916465014230, .6666666666666666666666666666666666666667,
.40806588980822172674223224930756259709600, .6649350649350649350649350649350649350649,
.41065992498526837639616360320360399782650, .6632124352331606217616580310880829015544,
.41324724855021932601317757871584035456180, .6614987080103359173126614987080103359173,
.41582789514371093497757669865677598863850, .6597938144329896907216494845360824742268,
.41840189913888381489925905043492093682300, .6580976863753213367609254498714652956298,
.42096929464412963239894338585145305842150, .6564102564102564102564102564102564102564,
.42353011550580327293502591601281892508280, .6547314578005115089514066496163682864450,
.42608439531090003260516141381231136620050, .6530612244897959183673469387755102040816,
.42863216738969872610098832410585600882780, .6513994910941475826972010178117048346056,
.43117346481837132143866142541810404509300, .6497461928934010152284263959390862944162,
.43370832042155937902094819946796633303180, .6481012658227848101265822784810126582278,
.43623676677491801667585491486534010618930, .6464646464646464646464646464646464646465,
.43875883620762790027214350629947148263450, .6448362720403022670025188916876574307305,
.44127456080487520440058801796112675219780, .6432160804020100502512562814070351758794,
.44378397241030093089975139264424797147500, .6416040100250626566416040100250626566416,
.44628710262841947420398014401143882423650, .6400000000000000000000000000000000000000,
.44878398282700665555822183705458883196130, .6384039900249376558603491271820448877805,
.45127464413945855836729492693848442286250, .6368159203980099502487562189054726368159,
.45375911746712049854579618113348260521900, .6352357320099255583126550868486352357320,
.45623743348158757315857769754074979573500, .6336633663366336633663366336633663366337,
.45870962262697662081833982483658473938700, .6320987654320987654320987654320987654321,
.46117571512217014895185229761409573256980, .6305418719211822660098522167487684729064,
.46363574096303250549055974261136725544930, .6289926289926289926289926289926289926290,
.46608972992459918316399125615134835243230, .6274509803921568627450980392156862745098,
.46853771156323925639597405279346276074650, .6259168704156479217603911980440097799511,
.47097971521879100631480241645476780831830, .6243902439024390243902439024390243902439,
.47341577001667212165614273544633761048330, .6228710462287104622871046228710462287105,
.47584590486996386493601107758877333253630, .6213592233009708737864077669902912621359,
.47827014848147025860569669930555392056700, .6198547215496368038740920096852300242131,
.48068852934575190261057286988943815231330, .6183574879227053140096618357487922705314,
.48310107575113581113157579238759353756900, .6168674698795180722891566265060240963855,
.48550781578170076890899053978500887751580, .6153846153846153846153846153846153846154,
.48790877731923892879351001283794175833480, .6139088729016786570743405275779376498801,
.49030398804519381705802061333088204264650, .6124401913875598086124401913875598086124,
.49269347544257524607047571407747454941280, .6109785202863961813842482100238663484487,
.49507726679785146739476431321236304938800, .6095238095238095238095238095238095238095,
.49745538920281889838648226032091770321130, .6080760095011876484560570071258907363420,
.49982786955644931126130359189119189977650, .6066350710900473933649289099526066350711,
.50219473456671548383667413872899487614650, .6052009456264775413711583924349881796690,
.50455601075239520092452494282042607665050, .6037735849056603773584905660377358490566,
.50691172444485432801997148999362252652650, .6023529411764705882352941176470588235294,
.50926190178980790257412536448100581765150, .6009389671361502347417840375586854460094,
.51160656874906207391973111953120678663250, .5995316159250585480093676814988290398126,
.51394575110223428282552049495279788970950, .5981308411214953271028037383177570093458,
.51627947444845445623684554448118433356300, .5967365967365967365967365967365967365967,
.51860776420804555186805373523384332656850, .5953488372093023255813953488372093023256,
.52093064562418522900344441950437612831600, .5939675174013921113689095127610208816705,
.52324814376454775732838697877014055848100, .5925925925925925925925925925925925925926,
.52556028352292727401362526507000438869000, .5912240184757505773672055427251732101617,
.52786708962084227803046587723656557500350, .5898617511520737327188940092165898617512,
.53016858660912158374145519701414741575700, .5885057471264367816091954022988505747126,
.53246479886947173376654518506256863474850, .5871559633027522935779816513761467889908,
.53475575061602764748158733709715306758900, .5858123569794050343249427917620137299771,
.53704146589688361856929077475797384977350, .5844748858447488584474885844748858447489,
.53932196859560876944783558428753167390800, .5831435079726651480637813211845102505695,
.54159728243274429804188230264117009937750, .5818181818181818181818181818181818181818,
.54386743096728351609669971367111429572100, .5804988662131519274376417233560090702948,
.54613243759813556721383065450936555862450, .5791855203619909502262443438914027149321,
.54839232556557315767520321969641372561450, .5778781038374717832957110609480812641084,
.55064711795266219063194057525834068655950, .5765765765765765765765765765765765765766,
.55289683768667763352766542084282264113450, .5752808988764044943820224719101123595506,
.55514150754050151093110798683483153581600, .5739910313901345291479820627802690582960,
.55738115013400635344709144192165695130850, .5727069351230425055928411633109619686801,
.55961578793542265941596269840374588966350, .5714285714285714285714285714285714285714,
.56184544326269181269140062795486301183700, .5701559020044543429844097995545657015590,
.56407013828480290218436721261241473257550, .5688888888888888888888888888888888888889,
.56628989502311577464155334382667206227800, .5676274944567627494456762749445676274945,
.56850473535266865532378233183408156037350, .5663716814159292035398230088495575221239,
.57071468100347144680739575051120482385150, .5651214128035320088300220750551876379691,
.57291975356178548306473885531886480748650, .5638766519823788546255506607929515418502,
.57511997447138785144460371157038025558000, .5626373626373626373626373626373626373626,
.57731536503482350219940144597785547375700, .5614035087719298245614035087719298245614,
.57950594641464214795689713355386629700650, .5601750547045951859956236323851203501094,
.58169173963462239562716149521293118596100, .5589519650655021834061135371179039301310,
.58387276558098266665552955601015128195300, .5577342047930283224400871459694989106754,
.58604904500357812846544902640744112432000, .5565217391304347826086956521739130434783,
.58822059851708596855957011939608491957200, .5553145336225596529284164859002169197397,
.59038744660217634674381770309992134571100, .5541125541125541125541125541125541125541,
.59254960960667157898740242671919986605650, .5529157667386609071274298056155507559395,
.59470710774669277576265358220553025603300, .5517241379310344827586206896551724137931,
.59685996110779382384237123915227130055450, .5505376344086021505376344086021505376344,
.59900818964608337768851242799428291618800, .5493562231759656652360515021459227467811,
.60115181318933474940990890900138765573500, .5481798715203426124197002141327623126338,
.60329085143808425240052883964381180703650, .5470085470085470085470085470085470085470,
.60542532396671688843525771517306566238400, .5458422174840085287846481876332622601279,
.60755525022454170969155029524699784815300, .5446808510638297872340425531914893617021,
.60968064953685519036241657886421307921400, .5435244161358811040339702760084925690021,
.61180154110599282990534675263916142284850, .5423728813559322033898305084745762711864,
.61391794401237043121710712512140162289150, .5412262156448202959830866807610993657505,
.61602987721551394351138242200249806046500, .5400843881856540084388185654008438818565,
.61813735955507864705538167982012964785100, .5389473684210526315789473684210526315789,
.62024040975185745772080281312810257077200, .5378151260504201680672268907563025210084,
.62233904640877868441606324267922900617100, .5366876310272536687631027253668763102725,
.62443328801189346144440150965237990021700, .5355648535564853556485355648535564853556,
.62652315293135274476554741340805776417250, .5344467640918580375782881002087682672234,
.62860865942237409420556559780379757285100, .5333333333333333333333333333333333333333,
.63068982562619868570408243613201193511500, .5322245322245322245322245322245322245322,
.63276666957103777644277897707070223987100, .5311203319502074688796680497925311203320,
.63483920917301017716738442686619237065300, .5300207039337474120082815734989648033126,
.63690746223706917739093569252872839570050, .5289256198347107438016528925619834710744,
.63897144645792069983514238629140891134750, .5278350515463917525773195876288659793814,
.64103117942093124081992527862894348800200, .5267489711934156378600823045267489711934,
.64308667860302726193566513757104985415950, .5256673511293634496919917864476386036961,
.64513796137358470073053240412264131009600, .5245901639344262295081967213114754098361,
.64718504499530948859131740391603671014300, .5235173824130879345603271983640081799591,
.64922794662510974195157587018911726772800, .5224489795918367346938775510204081632653,
.65126668331495807251485530287027359008800, .5213849287169042769857433808553971486762,
.65330127201274557080523663898929953575150, .5203252032520325203252032520325203252033,
.65533172956312757406749369692988693714150, .5192697768762677484787018255578093306288,
.65735807270835999727154330685152672231200, .5182186234817813765182186234817813765182,
.65938031808912778153342060249997302889800, .5171717171717171717171717171717171717172,
.66139848224536490484126716182800009846700, .5161290322580645161290322580645161290323,
.66341258161706617713093692145776003599150, .5150905432595573440643863179074446680080,
.66542263254509037562201001492212526500250, .5140562248995983935742971887550200803213,
.66742865127195616370414654738851822912700, .5130260521042084168336673346693386773547,
.66943065394262923906154583164607174694550, .5120000000000000000000000000000000000000,
.67142865660530226534774556057527661323550, .5109780439121756487025948103792415169661,
.67342267521216669923234121597488410770900, .5099601593625498007968127490039840637450,
.67541272562017662384192817626171745359900, .5089463220675944333996023856858846918489,
.67739882359180603188519853574689477682100, .5079365079365079365079365079365079365079,
.67938098479579733801614338517538271844400, .5069306930693069306930693069306930693069,
.68135922480790300781450241629499942064300, .5059288537549407114624505928853754940711,
.68333355911162063645036823800182901322850, .5049309664694280078895463510848126232742,
.68530400309891936760919861626462079584600, .5039370078740157480314960629921259842520,
.68727057207096020619019327568821609020250, .5029469548133595284872298624754420432220,
.68923328123880889251040571252815425395950, .5019607843137254901960784313725490196078,
.69314718055994530941723212145818, 5.0e-01,
};
static float logTab_f[(LOGTAB_MASK+1)*2];
static volatile bool logTab_f_initialized = false;
#define LOGTAB_TRANSLATE(tab, x, h) (((x) - 1.f)*tab[(h)+1])
static const double ln_2 = 0.69314718055994530941723212145818;
@ -1006,15 +673,10 @@ void log32f( const float *_x, float *y, int n )
{
CV_INSTRUMENT_REGION()
if( !logTab_f_initialized )
{
for( int j = 0; j < (LOGTAB_MASK+1)*2; j++ )
logTab_f[j] = (float)logTab[j];
logTab_f_initialized = true;
}
const float* const logTab_f = cv::details::getLogTab32f();
static const int LOGTAB_MASK2_32F = (1 << (23 - LOGTAB_SCALE)) - 1;
static const float
const int LOGTAB_MASK2_32F = (1 << (23 - LOGTAB_SCALE)) - 1;
const float
A0 = 0.3333333333333333333333333f,
A1 = -0.5f,
A2 = 1.f;
@ -1082,8 +744,10 @@ void log64f( const double *x, double *y, int n )
{
CV_INSTRUMENT_REGION()
static const int64 LOGTAB_MASK2_64F = ((int64)1 << (52 - LOGTAB_SCALE)) - 1;
static const double
const double* const logTab = cv::details::getLogTab64f();
const int64 LOGTAB_MASK2_64F = ((int64)1 << (52 - LOGTAB_SCALE)) - 1;
const double
A7 = 1.0,
A6 = -0.5,
A5 = 0.333333333333333314829616256247390992939472198486328125,

View File

@ -801,10 +801,12 @@ TraceStorage* TraceManagerThreadLocal::getStorage() const
const char* pos = strrchr(filepath.c_str(), '/'); // extract filename
#ifdef _WIN32
if (!pos)
strrchr(filepath.c_str(), '\\');
pos = strrchr(filepath.c_str(), '\\');
#endif
if (!pos)
pos = filepath.c_str();
else
pos += 1; // fix to skip extra slash in filename beginning
msg.printf("#thread file: %s\n", pos);
global->put(msg);
storage.reset(new AsyncTraceStorage(filepath));

View File

@ -59,6 +59,20 @@
A network training is in principle not supported.
@}
*/
/** @example samples/dnn/classification.cpp
Check @ref tutorial_dnn_googlenet "the corresponding tutorial" for more details
*/
/** @example samples/dnn/colorization.cpp
*/
/** @example samples/dnn/object_detection.cpp
Check @ref tutorial_dnn_yolo "the corresponding tutorial" for more details
*/
/** @example samples/dnn/openpose.cpp
*/
/** @example samples/dnn/segmentation.cpp
*/
/** @example samples/dnn/text_detection.cpp
*/
#include <opencv2/dnn/dnn.hpp>
#endif /* OPENCV_DNN_HPP */

View File

@ -104,8 +104,12 @@ def l2norm(x, name):
inp = tf.placeholder(dtype, [1, 300, 300, 3], 'data')
data_bn = batch_norm(inp, 'data_bn')
data_scale = scale(data_bn, 'data_scale')
data_scale = tf.pad(data_scale, [[0, 0], [3, 3], [3, 3], [0, 0]])
# Instead of tf.pad we use tf.space_to_batch_nd layers which override convolution's padding strategy to explicit numbers
# data_scale = tf.pad(data_scale, [[0, 0], [3, 3], [3, 3], [0, 0]])
data_scale = tf.space_to_batch_nd(data_scale, [1, 1], [[3, 3], [3, 3]], name='Pad')
conv1_h = conv(data_scale, stride=2, pad='VALID', name='conv1_h')
conv1_bn_h = batch_norm(conv1_h, 'conv1_bn_h')
conv1_scale_h = scale(conv1_bn_h, 'conv1_scale_h')
conv1_relu = tf.nn.relu(conv1_scale_h)
@ -133,8 +137,11 @@ layer_128_1_sum = layer_128_1_conv2 + layer_128_1_conv_expand_h
layer_256_1_bn1 = batch_norm(layer_128_1_sum, 'layer_256_1_bn1')
layer_256_1_scale1 = scale(layer_256_1_bn1, 'layer_256_1_scale1')
layer_256_1_relu1 = tf.nn.relu(layer_256_1_scale1)
layer_256_1_conv1 = tf.pad(layer_256_1_relu1, [[0, 0], [1, 1], [1, 1], [0, 0]])
# layer_256_1_conv1 = tf.pad(layer_256_1_relu1, [[0, 0], [1, 1], [1, 1], [0, 0]])
layer_256_1_conv1 = tf.space_to_batch_nd(layer_256_1_relu1, [1, 1], [[1, 1], [1, 1]], name='Pad_1')
layer_256_1_conv1 = conv(layer_256_1_conv1, stride=2, pad='VALID', name='layer_256_1_conv1')
layer_256_1_bn2 = batch_norm(layer_256_1_conv1, 'layer_256_1_bn2')
layer_256_1_scale2 = scale(layer_256_1_bn2, 'layer_256_1_scale2')
layer_256_1_relu2 = tf.nn.relu(layer_256_1_scale2)
@ -160,8 +167,11 @@ fc7 = tf.nn.relu(last_scale_h, name='last_relu')
conv6_1_h = conv(fc7, 'conv6_1_h', activ=tf.nn.relu)
conv6_2_h = conv(conv6_1_h, stride=2, name='conv6_2_h', activ=tf.nn.relu)
conv7_1_h = conv(conv6_2_h, 'conv7_1_h', activ=tf.nn.relu)
conv7_2_h = tf.pad(conv7_1_h, [[0, 0], [1, 1], [1, 1], [0, 0]])
# conv7_2_h = tf.pad(conv7_1_h, [[0, 0], [1, 1], [1, 1], [0, 0]])
conv7_2_h = tf.space_to_batch_nd(conv7_1_h, [1, 1], [[1, 1], [1, 1]], name='Pad_2')
conv7_2_h = conv(conv7_2_h, stride=2, pad='VALID', name='conv7_2_h', activ=tf.nn.relu)
conv8_1_h = conv(conv7_2_h, pad='SAME', name='conv8_1_h', activ=tf.nn.relu)
conv8_2_h = conv(conv8_1_h, pad='SAME', name='conv8_2_h', activ=tf.nn.relu)
conv9_1_h = conv(conv8_2_h, 'conv9_1_h', activ=tf.nn.relu)
@ -201,6 +211,7 @@ with tf.Session() as sess:
inputData = np.random.standard_normal([1, 3, 300, 300]).astype(np.float32)
cvNet.setInput(inputData)
cvNet.setPreferableBackend(cv.dnn.DNN_BACKEND_OPENCV)
outDNN = cvNet.forward(out_nodes)
outTF = sess.run([mbox_loc, mbox_conf_flatten], feed_dict={inp: inputData.transpose(0, 2, 3, 1)})
@ -254,7 +265,7 @@ for i in reversed(range(len(graph_def.node))):
del graph_def.node[i]
for attr in ['T', 'data_format', 'Tshape', 'N', 'Tidx', 'Tdim',
'use_cudnn_on_gpu', 'Index', 'Tperm', 'is_training',
'Tpaddings']:
'Tpaddings', 'Tblock_shape', 'Tcrops']:
if attr in graph_def.node[i].attr:
del graph_def.node[i].attr[attr]

View File

@ -63,9 +63,18 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() &&
pnorm == 2 && !blobs.empty();
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
{
if (pnorm != 2)
return false;
if (!blobs.empty())
return true;
if (preferableTarget == DNN_TARGET_MYRIAD)
return !acrossSpatial;
return startAxis == 1 && (!acrossSpatial || endAxis > 1);
}
else
return backendId == DNN_BACKEND_OPENCV;
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@ -80,6 +89,14 @@ public:
return true;
}
void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs) CV_OVERRIDE
{
CV_Assert(inputs.size() == 1);
endAxis = endAxis == -1 ? (inputs[0]->dims - 1) : endAxis;
startAxis = startAxis == -1 ? (inputs[0]->dims - 1) : startAxis;
acrossSpatial = (startAxis == 1 && endAxis == inputs[0]->dims - 1);
}
#ifdef HAVE_OPENCL
bool forward_ocl(InputArrayOfArrays inputs_, OutputArrayOfArrays outputs_, OutputArrayOfArrays internals_)
{
@ -240,24 +257,52 @@ public:
}
}
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> >&) CV_OVERRIDE
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> >& inputs) CV_OVERRIDE
{
#ifdef HAVE_INF_ENGINE
InferenceEngine::DataPtr input = infEngineDataNode(inputs[0]);
InferenceEngine::LayerParams lp;
lp.name = name;
lp.type = "Normalize";
lp.precision = InferenceEngine::Precision::FP32;
std::shared_ptr<InferenceEngine::CNNLayer> ieLayer(new InferenceEngine::CNNLayer(lp));
CV_Assert(!blobs.empty());
if (input->dims.size() == 4)
{
const int numChannels = input->dims[2]; // NOTE: input->dims are reversed (whcn)
ieLayer->params["eps"] = format("%f", epsilon);
ieLayer->params["across_spatial"] = acrossSpatial ? "1" : "0";
ieLayer->params["channel_shared"] = blobs[0].total() == 1 ? "1" : "0";
const size_t numChannels = blobs[0].total();
ieLayer->blobs["weights"] = wrapToInfEngineBlob(blobs[0], {numChannels}, InferenceEngine::Layout::C);
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
lp.type = "Normalize";
std::shared_ptr<InferenceEngine::CNNLayer> ieLayer(new InferenceEngine::CNNLayer(lp));
if (blobs.empty())
{
auto weights = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
InferenceEngine::Layout::C,
{numChannels});
weights->allocate();
std::vector<float> ones(numChannels, 1);
weights->set(ones);
ieLayer->blobs["weights"] = weights;
ieLayer->params["channel_shared"] = "0";
}
else
{
CV_Assert(numChannels == blobs[0].total());
ieLayer->blobs["weights"] = wrapToInfEngineBlob(blobs[0], {numChannels}, InferenceEngine::Layout::C);
ieLayer->params["channel_shared"] = blobs[0].total() == 1 ? "1" : "0";
}
ieLayer->params["eps"] = format("%f", epsilon);
ieLayer->params["across_spatial"] = acrossSpatial ? "1" : "0";
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
}
else
{
InferenceEngine::LayerParams lp;
lp.name = name;
lp.type = "GRN";
lp.precision = InferenceEngine::Precision::FP32;
std::shared_ptr<InferenceEngine::CNNLayer> ieLayer(new InferenceEngine::CNNLayer(lp));
ieLayer->params["bias"] = format("%f", epsilon);
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
}
#endif // HAVE_INF_ENGINE
return Ptr<BackendNode>();
}

View File

@ -529,7 +529,8 @@ const tensorflow::TensorProto& TFImporter::getConstBlob(const tensorflow::NodeDe
Pin kernel_inp = parsePin(layer.input(input_blob_index));
if (const_layers.find(kernel_inp.name) == const_layers.end())
CV_Error(Error::StsError, "Const kernel input not found");
CV_Error(Error::StsError, "Input [" + layer.input(input_blob_index) +
"] for node [" + layer.name() + "] not found");
if (kernel_inp.blobIndex != 0)
CV_Error(Error::StsError, "Unsupported kernel input");
@ -867,13 +868,13 @@ void TFImporter::populateNet(Net dstNet)
layerParams.set("num_output", layerParams.blobs[0].size[0]);
setStrides(layerParams, layer);
setPadding(layerParams, layer);
if (!layerParams.has("pad_w") && !layerParams.has("pad_h"))
setPadding(layerParams, layer);
// The final node of dilated convolution subgraph.
next_layers = getNextLayers(net, name, "BatchToSpaceND");
if (!next_layers.empty())
{
layerParams.set("pad_mode", ""); // We use padding values.
CV_Assert(next_layers.size() == 1);
ExcludeLayer(net, next_layers[0].second, 0, false);
layers_to_ignore.insert(next_layers[0].first);

View File

@ -240,7 +240,7 @@ TEST_P(Test_TensorFlow_layers, l2_normalize)
// TODO: fix it and add to l2_normalize
TEST_P(Test_TensorFlow_layers, l2_normalize_3d)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU)
throw SkipTestException("");
runTensorFlowNet("l2_normalize_3d");
}
@ -361,10 +361,6 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
{
checkBackend();
if (backend == DNN_BACKEND_INFERENCE_ENGINE &&
(target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
std::string proto = findDataFile("dnn/opencv_face_detector.pbtxt", false);
std::string model = findDataFile("dnn/opencv_face_detector_uint8.pb", false);
@ -387,7 +383,7 @@ TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
0, 1, 0.97203469, 0.67965847, 0.06876482, 0.73999709, 0.1513494,
0, 1, 0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 4e-3 : 3.4e-3;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.017 : 1e-2;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.024 : 1e-2;
normAssertDetections(ref, out, "", 0.9, scoreDiff, iouDiff);
}

View File

@ -452,12 +452,13 @@ The function getWindowImageRect returns the client screen coordinates, width and
*/
CV_EXPORTS_W Rect getWindowImageRect(const String& winname);
/** @example samples/cpp/create_mask.cpp
This program demonstrates using mouse events and how to make and use a mask image (black and white) .
*/
/** @brief Sets mouse handler for the specified window
@param winname Name of the window.
@param onMouse Mouse callback. See OpenCV samples, such as
<https://github.com/opencv/opencv/tree/master/samples/cpp/ffilldemo.cpp>, on how to specify and
use the callback.
@param onMouse Callback function for mouse events. See OpenCV samples on how to specify and use the callback.
@param userdata The optional parameter passed to the callback.
*/
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);

View File

@ -1191,7 +1191,7 @@ protected:
//! @addtogroup imgproc_feature
//! @{
/** @example lsd_lines.cpp
/** @example samples/cpp/lsd_lines.cpp
An example using the LineSegmentDetector
\image html building_lsd.png "Sample output image" width=434 height=300
*/
@ -1349,11 +1349,12 @@ operation is shifted.
*/
CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1));
/** @example Smoothing.cpp
/** @example samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp
Sample code for simple filters
![Sample screenshot](Smoothing_Tutorial_Result_Median_Filter.jpg)
Check @ref tutorial_gausian_median_blur_bilateral_filter "the corresponding tutorial" for more details
*/
/** @brief Blurs an image using the median filter.
The function smoothes an image using the median filter with the \f$\texttt{ksize} \times
@ -1556,11 +1557,12 @@ CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
Point anchor = Point(-1,-1),
double delta = 0, int borderType = BORDER_DEFAULT );
/** @example Sobel_Demo.cpp
/** @example samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
![Sample screenshot](Sobel_Derivatives_Tutorial_Result.jpg)
Check @ref tutorial_sobel_derivatives "the corresponding tutorial" for more details
*/
*/
/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to
@ -1656,8 +1658,8 @@ CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth,
int dx, int dy, double scale = 1, double delta = 0,
int borderType = BORDER_DEFAULT );
/** @example laplace.cpp
An example using Laplace transformations for edge detection
/** @example samples/cpp/laplace.cpp
An example using Laplace transformations for edge detection
*/
/** @brief Calculates the Laplacian of an image.
@ -1692,10 +1694,10 @@ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
//! @addtogroup imgproc_feature
//! @{
/** @example edge.cpp
This program demonstrates usage of the Canny edge detector
/** @example samples/cpp/edge.cpp
This program demonstrates usage of the Canny edge detector
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
*/
/** @brief Finds edges in an image using the Canny algorithm @cite Canny86 .
@ -1851,7 +1853,7 @@ where \f${DI_{p_i}}\f$ is an image gradient at one of the points \f$p_i\f$ in a
value of \f$q\f$ is to be found so that \f$\epsilon_i\f$ is minimized. A system of equations may be set up
with \f$\epsilon_i\f$ set to zero:
\f[\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\f]
\f[\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\f]
where the gradients are summed within a neighborhood ("search window") of \f$q\f$ . Calling the first
gradient term \f$G\f$ and the second gradient term \f$b\f$ gives:
@ -1865,7 +1867,7 @@ until the center stays within a set threshold.
@param corners Initial coordinates of the input corners and refined coordinates provided for
output.
@param winSize Half of the side length of the search window. For example, if winSize=Size(5,5) ,
then a \f$5*2+1 \times 5*2+1 = 11 \times 11\f$ search window is used.
then a \f$(5*2+1) \times (5*2+1) = 11 \times 11\f$ search window is used.
@param zeroZone Half of the size of the dead region in the middle of the search zone over which
the summation in the formula below is not done. It is used sometimes to avoid possible
singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such
@ -1932,7 +1934,7 @@ CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
InputArray mask, int blockSize,
int gradientSize, bool useHarrisDetector = false,
double k = 0.04 );
/** @example houghlines.cpp
/** @example samples/cpp/tutorial_code/ImgTrans/houghlines.cpp
An example using the Hough line detector
![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg)
*/
@ -2021,7 +2023,7 @@ CV_EXPORTS_W void HoughLinesPointSet( InputArray _point, OutputArray _lines, int
double min_rho, double max_rho, double rho_step,
double min_theta, double max_theta, double theta_step );
/** @example houghcircles.cpp
/** @example samples/cpp/tutorial_code/ImgTrans/houghcircles.cpp
An example using the Hough circle detector
*/
@ -2069,7 +2071,7 @@ CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
//! @addtogroup imgproc_filter
//! @{
/** @example morphology2.cpp
/** @example samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
Advanced morphology Transformations sample code
![Sample screenshot](Morphology_2_Tutorial_Result.jpg)
Check @ref tutorial_opening_closing_hats "the corresponding tutorial" for more details
@ -2102,11 +2104,12 @@ CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue() );
/** @example Morphology_1.cpp
/** @example samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp
Erosion and Dilation sample code
![Sample Screenshot-Erosion](Morphology_1_Tutorial_Erosion_Result.jpg)![Sample Screenshot-Dilation](Morphology_1_Tutorial_Dilation_Result.jpg)
Check @ref tutorial_erosion_dilatation "the corresponding tutorial" for more details
*/
*/
/** @brief Dilates an image by using a specific structuring element.
The function dilates the source image using the specified structuring element that determines the
@ -2236,9 +2239,10 @@ CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
int borderMode = BORDER_CONSTANT,
const Scalar& borderValue = Scalar());
/** @example warpPerspective_demo.cpp
/** @example samples/cpp/warpPerspective_demo.cpp
An example program shows using cv::findHomography and cv::warpPerspective for image warping
*/
*/
/** @brief Applies a perspective transformation to an image.
The function warpPerspective transforms the source image using the specified matrix:
@ -2436,7 +2440,7 @@ source image. The center must be inside the image.
CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
Point2f center, OutputArray patch, int patchType = -1 );
/** @example polar_transforms.cpp
/** @example samples/cpp/polar_transforms.cpp
An example using the cv::linearPolar and cv::logPolar operations
*/
@ -2871,9 +2875,10 @@ CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
//! @addtogroup imgproc_filter
//! @{
/** @example Pyramids.cpp
/** @example samples/cpp/tutorial_code/ImgProc/Pyramids/Pyramids.cpp
An example using pyrDown and pyrUp functions
*/
*/
/** @brief Blurs an image and downsamples it.
By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in
@ -3122,7 +3127,7 @@ CV_EXPORTS_AS(undistortPointsIter) void undistortPoints( InputArray src, OutputA
//! @addtogroup imgproc_hist
//! @{
/** @example demhist.cpp
/** @example samples/cpp/demhist.cpp
An example for creating histograms of an image
*/
@ -3319,9 +3324,9 @@ CV_EXPORTS_AS(EMD) float wrapperEMD( InputArray signature1, InputArray signature
//! @} imgproc_hist
/** @example watershed.cpp
/** @example samples/cpp/watershed.cpp
An example using the watershed algorithm
*/
*/
/** @brief Performs a marker-based image segmentation using the watershed algorithm.
@ -3399,10 +3404,10 @@ CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
//! @addtogroup imgproc_misc
//! @{
/** @example grabcut.cpp
/** @example samples/cpp/grabcut.cpp
An example using the GrabCut algorithm
![Sample Screenshot](grabcut_output1.jpg)
*/
*/
/** @brief Runs the GrabCut algorithm.
@ -3426,11 +3431,10 @@ CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect,
InputOutputArray bgdModel, InputOutputArray fgdModel,
int iterCount, int mode = GC_EVAL );
/** @example distrans.cpp
An example on using the distance transform\
/** @example samples/cpp/distrans.cpp
An example on using the distance transform
*/
/** @brief Calculates the distance to the closest zero pixel for each pixel of the source image.
The function cv::distanceTransform calculates the approximate or precise distance from every binary
@ -3502,8 +3506,8 @@ the first variant of the function and distanceType == #DIST_L1.
CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst,
int distanceType, int maskSize, int dstType=CV_32F);
/** @example ffilldemo.cpp
An example using the FloodFill technique
/** @example samples/cpp/ffilldemo.cpp
An example using the FloodFill technique
*/
/** @overload
@ -3703,9 +3707,10 @@ enum TemplateMatchModes {
TM_CCOEFF_NORMED = 5 //!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} }\f]
};
/** @example MatchTemplate_Demo.cpp
/** @example samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
An example using Template Matching algorithm
*/
*/
/** @brief Compares a template against overlapped image regions.
The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against
@ -3737,6 +3742,10 @@ CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
//! @addtogroup imgproc_shape
//! @{
/** @example samples/cpp/connected_components.cpp
This program demonstrates connected components and use of the trackbar
*/
/** @brief computes the connected components labeled image of boolean image
image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
@ -3844,6 +3853,16 @@ CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays cont
CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours,
int mode, int method, Point offset = Point());
/** @example samples/cpp/squares.cpp
A program using pyramid scaling, Canny, contours and contour simplification to find
squares in a list of images (pic1-6.png). Returns sequence of squares detected on the image.
*/
/** @example samples/tapi/squares.cpp
A program using pyramid scaling, Canny, contours and contour simplification to find
squares in the input image.
*/
/** @brief Approximates a polygonal curve(s) with the specified precision.
The function cv::approxPolyDP approximates a curve or a polygon with another curve/polygon with less
@ -3942,8 +3961,8 @@ The function finds the minimal enclosing circle of a 2D point set using an itera
CV_EXPORTS_W void minEnclosingCircle( InputArray points,
CV_OUT Point2f& center, CV_OUT float& radius );
/** @example minarea.cpp
*/
/** @example samples/cpp/minarea.cpp
*/
/** @brief Finds a triangle of minimum area enclosing a 2D point set and returns its area.
@ -3978,7 +3997,7 @@ The function compares two shapes. All three implemented methods use the Hu invar
CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
int method, double parameter );
/** @example convexhull.cpp
/** @example samples/cpp/convexhull.cpp
An example using the convexHull functionality
*/
@ -4038,8 +4057,8 @@ CV_EXPORTS_W bool isContourConvex( InputArray contour );
CV_EXPORTS_W float intersectConvexConvex( InputArray _p1, InputArray _p2,
OutputArray _p12, bool handleNested = true );
/** @example fitellipse.cpp
An example using the fitEllipse technique
/** @example samples/cpp/fitellipse.cpp
An example using the fitEllipse technique
*/
/** @brief Fits an ellipse around a set of 2D points.
@ -4255,9 +4274,10 @@ enum ColormapTypes
COLORMAP_PARULA = 12 //!< ![parula](pics/colormaps/colorscale_parula.jpg)
};
/** @example falsecolor.cpp
/** @example samples/cpp/falsecolor.cpp
An example using applyColorMap function
*/
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@ -4344,9 +4364,10 @@ CV_EXPORTS_W void rectangle(InputOutputArray img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
/** @example Drawing_2.cpp
/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp
An example using drawing functions
*/
*/
/** @brief Draws a circle.
The function cv::circle draws a simple or filled circle with a given center and radius.
@ -4470,9 +4491,11 @@ CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
const Scalar& color, int lineType = LINE_8, int shift = 0,
Point offset = Point() );
/** @example Drawing_1.cpp
/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp
An example using drawing functions
*/
Check @ref tutorial_random_generator_and_text "the corresponding tutorial" for more details
*/
/** @brief Fills the area bounded by one or more polygons.
The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill
@ -4512,14 +4535,14 @@ CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
bool isClosed, const Scalar& color,
int thickness = 1, int lineType = LINE_8, int shift = 0 );
/** @example contours2.cpp
An example program illustrates the use of cv::findContours and cv::drawContours
\image html WindowsQtContoursOutput.png "Screenshot of the program"
/** @example samples/cpp/contours2.cpp
An example program illustrates the use of cv::findContours and cv::drawContours
\image html WindowsQtContoursOutput.png "Screenshot of the program"
*/
/** @example segment_objects.cpp
/** @example samples/cpp/segment_objects.cpp
An example using drawContours to clean up a background segmentation result
*/
*/
/** @brief Draws contours outlines or filled contours.

View File

@ -51,12 +51,13 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
{
CV_INSTRUMENT_REGION()
const float samePointEps = 0.00001f; // used to test if two points are the same
// L2 metric
const float samePointEps = std::max(1e-16f, 1e-6f * (float)std::max(rect1.size.area(), rect2.size.area()));
Point2f vec1[4], vec2[4];
Point2f pts1[4], pts2[4];
std::vector <Point2f> intersection;
std::vector <Point2f> intersection; intersection.reserve(24);
rect1.points(pts1);
rect2.points(pts2);
@ -219,41 +220,80 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
}
}
// Get rid of dupes and order points.
for( int i = 0; i < (int)intersection.size()-1; i++ )
int N = (int)intersection.size();
if (N == 0)
{
float dx1 = intersection[i + 1].x - intersection[i].x;
float dy1 = intersection[i + 1].y - intersection[i].y;
for( size_t j = i+1; j < intersection.size(); j++ )
{
float dx = intersection[j].x - intersection[i].x;
float dy = intersection[j].y - intersection[i].y;
double d2 = dx*dx + dy*dy; // can be a really small number, need double here
return INTERSECT_NONE;
}
if( d2 < samePointEps*samePointEps )
// Get rid of duplicated points
int Nstride = N;
cv::AutoBuffer<float, 100> distPt(N * N);
cv::AutoBuffer<int> ptDistRemap(N);
for (int i = 0; i < N; ++i)
{
const Point2f pt0 = intersection[i];
ptDistRemap[i] = i;
for (int j = i + 1; j < N; )
{
const Point2f pt1 = intersection[j];
float d2 = normL2Sqr<float>(pt1 - pt0);
if(d2 <= samePointEps)
{
// Found a dupe, remove it
std::swap(intersection[j], intersection.back());
intersection.pop_back();
j--; // restart check
if (j < N - 1)
intersection[j] = intersection[N - 1];
N--;
continue;
}
else if (dx1 * dy - dy1 * dx < 0)
distPt[i*Nstride + j] = d2;
++j;
}
}
while (N > 8) // we still have duplicate points after samePointEps threshold (eliminate closest points)
{
int minI = 0;
int minJ = 1;
float minD = distPt[1];
for (int i = 0; i < N - 1; ++i)
{
float* pDist = distPt.data() + Nstride * ptDistRemap[i];
for (int j = i + 1; j < N; ++j)
{
float d = pDist[ptDistRemap[j]];
if (d < minD)
{
minD = d;
minI = i;
minJ = j;
}
}
}
CV_Assert(fabs(normL2Sqr<float>(intersection[minI] - intersection[minJ]) - minD) < 1e-6); // ptDistRemap is not corrupted
// drop minJ point
if (minJ < N - 1)
{
intersection[minJ] = intersection[N - 1];
ptDistRemap[minJ] = ptDistRemap[N - 1];
}
N--;
}
// order points
for (int i = 0; i < N - 1; ++i)
{
Point2f diffI = intersection[i + 1] - intersection[i];
for (int j = i + 2; j < N; ++j)
{
Point2f diffJ = intersection[j] - intersection[i];
if (diffI.cross(diffJ) < 0)
{
std::swap(intersection[i + 1], intersection[j]);
dx1 = dx;
dy1 = dy;
diffI = diffJ;
}
}
}
if( intersection.empty() )
{
return INTERSECT_NONE ;
}
// If this check fails then it means we're getting dupes, increase samePointEps
CV_Assert( intersection.size() <= 8 );
intersection.resize(N);
Mat(intersection).copyTo(intersectingRegion);
return ret;

View File

@ -49,29 +49,18 @@ namespace opencv_test { namespace {
#define ACCURACY 0.00001
class CV_RotatedRectangleIntersectionTest: public cvtest::ArrayTest
{
public:
// See pics/intersection.png for the scenarios we are testing
protected:
void run (int);
private:
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
void test7();
void test8();
void test9();
void test10();
void test11();
void test12();
void test13();
void test14();
};
// Test the following scenarios:
// 1 - no intersection
// 2 - partial intersection, rectangle translated
// 3 - partial intersection, rectangle rotated 45 degree on the corner, forms a triangle intersection
// 4 - full intersection, rectangles of same size directly on top of each other
// 5 - partial intersection, rectangle on top rotated 45 degrees
// 6 - partial intersection, rectangle on top of different size
// 7 - full intersection, rectangle fully enclosed in the other
// 8 - partial intersection, rectangle corner just touching. point contact
// 9 - partial intersetion. rectangle side by side, line contact
static void compare(const std::vector<Point2f>& test, const std::vector<Point2f>& target)
{
@ -80,45 +69,12 @@ static void compare(const std::vector<Point2f>& test, const std::vector<Point2f>
ASSERT_TRUE(target.size() < 4 || isContourConvex(target));
for( size_t i = 0; i < test.size(); i++ )
{
double dx = test[i].x - target[i].x;
double dy = test[i].y - target[i].y;
double r = sqrt(dx*dx + dy*dy);
double r = sqrt(normL2Sqr<double>(test[i] - target[i]));
ASSERT_LT(r, ACCURACY);
}
}
void CV_RotatedRectangleIntersectionTest::run(int)
{
// See pics/intersection.png for the scenarios we are testing
// Test the following scenarios:
// 1 - no intersection
// 2 - partial intersection, rectangle translated
// 3 - partial intersection, rectangle rotated 45 degree on the corner, forms a triangle intersection
// 4 - full intersection, rectangles of same size directly on top of each other
// 5 - partial intersection, rectangle on top rotated 45 degrees
// 6 - partial intersection, rectangle on top of different size
// 7 - full intersection, rectangle fully enclosed in the other
// 8 - partial intersection, rectangle corner just touching. point contact
// 9 - partial intersetion. rectangle side by side, line contact
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
test11();
test12();
test13();
test14();
}
void CV_RotatedRectangleIntersectionTest::test1()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_1)
{
// no intersection
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 12.0f);
@ -131,7 +87,7 @@ void CV_RotatedRectangleIntersectionTest::test1()
CV_Assert(vertices.empty());
}
void CV_RotatedRectangleIntersectionTest::test2()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_2)
{
// partial intersection, rectangles translated
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -150,7 +106,7 @@ void CV_RotatedRectangleIntersectionTest::test2()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test3()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_3)
{
// partial intersection, rectangles rotated 45 degree on the corner, forms a triangle intersection
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -168,7 +124,7 @@ void CV_RotatedRectangleIntersectionTest::test3()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test4()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_4)
{
// full intersection, rectangles of same size directly on top of each other
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -187,7 +143,7 @@ void CV_RotatedRectangleIntersectionTest::test4()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test5()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_5)
{
// partial intersection, rectangle on top rotated 45 degrees
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -210,7 +166,7 @@ void CV_RotatedRectangleIntersectionTest::test5()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test6()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_6)
{
// 6 - partial intersection, rectangle on top of different size
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -229,7 +185,7 @@ void CV_RotatedRectangleIntersectionTest::test6()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test7()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_7)
{
// full intersection, rectangle fully enclosed in the other
RotatedRect rect1(Point2f(0, 0), Size2f(12.34f, 56.78f), 0.0f);
@ -248,7 +204,7 @@ void CV_RotatedRectangleIntersectionTest::test7()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test8()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_8)
{
// intersection by a single vertex
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -261,7 +217,7 @@ void CV_RotatedRectangleIntersectionTest::test8()
compare(vertices, vector<Point2f>(1, Point2f(1.0f, 1.0f)));
}
void CV_RotatedRectangleIntersectionTest::test9()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_9)
{
// full intersection, rectangle fully enclosed in the other
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -278,7 +234,7 @@ void CV_RotatedRectangleIntersectionTest::test9()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test10()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_10)
{
// three points of rect2 are inside rect1.
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
@ -298,7 +254,7 @@ void CV_RotatedRectangleIntersectionTest::test10()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test11()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_11)
{
RotatedRect rect1(Point2f(0, 0), Size2f(4, 2), 0.0f);
RotatedRect rect2(Point2f(0, 0), Size2f(2, 2), -45.0f);
@ -318,7 +274,7 @@ void CV_RotatedRectangleIntersectionTest::test11()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test12()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_12)
{
RotatedRect rect1(Point2f(0, 0), Size2f(2, 2), 0.0f);
RotatedRect rect2(Point2f(0, 1), Size2f(1, 1), 0.0f);
@ -336,7 +292,7 @@ void CV_RotatedRectangleIntersectionTest::test12()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test13()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_13)
{
RotatedRect rect1(Point2f(0, 0), Size2f(1, 3), 0.0f);
RotatedRect rect2(Point2f(0, 1), Size2f(3, 1), 0.0f);
@ -354,7 +310,7 @@ void CV_RotatedRectangleIntersectionTest::test13()
compare(vertices, targetVertices);
}
void CV_RotatedRectangleIntersectionTest::test14()
TEST(Imgproc_RotatedRectangleIntersection, accuracy_14)
{
const int kNumTests = 100;
const float kWidth = 5;
@ -376,6 +332,38 @@ void CV_RotatedRectangleIntersectionTest::test14()
}
}
TEST (Imgproc_RotatedRectangleIntersection, accuracy) { CV_RotatedRectangleIntersectionTest test; test.safe_run(); }
TEST(Imgproc_RotatedRectangleIntersection, regression_12221_1)
{
RotatedRect r1(
Point2f(259.65081787109375, 51.58895492553711),
Size2f(5487.8779296875, 233.8921661376953),
-29.488616943359375);
RotatedRect r2(
Point2f(293.70465087890625, 112.10154724121094),
Size2f(5487.8896484375, 234.87368774414062),
-31.27001953125);
std::vector<Point2f> intersections;
int interType = cv::rotatedRectangleIntersection(r1, r2, intersections);
EXPECT_EQ(INTERSECT_PARTIAL, interType);
EXPECT_LE(intersections.size(), (size_t)8);
}
TEST(Imgproc_RotatedRectangleIntersection, regression_12221_2)
{
RotatedRect r1(
Point2f(239.78500366210938, 515.72021484375),
Size2f(70.23420715332031, 39.74684524536133),
-42.86162567138672);
RotatedRect r2(
Point2f(242.4205322265625, 510.1195373535156),
Size2f(66.85948944091797, 61.46455383300781),
-9.840961456298828);
std::vector<Point2f> intersections;
int interType = cv::rotatedRectangleIntersection(r1, r2, intersections);
EXPECT_EQ(INTERSECT_PARTIAL, interType);
EXPECT_LE(intersections.size(), (size_t)8);
}
}} // namespace

View File

@ -239,7 +239,18 @@ public:
/** @brief Returns vector of symbolic names captured in loadFromCSV() */
CV_WRAP virtual void getNames(std::vector<String>& names) const = 0;
CV_WRAP static Mat getSubVector(const Mat& vec, const Mat& idx);
/** @brief Extract from 1D vector elements specified by passed indexes.
@param vec input vector (supported types: CV_32S, CV_32F, CV_64F)
@param idx 1D index vector
*/
static CV_WRAP Mat getSubVector(const Mat& vec, const Mat& idx);
/** @brief Extract from matrix rows/cols specified by passed indexes.
@param matrix input matrix (supported types: CV_32S, CV_32F, CV_64F)
@param idx 1D index vector
@param layout specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES)
*/
static CV_WRAP Mat getSubMatrix(const Mat& matrix, const Mat& idx, int layout);
/** @brief Reads the dataset from a .csv file and returns the ready-to-use training data.

View File

@ -43,6 +43,8 @@
#include <algorithm>
#include <iterator>
#include <opencv2/core/utils/logger.hpp>
namespace cv { namespace ml {
static const float MISSED_VAL = TrainData::missingValue();
@ -52,64 +54,60 @@ TrainData::~TrainData() {}
Mat TrainData::getSubVector(const Mat& vec, const Mat& idx)
{
if( idx.empty() )
return vec;
int i, j, n = idx.checkVector(1, CV_32S);
int type = vec.type();
CV_Assert( type == CV_32S || type == CV_32F || type == CV_64F );
int dims = 1, m;
if (!(vec.cols == 1 || vec.rows == 1))
CV_LOG_WARNING(NULL, "'getSubVector(const Mat& vec, const Mat& idx)' call with non-1D input is deprecated. It is not designed to work with 2D matrixes (especially with 'cv::ml::COL_SAMPLE' layout).");
return getSubMatrix(vec, idx, vec.rows == 1 ? cv::ml::COL_SAMPLE : cv::ml::ROW_SAMPLE);
}
if( vec.cols == 1 || vec.rows == 1 )
template<typename T>
Mat getSubMatrixImpl(const Mat& m, const Mat& idx, int layout)
{
int nidx = idx.checkVector(1, CV_32S);
int dims = m.cols, nsamples = m.rows;
Mat subm;
if (layout == COL_SAMPLE)
{
dims = 1;
m = vec.cols + vec.rows - 1;
std::swap(dims, nsamples);
subm.create(dims, nidx, m.type());
}
else
{
dims = vec.cols;
m = vec.rows;
subm.create(nidx, dims, m.type());
}
Mat subvec;
for (int i = 0; i < nidx; i++)
{
int k = idx.at<int>(i); CV_CheckGE(k, 0, "Bad idx"); CV_CheckLT(k, nsamples, "Bad idx or layout");
if (dims == 1)
{
subm.at<T>(i) = m.at<T>(k); // at() has "transparent" access for 1D col-based / row-based vectors.
}
else if (layout == COL_SAMPLE)
{
for (int j = 0; j < dims; j++)
subm.at<T>(j, i) = m.at<T>(j, k);
}
else
{
for (int j = 0; j < dims; j++)
subm.at<T>(i, j) = m.at<T>(k, j);
}
}
return subm;
}
if( vec.cols == m )
subvec.create(dims, n, type);
else
subvec.create(n, dims, type);
if( type == CV_32S )
for( i = 0; i < n; i++ )
{
int k = idx.at<int>(i);
CV_Assert( 0 <= k && k < m );
if( dims == 1 )
subvec.at<int>(i) = vec.at<int>(k);
else
for( j = 0; j < dims; j++ )
subvec.at<int>(i, j) = vec.at<int>(k, j);
}
else if( type == CV_32F )
for( i = 0; i < n; i++ )
{
int k = idx.at<int>(i);
CV_Assert( 0 <= k && k < m );
if( dims == 1 )
subvec.at<float>(i) = vec.at<float>(k);
else
for( j = 0; j < dims; j++ )
subvec.at<float>(i, j) = vec.at<float>(k, j);
}
else
for( i = 0; i < n; i++ )
{
int k = idx.at<int>(i);
CV_Assert( 0 <= k && k < m );
if( dims == 1 )
subvec.at<double>(i) = vec.at<double>(k);
else
for( j = 0; j < dims; j++ )
subvec.at<double>(i, j) = vec.at<double>(k, j);
}
return subvec;
Mat TrainData::getSubMatrix(const Mat& m, const Mat& idx, int layout)
{
if (idx.empty())
return m;
int type = m.type();
CV_CheckType(type, type == CV_32S || type == CV_32F || type == CV_64F, "");
if (type == CV_32S || type == CV_32F) // 32-bit
return getSubMatrixImpl<int>(m, idx, layout);
if (type == CV_64F) // 64-bit
return getSubMatrixImpl<double>(m, idx, layout);
CV_Error(Error::StsInternal, "");
}
@ -152,7 +150,7 @@ public:
Mat getTestSamples() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(samples, idx);
return idx.empty() ? Mat() : getSubMatrix(samples, idx, getLayout());
}
Mat getSamples() const CV_OVERRIDE { return samples; }
@ -172,30 +170,30 @@ public:
}
Mat getTrainSampleWeights() const CV_OVERRIDE
{
return getSubVector(sampleWeights, getTrainSampleIdx());
return getSubVector(sampleWeights, getTrainSampleIdx()); // 1D-vector
}
Mat getTestSampleWeights() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(sampleWeights, idx);
return idx.empty() ? Mat() : getSubVector(sampleWeights, idx); // 1D-vector
}
Mat getTrainResponses() const CV_OVERRIDE
{
return getSubVector(responses, getTrainSampleIdx());
return getSubMatrix(responses, getTrainSampleIdx(), cv::ml::ROW_SAMPLE); // col-based responses are transposed in setData()
}
Mat getTrainNormCatResponses() const CV_OVERRIDE
{
return getSubVector(normCatResponses, getTrainSampleIdx());
return getSubMatrix(normCatResponses, getTrainSampleIdx(), cv::ml::ROW_SAMPLE); // like 'responses'
}
Mat getTestResponses() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(responses, idx);
return idx.empty() ? Mat() : getSubMatrix(responses, idx, cv::ml::ROW_SAMPLE); // col-based responses are transposed in setData()
}
Mat getTestNormCatResponses() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(normCatResponses, idx);
return idx.empty() ? Mat() : getSubMatrix(normCatResponses, idx, cv::ml::ROW_SAMPLE); // like 'responses'
}
Mat getNormCatResponses() const CV_OVERRIDE { return normCatResponses; }
Mat getClassLabels() const CV_OVERRIDE { return classLabels; }

View File

@ -721,5 +721,68 @@ void CV_MLBaseTest::load( const char* filename )
CV_Error( CV_StsNotImplemented, "invalid stat model name");
}
TEST(TrainDataGet, layout_ROW_SAMPLE) // Details: #12236
{
cv::Mat test = cv::Mat::ones(150, 30, CV_32FC1) * 2;
test.col(3) += Scalar::all(3);
cv::Mat labels = cv::Mat::ones(150, 3, CV_32SC1) * 5;
labels.col(1) += 1;
cv::Ptr<cv::ml::TrainData> train_data = cv::ml::TrainData::create(test, cv::ml::ROW_SAMPLE, labels);
train_data->setTrainTestSplitRatio(0.9);
Mat tidx = train_data->getTestSampleIdx();
EXPECT_EQ((size_t)15, tidx.total());
Mat tresp = train_data->getTestResponses();
EXPECT_EQ(15, tresp.rows);
EXPECT_EQ(labels.cols, tresp.cols);
EXPECT_EQ(5, tresp.at<int>(0, 0)) << tresp;
EXPECT_EQ(6, tresp.at<int>(0, 1)) << tresp;
EXPECT_EQ(6, tresp.at<int>(14, 1)) << tresp;
EXPECT_EQ(5, tresp.at<int>(14, 2)) << tresp;
Mat tsamples = train_data->getTestSamples();
EXPECT_EQ(15, tsamples.rows);
EXPECT_EQ(test.cols, tsamples.cols);
EXPECT_EQ(2, tsamples.at<float>(0, 0)) << tsamples;
EXPECT_EQ(5, tsamples.at<float>(0, 3)) << tsamples;
EXPECT_EQ(2, tsamples.at<float>(14, test.cols - 1)) << tsamples;
EXPECT_EQ(5, tsamples.at<float>(14, 3)) << tsamples;
}
TEST(TrainDataGet, layout_COL_SAMPLE) // Details: #12236
{
cv::Mat test = cv::Mat::ones(30, 150, CV_32FC1) * 3;
test.row(3) += Scalar::all(3);
cv::Mat labels = cv::Mat::ones(3, 150, CV_32SC1) * 5;
labels.row(1) += 1;
cv::Ptr<cv::ml::TrainData> train_data = cv::ml::TrainData::create(test, cv::ml::COL_SAMPLE, labels);
train_data->setTrainTestSplitRatio(0.9);
Mat tidx = train_data->getTestSampleIdx();
EXPECT_EQ((size_t)15, tidx.total());
Mat tresp = train_data->getTestResponses(); // always row-based, transposed
EXPECT_EQ(15, tresp.rows);
EXPECT_EQ(labels.rows, tresp.cols);
EXPECT_EQ(5, tresp.at<int>(0, 0)) << tresp;
EXPECT_EQ(6, tresp.at<int>(0, 1)) << tresp;
EXPECT_EQ(6, tresp.at<int>(14, 1)) << tresp;
EXPECT_EQ(5, tresp.at<int>(14, 2)) << tresp;
Mat tsamples = train_data->getTestSamples();
EXPECT_EQ(15, tsamples.cols);
EXPECT_EQ(test.rows, tsamples.rows);
EXPECT_EQ(3, tsamples.at<float>(0, 0)) << tsamples;
EXPECT_EQ(6, tsamples.at<float>(3, 0)) << tsamples;
EXPECT_EQ(6, tsamples.at<float>(3, 14)) << tsamples;
EXPECT_EQ(3, tsamples.at<float>(test.rows - 1, 14)) << tsamples;
}
} // namespace
/* End of file. */

View File

@ -215,7 +215,7 @@ public:
virtual Ptr<MaskGenerator> getMaskGenerator() = 0;
};
/** @example facedetect.cpp
/** @example samples/cpp/facedetect.cpp
This program demonstrates usage of the Cascade classifier class
\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254
*/
@ -443,7 +443,7 @@ public:
*/
CV_WRAP double getWinSigma() const;
/**@example peopledetect.cpp
/**@example samples/cpp/peopledetect.cpp
*/
/**@brief Sets coefficients for the linear SVM classifier.
@param _svmdetector coefficients for the linear SVM classifier.
@ -478,7 +478,7 @@ public:
*/
virtual void copyTo(HOGDescriptor& c) const;
/**@example train_HOG.cpp
/**@example samples/cpp/train_HOG.cpp
*/
/** @brief Computes HOG descriptors of given image.
@param img Matrix of the type CV_8U containing an image where HOG features will be calculated.
@ -575,7 +575,7 @@ public:
*/
CV_WRAP static std::vector<float> getDefaultPeopleDetector();
/**@example hog.cpp
/**@example samples/tapi/hog.cpp
*/
/** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows).
*/

View File

@ -730,7 +730,7 @@ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray co
//! @addtogroup photo_clone
//! @{
/** @example cloning_demo.cpp
/** @example samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp
An example using seamlessClone function
*/
/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters,
@ -836,7 +836,7 @@ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flag
CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
float sigma_r = 0.15f);
/** @example npr_demo.cpp
/** @example samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp
An example using non-photorealistic line drawing functions
*/
/** @brief Pencil-like non-photorealistic line drawing

View File

@ -62,12 +62,12 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point
int h = mask.size().height;
int w = mask.size().width;
Mat gray = Mat(mask.size(),CV_8UC1);
Mat gray;
if(mask.channels() == 3)
cvtColor(mask, gray, COLOR_BGR2GRAY );
else
gray = mask;
mask.copyTo(gray);
for(int i=0;i<h;i++)
{
@ -105,7 +105,7 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point
}
void cv::colorChange(InputArray _src, InputArray _mask, OutputArray _dst, float r, float g, float b)
void cv::colorChange(InputArray _src, InputArray _mask, OutputArray _dst, float red, float green, float blue)
{
CV_INSTRUMENT_REGION()
@ -114,18 +114,12 @@ void cv::colorChange(InputArray _src, InputArray _mask, OutputArray _dst, float
_dst.create(src.size(), src.type());
Mat blend = _dst.getMat();
float red = r;
float green = g;
float blue = b;
Mat gray = Mat::zeros(mask.size(),CV_8UC1);
Mat gray, cs_mask;
if(mask.channels() == 3)
cvtColor(mask, gray, COLOR_BGR2GRAY );
else
gray = mask;
Mat cs_mask = Mat::zeros(src.size(),CV_8UC3);
mask.copyTo(gray);
src.copyTo(cs_mask,gray);
@ -133,26 +127,21 @@ void cv::colorChange(InputArray _src, InputArray _mask, OutputArray _dst, float
obj.localColorChange(src,cs_mask,gray,blend,red,green,blue);
}
void cv::illuminationChange(InputArray _src, InputArray _mask, OutputArray _dst, float a, float b)
void cv::illuminationChange(InputArray _src, InputArray _mask, OutputArray _dst, float alpha, float beta)
{
CV_INSTRUMENT_REGION()
Mat src = _src.getMat();
Mat mask = _mask.getMat();
_dst.create(src.size(), src.type());
Mat blend = _dst.getMat();
float alpha = a;
float beta = b;
Mat gray = Mat::zeros(mask.size(),CV_8UC1);
Mat gray, cs_mask;
if(mask.channels() == 3)
cvtColor(mask, gray, COLOR_BGR2GRAY );
else
gray = mask;
Mat cs_mask = Mat::zeros(src.size(),CV_8UC3);
mask.copyTo(gray);
src.copyTo(cs_mask,gray);
@ -166,20 +155,16 @@ void cv::textureFlattening(InputArray _src, InputArray _mask, OutputArray _dst,
{
CV_INSTRUMENT_REGION()
Mat src = _src.getMat();
Mat mask = _mask.getMat();
_dst.create(src.size(), src.type());
Mat blend = _dst.getMat();
Mat gray = Mat::zeros(mask.size(),CV_8UC1);
Mat gray, cs_mask;
if(mask.channels() == 3)
cvtColor(mask, gray, COLOR_BGR2GRAY );
else
gray = mask;
Mat cs_mask = Mat::zeros(src.size(),CV_8UC3);
mask.copyTo(gray);
src.copyTo(cs_mask,gray);

View File

@ -66,7 +66,6 @@ namespace cv
void poisson(const cv::Mat &destination);
void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned);
void dst(const Mat& src, Mat& dest, bool invert = false);
void idst(const Mat& src, Mat& dest);
void solve(const Mat &img, Mat& mod_diff, Mat &result);
void poissonSolver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result);

View File

@ -147,15 +147,9 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert)
split(complex, planes2);
temp = planes2[1].t();
dest = Mat::zeros(src.size(), CV_32F);
temp(Rect( 0, 1, src.cols, src.rows)).copyTo(dest);
}
void Cloning::idst(const Mat& src, Mat& dest)
{
dst(src, dest, true);
}
void Cloning::solve(const Mat &img, Mat& mod_diff, Mat &result)
{
const int w = img.cols;
@ -173,7 +167,7 @@ void Cloning::solve(const Mat &img, Mat& mod_diff, Mat &result)
}
}
idst(res, mod_diff);
dst(res, mod_diff, true);
unsigned char * resLinePtr = result.ptr<unsigned char>(0);
const unsigned char * imgLinePtr = img.ptr<unsigned char>(0);
@ -221,9 +215,7 @@ void Cloning::poissonSolver(const Mat &img, Mat &laplacianX , Mat &laplacianY, M
const int w = img.cols;
const int h = img.rows;
Mat lap = Mat(img.size(),CV_32FC1);
lap = laplacianX + laplacianY;
Mat lap = laplacianX + laplacianY;
Mat bound = img.clone();
@ -264,19 +256,19 @@ void Cloning::initVariables(const Mat &destination, const Mat &binaryMask)
void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask)
{
initVariables(destination,binaryMask);
initVariables(destination, binaryMask);
computeGradientX(destination,destinationGradientX);
computeGradientY(destination,destinationGradientY);
computeGradientX(destination, destinationGradientX);
computeGradientY(destination, destinationGradientY);
computeGradientX(patch,patchGradientX);
computeGradientY(patch,patchGradientY);
computeGradientX(patch, patchGradientX);
computeGradientY(patch, patchGradientY);
Mat Kernel(Size(3, 3), CV_8UC1);
Kernel.setTo(Scalar(1));
erode(binaryMask, binaryMask, Kernel, Point(-1,-1), 3);
binaryMask.convertTo(binaryMaskFloat,CV_32FC1,1.0/255.0);
binaryMask.convertTo(binaryMaskFloat, CV_32FC1, 1.0/255.0);
}
void Cloning::scalarProduct(Mat mat, float r, float g, float b)
@ -305,11 +297,8 @@ void Cloning::arrayProduct(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& resu
void Cloning::poisson(const Mat &destination)
{
Mat laplacianX = Mat(destination.size(),CV_32FC3);
Mat laplacianY = Mat(destination.size(),CV_32FC3);
laplacianX = destinationGradientX + patchGradientX;
laplacianY = destinationGradientY + patchGradientY;
Mat laplacianX = destinationGradientX + patchGradientX;
Mat laplacianY = destinationGradientY + patchGradientY;
computeLaplacianX(laplacianX,laplacianX);
computeLaplacianY(laplacianY,laplacianY);
@ -331,8 +320,8 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
wmask.convertTo(binaryMaskFloatInverted,CV_32FC1,1.0/255.0);
arrayProduct(destinationGradientX,binaryMaskFloatInverted, destinationGradientX);
arrayProduct(destinationGradientY,binaryMaskFloatInverted, destinationGradientY);
arrayProduct(destinationGradientX, binaryMaskFloatInverted, destinationGradientX);
arrayProduct(destinationGradientY, binaryMaskFloatInverted, destinationGradientY);
poisson(I);
@ -351,8 +340,8 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &b
switch(flag)
{
case NORMAL_CLONE:
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
arrayProduct(patchGradientX, binaryMaskFloat, patchGradientX);
arrayProduct(patchGradientY, binaryMaskFloat, patchGradientY);
break;
case MIXED_CLONE:
@ -392,7 +381,7 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &b
break;
case MONOCHROME_TRANSFER:
Mat gray = Mat(patch.size(),CV_8UC1);
Mat gray;
cvtColor(patch, gray, COLOR_BGR2GRAY );
computeGradientX(gray,patchGradientX);
@ -429,7 +418,7 @@ void Cloning::illuminationChange(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, flo
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
Mat mag = Mat(I.size(),CV_32FC3);
Mat mag;
magnitude(patchGradientX,patchGradientY,mag);
Mat multX, multY, multx_temp, multy_temp;
@ -457,11 +446,10 @@ void Cloning::textureFlatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold,
{
computeDerivatives(I,mask,wmask);
Mat out = Mat(mask.size(),CV_8UC1);
Mat out;
Canny(mask,out,low_threshold,high_threshold,kernel_size);
Mat zeros(patchGradientX.size(), CV_32FC3);
zeros.setTo(0);
Mat zeros = Mat::zeros(patchGradientX.size(), CV_32FC3);
Mat zerosMask = (out != 255);
zeros.copyTo(patchGradientX, zerosMask);
zeros.copyTo(patchGradientY, zerosMask);

View File

@ -53,7 +53,7 @@ namespace cv
//! @addtogroup shape
//! @{
/** @example shape_example.cpp
/** @example samples/cpp/shape_example.cpp
An example using shape distance algorithm
*/
/** @brief Abstract base class for shape distance algorithms.

View File

@ -109,6 +109,14 @@ namespace cv {
//! @addtogroup stitching
//! @{
/** @example samples/cpp/stitching.cpp
A basic example on image stitching
*/
/** @example samples/cpp/stitching_detailed.cpp
A detailed example on image stitching
*/
/** @brief High level image stitcher.
It's possible to use this class without being aware of the entire stitching pipeline. However, to

View File

@ -78,9 +78,10 @@ See the OpenCV sample camshiftdemo.c that tracks colored objects.
*/
CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
TermCriteria criteria );
/** @example camshiftdemo.cpp
/** @example samples/cpp/camshiftdemo.cpp
An example using the mean-shift tracking algorithm
*/
/** @brief Finds an object on a back projection image.
@param probImage Back projection of the object histogram. See calcBackProject for details.
@ -123,9 +124,10 @@ CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays py
int derivBorder = BORDER_CONSTANT,
bool tryReuseInputImage = true );
/** @example lkdemo.cpp
/** @example samples/cpp/lkdemo.cpp
An example using the Lucas-Kanade optical flow algorithm
*/
*/
/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
pyramids.
@ -263,9 +265,9 @@ enum
MOTION_HOMOGRAPHY = 3
};
/** @example image_alignment.cpp
/** @example samples/cpp/image_alignment.cpp
An example using the image alignment ECC algorithm
*/
*/
/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .
@ -322,9 +324,10 @@ CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray input
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001),
InputArray inputMask = noArray());
/** @example kalman.cpp
/** @example samples/cpp/kalman.cpp
An example using the standard Kalman filter
*/
/** @brief Kalman filter class.
The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,

View File

@ -815,13 +815,18 @@ protected:
class IVideoWriter;
/** @example videowriter_basic.cpp
/** @example samples/cpp/tutorial_code/videoio/video-write/video-write.cpp
Check @ref tutorial_video_write "the corresponding tutorial" for more details
*/
/** @example samples/cpp/videowriter_basic.cpp
An example using VideoCapture and VideoWriter class
*/
*/
/** @brief Video writer class.
The class provides C++ API for writing video files or image sequences.
*/
*/
class CV_EXPORTS_W VideoWriter
{
public:

View File

@ -1,3 +1,4 @@
#include <opencv2/core/utility.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
@ -32,44 +33,29 @@ static void on_trackbar(int, void*)
imshow( "Connected Components", dst );
}
static void help()
{
cout << "\n This program demonstrates connected components and use of the trackbar\n"
"Usage: \n"
" ./connected_components <image(../data/stuff.jpg as default)>\n"
"The image is converted to grayscale and displayed, another image has a trackbar\n"
"that controls thresholding and thereby the extracted contours which are drawn in color\n";
}
const char* keys =
{
"{help h||}{@image|../data/stuff.jpg|image for converting to a grayscale}"
};
int main( int argc, const char** argv )
{
CommandLineParser parser(argc, argv, keys);
if (parser.has("help"))
{
help();
return 0;
}
string inputImage = parser.get<string>(0);
img = imread(inputImage.c_str(), 0);
CommandLineParser parser(argc, argv, "{@image|../data/stuff.jpg|image for converting to a grayscale}");
parser.about("\nThis program demonstrates connected components and use of the trackbar\n");
parser.printMessage();
cout << "\nThe image is converted to grayscale and displayed, another image has a trackbar\n"
"that controls thresholding and thereby the extracted contours which are drawn in color\n";
String inputImage = parser.get<string>(0);
img = imread(inputImage, IMREAD_GRAYSCALE);
if(img.empty())
{
cout << "Could not read input image file: " << inputImage << endl;
return -1;
return EXIT_FAILURE;
}
namedWindow( "Image", 1 );
imshow( "Image", img );
namedWindow( "Connected Components", 1 );
namedWindow( "Connected Components", WINDOW_AUTOSIZE);
createTrackbar( "Threshold", "Connected Components", &threshval, 255, on_trackbar );
on_trackbar(threshval, 0);
waitKey(0);
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,3 +1,4 @@
// The "Square Detector" program.
// It loads several images sequentially and tries to find squares in
// each image
@ -8,22 +9,18 @@
#include "opencv2/highgui.hpp"
#include <iostream>
#include <math.h>
#include <string.h>
using namespace cv;
using namespace std;
static void help()
static void help(const char* programName)
{
cout <<
"\nA program using pyramid scaling, Canny, contours, contour simpification and\n"
"memory storage (it's got it all folks) to find\n"
"squares in a list of images pic1-6.png\n"
"\nA program using pyramid scaling, Canny, contours and contour simplification\n"
"to find squares in a list of images (pic1-6.png)\n"
"Returns sequence of squares detected on the image.\n"
"the sequence is stored in the specified memory storage\n"
"Call:\n"
"./squares [file_name (optional)]\n"
"./" << programName << " [file_name (optional)]\n"
"Using OpenCV version " << CV_VERSION << "\n" << endl;
}
@ -44,7 +41,6 @@ static double angle( Point pt1, Point pt2, Point pt0 )
}
// returns sequence of squares detected on the image.
// the sequence is stored in the specified memory storage
static void findSquares( const Mat& image, vector<vector<Point> >& squares )
{
squares.clear();
@ -93,7 +89,7 @@ static void findSquares( const Mat& image, vector<vector<Point> >& squares )
{
// approximate contour with accuracy proportional
// to the contour perimeter
approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.02, true);
approxPolyDP(contours[i], approx, arcLength(contours[i], true)*0.02, true);
// square contours should have 4 vertices after approximation
// relatively large area (to filter out noisy contours)
@ -102,8 +98,8 @@ static void findSquares( const Mat& image, vector<vector<Point> >& squares )
// area may be positive or negative - in accordance with the
// contour orientation
if( approx.size() == 4 &&
fabs(contourArea(Mat(approx))) > 1000 &&
isContourConvex(Mat(approx)) )
fabs(contourArea(approx)) > 1000 &&
isContourConvex(approx) )
{
double maxCosine = 0;
@ -144,7 +140,7 @@ int main(int argc, char** argv)
{
static const char* names[] = { "../data/pic1.png", "../data/pic2.png", "../data/pic3.png",
"../data/pic4.png", "../data/pic5.png", "../data/pic6.png", 0 };
help();
help(argv[0]);
if( argc > 1)
{
@ -152,12 +148,11 @@ int main(int argc, char** argv)
names[1] = "0";
}
namedWindow( wndname, 1 );
vector<vector<Point> > squares;
for( int i = 0; names[i] != 0; i++ )
{
Mat image = imread(names[i], 1);
Mat image = imread(names[i], IMREAD_COLOR);
if( image.empty() )
{
cout << "Couldn't load " << names[i] << endl;
@ -167,7 +162,7 @@ int main(int argc, char** argv)
findSquares(image, squares);
drawSquares(image, squares);
char c = (char)waitKey();
int c = waitKey();
if( c == 27 )
break;
}

View File

@ -20,8 +20,9 @@ int parseCmdArgs(int argc, char** argv);
int main(int argc, char* argv[])
{
int retval = parseCmdArgs(argc, argv);
if (retval) return -1;
if (retval) return EXIT_FAILURE;
//![stitching]
Mat pano;
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(imgs, pano);
@ -29,12 +30,13 @@ int main(int argc, char* argv[])
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
return EXIT_FAILURE;
}
//![stitching]
imwrite(result_name, pano);
cout << "stitching completed successfully\n" << result_name << " saved!";
return 0;
return EXIT_SUCCESS;
}
@ -63,7 +65,7 @@ int parseCmdArgs(int argc, char** argv)
if (argc == 1)
{
printUsage(argv);
return -1;
return EXIT_FAILURE;
}
for (int i = 1; i < argc; ++i)
@ -71,7 +73,7 @@ int parseCmdArgs(int argc, char** argv)
if (string(argv[i]) == "--help" || string(argv[i]) == "/?")
{
printUsage(argv);
return -1;
return EXIT_FAILURE;
}
else if (string(argv[i]) == "--try_use_gpu")
{
@ -82,7 +84,7 @@ int parseCmdArgs(int argc, char** argv)
else
{
cout << "Bad --try_use_gpu flag value\n";
return -1;
return EXIT_FAILURE;
}
i++;
}
@ -104,7 +106,7 @@ int parseCmdArgs(int argc, char** argv)
else
{
cout << "Bad --mode flag value\n";
return -1;
return EXIT_FAILURE;
}
i++;
}
@ -114,7 +116,7 @@ int parseCmdArgs(int argc, char** argv)
if (img.empty())
{
cout << "Can't read image '" << argv[i] << "'\n";
return -1;
return EXIT_FAILURE;
}
if (divide_images)
@ -130,5 +132,5 @@ int parseCmdArgs(int argc, char** argv)
imgs.push_back(img);
}
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,45 +1,3 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//
//M*/
#include <iostream>
#include <fstream>

View File

@ -33,7 +33,7 @@ void Morphology_Operations( int, void* );
int main( int argc, char** argv )
{
//![load]
CommandLineParser parser( argc, argv, "{@input | ../data/LinuxLogo.jpg | input image}" );
CommandLineParser parser( argc, argv, "{@input | ../data/baboon.jpg | input image}" );
src = imread( parser.get<String>( "@input" ), IMREAD_COLOR );
if (src.empty())
{

View File

@ -35,11 +35,55 @@ node {
input: "data_scale/Mul"
input: "data_scale/add"
}
node {
name: "SpaceToBatchND/block_shape"
op: "Const"
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
dim {
size: 2
}
}
int_val: 1
int_val: 1
}
}
}
}
node {
name: "SpaceToBatchND/paddings"
op: "Const"
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
dim {
size: 2
}
dim {
size: 2
}
}
int_val: 3
int_val: 3
int_val: 3
int_val: 3
}
}
}
}
node {
name: "Pad"
op: "Pad"
op: "SpaceToBatchND"
input: "data_scale/BiasAdd"
input: "Pad/paddings"
input: "SpaceToBatchND/block_shape"
input: "SpaceToBatchND/paddings"
}
node {
name: "conv1_h/Conv2D"
@ -81,10 +125,15 @@ node {
input: "conv1_h/Conv2D"
input: "conv1_h/bias"
}
node {
name: "BatchToSpaceND"
op: "BatchToSpaceND"
input: "conv1_h/BiasAdd"
}
node {
name: "conv1_bn_h/FusedBatchNorm"
op: "FusedBatchNorm"
input: "conv1_h/BiasAdd"
input: "BatchToSpaceND"
input: "conv1_bn_h/gamma"
input: "conv1_bn_h/beta"
input: "conv1_bn_h/mean"
@ -439,10 +488,28 @@ node {
input: "layer_256_1_scale1/BiasAdd"
}
node {
name: "Pad_1"
op: "Pad"
input: "Relu_4"
input: "Pad_1/paddings"
name: "SpaceToBatchND_1/paddings"
op: "Const"
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
dim {
size: 2
}
dim {
size: 2
}
}
int_val: 1
int_val: 1
int_val: 1
int_val: 1
}
}
}
}
node {
name: "layer_256_1_conv_expand/Conv2D"
@ -580,6 +647,13 @@ node {
op: "Flatten"
input: "conv4_3_norm_mbox_conf/BiasAdd"
}
node {
name: "Pad_1"
op: "SpaceToBatchND"
input: "Relu_4"
input: "SpaceToBatchND/block_shape"
input: "SpaceToBatchND_1/paddings"
}
node {
name: "layer_256_1_conv1/Conv2D"
op: "Conv2D"
@ -620,10 +694,15 @@ node {
input: "layer_256_1_conv1/Conv2D"
input: "layer_256_1_conv1/Conv2D_bn_offset"
}
node {
name: "BatchToSpaceND_1"
op: "BatchToSpaceND"
input: "layer_256_1_bn2/FusedBatchNorm"
}
node {
name: "layer_256_1_scale2/Mul"
op: "Mul"
input: "layer_256_1_bn2/FusedBatchNorm"
input: "BatchToSpaceND_1"
input: "layer_256_1_scale2/mul"
}
node {
@ -806,12 +885,6 @@ node {
input: "Relu_7"
input: "layer_512_1_conv2_h/convolution/SpaceToBatchND/block_shape"
input: "layer_512_1_conv2_h/convolution/SpaceToBatchND/paddings"
attr {
key: "Tblock_shape"
value {
type: DT_INT32
}
}
}
node {
name: "layer_512_1_conv2_h/convolution"
@ -853,18 +926,6 @@ node {
input: "layer_512_1_conv2_h/convolution"
input: "layer_512_1_conv2_h/convolution/BatchToSpaceND/block_shape"
input: "layer_512_1_conv2_h/convolution/BatchToSpaceND/crops"
attr {
key: "Tblock_shape"
value {
type: DT_INT32
}
}
attr {
key: "Tcrops"
value {
type: DT_INT32
}
}
}
node {
name: "add_3"
@ -1041,9 +1102,10 @@ node {
}
node {
name: "Pad_2"
op: "Pad"
op: "SpaceToBatchND"
input: "conv7_1_h/Relu"
input: "Pad_2/paddings"
input: "SpaceToBatchND/block_shape"
input: "SpaceToBatchND_1/paddings"
}
node {
name: "conv7_2_h/Conv2D"
@ -1085,10 +1147,15 @@ node {
input: "conv7_2_h/Conv2D"
input: "conv7_2_h/bias"
}
node {
name: "BatchToSpaceND_2"
op: "BatchToSpaceND"
input: "conv7_2_h/BiasAdd"
}
node {
name: "conv7_2_h/Relu"
op: "Relu"
input: "conv7_2_h/BiasAdd"
input: "BatchToSpaceND_2"
}
node {
name: "conv8_1_h/Conv2D"

View File

@ -1,6 +1,3 @@
// The "Square Detector" program.
// It loads several images sequentially and tries to find squares in
// each image
#include "opencv2/core.hpp"
#include "opencv2/core/ocl.hpp"
@ -9,7 +6,6 @@
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <string.h>
using namespace cv;
using namespace std;
@ -31,7 +27,6 @@ static double angle( Point pt1, Point pt2, Point pt0 )
// returns sequence of squares detected on the image.
// the sequence is stored in the specified memory storage
static void findSquares( const UMat& image, vector<vector<Point> >& squares )
{
squares.clear();
@ -66,7 +61,7 @@ static void findSquares( const UMat& image, vector<vector<Point> >& squares )
{
// apply threshold if l!=0:
// tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0
cv::threshold(gray0, gray, (l+1)*255/N, 255, THRESH_BINARY);
threshold(gray0, gray, (l+1)*255/N, 255, THRESH_BINARY);
}
// find contours and store them all as a list
@ -80,7 +75,7 @@ static void findSquares( const UMat& image, vector<vector<Point> >& squares )
// approximate contour with accuracy proportional
// to the contour perimeter
approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.02, true);
approxPolyDP(contours[i], approx, arcLength(contours[i], true)*0.02, true);
// square contours should have 4 vertices after approximation
// relatively large area (to filter out noisy contours)
@ -89,8 +84,8 @@ static void findSquares( const UMat& image, vector<vector<Point> >& squares )
// area may be positive or negative - in accordance with the
// contour orientation
if( approx.size() == 4 &&
fabs(contourArea(Mat(approx))) > 1000 &&
isContourConvex(Mat(approx)) )
fabs(contourArea(approx)) > 1000 &&
isContourConvex(approx) )
{
double maxCosine = 0;
@ -150,7 +145,7 @@ int main(int argc, char** argv)
if(cmd.has("help"))
{
cout << "Usage : squares [options]" << endl;
cout << "Usage : " << argv[0] << " [options]" << endl;
cout << "Available options:" << endl;
cmd.printMessage();
return EXIT_SUCCESS;
@ -158,7 +153,7 @@ int main(int argc, char** argv)
if (cmd.has("cpu_mode"))
{
ocl::setUseOpenCL(false);
std::cout << "OpenCL was disabled" << std::endl;
cout << "OpenCL was disabled" << endl;
}
string inputName = cmd.get<string>("i");
@ -185,11 +180,11 @@ int main(int argc, char** argv)
do
{
int64 t_start = cv::getTickCount();
int64 t_start = getTickCount();
findSquares(image, squares);
t_cpp += cv::getTickCount() - t_start;
t_start = cv::getTickCount();
t_start = getTickCount();
cout << "run loop: " << j << endl;
}