Compare commits
73 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b38c50b3d0 | |||
| dd06540e1f | |||
| 50b61668e2 | |||
| 1df84f7246 | |||
| bdc34984f1 | |||
| af0c930e77 | |||
| bb45bf9695 | |||
| 4e0d2a3e6c | |||
| da6d8961fc | |||
| 3e027df583 | |||
| 6477262e63 | |||
| f79599f949 | |||
| c94d75874b | |||
| 21f3987d53 | |||
| d10a219833 | |||
| bd7bf39b4b | |||
| 472b71ecef | |||
| 4f360f8b1a | |||
| e8d45a9cdd | |||
| ff2eface19 | |||
| 29ce348c4d | |||
| b2a4069f55 | |||
| 4d78342919 | |||
| 1272332ae3 | |||
| b47c9ac643 | |||
| 1c20a7f008 | |||
| 6700fdb81f | |||
| 096366738b | |||
| 6a6506b02d | |||
| 59ccf2c9e0 | |||
| 2c42361ecd | |||
| 18833d5121 | |||
| f25450791b | |||
| c9faa09d55 | |||
| 1deeca985f | |||
| 6acabd1fd8 | |||
| 5ac9a2a7d0 | |||
| 808c89adc1 | |||
| a527e8cc73 | |||
| 10c570b558 | |||
| 76f47548b3 | |||
| 67d46dfc6c | |||
| 3c03fb56e0 | |||
| 378cf2ab63 | |||
| c6f5b013ec | |||
| e593d5bbc5 | |||
| 3f5c3ddd27 | |||
| ab8ba047a5 | |||
| cecc19381f | |||
| 6e84abc746 | |||
| 322c6b1ba4 | |||
| 73d44c7881 | |||
| 31fef14d76 | |||
| 7ee69740e8 | |||
| c61bc3a0cb | |||
| b24fc6954d | |||
| 828cb4286d | |||
| ee5e0e16d9 | |||
| b907bfe3e7 | |||
| f84eb3dde6 | |||
| b996b618e0 | |||
| 98c5ce9347 | |||
| f89defad5d | |||
| 96f92c6705 | |||
| f0c46a4c74 | |||
| 9752d45c87 | |||
| 860ae77ec9 | |||
| 1567a65475 | |||
| d2e08a524e | |||
| 216cd7dc61 | |||
| 4910f16f16 | |||
| 5b3ac112fe | |||
| f2e1710dd5 |
@@ -276,7 +276,7 @@ OCV_OPTION(WITH_VA "Include VA support" OFF
|
|||||||
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
|
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
|
||||||
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF ((UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)) )
|
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF ((UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)) )
|
||||||
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||||
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
|
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" OFF IF (UNIX AND NOT ANDROID AND NOT IOS) )
|
||||||
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION) IF (NOT ANDROID AND NOT IOS) )
|
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION) IF (NOT ANDROID AND NOT IOS) )
|
||||||
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
|
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
|
||||||
OCV_OPTION(WITH_PROTOBUF "Enable libprotobuf" ON )
|
OCV_OPTION(WITH_PROTOBUF "Enable libprotobuf" ON )
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ endif()
|
|||||||
|
|
||||||
if(VA_INCLUDE_DIR)
|
if(VA_INCLUDE_DIR)
|
||||||
set(HAVE_VA TRUE)
|
set(HAVE_VA TRUE)
|
||||||
set(VA_LIBRARIES "-lva" "-lva-drm")
|
if(NOT DEFINED VA_LIBRARIES)
|
||||||
|
set(VA_LIBRARIES "va" "va-drm")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(HAVE_VA FALSE)
|
set(HAVE_VA FALSE)
|
||||||
message(WARNING "libva installation is not found.")
|
message(WARNING "libva installation is not found.")
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Changing the contrast and brightness of an image! {#tutorial_basic_linear_transform}
|
Changing the contrast and brightness of an image! {#tutorial_basic_linear_transform}
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_adding_images}
|
||||||
|
@next_tutorial{tutorial_discrete_fourier_transform}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Discrete Fourier Transform {#tutorial_discrete_fourier_transform}
|
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}
|
@next_tutorial{tutorial_file_input_output_with_xml_yml}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
File Input and Output using XML and YAML files {#tutorial_file_input_output_with_xml_yml}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
How to scan images, lookup tables and time measurement with OpenCV {#tutorial_how_to_scan_images}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
How to use the OpenCV parallel_for_ to parallelize your code {#tutorial_how_to_use_OpenCV_parallel_for_}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Intel® IPP Asynchronous C/C++ library in OpenCV {#tutorial_how_to_use_ippa_conversion}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Interoperability with OpenCV 1 {#tutorial_interoperability_with_OpenCV_1}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Operations with images {#tutorial_mat_operations}
|
Operations with images {#tutorial_mat_operations}
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_mat_mask_operations}
|
||||||
|
@next_tutorial{tutorial_adding_images}
|
||||||
|
|
||||||
Input/Output
|
Input/Output
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
Mat - The Basic Image Container {#tutorial_mat_the_basic_image_container}
|
Mat - The Basic Image Container {#tutorial_mat_the_basic_image_container}
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
|
@next_tutorial{tutorial_how_to_scan_images}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -62,24 +62,6 @@ understanding how to manipulate the images on a pixel level.
|
|||||||
|
|
||||||
We will learn how to change our image appearance!
|
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
|
- @subpage tutorial_discrete_fourier_transform
|
||||||
|
|
||||||
*Languages:* C++, Java, Python
|
*Languages:* C++, Java, Python
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
Basic Drawing {#tutorial_basic_geometric_drawing}
|
Basic Drawing {#tutorial_basic_geometric_drawing}
|
||||||
=============
|
=============
|
||||||
|
|
||||||
@prev_tutorial{tutorial_basic_linear_transform}
|
|
||||||
@next_tutorial{tutorial_random_generator_and_text}
|
@next_tutorial{tutorial_random_generator_and_text}
|
||||||
|
|
||||||
Goals
|
Goals
|
||||||
@@ -82,20 +81,20 @@ Code
|
|||||||
|
|
||||||
@add_toggle_cpp
|
@add_toggle_cpp
|
||||||
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
||||||
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp)
|
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp)
|
||||||
@include samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp
|
@include samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp
|
||||||
@end_toggle
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@add_toggle_java
|
||||||
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
||||||
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java)
|
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java)
|
||||||
@include samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java
|
@include samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java
|
||||||
@end_toggle
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@add_toggle_python
|
||||||
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
||||||
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py)
|
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py)
|
||||||
@include samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py
|
@include samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py
|
||||||
@end_toggle
|
@end_toggle
|
||||||
|
|
||||||
Explanation
|
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
|
Since we plan to draw two examples (an atom and a rook), we have to create two images and two
|
||||||
windows to display them.
|
windows to display them.
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
We created functions to draw different geometric shapes. For instance, to draw the atom we used
|
We created functions to draw different geometric shapes. For instance, to draw the atom we used
|
||||||
**MyEllipse** and **MyFilledCircle**:
|
**MyEllipse** and **MyFilledCircle**:
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
And to draw the rook we employed **MyLine**, **rectangle** and a **MyPolygon**:
|
And to draw the rook we employed **MyLine**, **rectangle** and a **MyPolygon**:
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
|
|
||||||
@@ -149,15 +148,15 @@ Let's check what is inside each of these functions:
|
|||||||
|
|
||||||
<H4>MyLine</H4>
|
<H4>MyLine</H4>
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
- As we can see, **MyLine** just call the function **line()** , which does the following:
|
- 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>
|
<H4>MyEllipse</H4>
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
- From the code above, we can observe that the function **ellipse()** draws an ellipse such
|
- 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>
|
<H4>MyFilledCircle</H4>
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
- Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
- Similar to the ellipse function, we can observe that *circle* receives as arguments:
|
||||||
@@ -215,15 +214,15 @@ Let's check what is inside each of these functions:
|
|||||||
|
|
||||||
<H4>MyPolygon</H4>
|
<H4>MyPolygon</H4>
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
- To draw a filled polygon we use the function **fillPoly()** . We note that:
|
- 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>
|
<H4>rectangle</H4>
|
||||||
@add_toggle_cpp
|
@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
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_java
|
@add_toggle_java
|
||||||
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
|
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
|
||||||
@end_toggle
|
@end_toggle
|
||||||
|
|
||||||
@add_toggle_python
|
@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
|
@end_toggle
|
||||||
|
|
||||||
- Finally we have the @ref cv::rectangle function (we did not create a special function for
|
- Finally we have the @ref cv::rectangle function (we did not create a special function for
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -1,6 +1,9 @@
|
|||||||
Eroding and Dilating {#tutorial_erosion_dilatation}
|
Eroding and Dilating {#tutorial_erosion_dilatation}
|
||||||
====================
|
====================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_gausian_median_blur_bilateral_filter}
|
||||||
|
@next_tutorial{tutorial_opening_closing_hats}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
Smoothing Images {#tutorial_gausian_median_blur_bilateral_filter}
|
Smoothing Images {#tutorial_gausian_median_blur_bilateral_filter}
|
||||||
================
|
================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_random_generator_and_text}
|
||||||
@next_tutorial{tutorial_erosion_dilatation}
|
@next_tutorial{tutorial_erosion_dilatation}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Back Projection {#tutorial_back_projection}
|
Back Projection {#tutorial_back_projection}
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_histogram_comparison}
|
||||||
|
@next_tutorial{tutorial_template_matching}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Histogram Calculation {#tutorial_histogram_calculation}
|
Histogram Calculation {#tutorial_histogram_calculation}
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_histogram_equalization}
|
||||||
|
@next_tutorial{tutorial_histogram_comparison}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Histogram Comparison {#tutorial_histogram_comparison}
|
Histogram Comparison {#tutorial_histogram_comparison}
|
||||||
====================
|
====================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_histogram_calculation}
|
||||||
|
@next_tutorial{tutorial_back_projection}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Histogram Equalization {#tutorial_histogram_equalization}
|
Histogram Equalization {#tutorial_histogram_equalization}
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_warp_affine}
|
||||||
|
@next_tutorial{tutorial_histogram_calculation}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Canny Edge Detector {#tutorial_canny_detector}
|
Canny Edge Detector {#tutorial_canny_detector}
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_laplace_operator}
|
||||||
|
@next_tutorial{tutorial_hough_lines}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Image Segmentation with Distance Transform and Watershed Algorithm {#tutorial_distance_transform}
|
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
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Remapping {#tutorial_remap}
|
Remapping {#tutorial_remap}
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_hough_circle}
|
||||||
|
@next_tutorial{tutorial_warp_affine}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Affine Transformations {#tutorial_warp_affine}
|
Affine Transformations {#tutorial_warp_affine}
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_remap}
|
||||||
|
@next_tutorial{tutorial_histogram_equalization}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
More Morphology Transformations {#tutorial_opening_closing_hats}
|
More Morphology Transformations {#tutorial_opening_closing_hats}
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_erosion_dilatation}
|
||||||
|
@next_tutorial{tutorial_hitOrMiss}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
Out-of-focus Deblur Filter {#tutorial_out_of_focus_deblur_filter}
|
Out-of-focus Deblur Filter {#tutorial_out_of_focus_deblur_filter}
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_distance_transform}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -1,6 +1,9 @@
|
|||||||
Random generator and text with OpenCV {#tutorial_random_generator_and_text}
|
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
|
Goals
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
Creating Bounding boxes and circles for contours {#tutorial_bounding_rects_circles}
|
Creating Bounding boxes and circles for contours {#tutorial_bounding_rects_circles}
|
||||||
================================================
|
================================================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_hull}
|
||||||
|
@next_tutorial{tutorial_bounding_rotated_ellipses}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Creating Bounding rotated boxes and ellipses for contours {#tutorial_bounding_rotated_ellipses}
|
Creating Bounding rotated boxes and ellipses for contours {#tutorial_bounding_rotated_ellipses}
|
||||||
=========================================================
|
=========================================================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_bounding_rects_circles}
|
||||||
|
@next_tutorial{tutorial_moments}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Finding contours in your image {#tutorial_find_contours}
|
Finding contours in your image {#tutorial_find_contours}
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_template_matching}
|
||||||
|
@next_tutorial{tutorial_hull}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Convex Hull {#tutorial_hull}
|
Convex Hull {#tutorial_hull}
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_find_contours}
|
||||||
|
@next_tutorial{tutorial_bounding_rects_circles}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Image Moments {#tutorial_moments}
|
Image Moments {#tutorial_moments}
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_bounding_rotated_ellipses}
|
||||||
|
@next_tutorial{tutorial_point_polygon_test}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Point Polygon Test {#tutorial_point_polygon_test}
|
Point Polygon Test {#tutorial_point_polygon_test}
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_moments}
|
||||||
|
@next_tutorial{tutorial_distance_transform}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
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
|
- @subpage tutorial_gausian_median_blur_bilateral_filter
|
||||||
|
|
||||||
*Languages:* C++, Java, Python
|
*Languages:* C++, Java, Python
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Basic Thresholding Operations {#tutorial_threshold}
|
Basic Thresholding Operations {#tutorial_threshold}
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_pyramids}
|
||||||
|
@next_tutorial{tutorial_threshold_inRange}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Thresholding Operations using inRange {#tutorial_threshold_inRange}
|
Thresholding Operations using inRange {#tutorial_threshold_inRange}
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
|
@prev_tutorial{tutorial_threshold}
|
||||||
|
@next_tutorial{tutorial_filter_2d}
|
||||||
|
|
||||||
Goal
|
Goal
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,7 @@ Explanation
|
|||||||
|
|
||||||
The most important code part is:
|
The most important code part is:
|
||||||
|
|
||||||
@code{.cpp}
|
@snippet cpp/stitching.cpp stitching
|
||||||
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
|
|
||||||
|
|
||||||
A new instance of stitcher is created and the @ref cv::Stitcher::stitch will
|
A new instance of stitcher is created and the @ref cv::Stitcher::stitch will
|
||||||
do all the hard work.
|
do all the hard work.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ As always, we would be happy to hear your comments and receive your contribution
|
|||||||
- @subpage tutorial_table_of_content_core
|
- @subpage tutorial_table_of_content_core
|
||||||
|
|
||||||
Here you will learn
|
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.
|
to manipulate the images on a pixel level.
|
||||||
|
|
||||||
- @subpage tutorial_table_of_content_imgproc
|
- @subpage tutorial_table_of_content_imgproc
|
||||||
|
|||||||
@@ -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
|
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.
|
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$).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -307,11 +307,11 @@ optimization procedures like calibrateCamera, stereoCalibrate, or solvePnP .
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
|
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
|
||||||
|
|
||||||
/** @example pose_from_homography.cpp
|
/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp
|
||||||
An example program about pose estimation from coplanar points
|
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.
|
/** @brief Finds a perspective transformation between two planes.
|
||||||
|
|
||||||
@@ -526,11 +526,11 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
|
|||||||
OutputArray jacobian = noArray(),
|
OutputArray jacobian = noArray(),
|
||||||
double aspectRatio = 0 );
|
double aspectRatio = 0 );
|
||||||
|
|
||||||
/** @example homography_from_camera_displacement.cpp
|
/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp
|
||||||
An example program about homography from the camera displacement
|
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.
|
/** @brief Finds an object pose from 3D-2D point correspondences.
|
||||||
|
|
||||||
@@ -1966,11 +1966,11 @@ CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, Out
|
|||||||
size_t maxIters = 2000, double confidence = 0.99,
|
size_t maxIters = 2000, double confidence = 0.99,
|
||||||
size_t refineIters = 10);
|
size_t refineIters = 10);
|
||||||
|
|
||||||
/** @example decompose_homography.cpp
|
/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp
|
||||||
An example program with homography decomposition.
|
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).
|
/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,14 @@ if(CV_TRACE AND HAVE_ITT AND BUILD_ITT)
|
|||||||
add_definitions(-DOPENCV_WITH_ITT=1)
|
add_definitions(-DOPENCV_WITH_ITT=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
|
file(GLOB lib_cuda_hdrs
|
||||||
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
|
||||||
file(GLOB_RECURSE module_opencl_hdrs "include/opencv2/${name}/opencl/*")
|
"${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" FILES ${lib_cuda_hdrs})
|
||||||
source_group("Include\\Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
|
source_group("Include\\Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
|
||||||
|
|||||||
@@ -273,9 +273,11 @@ of p and len.
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
|
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
|
||||||
|
|
||||||
/** @example copyMakeBorder_demo.cpp
|
/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
|
||||||
An example using copyMakeBorder function
|
An example using copyMakeBorder function.
|
||||||
*/
|
Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details
|
||||||
|
*/
|
||||||
|
|
||||||
/** @brief Forms a border around an image.
|
/** @brief Forms a border around an image.
|
||||||
|
|
||||||
The function copies the source image into the middle of the destination image. The areas to the
|
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);
|
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.
|
/** @brief Calculates the weighted sum of two arrays.
|
||||||
|
|
||||||
The function addWeighted calculates the weighted sum of two arrays as follows:
|
The function addWeighted calculates the weighted sum of two arrays as follows:
|
||||||
@@ -2527,14 +2530,18 @@ public:
|
|||||||
Mat mean; //!< mean value subtracted before the projection and added after the back projection
|
Mat mean; //!< mean value subtracted before the projection and added after the back projection
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @example pca.cpp
|
/** @example samples/cpp/pca.cpp
|
||||||
An example using %PCA for dimensionality reduction while maintaining an amount of variance
|
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
|
@brief Linear Discriminant Analysis
|
||||||
@todo document this class
|
@todo document this class
|
||||||
*/
|
*/
|
||||||
class CV_EXPORTS LDA
|
class CV_EXPORTS LDA
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -2850,7 +2857,7 @@ public:
|
|||||||
use explicit type cast operators, as in the a1 initialization above.
|
use explicit type cast operators, as in the a1 initialization above.
|
||||||
@param a lower inclusive boundary of the returned random number.
|
@param a lower inclusive boundary of the returned random number.
|
||||||
@param b upper non-inclusive boundary of the returned random number.
|
@param b upper non-inclusive boundary of the returned random number.
|
||||||
*/
|
*/
|
||||||
int uniform(int a, int b);
|
int uniform(int a, int b);
|
||||||
/** @overload */
|
/** @overload */
|
||||||
float uniform(float a, float b);
|
float uniform(float a, float b);
|
||||||
@@ -2912,7 +2919,7 @@ public:
|
|||||||
|
|
||||||
Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
|
Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
|
||||||
@todo document
|
@todo document
|
||||||
*/
|
*/
|
||||||
class CV_EXPORTS RNG_MT19937
|
class CV_EXPORTS RNG_MT19937
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -2930,17 +2937,11 @@ public:
|
|||||||
unsigned operator ()(unsigned N);
|
unsigned operator ()(unsigned N);
|
||||||
unsigned operator ()();
|
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);
|
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);
|
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);
|
double uniform(double a, double b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -2954,8 +2955,8 @@ private:
|
|||||||
//! @addtogroup core_cluster
|
//! @addtogroup core_cluster
|
||||||
//! @{
|
//! @{
|
||||||
|
|
||||||
/** @example kmeans.cpp
|
/** @example samples/cpp/kmeans.cpp
|
||||||
An example on K-means clustering
|
An example on K-means clustering
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @brief Finds centers of clusters and groups input samples around the clusters.
|
/** @brief Finds centers of clusters and groups input samples around the clusters.
|
||||||
@@ -3067,7 +3068,7 @@ etc.).
|
|||||||
|
|
||||||
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
|
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
|
||||||
@snippet snippets/core_various.cpp Algorithm
|
@snippet snippets/core_various.cpp Algorithm
|
||||||
*/
|
*/
|
||||||
class CV_EXPORTS_W Algorithm
|
class CV_EXPORTS_W Algorithm
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -3083,8 +3084,8 @@ public:
|
|||||||
virtual void write(FileStorage& fs) const { (void)fs; }
|
virtual void write(FileStorage& fs) const { (void)fs; }
|
||||||
|
|
||||||
/** @brief simplified API for language bindings
|
/** @brief simplified API for language bindings
|
||||||
* @overload
|
* @overload
|
||||||
*/
|
*/
|
||||||
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
||||||
|
|
||||||
/** @brief Reads algorithm parameters from a file storage
|
/** @brief Reads algorithm parameters from a file storage
|
||||||
@@ -3092,20 +3093,20 @@ public:
|
|||||||
CV_WRAP virtual void read(const FileNode& fn) { (void)fn; }
|
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
|
/** @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; }
|
CV_WRAP virtual bool empty() const { return false; }
|
||||||
|
|
||||||
/** @brief Reads algorithm from the file node
|
/** @brief Reads algorithm from the file node
|
||||||
|
|
||||||
This is static template method of Algorithm. It's usage is following (in the case of SVM):
|
This is static template method of Algorithm. It's usage is following (in the case of SVM):
|
||||||
@code
|
@code
|
||||||
cv::FileStorage fsRead("example.xml", FileStorage::READ);
|
cv::FileStorage fsRead("example.xml", FileStorage::READ);
|
||||||
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
|
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
|
||||||
@endcode
|
@endcode
|
||||||
In order to make this method work, the derived class must overwrite Algorithm::read(const
|
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
|
FileNode& fn) and also have static create() method without parameters
|
||||||
(or with all the optional parameters)
|
(or with all the optional parameters)
|
||||||
*/
|
*/
|
||||||
template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
|
template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
|
||||||
{
|
{
|
||||||
Ptr<_Tp> obj = _Tp::create();
|
Ptr<_Tp> obj = _Tp::create();
|
||||||
@@ -3115,16 +3116,16 @@ public:
|
|||||||
|
|
||||||
/** @brief Loads algorithm from the file
|
/** @brief Loads algorithm from the file
|
||||||
|
|
||||||
@param filename Name of the file to read.
|
@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 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):
|
This is static template method of Algorithm. It's usage is following (in the case of SVM):
|
||||||
@code
|
@code
|
||||||
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
|
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
|
||||||
@endcode
|
@endcode
|
||||||
In order to make this method work, the derived class must overwrite Algorithm::read(const
|
In order to make this method work, the derived class must overwrite Algorithm::read(const
|
||||||
FileNode& fn).
|
FileNode& fn).
|
||||||
*/
|
*/
|
||||||
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
|
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
|
||||||
{
|
{
|
||||||
FileStorage fs(filename, FileStorage::READ);
|
FileStorage fs(filename, FileStorage::READ);
|
||||||
@@ -3138,14 +3139,14 @@ public:
|
|||||||
|
|
||||||
/** @brief Loads algorithm from a String
|
/** @brief Loads algorithm from a String
|
||||||
|
|
||||||
@param strModel The string variable containing the model you want to load.
|
@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 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):
|
This is static template method of Algorithm. It's usage is following (in the case of SVM):
|
||||||
@code
|
@code
|
||||||
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
|
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
|
||||||
@endcode
|
@endcode
|
||||||
*/
|
*/
|
||||||
template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
|
template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
|
||||||
{
|
{
|
||||||
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
|
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
|
||||||
@@ -3156,11 +3157,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Saves the algorithm to a file.
|
/** 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;
|
CV_WRAP virtual void save(const String& filename) const;
|
||||||
|
|
||||||
/** Returns the algorithm string identifier.
|
/** 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;
|
CV_WRAP virtual String getDefaultName() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
|
|||||||
// We need to use simplified definition for them.
|
// We need to use simplified definition for them.
|
||||||
#define CV_Error(...) do { abort(); } while (0)
|
#define CV_Error(...) do { abort(); } while (0)
|
||||||
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
|
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
|
||||||
#define CV_Assert_1( expr ) do { if (!(expr)) abort(); } while (0)
|
#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)
|
||||||
|
|
||||||
#else // CV_STATIC_ANALYSIS
|
#else // CV_STATIC_ANALYSIS
|
||||||
|
|
||||||
@@ -444,7 +444,13 @@ for example:
|
|||||||
*/
|
*/
|
||||||
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||||
|
|
||||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
/** @brief Checks a condition at runtime and throws exception if it fails
|
||||||
|
|
||||||
|
The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
|
||||||
|
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
|
||||||
|
configurations while CV_DbgAssert is only retained in the Debug configuration.
|
||||||
|
*/
|
||||||
|
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||||
|
|
||||||
//! @cond IGNORED
|
//! @cond IGNORED
|
||||||
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||||
@@ -454,8 +460,8 @@ for example:
|
|||||||
#define CV_Error CV__ErrorNoReturn
|
#define CV_Error CV__ErrorNoReturn
|
||||||
#undef CV_Error_
|
#undef CV_Error_
|
||||||
#define CV_Error_ CV__ErrorNoReturn_
|
#define CV_Error_ CV__ErrorNoReturn_
|
||||||
#undef CV_Assert_1
|
#undef CV_Assert
|
||||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||||
#else
|
#else
|
||||||
// backward compatibility
|
// backward compatibility
|
||||||
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
||||||
@@ -465,6 +471,18 @@ for example:
|
|||||||
|
|
||||||
#endif // CV_STATIC_ANALYSIS
|
#endif // CV_STATIC_ANALYSIS
|
||||||
|
|
||||||
|
//! @cond IGNORED
|
||||||
|
|
||||||
|
#if defined OPENCV_FORCE_MULTIARG_ASSERT_CHECK && defined CV_STATIC_ANALYSIS
|
||||||
|
#warning "OPENCV_FORCE_MULTIARG_ASSERT_CHECK can't be used with CV_STATIC_ANALYSIS"
|
||||||
|
#undef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||||
|
#define CV_Assert_1( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||||
|
#else
|
||||||
|
#define CV_Assert_1 CV_Assert
|
||||||
|
#endif
|
||||||
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
||||||
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
||||||
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
||||||
@@ -475,21 +493,18 @@ for example:
|
|||||||
#define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9)
|
#define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9)
|
||||||
#define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10)
|
#define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10)
|
||||||
|
|
||||||
#define CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
|
#define CV_Assert_N(...) do { __CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
|
||||||
#define CV_VA_NUM_ARGS(...) CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
|
||||||
|
|
||||||
/** @brief Checks a condition at runtime and throws exception if it fails
|
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||||
|
#undef CV_Assert
|
||||||
|
#define CV_Assert CV_Assert_N
|
||||||
|
#endif
|
||||||
|
//! @endcond
|
||||||
|
|
||||||
The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
|
|
||||||
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
|
|
||||||
configurations while CV_DbgAssert is only retained in the Debug configuration.
|
|
||||||
*/
|
|
||||||
#define CV_Assert(...) do { CVAUX_CONCAT(CV_Assert_, CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
|
|
||||||
|
|
||||||
/** replaced with CV_Assert(expr) in Debug configuration */
|
|
||||||
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
|
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
|
||||||
# define CV_DbgAssert(expr) CV_Assert(expr)
|
# define CV_DbgAssert(expr) CV_Assert(expr)
|
||||||
#else
|
#else
|
||||||
|
/** replaced with CV_Assert(expr) in Debug configuration */
|
||||||
# define CV_DbgAssert(expr)
|
# define CV_DbgAssert(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
|
|||||||
#define __CV_CAT(x, y) __CV_CAT_(x, y)
|
#define __CV_CAT(x, y) __CV_CAT_(x, y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
|
||||||
|
#define __CV_VA_NUM_ARGS(...) __CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||||
|
|
||||||
// undef problematic defines sometimes defined by system headers (windows.h in particular)
|
// undef problematic defines sometimes defined by system headers (windows.h in particular)
|
||||||
#undef small
|
#undef small
|
||||||
@@ -347,7 +349,13 @@ Cv64suf;
|
|||||||
// We need to use simplified definition for them.
|
// We need to use simplified definition for them.
|
||||||
#ifndef CV_STATIC_ANALYSIS
|
#ifndef CV_STATIC_ANALYSIS
|
||||||
# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
|
# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
|
||||||
# define CV_STATIC_ANALYSIS
|
# define CV_STATIC_ANALYSIS 1
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1) // defined and not empty
|
||||||
|
# if 0 == CV_STATIC_ANALYSIS
|
||||||
|
# undef CV_STATIC_ANALYSIS
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,18 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
|||||||
#define CV_SIMD512_64F 0
|
#define CV_SIMD512_64F 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CV_SIMD128_FP16
|
||||||
|
#define CV_SIMD128_FP16 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CV_SIMD256_FP16
|
||||||
|
#define CV_SIMD256_FP16 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CV_SIMD512_FP16
|
||||||
|
#define CV_SIMD512_FP16 0
|
||||||
|
#endif
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
#define CV_INTRIN_DEFINE_WIDE_INTRIN(typ, vtyp, short_typ, prefix, loadsfx) \
|
#define CV_INTRIN_DEFINE_WIDE_INTRIN(typ, vtyp, short_typ, prefix, loadsfx) \
|
||||||
@@ -274,8 +286,8 @@ template<typename _Tp> struct V_RegTraits
|
|||||||
#if CV_SIMD128_64F
|
#if CV_SIMD128_64F
|
||||||
CV_DEF_REG_TRAITS(v, v_float64x2, double, f64, v_float64x2, void, void, v_int64x2, v_int32x4);
|
CV_DEF_REG_TRAITS(v, v_float64x2, double, f64, v_float64x2, void, void, v_int64x2, v_int32x4);
|
||||||
#endif
|
#endif
|
||||||
#if CV_FP16
|
#if CV_SIMD128_FP16
|
||||||
CV_DEF_REG_TRAITS(v, v_float16x8, short, f16, v_float32x4, void, void, v_int16x8, v_int16x8);
|
CV_DEF_REG_TRAITS(v, v_float16x8, short, f16, v_float16x8, void, void, v_int16x8, v_int16x8);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -290,8 +302,8 @@ template<typename _Tp> struct V_RegTraits
|
|||||||
CV_DEF_REG_TRAITS(v256, v_uint64x4, uint64, u64, v_uint64x4, void, void, v_int64x4, void);
|
CV_DEF_REG_TRAITS(v256, v_uint64x4, uint64, u64, v_uint64x4, void, void, v_int64x4, void);
|
||||||
CV_DEF_REG_TRAITS(v256, v_int64x4, int64, s64, v_uint64x4, void, void, v_int64x4, void);
|
CV_DEF_REG_TRAITS(v256, v_int64x4, int64, s64, v_uint64x4, void, void, v_int64x4, void);
|
||||||
CV_DEF_REG_TRAITS(v256, v_float64x4, double, f64, v_float64x4, void, void, v_int64x4, v_int32x8);
|
CV_DEF_REG_TRAITS(v256, v_float64x4, double, f64, v_float64x4, void, void, v_int64x4, v_int32x8);
|
||||||
#if CV_FP16
|
#if CV_SIMD256_FP16
|
||||||
CV_DEF_REG_TRAITS(v256, v_float16x16, short, f16, v_float32x8, void, void, v_int16x16, void);
|
CV_DEF_REG_TRAITS(v256, v_float16x16, short, f16, v_float16x16, void, void, v_int16x16, void);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -309,6 +321,7 @@ using namespace CV__SIMD_NAMESPACE;
|
|||||||
namespace CV__SIMD_NAMESPACE {
|
namespace CV__SIMD_NAMESPACE {
|
||||||
#define CV_SIMD 1
|
#define CV_SIMD 1
|
||||||
#define CV_SIMD_64F CV_SIMD256_64F
|
#define CV_SIMD_64F CV_SIMD256_64F
|
||||||
|
#define CV_SIMD_FP16 CV_SIMD256_FP16
|
||||||
#define CV_SIMD_WIDTH 32
|
#define CV_SIMD_WIDTH 32
|
||||||
typedef v_uint8x32 v_uint8;
|
typedef v_uint8x32 v_uint8;
|
||||||
typedef v_int8x32 v_int8;
|
typedef v_int8x32 v_int8;
|
||||||
@@ -323,6 +336,10 @@ namespace CV__SIMD_NAMESPACE {
|
|||||||
typedef v_float64x4 v_float64;
|
typedef v_float64x4 v_float64;
|
||||||
#endif
|
#endif
|
||||||
#if CV_FP16
|
#if CV_FP16
|
||||||
|
#define vx_load_fp16_f32 v256_load_fp16_f32
|
||||||
|
#define vx_store_fp16 v_store_fp16
|
||||||
|
#endif
|
||||||
|
#if CV_SIMD256_FP16
|
||||||
typedef v_float16x16 v_float16;
|
typedef v_float16x16 v_float16;
|
||||||
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v256, load_f16)
|
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v256, load_f16)
|
||||||
#endif
|
#endif
|
||||||
@@ -336,6 +353,7 @@ using namespace CV__SIMD_NAMESPACE;
|
|||||||
namespace CV__SIMD_NAMESPACE {
|
namespace CV__SIMD_NAMESPACE {
|
||||||
#define CV_SIMD CV_SIMD128
|
#define CV_SIMD CV_SIMD128
|
||||||
#define CV_SIMD_64F CV_SIMD128_64F
|
#define CV_SIMD_64F CV_SIMD128_64F
|
||||||
|
#define CV_SIMD_FP16 CV_SIMD128_FP16
|
||||||
#define CV_SIMD_WIDTH 16
|
#define CV_SIMD_WIDTH 16
|
||||||
typedef v_uint8x16 v_uint8;
|
typedef v_uint8x16 v_uint8;
|
||||||
typedef v_int8x16 v_int8;
|
typedef v_int8x16 v_int8;
|
||||||
@@ -350,6 +368,10 @@ namespace CV__SIMD_NAMESPACE {
|
|||||||
typedef v_float64x2 v_float64;
|
typedef v_float64x2 v_float64;
|
||||||
#endif
|
#endif
|
||||||
#if CV_FP16
|
#if CV_FP16
|
||||||
|
#define vx_load_fp16_f32 v128_load_fp16_f32
|
||||||
|
#define vx_store_fp16 v_store_fp16
|
||||||
|
#endif
|
||||||
|
#if CV_SIMD128_FP16
|
||||||
typedef v_float16x8 v_float16;
|
typedef v_float16x8 v_float16;
|
||||||
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v, load_f16)
|
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v, load_f16)
|
||||||
#endif
|
#endif
|
||||||
@@ -393,6 +415,11 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
|||||||
#define CV_SIMD_64F 0
|
#define CV_SIMD_64F 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CV_SIMD_FP16
|
||||||
|
#define CV_SIMD_FP16 0 //!< Defined to 1 on native support of operations with float16x8_t / float16x16_t (SIMD256) types
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef CV_SIMD
|
#ifndef CV_SIMD
|
||||||
#define CV_SIMD 0
|
#define CV_SIMD 0
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#define CV_SIMD256 1
|
#define CV_SIMD256 1
|
||||||
#define CV_SIMD256_64F 1
|
#define CV_SIMD256_64F 1
|
||||||
|
#define CV_SIMD256_FP16 0 // no native operations with FP16 type. Only load/store from float32x8 are available (if CV_FP16 == 1)
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@@ -262,26 +263,6 @@ struct v_float64x4
|
|||||||
double get0() const { return _mm_cvtsd_f64(_mm256_castpd256_pd128(val)); }
|
double get0() const { return _mm_cvtsd_f64(_mm256_castpd256_pd128(val)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct v_float16x16
|
|
||||||
{
|
|
||||||
typedef short lane_type;
|
|
||||||
enum { nlanes = 16 };
|
|
||||||
__m256i val;
|
|
||||||
|
|
||||||
explicit v_float16x16(__m256i v) : val(v) {}
|
|
||||||
v_float16x16(short v0, short v1, short v2, short v3,
|
|
||||||
short v4, short v5, short v6, short v7,
|
|
||||||
short v8, short v9, short v10, short v11,
|
|
||||||
short v12, short v13, short v14, short v15)
|
|
||||||
{
|
|
||||||
val = _mm256_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
|
|
||||||
}
|
|
||||||
v_float16x16() : val(_mm256_setzero_si256()) {}
|
|
||||||
short get0() const { return (short)_v_cvtsi256_si32(val); }
|
|
||||||
};
|
|
||||||
inline v_float16x16 v256_setzero_f16() { return v_float16x16(_mm256_setzero_si256()); }
|
|
||||||
inline v_float16x16 v256_setall_f16(short val) { return v_float16x16(_mm256_set1_epi16(val)); }
|
|
||||||
|
|
||||||
//////////////// Load and store operations ///////////////
|
//////////////// Load and store operations ///////////////
|
||||||
|
|
||||||
#define OPENCV_HAL_IMPL_AVX_LOADSTORE(_Tpvec, _Tp) \
|
#define OPENCV_HAL_IMPL_AVX_LOADSTORE(_Tpvec, _Tp) \
|
||||||
@@ -424,20 +405,18 @@ inline v_float64x4 v_reinterpret_as_f64(const v_float64x4& a)
|
|||||||
inline v_float64x4 v_reinterpret_as_f64(const v_float32x8& a)
|
inline v_float64x4 v_reinterpret_as_f64(const v_float32x8& a)
|
||||||
{ return v_float64x4(_mm256_castps_pd(a.val)); }
|
{ return v_float64x4(_mm256_castps_pd(a.val)); }
|
||||||
|
|
||||||
inline v_float16x16 v256_load_f16(const short* ptr)
|
#if CV_FP16
|
||||||
{ return v_float16x16(_mm256_loadu_si256((const __m256i*)ptr)); }
|
inline v_float32x8 v256_load_fp16_f32(const short* ptr)
|
||||||
inline v_float16x16 v256_load_f16_aligned(const short* ptr)
|
{
|
||||||
{ return v_float16x16(_mm256_load_si256((const __m256i*)ptr)); }
|
return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr)));
|
||||||
|
}
|
||||||
|
|
||||||
inline v_float16x16 v256_load_f16_low(const short* ptr)
|
inline void v_store_fp16(short* ptr, const v_float32x8& a)
|
||||||
{ return v_float16x16(v256_load_low(ptr).val); }
|
{
|
||||||
inline v_float16x16 v256_load_f16_halves(const short* ptr0, const short* ptr1)
|
__m128i fp16_value = _mm256_cvtps_ph(a.val, 0);
|
||||||
{ return v_float16x16(v256_load_halves(ptr0, ptr1).val); }
|
_mm_store_si128((__m128i*)ptr, fp16_value);
|
||||||
|
}
|
||||||
inline void v_store(short* ptr, const v_float16x16& a)
|
#endif
|
||||||
{ _mm256_storeu_si256((__m256i*)ptr, a.val); }
|
|
||||||
inline void v_store_aligned(short* ptr, const v_float16x16& a)
|
|
||||||
{ _mm256_store_si256((__m256i*)ptr, a.val); }
|
|
||||||
|
|
||||||
/* Recombine */
|
/* Recombine */
|
||||||
/*#define OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, perm) \
|
/*#define OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, perm) \
|
||||||
@@ -1262,20 +1241,6 @@ inline v_float64x4 v_cvt_f64(const v_float32x8& a)
|
|||||||
inline v_float64x4 v_cvt_f64_high(const v_float32x8& a)
|
inline v_float64x4 v_cvt_f64_high(const v_float32x8& a)
|
||||||
{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_high(a.val))); }
|
{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_high(a.val))); }
|
||||||
|
|
||||||
#if CV_FP16
|
|
||||||
inline v_float32x8 v_cvt_f32(const v_float16x16& a)
|
|
||||||
{ return v_float32x8(_mm256_cvtph_ps(_v256_extract_low(a.val))); }
|
|
||||||
|
|
||||||
inline v_float32x8 v_cvt_f32_high(const v_float16x16& a)
|
|
||||||
{ return v_float32x8(_mm256_cvtph_ps(_v256_extract_high(a.val))); }
|
|
||||||
|
|
||||||
inline v_float16x16 v_cvt_f16(const v_float32x8& a, const v_float32x8& b)
|
|
||||||
{
|
|
||||||
__m128i ah = _mm256_cvtps_ph(a.val, 0), bh = _mm256_cvtps_ph(b.val, 0);
|
|
||||||
return v_float16x16(_mm256_inserti128_si256(_mm256_castsi128_si256(ah), bh, 1));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////// Lookup table access ////////////////////
|
////////////// Lookup table access ////////////////////
|
||||||
|
|
||||||
inline v_int32x8 v_lut(const int* tab, const v_int32x8& idxvec)
|
inline v_int32x8 v_lut(const int* tab, const v_int32x8& idxvec)
|
||||||
|
|||||||
@@ -62,6 +62,15 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
|||||||
#define CV_SIMD128_64F 0
|
#define CV_SIMD128_64F 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CV_SIMD128_FP16
|
||||||
|
# if CV_FP16 && (defined(__GNUC__) && __GNUC__ >= 5) // #12027: float16x8_t is missing in GCC 4.8.2
|
||||||
|
# define CV_SIMD128_FP16 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef CV_SIMD128_FP16
|
||||||
|
# define CV_SIMD128_FP16 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CV_SIMD128_64F
|
#if CV_SIMD128_64F
|
||||||
#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \
|
#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \
|
||||||
template <typename T> static inline \
|
template <typename T> static inline \
|
||||||
@@ -280,28 +289,9 @@ struct v_float64x2
|
|||||||
|
|
||||||
#if CV_FP16
|
#if CV_FP16
|
||||||
// Workaround for old compilers
|
// Workaround for old compilers
|
||||||
static inline int16x8_t vreinterpretq_s16_f16(float16x8_t a) { return (int16x8_t)a; }
|
|
||||||
static inline float16x8_t vreinterpretq_f16_s16(int16x8_t a) { return (float16x8_t)a; }
|
|
||||||
static inline int16x4_t vreinterpret_s16_f16(float16x4_t a) { return (int16x4_t)a; }
|
static inline int16x4_t vreinterpret_s16_f16(float16x4_t a) { return (int16x4_t)a; }
|
||||||
static inline float16x4_t vreinterpret_f16_s16(int16x4_t a) { return (float16x4_t)a; }
|
static inline float16x4_t vreinterpret_f16_s16(int16x4_t a) { return (float16x4_t)a; }
|
||||||
|
|
||||||
static inline float16x8_t cv_vld1q_f16(const void* ptr)
|
|
||||||
{
|
|
||||||
#ifndef vld1q_f16 // APPLE compiler defines vld1_f16 as macro
|
|
||||||
return vreinterpretq_f16_s16(vld1q_s16((const short*)ptr));
|
|
||||||
#else
|
|
||||||
return vld1q_f16((const __fp16*)ptr);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
static inline void cv_vst1q_f16(void* ptr, float16x8_t a)
|
|
||||||
{
|
|
||||||
#ifndef vst1q_f16 // APPLE compiler defines vst1_f16 as macro
|
|
||||||
vst1q_s16((short*)ptr, vreinterpretq_s16_f16(a));
|
|
||||||
#else
|
|
||||||
vst1q_f16((__fp16*)ptr, a);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float16x4_t cv_vld1_f16(const void* ptr)
|
static inline float16x4_t cv_vld1_f16(const void* ptr)
|
||||||
{
|
{
|
||||||
#ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro
|
#ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro
|
||||||
@@ -323,6 +313,45 @@ static inline void cv_vst1_f16(void* ptr, float16x4_t a)
|
|||||||
#define vdup_n_f16(v) (float16x4_t){v, v, v, v}
|
#define vdup_n_f16(v) (float16x4_t){v, v, v, v}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // CV_FP16
|
||||||
|
|
||||||
|
#if CV_FP16
|
||||||
|
inline v_float32x4 v128_load_fp16_f32(const short* ptr)
|
||||||
|
{
|
||||||
|
float16x4_t a = cv_vld1_f16((const __fp16*)ptr);
|
||||||
|
return v_float32x4(vcvt_f32_f16(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void v_store_fp16(short* ptr, const v_float32x4& a)
|
||||||
|
{
|
||||||
|
float16x4_t fp16 = vcvt_f16_f32(a.val);
|
||||||
|
cv_vst1_f16((short*)ptr, fp16);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if CV_SIMD128_FP16
|
||||||
|
// Workaround for old compilers
|
||||||
|
static inline int16x8_t vreinterpretq_s16_f16(float16x8_t a) { return (int16x8_t)a; }
|
||||||
|
static inline float16x8_t vreinterpretq_f16_s16(int16x8_t a) { return (float16x8_t)a; }
|
||||||
|
|
||||||
|
static inline float16x8_t cv_vld1q_f16(const void* ptr)
|
||||||
|
{
|
||||||
|
#ifndef vld1q_f16 // APPLE compiler defines vld1_f16 as macro
|
||||||
|
return vreinterpretq_f16_s16(vld1q_s16((const short*)ptr));
|
||||||
|
#else
|
||||||
|
return vld1q_f16((const __fp16*)ptr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
static inline void cv_vst1q_f16(void* ptr, float16x8_t a)
|
||||||
|
{
|
||||||
|
#ifndef vst1q_f16 // APPLE compiler defines vst1_f16 as macro
|
||||||
|
vst1q_s16((short*)ptr, vreinterpretq_s16_f16(a));
|
||||||
|
#else
|
||||||
|
vst1q_f16((__fp16*)ptr, a);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
struct v_float16x8
|
struct v_float16x8
|
||||||
{
|
{
|
||||||
typedef short lane_type;
|
typedef short lane_type;
|
||||||
@@ -344,7 +373,8 @@ struct v_float16x8
|
|||||||
|
|
||||||
inline v_float16x8 v_setzero_f16() { return v_float16x8(vreinterpretq_f16_s16(vdupq_n_s16((short)0))); }
|
inline v_float16x8 v_setzero_f16() { return v_float16x8(vreinterpretq_f16_s16(vdupq_n_s16((short)0))); }
|
||||||
inline v_float16x8 v_setall_f16(short v) { return v_float16x8(vreinterpretq_f16_s16(vdupq_n_s16(v))); }
|
inline v_float16x8 v_setall_f16(short v) { return v_float16x8(vreinterpretq_f16_s16(vdupq_n_s16(v))); }
|
||||||
#endif
|
|
||||||
|
#endif // CV_SIMD128_FP16
|
||||||
|
|
||||||
#define OPENCV_HAL_IMPL_NEON_INIT(_Tpv, _Tp, suffix) \
|
#define OPENCV_HAL_IMPL_NEON_INIT(_Tpv, _Tp, suffix) \
|
||||||
inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(vdupq_n_##suffix((_Tp)0)); } \
|
inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(vdupq_n_##suffix((_Tp)0)); } \
|
||||||
@@ -889,7 +919,7 @@ OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32)
|
|||||||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
|
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CV_FP16
|
#if CV_SIMD128_FP16
|
||||||
// Workaround for old comiplers
|
// Workaround for old comiplers
|
||||||
inline v_float16x8 v_load_f16(const short* ptr)
|
inline v_float16x8 v_load_f16(const short* ptr)
|
||||||
{ return v_float16x8(cv_vld1q_f16(ptr)); }
|
{ return v_float16x8(cv_vld1q_f16(ptr)); }
|
||||||
@@ -1462,7 +1492,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CV_FP16
|
#if CV_SIMD128_FP16
|
||||||
inline v_float32x4 v_cvt_f32(const v_float16x8& a)
|
inline v_float32x4 v_cvt_f32(const v_float16x8& a)
|
||||||
{
|
{
|
||||||
return v_float32x4(vcvt_f32_f16(vget_low_f16(a.val)));
|
return v_float32x4(vcvt_f32_f16(vget_low_f16(a.val)));
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#define CV_SIMD128 1
|
#define CV_SIMD128 1
|
||||||
#define CV_SIMD128_64F 1
|
#define CV_SIMD128_64F 1
|
||||||
|
#define CV_SIMD128_FP16 0 // no native operations with FP16 type.
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@@ -272,28 +273,6 @@ struct v_float64x2
|
|||||||
__m128d val;
|
__m128d val;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct v_float16x8
|
|
||||||
{
|
|
||||||
typedef short lane_type;
|
|
||||||
typedef __m128i vector_type;
|
|
||||||
enum { nlanes = 8 };
|
|
||||||
|
|
||||||
v_float16x8() : val(_mm_setzero_si128()) {}
|
|
||||||
explicit v_float16x8(__m128i v) : val(v) {}
|
|
||||||
v_float16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7)
|
|
||||||
{
|
|
||||||
val = _mm_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7);
|
|
||||||
}
|
|
||||||
short get0() const
|
|
||||||
{
|
|
||||||
return (short)_mm_cvtsi128_si32(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
__m128i val;
|
|
||||||
};
|
|
||||||
inline v_float16x8 v_setzero_f16() { return v_float16x8(_mm_setzero_si128()); }
|
|
||||||
inline v_float16x8 v_setall_f16(short val) { return v_float16x8(_mm_set1_epi16(val)); }
|
|
||||||
|
|
||||||
namespace hal_sse_internal
|
namespace hal_sse_internal
|
||||||
{
|
{
|
||||||
template <typename to_sse_type, typename from_sse_type>
|
template <typename to_sse_type, typename from_sse_type>
|
||||||
@@ -1330,21 +1309,6 @@ inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
|
|||||||
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps)
|
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps)
|
||||||
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd)
|
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd)
|
||||||
|
|
||||||
inline v_float16x8 v_load_f16(const short* ptr)
|
|
||||||
{ return v_float16x8(_mm_loadu_si128((const __m128i*)ptr)); }
|
|
||||||
inline v_float16x8 v_load_f16_aligned(const short* ptr)
|
|
||||||
{ return v_float16x8(_mm_load_si128((const __m128i*)ptr)); }
|
|
||||||
|
|
||||||
inline v_float16x8 v_load_f16_low(const short* ptr)
|
|
||||||
{ return v_float16x8(v_load_low(ptr).val); }
|
|
||||||
inline v_float16x8 v_load_f16_halves(const short* ptr0, const short* ptr1)
|
|
||||||
{ return v_float16x8(v_load_halves(ptr0, ptr1).val); }
|
|
||||||
|
|
||||||
inline void v_store(short* ptr, const v_float16x8& a)
|
|
||||||
{ _mm_storeu_si128((__m128i*)ptr, a.val); }
|
|
||||||
inline void v_store_aligned(short* ptr, const v_float16x8& a)
|
|
||||||
{ _mm_store_si128((__m128i*)ptr, a.val); }
|
|
||||||
|
|
||||||
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(_Tpvec, scalartype, func, suffix, sbit) \
|
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(_Tpvec, scalartype, func, suffix, sbit) \
|
||||||
inline scalartype v_reduce_##func(const v_##_Tpvec& a) \
|
inline scalartype v_reduce_##func(const v_##_Tpvec& a) \
|
||||||
{ \
|
{ \
|
||||||
@@ -2622,19 +2586,15 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CV_FP16
|
#if CV_FP16
|
||||||
inline v_float32x4 v_cvt_f32(const v_float16x8& a)
|
inline v_float32x4 v128_load_fp16_f32(const short* ptr)
|
||||||
{
|
{
|
||||||
return v_float32x4(_mm_cvtph_ps(a.val));
|
return v_float32x4(_mm_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline v_float32x4 v_cvt_f32_high(const v_float16x8& a)
|
inline void v_store_fp16(short* ptr, const v_float32x4& a)
|
||||||
{
|
{
|
||||||
return v_float32x4(_mm_cvtph_ps(_mm_unpackhi_epi64(a.val, a.val)));
|
__m128i fp16_value = _mm_cvtps_ph(a.val, 0);
|
||||||
}
|
_mm_storel_epi64((__m128i*)ptr, fp16_value);
|
||||||
|
|
||||||
inline v_float16x8 v_cvt_f16(const v_float32x4& a, const v_float32x4& b)
|
|
||||||
{
|
|
||||||
return v_float16x8(_mm_unpacklo_epi64(_mm_cvtps_ph(a.val, 0), _mm_cvtps_ph(b.val, 0)));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ protected:
|
|||||||
MatStep& operator = (const MatStep&);
|
MatStep& operator = (const MatStep&);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @example cout_mat.cpp
|
/** @example samples/cpp/cout_mat.cpp
|
||||||
An example demonstrating the serial out capabilities of cv::Mat
|
An example demonstrating the serial out capabilities of cv::Mat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -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`
|
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.
|
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
|
A complete example using the FileStorage interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#define CV_VERSION_MAJOR 3
|
#define CV_VERSION_MAJOR 3
|
||||||
#define CV_VERSION_MINOR 4
|
#define CV_VERSION_MINOR 4
|
||||||
#define CV_VERSION_REVISION 3
|
#define CV_VERSION_REVISION 3
|
||||||
#define CV_VERSION_STATUS "-openvino.2018R3"
|
#define CV_VERSION_STATUS ""
|
||||||
|
|
||||||
#define CVAUX_STR_EXP(__A) #__A
|
#define CVAUX_STR_EXP(__A) #__A
|
||||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package org.opencv.core;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.opencv.core.RotatedRect;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class MatOfRotatedRect extends Mat {
|
||||||
|
// 32FC5
|
||||||
|
private static final int _depth = CvType.CV_32F;
|
||||||
|
private static final int _channels = 5;
|
||||||
|
|
||||||
|
public MatOfRotatedRect() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MatOfRotatedRect(long addr) {
|
||||||
|
super(addr);
|
||||||
|
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||||
|
throw new IllegalArgumentException("Incompatible Mat");
|
||||||
|
//FIXME: do we need release() here?
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MatOfRotatedRect fromNativeAddr(long addr) {
|
||||||
|
return new MatOfRotatedRect(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MatOfRotatedRect(Mat m) {
|
||||||
|
super(m, Range.all());
|
||||||
|
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||||
|
throw new IllegalArgumentException("Incompatible Mat");
|
||||||
|
//FIXME: do we need release() here?
|
||||||
|
}
|
||||||
|
|
||||||
|
public MatOfRotatedRect(RotatedRect...a) {
|
||||||
|
super();
|
||||||
|
fromArray(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void alloc(int elemNumber) {
|
||||||
|
if(elemNumber>0)
|
||||||
|
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fromArray(RotatedRect...a) {
|
||||||
|
if(a==null || a.length==0)
|
||||||
|
return;
|
||||||
|
int num = a.length;
|
||||||
|
alloc(num);
|
||||||
|
float buff[] = new float[num * _channels];
|
||||||
|
for(int i=0; i<num; i++) {
|
||||||
|
RotatedRect r = a[i];
|
||||||
|
buff[_channels*i+0] = (float) r.center.x;
|
||||||
|
buff[_channels*i+1] = (float) r.center.y;
|
||||||
|
buff[_channels*i+2] = (float) r.size.width;
|
||||||
|
buff[_channels*i+3] = (float) r.size.height;
|
||||||
|
buff[_channels*i+4] = (float) r.angle;
|
||||||
|
}
|
||||||
|
put(0, 0, buff); //TODO: check ret val!
|
||||||
|
}
|
||||||
|
|
||||||
|
public RotatedRect[] toArray() {
|
||||||
|
int num = (int) total();
|
||||||
|
RotatedRect[] a = new RotatedRect[num];
|
||||||
|
if(num == 0)
|
||||||
|
return a;
|
||||||
|
float buff[] = new float[_channels];
|
||||||
|
for(int i=0; i<num; i++) {
|
||||||
|
get(i, 0, buff); //TODO: check ret val!
|
||||||
|
a[i] = new RotatedRect(new Point(buff[0],buff[1]),new Size(buff[2],buff[3]),buff[4]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fromList(List<RotatedRect> lr) {
|
||||||
|
RotatedRect ap[] = lr.toArray(new RotatedRect[0]);
|
||||||
|
fromArray(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RotatedRect> toList() {
|
||||||
|
RotatedRect[] ar = toArray();
|
||||||
|
return Arrays.asList(ar);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
package org.opencv.test.core;
|
package org.opencv.test.core;
|
||||||
|
|
||||||
|
import org.opencv.core.CvType;
|
||||||
import org.opencv.core.Point;
|
import org.opencv.core.Point;
|
||||||
import org.opencv.core.Rect;
|
import org.opencv.core.Rect;
|
||||||
import org.opencv.core.RotatedRect;
|
import org.opencv.core.RotatedRect;
|
||||||
|
import org.opencv.core.MatOfRotatedRect;
|
||||||
import org.opencv.core.Size;
|
import org.opencv.core.Size;
|
||||||
import org.opencv.test.OpenCVTestCase;
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RotatedRectTest extends OpenCVTestCase {
|
public class RotatedRectTest extends OpenCVTestCase {
|
||||||
|
|
||||||
private double angle;
|
private double angle;
|
||||||
@@ -188,4 +193,21 @@ public class RotatedRectTest extends OpenCVTestCase {
|
|||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMatOfRotatedRect() {
|
||||||
|
RotatedRect a = new RotatedRect(new Point(1,2),new Size(3,4),5.678);
|
||||||
|
RotatedRect b = new RotatedRect(new Point(9,8),new Size(7,6),5.432);
|
||||||
|
MatOfRotatedRect m = new MatOfRotatedRect(a,b,a,b,a,b,a,b);
|
||||||
|
assertEquals(m.rows(), 8);
|
||||||
|
assertEquals(m.cols(), 1);
|
||||||
|
assertEquals(m.type(), CvType.CV_32FC(5));
|
||||||
|
RotatedRect[] arr = m.toArray();
|
||||||
|
assertEquals(arr[2].angle, a.angle, EPS);
|
||||||
|
assertEquals(arr[3].center.x, b.center.x);
|
||||||
|
assertEquals(arr[3].size.width, b.size.width);
|
||||||
|
List<RotatedRect> li = m.toList();
|
||||||
|
assertEquals(li.size(), 8);
|
||||||
|
RotatedRect rr = li.get(7);
|
||||||
|
assertEquals(rr.angle, b.angle, EPS);
|
||||||
|
assertEquals(rr.center.y, b.center.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ namespace opencv_test
|
|||||||
{
|
{
|
||||||
using namespace perf;
|
using namespace perf;
|
||||||
|
|
||||||
#define TYPICAL_MAT_SIZES_CORE_ARITHM szVGA, sz720p, sz1080p
|
typedef Size_MatType BinaryOpTest;
|
||||||
#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 ) )
|
|
||||||
|
|
||||||
PERF_TEST_P(Size_MatType, min, TYPICAL_MATS_CORE_ARITHM)
|
PERF_TEST_P_(BinaryOpTest, min)
|
||||||
{
|
{
|
||||||
Size sz = get<0>(GetParam());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
TEST_CYCLE() cv::max(a, b, c);
|
||||||
|
|
||||||
SANITY_CHECK(c);
|
SANITY_CHECK_NOTHING();
|
||||||
}
|
}
|
||||||
|
|
||||||
PERF_TEST_P(Size_MatType, absdiff, TYPICAL_MATS_CORE_ARITHM)
|
PERF_TEST_P_(BinaryOpTest, maxScalarSameType)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
Size sz = get<0>(GetParam());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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)
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||||
{
|
{
|
||||||
//see ticket 1529: absdiff can be without saturation on 32S
|
//see ticket 1529: absdiff can be without saturation on 32S
|
||||||
a /= 2;
|
a /= 2;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
eps = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CYCLE() cv::absdiff(a, b, c);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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.in(a, b, WARMUP_RNG).out(c);
|
||||||
declare.time(50);
|
declare.time(50);
|
||||||
|
|
||||||
double eps = 1e-8;
|
|
||||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||||
{
|
{
|
||||||
//see ticket 1529: add can be without saturation on 32S
|
//see ticket 1529: add can be without saturation on 32S
|
||||||
a /= 2;
|
a /= 2;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
eps = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CYCLE() cv::add(a, b, c);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
declare.in(a, b, WARMUP_RNG).out(c);
|
||||||
|
|
||||||
double eps = 1e-8;
|
|
||||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||||
{
|
{
|
||||||
//see ticket 1529: add can be without saturation on 32S
|
//see ticket 1529: add can be without saturation on 32S
|
||||||
a /= 2;
|
a /= 2;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
eps = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CYCLE() cv::add(a, b, c);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
declare.in(a, b, WARMUP_RNG).out(c);
|
||||||
|
|
||||||
double eps = 1e-8;
|
|
||||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||||
{
|
{
|
||||||
//see ticket 1529: subtract can be without saturation on 32S
|
//see ticket 1529: subtract can be without saturation on 32S
|
||||||
a /= 2;
|
a /= 2;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
eps = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CYCLE() cv::subtract(a, b, c);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
declare.in(a, b, WARMUP_RNG).out(c);
|
||||||
|
|
||||||
double eps = 1e-8;
|
|
||||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||||
{
|
{
|
||||||
//see ticket 1529: subtract can be without saturation on 32S
|
//see ticket 1529: subtract can be without saturation on 32S
|
||||||
a /= 2;
|
a /= 2;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
eps = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CYCLE() cv::subtract(a, b, c);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(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);
|
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());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(GetParam());
|
int type = get<1>(GetParam());
|
||||||
@@ -267,7 +379,7 @@ PERF_TEST_P(Size_MatType, divide, TYPICAL_MATS_CORE_ARITHM)
|
|||||||
SANITY_CHECK_NOTHING();
|
SANITY_CHECK_NOTHING();
|
||||||
}
|
}
|
||||||
|
|
||||||
PERF_TEST_P(Size_MatType, reciprocal, TYPICAL_MATS_CORE_ARITHM)
|
PERF_TEST_P_(BinaryOpTest, reciprocal)
|
||||||
{
|
{
|
||||||
Size sz = get<0>(GetParam());
|
Size sz = get<0>(GetParam());
|
||||||
int type = get<1>(GetParam());
|
int type = get<1>(GetParam());
|
||||||
@@ -281,4 +393,11 @@ PERF_TEST_P(Size_MatType, reciprocal, TYPICAL_MATS_CORE_ARITHM)
|
|||||||
SANITY_CHECK_NOTHING();
|
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
|
} // namespace
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include "opencl_kernels_core.hpp"
|
#include "opencl_kernels_core.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "mathfuncs.hpp"
|
||||||
|
|
||||||
namespace cv
|
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. */
|
/* End of 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
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
// 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.
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
|
||||||
|
#include "mathfuncs.hpp"
|
||||||
|
|
||||||
namespace cv { namespace hal {
|
namespace cv { namespace hal {
|
||||||
|
|
||||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||||
@@ -409,76 +411,6 @@ void log64f(const double *src, double *dst, int n)
|
|||||||
|
|
||||||
#define EXPPOLY_32F_A0 .9670371139572337719125840413672004409288e-2
|
#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
|
// the code below uses _mm_cast* intrinsics, which are not avialable on VS2005
|
||||||
#if (defined _MSC_VER && _MSC_VER < 1500) || \
|
#if (defined _MSC_VER && _MSC_VER < 1500) || \
|
||||||
(!defined __APPLE__ && defined __GNUC__ && __GNUC__*100 + __GNUC_MINOR__ < 402)
|
(!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()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
if( !extTab_f_initialized )
|
const float* const expTab_f = cv::details::getExpTab32f();
|
||||||
{
|
|
||||||
for( int j = 0; j <= EXPTAB_MASK; j++ )
|
|
||||||
expTab_f[j] = (float)expTab[j];
|
|
||||||
extTab_f_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const float
|
const float
|
||||||
A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
|
A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
|
||||||
A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
|
A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
|
||||||
A2 = (float)(.2402265109513301490103372422686535526573 / 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()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
static const double
|
const double* const expTab = cv::details::getExpTab64f();
|
||||||
|
|
||||||
|
const double
|
||||||
A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
|
A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
|
||||||
A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
|
A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
|
||||||
A3 = .24022650695886477918181338054308 / 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_SCALE 8
|
||||||
#define LOGTAB_MASK ((1 << LOGTAB_SCALE) - 1)
|
#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])
|
#define LOGTAB_TRANSLATE(tab, x, h) (((x) - 1.f)*tab[(h)+1])
|
||||||
static const double ln_2 = 0.69314718055994530941723212145818;
|
static const double ln_2 = 0.69314718055994530941723212145818;
|
||||||
|
|
||||||
@@ -1006,15 +673,10 @@ void log32f( const float *_x, float *y, int n )
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
if( !logTab_f_initialized )
|
const float* const logTab_f = cv::details::getLogTab32f();
|
||||||
{
|
|
||||||
for( int j = 0; j < (LOGTAB_MASK+1)*2; j++ )
|
|
||||||
logTab_f[j] = (float)logTab[j];
|
|
||||||
logTab_f_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int LOGTAB_MASK2_32F = (1 << (23 - LOGTAB_SCALE)) - 1;
|
const int LOGTAB_MASK2_32F = (1 << (23 - LOGTAB_SCALE)) - 1;
|
||||||
static const float
|
const float
|
||||||
A0 = 0.3333333333333333333333333f,
|
A0 = 0.3333333333333333333333333f,
|
||||||
A1 = -0.5f,
|
A1 = -0.5f,
|
||||||
A2 = 1.f;
|
A2 = 1.f;
|
||||||
@@ -1082,8 +744,10 @@ void log64f( const double *x, double *y, int n )
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
static const int64 LOGTAB_MASK2_64F = ((int64)1 << (52 - LOGTAB_SCALE)) - 1;
|
const double* const logTab = cv::details::getLogTab64f();
|
||||||
static const double
|
|
||||||
|
const int64 LOGTAB_MASK2_64F = ((int64)1 << (52 - LOGTAB_SCALE)) - 1;
|
||||||
|
const double
|
||||||
A7 = 1.0,
|
A7 = 1.0,
|
||||||
A6 = -0.5,
|
A6 = -0.5,
|
||||||
A5 = 0.333333333333333314829616256247390992939472198486328125,
|
A5 = 0.333333333333333314829616256247390992939472198486328125,
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
|
|||||||
int depth = matA.depth(), cn = matA.channels();
|
int depth = matA.depth(), cn = matA.channels();
|
||||||
int type = CV_MAKETYPE(depth, cn);
|
int type = CV_MAKETYPE(depth, cn);
|
||||||
|
|
||||||
CV_Assert( type == matB.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) );
|
CV_Assert_N( type == matB.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) );
|
||||||
|
|
||||||
const ocl::Device & dev = ocl::Device::getDefault();
|
const ocl::Device & dev = ocl::Device::getDefault();
|
||||||
bool doubleSupport = dev.doubleFPConfig() > 0;
|
bool doubleSupport = dev.doubleFPConfig() > 0;
|
||||||
@@ -1555,7 +1555,7 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
|||||||
Size a_size = A.size(), d_size;
|
Size a_size = A.size(), d_size;
|
||||||
int len = 0, type = A.type();
|
int len = 0, type = A.type();
|
||||||
|
|
||||||
CV_Assert( type == B.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) );
|
CV_Assert_N( type == B.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) );
|
||||||
|
|
||||||
switch( flags & (GEMM_1_T|GEMM_2_T) )
|
switch( flags & (GEMM_1_T|GEMM_2_T) )
|
||||||
{
|
{
|
||||||
@@ -1583,7 +1583,7 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
|||||||
|
|
||||||
if( !C.empty() )
|
if( !C.empty() )
|
||||||
{
|
{
|
||||||
CV_Assert( C.type() == type,
|
CV_Assert_N( C.type() == type,
|
||||||
(((flags&GEMM_3_T) == 0 && C.rows == d_size.height && C.cols == d_size.width) ||
|
(((flags&GEMM_3_T) == 0 && C.rows == d_size.height && C.cols == d_size.width) ||
|
||||||
((flags&GEMM_3_T) != 0 && C.rows == d_size.width && C.cols == d_size.height)));
|
((flags&GEMM_3_T) != 0 && C.rows == d_size.width && C.cols == d_size.height)));
|
||||||
}
|
}
|
||||||
@@ -2457,7 +2457,7 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean,
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
CV_Assert( data, nsamples > 0 );
|
CV_Assert_N( data, nsamples > 0 );
|
||||||
Size size = data[0].size();
|
Size size = data[0].size();
|
||||||
int sz = size.width * size.height, esz = (int)data[0].elemSize();
|
int sz = size.width * size.height, esz = (int)data[0].elemSize();
|
||||||
int type = data[0].type();
|
int type = data[0].type();
|
||||||
@@ -2480,7 +2480,7 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean,
|
|||||||
|
|
||||||
for( int i = 0; i < nsamples; i++ )
|
for( int i = 0; i < nsamples; i++ )
|
||||||
{
|
{
|
||||||
CV_Assert( data[i].size() == size, data[i].type() == type );
|
CV_Assert_N( data[i].size() == size, data[i].type() == type );
|
||||||
if( data[i].isContinuous() )
|
if( data[i].isContinuous() )
|
||||||
memcpy( _data.ptr(i), data[i].ptr(), sz*esz );
|
memcpy( _data.ptr(i), data[i].ptr(), sz*esz );
|
||||||
else
|
else
|
||||||
@@ -2516,7 +2516,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for(std::vector<cv::Mat>::iterator each = src.begin(); each != src.end(); ++each, ++i )
|
for(std::vector<cv::Mat>::iterator each = src.begin(); each != src.end(); ++each, ++i )
|
||||||
{
|
{
|
||||||
CV_Assert( (*each).size() == size, (*each).type() == type );
|
CV_Assert_N( (*each).size() == size, (*each).type() == type );
|
||||||
Mat dataRow(size.height, size.width, type, _data.ptr(i));
|
Mat dataRow(size.height, size.width, type, _data.ptr(i));
|
||||||
(*each).copyTo(dataRow);
|
(*each).copyTo(dataRow);
|
||||||
}
|
}
|
||||||
@@ -2595,7 +2595,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
|
|||||||
AutoBuffer<double> buf(len);
|
AutoBuffer<double> buf(len);
|
||||||
double result = 0;
|
double result = 0;
|
||||||
|
|
||||||
CV_Assert( type == v2.type(), type == icovar.type(),
|
CV_Assert_N( type == v2.type(), type == icovar.type(),
|
||||||
sz == v2.size(), len == icovar.rows && len == icovar.cols );
|
sz == v2.size(), len == icovar.rows && len == icovar.cols );
|
||||||
|
|
||||||
sz.width *= v1.channels();
|
sz.width *= v1.channels();
|
||||||
@@ -2888,7 +2888,7 @@ void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata,
|
|||||||
|
|
||||||
if( !delta.empty() )
|
if( !delta.empty() )
|
||||||
{
|
{
|
||||||
CV_Assert( delta.channels() == 1,
|
CV_Assert_N( delta.channels() == 1,
|
||||||
(delta.rows == src.rows || delta.rows == 1),
|
(delta.rows == src.rows || delta.rows == 1),
|
||||||
(delta.cols == src.cols || delta.cols == 1));
|
(delta.cols == src.cols || delta.cols == 1));
|
||||||
if( delta.type() != dtype )
|
if( delta.type() != dtype )
|
||||||
@@ -3291,7 +3291,7 @@ double Mat::dot(InputArray _mat) const
|
|||||||
Mat mat = _mat.getMat();
|
Mat mat = _mat.getMat();
|
||||||
int cn = channels();
|
int cn = channels();
|
||||||
DotProdFunc func = getDotProdFunc(depth());
|
DotProdFunc func = getDotProdFunc(depth());
|
||||||
CV_Assert( mat.type() == type(), mat.size == size, func != 0 );
|
CV_Assert_N( mat.type() == type(), mat.size == size, func != 0 );
|
||||||
|
|
||||||
if( isContinuous() && mat.isContinuous() )
|
if( isContinuous() && mat.isContinuous() )
|
||||||
{
|
{
|
||||||
@@ -3327,7 +3327,7 @@ CV_IMPL void cvGEMM( const CvArr* Aarr, const CvArr* Barr, double alpha,
|
|||||||
if( Carr )
|
if( Carr )
|
||||||
C = cv::cvarrToMat(Carr);
|
C = cv::cvarrToMat(Carr);
|
||||||
|
|
||||||
CV_Assert( (D.rows == ((flags & CV_GEMM_A_T) == 0 ? A.rows : A.cols)),
|
CV_Assert_N( (D.rows == ((flags & CV_GEMM_A_T) == 0 ? A.rows : A.cols)),
|
||||||
(D.cols == ((flags & CV_GEMM_B_T) == 0 ? B.cols : B.rows)),
|
(D.cols == ((flags & CV_GEMM_B_T) == 0 ? B.cols : B.rows)),
|
||||||
D.type() == A.type() );
|
D.type() == A.type() );
|
||||||
|
|
||||||
@@ -3350,7 +3350,7 @@ cvTransform( const CvArr* srcarr, CvArr* dstarr,
|
|||||||
m = _m;
|
m = _m;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_Assert( dst.depth() == src.depth(), dst.channels() == m.rows );
|
CV_Assert_N( dst.depth() == src.depth(), dst.channels() == m.rows );
|
||||||
cv::transform( src, dst, m );
|
cv::transform( src, dst, m );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3360,7 +3360,7 @@ cvPerspectiveTransform( const CvArr* srcarr, CvArr* dstarr, const CvMat* mat )
|
|||||||
{
|
{
|
||||||
cv::Mat m = cv::cvarrToMat(mat), src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
cv::Mat m = cv::cvarrToMat(mat), src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
||||||
|
|
||||||
CV_Assert( dst.type() == src.type(), dst.channels() == m.rows-1 );
|
CV_Assert_N( dst.type() == src.type(), dst.channels() == m.rows-1 );
|
||||||
cv::perspectiveTransform( src, dst, m );
|
cv::perspectiveTransform( src, dst, m );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3370,7 +3370,7 @@ CV_IMPL void cvScaleAdd( const CvArr* srcarr1, CvScalar scale,
|
|||||||
{
|
{
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
||||||
|
|
||||||
CV_Assert( src1.size == dst.size, src1.type() == dst.type() );
|
CV_Assert_N( src1.size == dst.size, src1.type() == dst.type() );
|
||||||
cv::scaleAdd( src1, scale.val[0], cv::cvarrToMat(srcarr2), dst );
|
cv::scaleAdd( src1, scale.val[0], cv::cvarrToMat(srcarr2), dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3380,7 +3380,7 @@ cvCalcCovarMatrix( const CvArr** vecarr, int count,
|
|||||||
CvArr* covarr, CvArr* avgarr, int flags )
|
CvArr* covarr, CvArr* avgarr, int flags )
|
||||||
{
|
{
|
||||||
cv::Mat cov0 = cv::cvarrToMat(covarr), cov = cov0, mean0, mean;
|
cv::Mat cov0 = cv::cvarrToMat(covarr), cov = cov0, mean0, mean;
|
||||||
CV_Assert( vecarr != 0, count >= 1 );
|
CV_Assert_N( vecarr != 0, count >= 1 );
|
||||||
|
|
||||||
if( avgarr )
|
if( avgarr )
|
||||||
mean = mean0 = cv::cvarrToMat(avgarr);
|
mean = mean0 = cv::cvarrToMat(avgarr);
|
||||||
@@ -3460,7 +3460,7 @@ cvCalcPCA( const CvArr* data_arr, CvArr* avg_arr, CvArr* eigenvals, CvArr* eigen
|
|||||||
int ecount0 = evals0.cols + evals0.rows - 1;
|
int ecount0 = evals0.cols + evals0.rows - 1;
|
||||||
int ecount = evals.cols + evals.rows - 1;
|
int ecount = evals.cols + evals.rows - 1;
|
||||||
|
|
||||||
CV_Assert( (evals0.cols == 1 || evals0.rows == 1),
|
CV_Assert_N( (evals0.cols == 1 || evals0.rows == 1),
|
||||||
ecount0 <= ecount,
|
ecount0 <= ecount,
|
||||||
evects0.cols == evects.cols,
|
evects0.cols == evects.cols,
|
||||||
evects0.rows == ecount0 );
|
evects0.rows == ecount0 );
|
||||||
@@ -3491,12 +3491,12 @@ cvProjectPCA( const CvArr* data_arr, const CvArr* avg_arr,
|
|||||||
int n;
|
int n;
|
||||||
if( mean.rows == 1 )
|
if( mean.rows == 1 )
|
||||||
{
|
{
|
||||||
CV_Assert(dst.cols <= evects.rows, dst.rows == data.rows);
|
CV_Assert_N(dst.cols <= evects.rows, dst.rows == data.rows);
|
||||||
n = dst.cols;
|
n = dst.cols;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_Assert(dst.rows <= evects.rows, dst.cols == data.cols);
|
CV_Assert_N(dst.rows <= evects.rows, dst.cols == data.cols);
|
||||||
n = dst.rows;
|
n = dst.rows;
|
||||||
}
|
}
|
||||||
pca.eigenvectors = evects.rowRange(0, n);
|
pca.eigenvectors = evects.rowRange(0, n);
|
||||||
@@ -3522,12 +3522,12 @@ cvBackProjectPCA( const CvArr* proj_arr, const CvArr* avg_arr,
|
|||||||
int n;
|
int n;
|
||||||
if( mean.rows == 1 )
|
if( mean.rows == 1 )
|
||||||
{
|
{
|
||||||
CV_Assert(data.cols <= evects.rows, dst.rows == data.rows);
|
CV_Assert_N(data.cols <= evects.rows, dst.rows == data.rows);
|
||||||
n = data.cols;
|
n = data.cols;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_Assert(data.rows <= evects.rows, dst.cols == data.cols);
|
CV_Assert_N(data.rows <= evects.rows, dst.cols == data.cols);
|
||||||
n = data.rows;
|
n = data.rows;
|
||||||
}
|
}
|
||||||
pca.eigenvectors = evects.rowRange(0, n);
|
pca.eigenvectors = evects.rowRange(0, n);
|
||||||
|
|||||||
@@ -801,10 +801,12 @@ TraceStorage* TraceManagerThreadLocal::getStorage() const
|
|||||||
const char* pos = strrchr(filepath.c_str(), '/'); // extract filename
|
const char* pos = strrchr(filepath.c_str(), '/'); // extract filename
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!pos)
|
if (!pos)
|
||||||
strrchr(filepath.c_str(), '\\');
|
pos = strrchr(filepath.c_str(), '\\');
|
||||||
#endif
|
#endif
|
||||||
if (!pos)
|
if (!pos)
|
||||||
pos = filepath.c_str();
|
pos = filepath.c_str();
|
||||||
|
else
|
||||||
|
pos += 1; // fix to skip extra slash in filename beginning
|
||||||
msg.printf("#thread file: %s\n", pos);
|
msg.printf("#thread file: %s\n", pos);
|
||||||
global->put(msg);
|
global->put(msg);
|
||||||
storage.reset(new AsyncTraceStorage(filepath));
|
storage.reset(new AsyncTraceStorage(filepath));
|
||||||
|
|||||||
@@ -324,6 +324,163 @@ static void copy_convert_bgr_to_nv12(const VAImage& image, const Mat& bgr, unsig
|
|||||||
dstUV += dstStepUV;
|
dstUV += dstStepUV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void copy_convert_yv12_to_bgr(const VAImage& image, const unsigned char* buffer, Mat& bgr)
|
||||||
|
{
|
||||||
|
const float d1 = 16.0f;
|
||||||
|
const float d2 = 128.0f;
|
||||||
|
|
||||||
|
static const float coeffs[5] =
|
||||||
|
{
|
||||||
|
1.163999557f,
|
||||||
|
2.017999649f,
|
||||||
|
-0.390999794f,
|
||||||
|
-0.812999725f,
|
||||||
|
1.5959997177f
|
||||||
|
};
|
||||||
|
|
||||||
|
CV_CheckEQ(image.format.fourcc, VA_FOURCC_YV12, "Unexpected image format");
|
||||||
|
CV_CheckEQ(image.num_planes, 3, "");
|
||||||
|
|
||||||
|
const size_t srcOffsetY = image.offsets[0];
|
||||||
|
const size_t srcOffsetV = image.offsets[1];
|
||||||
|
const size_t srcOffsetU = image.offsets[2];
|
||||||
|
|
||||||
|
const size_t srcStepY = image.pitches[0];
|
||||||
|
const size_t srcStepU = image.pitches[1];
|
||||||
|
const size_t srcStepV = image.pitches[2];
|
||||||
|
|
||||||
|
const size_t dstStep = bgr.step;
|
||||||
|
|
||||||
|
const unsigned char* srcY_ = buffer + srcOffsetY;
|
||||||
|
const unsigned char* srcV_ = buffer + srcOffsetV;
|
||||||
|
const unsigned char* srcU_ = buffer + srcOffsetU;
|
||||||
|
|
||||||
|
for (int y = 0; y < bgr.rows; y += 2)
|
||||||
|
{
|
||||||
|
const unsigned char* srcY0 = srcY_ + (srcStepY) * y;
|
||||||
|
const unsigned char* srcY1 = srcY0 + srcStepY;
|
||||||
|
|
||||||
|
const unsigned char* srcV = srcV_ + (srcStepV) * y / 2;
|
||||||
|
const unsigned char* srcU = srcU_ + (srcStepU) * y / 2;
|
||||||
|
|
||||||
|
unsigned char* dst0 = bgr.data + (dstStep) * y;
|
||||||
|
unsigned char* dst1 = dst0 + dstStep;
|
||||||
|
|
||||||
|
for (int x = 0; x < bgr.cols; x += 2)
|
||||||
|
{
|
||||||
|
float Y0 = float(srcY0[x+0]);
|
||||||
|
float Y1 = float(srcY0[x+1]);
|
||||||
|
float Y2 = float(srcY1[x+0]);
|
||||||
|
float Y3 = float(srcY1[x+1]);
|
||||||
|
|
||||||
|
float U = float(srcU[x/2]) - d2;
|
||||||
|
float V = float(srcV[x/2]) - d2;
|
||||||
|
|
||||||
|
Y0 = std::max(0.0f, Y0 - d1) * coeffs[0];
|
||||||
|
Y1 = std::max(0.0f, Y1 - d1) * coeffs[0];
|
||||||
|
Y2 = std::max(0.0f, Y2 - d1) * coeffs[0];
|
||||||
|
Y3 = std::max(0.0f, Y3 - d1) * coeffs[0];
|
||||||
|
|
||||||
|
float ruv = coeffs[4]*V;
|
||||||
|
float guv = coeffs[3]*V + coeffs[2]*U;
|
||||||
|
float buv = coeffs[1]*U;
|
||||||
|
|
||||||
|
dst0[(x+0)*NCHANNELS+0] = saturate_cast<unsigned char>(Y0 + buv);
|
||||||
|
dst0[(x+0)*NCHANNELS+1] = saturate_cast<unsigned char>(Y0 + guv);
|
||||||
|
dst0[(x+0)*NCHANNELS+2] = saturate_cast<unsigned char>(Y0 + ruv);
|
||||||
|
|
||||||
|
dst0[(x+1)*NCHANNELS+0] = saturate_cast<unsigned char>(Y1 + buv);
|
||||||
|
dst0[(x+1)*NCHANNELS+1] = saturate_cast<unsigned char>(Y1 + guv);
|
||||||
|
dst0[(x+1)*NCHANNELS+2] = saturate_cast<unsigned char>(Y1 + ruv);
|
||||||
|
|
||||||
|
dst1[(x+0)*NCHANNELS+0] = saturate_cast<unsigned char>(Y2 + buv);
|
||||||
|
dst1[(x+0)*NCHANNELS+1] = saturate_cast<unsigned char>(Y2 + guv);
|
||||||
|
dst1[(x+0)*NCHANNELS+2] = saturate_cast<unsigned char>(Y2 + ruv);
|
||||||
|
|
||||||
|
dst1[(x+1)*NCHANNELS+0] = saturate_cast<unsigned char>(Y3 + buv);
|
||||||
|
dst1[(x+1)*NCHANNELS+1] = saturate_cast<unsigned char>(Y3 + guv);
|
||||||
|
dst1[(x+1)*NCHANNELS+2] = saturate_cast<unsigned char>(Y3 + ruv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_convert_bgr_to_yv12(const VAImage& image, const Mat& bgr, unsigned char* buffer)
|
||||||
|
{
|
||||||
|
const float d1 = 16.0f;
|
||||||
|
const float d2 = 128.0f;
|
||||||
|
|
||||||
|
static const float coeffs[8] =
|
||||||
|
{
|
||||||
|
0.256999969f, 0.50399971f, 0.09799957f, -0.1479988098f,
|
||||||
|
-0.2909994125f, 0.438999176f, -0.3679990768f, -0.0709991455f
|
||||||
|
};
|
||||||
|
|
||||||
|
CV_CheckEQ(image.format.fourcc, VA_FOURCC_YV12, "Unexpected image format");
|
||||||
|
CV_CheckEQ(image.num_planes, 3, "");
|
||||||
|
|
||||||
|
const size_t dstOffsetY = image.offsets[0];
|
||||||
|
const size_t dstOffsetV = image.offsets[1];
|
||||||
|
const size_t dstOffsetU = image.offsets[2];
|
||||||
|
|
||||||
|
const size_t dstStepY = image.pitches[0];
|
||||||
|
const size_t dstStepU = image.pitches[1];
|
||||||
|
const size_t dstStepV = image.pitches[2];
|
||||||
|
|
||||||
|
unsigned char* dstY_ = buffer + dstOffsetY;
|
||||||
|
unsigned char* dstV_ = buffer + dstOffsetV;
|
||||||
|
unsigned char* dstU_ = buffer + dstOffsetU;
|
||||||
|
|
||||||
|
const size_t srcStep = bgr.step;
|
||||||
|
|
||||||
|
for (int y = 0; y < bgr.rows; y += 2)
|
||||||
|
{
|
||||||
|
unsigned char* dstY0 = dstY_ + (dstStepY) * y;
|
||||||
|
unsigned char* dstY1 = dstY0 + dstStepY;
|
||||||
|
|
||||||
|
unsigned char* dstV = dstV_ + (dstStepV) * y / 2;
|
||||||
|
unsigned char* dstU = dstU_ + (dstStepU) * y / 2;
|
||||||
|
|
||||||
|
const unsigned char* src0 = bgr.data + (srcStep) * y;
|
||||||
|
const unsigned char* src1 = src0 + srcStep;
|
||||||
|
|
||||||
|
for (int x = 0; x < bgr.cols; x += 2)
|
||||||
|
{
|
||||||
|
float B0 = float(src0[(x+0)*NCHANNELS+0]);
|
||||||
|
float G0 = float(src0[(x+0)*NCHANNELS+1]);
|
||||||
|
float R0 = float(src0[(x+0)*NCHANNELS+2]);
|
||||||
|
|
||||||
|
float B1 = float(src0[(x+1)*NCHANNELS+0]);
|
||||||
|
float G1 = float(src0[(x+1)*NCHANNELS+1]);
|
||||||
|
float R1 = float(src0[(x+1)*NCHANNELS+2]);
|
||||||
|
|
||||||
|
float B2 = float(src1[(x+0)*NCHANNELS+0]);
|
||||||
|
float G2 = float(src1[(x+0)*NCHANNELS+1]);
|
||||||
|
float R2 = float(src1[(x+0)*NCHANNELS+2]);
|
||||||
|
|
||||||
|
float B3 = float(src1[(x+1)*NCHANNELS+0]);
|
||||||
|
float G3 = float(src1[(x+1)*NCHANNELS+1]);
|
||||||
|
float R3 = float(src1[(x+1)*NCHANNELS+2]);
|
||||||
|
|
||||||
|
float Y0 = coeffs[0]*R0 + coeffs[1]*G0 + coeffs[2]*B0 + d1;
|
||||||
|
float Y1 = coeffs[0]*R1 + coeffs[1]*G1 + coeffs[2]*B1 + d1;
|
||||||
|
float Y2 = coeffs[0]*R2 + coeffs[1]*G2 + coeffs[2]*B2 + d1;
|
||||||
|
float Y3 = coeffs[0]*R3 + coeffs[1]*G3 + coeffs[2]*B3 + d1;
|
||||||
|
|
||||||
|
float U = coeffs[3]*R0 + coeffs[4]*G0 + coeffs[5]*B0 + d2;
|
||||||
|
float V = coeffs[5]*R0 + coeffs[6]*G0 + coeffs[7]*B0 + d2;
|
||||||
|
|
||||||
|
dstY0[x+0] = saturate_cast<unsigned char>(Y0);
|
||||||
|
dstY0[x+1] = saturate_cast<unsigned char>(Y1);
|
||||||
|
dstY1[x+0] = saturate_cast<unsigned char>(Y2);
|
||||||
|
dstY1[x+1] = saturate_cast<unsigned char>(Y3);
|
||||||
|
|
||||||
|
dstU[x/2] = saturate_cast<unsigned char>(U);
|
||||||
|
dstV[x/2] = saturate_cast<unsigned char>(V);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // HAVE_VA
|
#endif // HAVE_VA
|
||||||
|
|
||||||
void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size)
|
void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size)
|
||||||
@@ -412,9 +569,12 @@ void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface,
|
|||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
||||||
|
|
||||||
CV_Assert(image.format.fourcc == VA_FOURCC_NV12);
|
if (image.format.fourcc == VA_FOURCC_NV12)
|
||||||
|
copy_convert_bgr_to_nv12(image, m, buffer);
|
||||||
copy_convert_bgr_to_nv12(image, m, buffer);
|
if (image.format.fourcc == VA_FOURCC_YV12)
|
||||||
|
copy_convert_bgr_to_yv12(image, m, buffer);
|
||||||
|
else
|
||||||
|
CV_Check((int)image.format.fourcc, image.format.fourcc == VA_FOURCC_NV12 || image.format.fourcc == VA_FOURCC_YV12, "Unexpected image format");
|
||||||
|
|
||||||
status = vaUnmapBuffer(display, image.buf);
|
status = vaUnmapBuffer(display, image.buf);
|
||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
@@ -510,9 +670,12 @@ void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, Out
|
|||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
CV_Error(cv::Error::StsError, "VA-API: vaMapBuffer failed");
|
||||||
|
|
||||||
CV_Assert(image.format.fourcc == VA_FOURCC_NV12);
|
if (image.format.fourcc == VA_FOURCC_NV12)
|
||||||
|
copy_convert_nv12_to_bgr(image, buffer, m);
|
||||||
copy_convert_nv12_to_bgr(image, buffer, m);
|
if (image.format.fourcc == VA_FOURCC_YV12)
|
||||||
|
copy_convert_yv12_to_bgr(image, buffer, m);
|
||||||
|
else
|
||||||
|
CV_Check((int)image.format.fourcc, image.format.fourcc == VA_FOURCC_NV12 || image.format.fourcc == VA_FOURCC_YV12, "Unexpected image format");
|
||||||
|
|
||||||
status = vaUnmapBuffer(display, image.buf);
|
status = vaUnmapBuffer(display, image.buf);
|
||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
|
|||||||
@@ -2117,4 +2117,71 @@ TEST(Core_Norm, IPP_regression_NORM_L1_16UC3_small)
|
|||||||
EXPECT_EQ((double)20*cn, cv::norm(a, b, NORM_L1, mask));
|
EXPECT_EQ((double)20*cn, cv::norm(a, b, NORM_L1, mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(Core_ConvertTo, regression_12121)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(-1));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_8U);
|
||||||
|
EXPECT_EQ(0, dst.at<uchar>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_8U);
|
||||||
|
EXPECT_EQ(0, dst.at<uchar>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN + 32767));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_8U);
|
||||||
|
EXPECT_EQ(0, dst.at<uchar>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN + 32768));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_8U);
|
||||||
|
EXPECT_EQ(0, dst.at<uchar>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(32768));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_8U);
|
||||||
|
EXPECT_EQ(255, dst.at<uchar>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_16U);
|
||||||
|
EXPECT_EQ(0, dst.at<ushort>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN + 32767));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_16U);
|
||||||
|
EXPECT_EQ(0, dst.at<ushort>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(INT_MIN + 32768));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_16U);
|
||||||
|
EXPECT_EQ(0, dst.at<ushort>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Mat src(4, 64, CV_32SC1, Scalar(65536));
|
||||||
|
Mat dst;
|
||||||
|
src.convertTo(dst, CV_16U);
|
||||||
|
EXPECT_EQ(65535, dst.at<ushort>(0, 0)) << "src=" << src.at<int>(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
|||||||
@@ -1123,9 +1123,37 @@ template<typename R> struct TheTest
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CV_FP16
|
||||||
|
TheTest & test_loadstore_fp16_f32()
|
||||||
|
{
|
||||||
|
printf("test_loadstore_fp16_f32 ...\n");
|
||||||
|
AlignedData<v_uint16> data; data.a.clear();
|
||||||
|
data.a.d[0] = 0x3c00; // 1.0
|
||||||
|
data.a.d[R::nlanes - 1] = (unsigned short)0xc000; // -2.0
|
||||||
|
AlignedData<v_float32> data_f32; data_f32.a.clear();
|
||||||
|
AlignedData<v_uint16> out;
|
||||||
|
|
||||||
|
R r1 = vx_load_fp16_f32((short*)data.a.d);
|
||||||
|
R r2(r1);
|
||||||
|
EXPECT_EQ(1.0f, r1.get0());
|
||||||
|
vx_store(data_f32.a.d, r2);
|
||||||
|
EXPECT_EQ(-2.0f, data_f32.a.d[R::nlanes - 1]);
|
||||||
|
|
||||||
|
out.a.clear();
|
||||||
|
vx_store_fp16((short*)out.a.d, r2);
|
||||||
|
for (int i = 0; i < R::nlanes; ++i)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(data.a[i], out.a[i]) << "i=" << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CV_SIMD_FP16
|
||||||
TheTest & test_loadstore_fp16()
|
TheTest & test_loadstore_fp16()
|
||||||
{
|
{
|
||||||
#if CV_FP16 && CV_SIMD
|
printf("test_loadstore_fp16 ...\n");
|
||||||
AlignedData<R> data;
|
AlignedData<R> data;
|
||||||
AlignedData<R> out;
|
AlignedData<R> out;
|
||||||
|
|
||||||
@@ -1149,12 +1177,10 @@ template<typename R> struct TheTest
|
|||||||
EXPECT_EQ(data.a, out.a);
|
EXPECT_EQ(data.a, out.a);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TheTest & test_float_cvt_fp16()
|
TheTest & test_float_cvt_fp16()
|
||||||
{
|
{
|
||||||
#if CV_FP16 && CV_SIMD
|
printf("test_float_cvt_fp16 ...\n");
|
||||||
AlignedData<v_float32> data;
|
AlignedData<v_float32> data;
|
||||||
|
|
||||||
// check conversion
|
// check conversion
|
||||||
@@ -1165,9 +1191,8 @@ template<typename R> struct TheTest
|
|||||||
EXPECT_EQ(r3.get0(), r1.get0());
|
EXPECT_EQ(r3.get0(), r1.get0());
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1448,11 +1473,14 @@ void test_hal_intrin_float64()
|
|||||||
void test_hal_intrin_float16()
|
void test_hal_intrin_float16()
|
||||||
{
|
{
|
||||||
DUMP_ENTRY(v_float16);
|
DUMP_ENTRY(v_float16);
|
||||||
#if CV_SIMD_WIDTH > 16
|
#if CV_FP16
|
||||||
|
TheTest<v_float32>().test_loadstore_fp16_f32();
|
||||||
|
#endif
|
||||||
|
#if CV_SIMD_FP16
|
||||||
TheTest<v_float16>()
|
TheTest<v_float16>()
|
||||||
.test_loadstore_fp16()
|
.test_loadstore_fp16()
|
||||||
.test_float_cvt_fp16()
|
.test_float_cvt_fp16()
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -278,20 +278,12 @@ namespace
|
|||||||
{
|
{
|
||||||
template<typename T, bool Signed = numeric_limits<T>::is_signed> struct PowOp : unary_function<T, T>
|
template<typename T, bool Signed = numeric_limits<T>::is_signed> struct PowOp : unary_function<T, T>
|
||||||
{
|
{
|
||||||
float power;
|
typedef typename LargerType<T, float>::type LargerType;
|
||||||
|
LargerType power;
|
||||||
|
|
||||||
__device__ __forceinline__ T operator()(T e) const
|
__device__ __forceinline__ T operator()(T e) const
|
||||||
{
|
{
|
||||||
return cudev::saturate_cast<T>(__powf((float)e, power));
|
T res = cudev::saturate_cast<T>(__powf(e < 0 ? -e : e, power));
|
||||||
}
|
|
||||||
};
|
|
||||||
template<typename T> struct PowOp<T, true> : unary_function<T, T>
|
|
||||||
{
|
|
||||||
float power;
|
|
||||||
|
|
||||||
__device__ __forceinline__ T operator()(T e) const
|
|
||||||
{
|
|
||||||
T res = cudev::saturate_cast<T>(__powf((float)e, power));
|
|
||||||
|
|
||||||
if ((e < 0) && (1 & static_cast<int>(power)))
|
if ((e < 0) && (1 & static_cast<int>(power)))
|
||||||
res *= -1;
|
res *= -1;
|
||||||
@@ -299,22 +291,15 @@ namespace
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<> struct PowOp<float> : unary_function<float, float>
|
|
||||||
{
|
|
||||||
float power;
|
|
||||||
|
|
||||||
__device__ __forceinline__ float operator()(float e) const
|
template<typename T> struct PowOp<T, false> : unary_function<T, T>
|
||||||
{
|
|
||||||
return __powf(::fabs(e), power);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template<> struct PowOp<double> : unary_function<double, double>
|
|
||||||
{
|
{
|
||||||
double power;
|
typedef typename LargerType<T, float>::type LargerType;
|
||||||
|
LargerType power;
|
||||||
|
|
||||||
__device__ __forceinline__ double operator()(double e) const
|
__device__ __forceinline__ T operator()(T e) const
|
||||||
{
|
{
|
||||||
return ::pow(::fabs(e), power);
|
return cudev::saturate_cast<T>(__powf(e, power));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,20 @@
|
|||||||
A network training is in principle not supported.
|
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>
|
#include <opencv2/dnn/dnn.hpp>
|
||||||
|
|
||||||
#endif /* OPENCV_DNN_HPP */
|
#endif /* OPENCV_DNN_HPP */
|
||||||
|
|||||||
@@ -900,7 +900,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
|||||||
CV_OUT std::vector<int>& indices,
|
CV_OUT std::vector<int>& indices,
|
||||||
const float eta = 1.f, const int top_k = 0);
|
const float eta = 1.f, const int top_k = 0);
|
||||||
|
|
||||||
CV_EXPORTS void NMSBoxes(const std::vector<RotatedRect>& bboxes, const std::vector<float>& scores,
|
CV_EXPORTS_AS(NMSBoxesRotated) void NMSBoxes(const std::vector<RotatedRect>& bboxes, const std::vector<float>& scores,
|
||||||
const float score_threshold, const float nms_threshold,
|
const float score_threshold, const float nms_threshold,
|
||||||
CV_OUT std::vector<int>& indices,
|
CV_OUT std::vector<int>& indices,
|
||||||
const float eta = 1.f, const int top_k = 0);
|
const float eta = 1.f, const int top_k = 0);
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ inline Range clamp(const Range& r, int axisSize)
|
|||||||
{
|
{
|
||||||
Range clamped(std::max(r.start, 0),
|
Range clamped(std::max(r.start, 0),
|
||||||
r.end > 0 ? std::min(r.end, axisSize) : axisSize + r.end + 1);
|
r.end > 0 ? std::min(r.end, axisSize) : axisSize + r.end + 1);
|
||||||
CV_Assert(clamped.start < clamped.end, clamped.end <= axisSize);
|
CV_Assert_N(clamped.start < clamped.end, clamped.end <= axisSize);
|
||||||
return clamped;
|
return clamped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!layerParams.get<bool>("use_global_stats", true))
|
if (!layerParams.get<bool>("use_global_stats", true))
|
||||||
{
|
{
|
||||||
CV_Assert(layer.bottom_size() == 1, layer.top_size() == 1);
|
CV_Assert_N(layer.bottom_size() == 1, layer.top_size() == 1);
|
||||||
|
|
||||||
LayerParams mvnParams;
|
LayerParams mvnParams;
|
||||||
mvnParams.set("eps", layerParams.get<float>("eps", 1e-5));
|
mvnParams.set("eps", layerParams.get<float>("eps", 1e-5));
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
|
|||||||
if (ddepth == CV_8U)
|
if (ddepth == CV_8U)
|
||||||
{
|
{
|
||||||
CV_CheckEQ(scalefactor, 1.0, "Scaling is not supported for CV_8U blob depth");
|
CV_CheckEQ(scalefactor, 1.0, "Scaling is not supported for CV_8U blob depth");
|
||||||
CV_Assert(mean_ == Scalar(), "Mean subtraction is not supported for CV_8U blob depth");
|
CV_Assert(mean_ == Scalar() && "Mean subtraction is not supported for CV_8U blob depth");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Mat> images;
|
std::vector<Mat> images;
|
||||||
@@ -451,8 +451,8 @@ struct DataLayer : public Layer
|
|||||||
{
|
{
|
||||||
double scale = scaleFactors[i];
|
double scale = scaleFactors[i];
|
||||||
Scalar& mean = means[i];
|
Scalar& mean = means[i];
|
||||||
CV_Assert(mean == Scalar() || inputsData[i].size[1] <= 4,
|
CV_Assert(mean == Scalar() || inputsData[i].size[1] <= 4);
|
||||||
outputs[i].type() == CV_32F);
|
CV_CheckTypeEQ(outputs[i].type(), CV_32FC1, "");
|
||||||
|
|
||||||
bool singleMean = true;
|
bool singleMean = true;
|
||||||
for (int j = 1; j < std::min(4, inputsData[i].size[1]) && singleMean; ++j)
|
for (int j = 1; j < std::min(4, inputsData[i].size[1]) && singleMean; ++j)
|
||||||
@@ -569,7 +569,7 @@ struct DataLayer : public Layer
|
|||||||
|
|
||||||
void finalize(const std::vector<Mat*>&, std::vector<Mat>& outputs) CV_OVERRIDE
|
void finalize(const std::vector<Mat*>&, std::vector<Mat>& outputs) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
CV_Assert(outputs.size() == scaleFactors.size(), outputs.size() == means.size(),
|
CV_Assert_N(outputs.size() == scaleFactors.size(), outputs.size() == means.size(),
|
||||||
inputsData.size() == outputs.size());
|
inputsData.size() == outputs.size());
|
||||||
skip = true;
|
skip = true;
|
||||||
for (int i = 0; skip && i < inputsData.size(); ++i)
|
for (int i = 0; skip && i < inputsData.size(); ++i)
|
||||||
@@ -588,7 +588,8 @@ struct DataLayer : public Layer
|
|||||||
lp.precision = InferenceEngine::Precision::FP32;
|
lp.precision = InferenceEngine::Precision::FP32;
|
||||||
std::shared_ptr<InferenceEngine::ScaleShiftLayer> ieLayer(new InferenceEngine::ScaleShiftLayer(lp));
|
std::shared_ptr<InferenceEngine::ScaleShiftLayer> ieLayer(new InferenceEngine::ScaleShiftLayer(lp));
|
||||||
|
|
||||||
CV_Assert(inputsData.size() == 1, inputsData[0].dims == 4);
|
CV_CheckEQ(inputsData.size(), (size_t)1, "");
|
||||||
|
CV_CheckEQ(inputsData[0].dims, 4, "");
|
||||||
const size_t numChannels = inputsData[0].size[1];
|
const size_t numChannels = inputsData[0].size[1];
|
||||||
CV_Assert(numChannels <= 4);
|
CV_Assert(numChannels <= 4);
|
||||||
|
|
||||||
@@ -698,9 +699,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reuseOrCreate(const MatShape& shape, const LayerPin& lp, Mat& dst, bool forceCreate, bool use_half)
|
void reuseOrCreate(const MatShape& shape, const LayerPin& lp, Mat& dst, bool use_half)
|
||||||
{
|
{
|
||||||
if (!DNN_DISABLE_MEMORY_OPTIMIZATIONS && !forceCreate)
|
if (!DNN_DISABLE_MEMORY_OPTIMIZATIONS)
|
||||||
{
|
{
|
||||||
Mat bestBlob;
|
Mat bestBlob;
|
||||||
LayerPin bestBlobPin;
|
LayerPin bestBlobPin;
|
||||||
@@ -746,7 +747,7 @@ public:
|
|||||||
|
|
||||||
void allocateBlobsForLayer(LayerData &ld, const LayerShapes& layerShapes,
|
void allocateBlobsForLayer(LayerData &ld, const LayerShapes& layerShapes,
|
||||||
std::vector<LayerPin>& pinsForInternalBlobs,
|
std::vector<LayerPin>& pinsForInternalBlobs,
|
||||||
bool forceCreate = false, bool use_half = false)
|
bool use_half = false)
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
|
|
||||||
@@ -817,7 +818,7 @@ public:
|
|||||||
reuse(ld.inputBlobsId[0], blobPin);
|
reuse(ld.inputBlobsId[0], blobPin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reuseOrCreate(shapes[index], blobPin, *blobs[index], forceCreate, use_half);
|
reuseOrCreate(shapes[index], blobPin, *blobs[index], use_half);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1238,7 @@ struct Net::Impl
|
|||||||
void initHalideBackend()
|
void initHalideBackend()
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
CV_Assert(preferableBackend == DNN_BACKEND_HALIDE, haveHalide());
|
CV_Assert_N(preferableBackend == DNN_BACKEND_HALIDE, haveHalide());
|
||||||
|
|
||||||
// Iterator to current layer.
|
// Iterator to current layer.
|
||||||
MapIdToLayerData::iterator it = layers.begin();
|
MapIdToLayerData::iterator it = layers.begin();
|
||||||
@@ -1302,7 +1303,7 @@ struct Net::Impl
|
|||||||
if (!node.empty())
|
if (!node.empty())
|
||||||
{
|
{
|
||||||
Ptr<InfEngineBackendNode> ieNode = node.dynamicCast<InfEngineBackendNode>();
|
Ptr<InfEngineBackendNode> ieNode = node.dynamicCast<InfEngineBackendNode>();
|
||||||
CV_Assert(!ieNode.empty(), !ieNode->net.empty());
|
CV_Assert(!ieNode.empty()); CV_Assert(!ieNode->net.empty());
|
||||||
layerNet = ieNode->net;
|
layerNet = ieNode->net;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1316,7 +1317,7 @@ struct Net::Impl
|
|||||||
if (!inpNode.empty())
|
if (!inpNode.empty())
|
||||||
{
|
{
|
||||||
Ptr<InfEngineBackendNode> ieInpNode = inpNode.dynamicCast<InfEngineBackendNode>();
|
Ptr<InfEngineBackendNode> ieInpNode = inpNode.dynamicCast<InfEngineBackendNode>();
|
||||||
CV_Assert(!ieInpNode.empty(), !ieInpNode->net.empty());
|
CV_Assert(!ieInpNode.empty()); CV_Assert(!ieInpNode->net.empty());
|
||||||
if (layerNet != ieInpNode->net)
|
if (layerNet != ieInpNode->net)
|
||||||
{
|
{
|
||||||
// layerNet is empty or nodes are from different graphs.
|
// layerNet is empty or nodes are from different graphs.
|
||||||
@@ -1330,7 +1331,7 @@ struct Net::Impl
|
|||||||
void initInfEngineBackend()
|
void initInfEngineBackend()
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
CV_Assert(preferableBackend == DNN_BACKEND_INFERENCE_ENGINE, haveInfEngine());
|
CV_Assert_N(preferableBackend == DNN_BACKEND_INFERENCE_ENGINE, haveInfEngine());
|
||||||
#ifdef HAVE_INF_ENGINE
|
#ifdef HAVE_INF_ENGINE
|
||||||
MapIdToLayerData::iterator it;
|
MapIdToLayerData::iterator it;
|
||||||
Ptr<InfEngineBackendNet> net;
|
Ptr<InfEngineBackendNet> net;
|
||||||
@@ -1425,7 +1426,7 @@ struct Net::Impl
|
|||||||
if (!inpNode.empty())
|
if (!inpNode.empty())
|
||||||
{
|
{
|
||||||
Ptr<InfEngineBackendNode> ieInpNode = inpNode.dynamicCast<InfEngineBackendNode>();
|
Ptr<InfEngineBackendNode> ieInpNode = inpNode.dynamicCast<InfEngineBackendNode>();
|
||||||
CV_Assert(!ieInpNode.empty(), !ieInpNode->net.empty());
|
CV_Assert(!ieInpNode.empty()); CV_Assert(!ieInpNode->net.empty());
|
||||||
if (ieInpNode->net != net)
|
if (ieInpNode->net != net)
|
||||||
{
|
{
|
||||||
net = Ptr<InfEngineBackendNet>();
|
net = Ptr<InfEngineBackendNet>();
|
||||||
@@ -1606,7 +1607,6 @@ struct Net::Impl
|
|||||||
|
|
||||||
std::vector<LayerPin> pinsForInternalBlobs;
|
std::vector<LayerPin> pinsForInternalBlobs;
|
||||||
blobManager.allocateBlobsForLayer(ld, layerShapesIt->second, pinsForInternalBlobs,
|
blobManager.allocateBlobsForLayer(ld, layerShapesIt->second, pinsForInternalBlobs,
|
||||||
preferableBackend == DNN_BACKEND_INFERENCE_ENGINE,
|
|
||||||
preferableBackend == DNN_BACKEND_OPENCV &&
|
preferableBackend == DNN_BACKEND_OPENCV &&
|
||||||
preferableTarget == DNN_TARGET_OPENCL_FP16);
|
preferableTarget == DNN_TARGET_OPENCL_FP16);
|
||||||
ld.outputBlobsWrappers.resize(ld.outputBlobs.size());
|
ld.outputBlobsWrappers.resize(ld.outputBlobs.size());
|
||||||
@@ -1827,7 +1827,7 @@ struct Net::Impl
|
|||||||
// To prevent memory collisions (i.e. when input of
|
// To prevent memory collisions (i.e. when input of
|
||||||
// [conv] and output of [eltwise] is the same blob)
|
// [conv] and output of [eltwise] is the same blob)
|
||||||
// we allocate a new blob.
|
// we allocate a new blob.
|
||||||
CV_Assert(ld.outputBlobs.size() == 1, ld.outputBlobsWrappers.size() == 1);
|
CV_Assert_N(ld.outputBlobs.size() == 1, ld.outputBlobsWrappers.size() == 1);
|
||||||
ld.outputBlobs[0] = ld.outputBlobs[0].clone();
|
ld.outputBlobs[0] = ld.outputBlobs[0].clone();
|
||||||
ld.outputBlobsWrappers[0] = wrap(ld.outputBlobs[0]);
|
ld.outputBlobsWrappers[0] = wrap(ld.outputBlobs[0]);
|
||||||
|
|
||||||
@@ -1984,7 +1984,7 @@ struct Net::Impl
|
|||||||
}
|
}
|
||||||
// Layers that refer old input Mat will refer to the
|
// Layers that refer old input Mat will refer to the
|
||||||
// new data but the same Mat object.
|
// new data but the same Mat object.
|
||||||
CV_Assert(curr_output.data == output_slice.data, oldPtr == &curr_output);
|
CV_Assert_N(curr_output.data == output_slice.data, oldPtr == &curr_output);
|
||||||
}
|
}
|
||||||
ld.skip = true;
|
ld.skip = true;
|
||||||
printf_(("\toptimized out Concat layer %s\n", concatLayer->name.c_str()));
|
printf_(("\toptimized out Concat layer %s\n", concatLayer->name.c_str()));
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
float varMeanScale = 1.f;
|
float varMeanScale = 1.f;
|
||||||
if (!hasWeights && !hasBias && blobs.size() > 2 && useGlobalStats) {
|
if (!hasWeights && !hasBias && blobs.size() > 2 && useGlobalStats) {
|
||||||
CV_Assert(blobs.size() == 3, blobs[2].type() == CV_32F);
|
CV_Assert(blobs.size() == 3); CV_CheckTypeEQ(blobs[2].type(), CV_32FC1, "");
|
||||||
varMeanScale = blobs[2].at<float>(0);
|
varMeanScale = blobs[2].at<float>(0);
|
||||||
if (varMeanScale != 0)
|
if (varMeanScale != 0)
|
||||||
varMeanScale = 1/varMeanScale;
|
varMeanScale = 1/varMeanScale;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public:
|
|||||||
|
|
||||||
virtual bool supportBackend(int backendId) CV_OVERRIDE
|
virtual bool supportBackend(int backendId) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_INF_ENGINE
|
||||||
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
|
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
|
||||||
{
|
{
|
||||||
if (type == "Convolution")
|
if (type == "Convolution")
|
||||||
@@ -91,13 +92,19 @@ public:
|
|||||||
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW layout
|
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW layout
|
||||||
const int group = numOutput / outGroupCn;
|
const int group = numOutput / outGroupCn;
|
||||||
if (group != 1)
|
if (group != 1)
|
||||||
|
{
|
||||||
|
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R3)
|
||||||
|
return preferableTarget == DNN_TARGET_CPU;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (preferableTarget == DNN_TARGET_OPENCL || preferableTarget == DNN_TARGET_OPENCL_FP16)
|
if (preferableTarget == DNN_TARGET_OPENCL || preferableTarget == DNN_TARGET_OPENCL_FP16)
|
||||||
return dilation.width == 1 && dilation.height == 1;
|
return dilation.width == 1 && dilation.height == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // HAVE_INF_ENGINE
|
||||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,8 +356,8 @@ public:
|
|||||||
// (conv(I) + b1 ) * w + b2
|
// (conv(I) + b1 ) * w + b2
|
||||||
// means to replace convolution's weights to [w*conv(I)] and bias to [b1 * w + b2]
|
// means to replace convolution's weights to [w*conv(I)] and bias to [b1 * w + b2]
|
||||||
const int outCn = weightsMat.size[0];
|
const int outCn = weightsMat.size[0];
|
||||||
CV_Assert(!weightsMat.empty(), biasvec.size() == outCn + 2,
|
CV_Assert_N(!weightsMat.empty(), biasvec.size() == outCn + 2,
|
||||||
w.empty() || outCn == w.total(), b.empty() || outCn == b.total());
|
w.empty() || outCn == w.total(), b.empty() || outCn == b.total());
|
||||||
|
|
||||||
if (!w.empty())
|
if (!w.empty())
|
||||||
{
|
{
|
||||||
@@ -512,13 +519,14 @@ public:
|
|||||||
Size kernel, Size pad, Size stride, Size dilation,
|
Size kernel, Size pad, Size stride, Size dilation,
|
||||||
const ActivationLayer* activ, int ngroups, int nstripes )
|
const ActivationLayer* activ, int ngroups, int nstripes )
|
||||||
{
|
{
|
||||||
CV_Assert( input.dims == 4 && output.dims == 4,
|
CV_Assert_N(
|
||||||
|
input.dims == 4 && output.dims == 4,
|
||||||
input.size[0] == output.size[0],
|
input.size[0] == output.size[0],
|
||||||
weights.rows == output.size[1],
|
weights.rows == output.size[1],
|
||||||
weights.cols == (input.size[1]/ngroups)*kernel.width*kernel.height,
|
weights.cols == (input.size[1]/ngroups)*kernel.width*kernel.height,
|
||||||
input.type() == output.type(),
|
input.type() == output.type(),
|
||||||
input.type() == weights.type(),
|
input.type() == weights.type(),
|
||||||
input.type() == CV_32F,
|
input.type() == CV_32FC1,
|
||||||
input.isContinuous(),
|
input.isContinuous(),
|
||||||
output.isContinuous(),
|
output.isContinuous(),
|
||||||
biasvec.size() == (size_t)output.size[1]+2);
|
biasvec.size() == (size_t)output.size[1]+2);
|
||||||
@@ -1009,8 +1017,8 @@ public:
|
|||||||
name.c_str(), inputs[0]->size[0], inputs[0]->size[1], inputs[0]->size[2], inputs[0]->size[3],
|
name.c_str(), inputs[0]->size[0], inputs[0]->size[1], inputs[0]->size[2], inputs[0]->size[3],
|
||||||
kernel.width, kernel.height, pad.width, pad.height,
|
kernel.width, kernel.height, pad.width, pad.height,
|
||||||
stride.width, stride.height, dilation.width, dilation.height);*/
|
stride.width, stride.height, dilation.width, dilation.height);*/
|
||||||
CV_Assert(inputs.size() == (size_t)1, inputs[0]->size[1] % blobs[0].size[1] == 0,
|
CV_Assert_N(inputs.size() == (size_t)1, inputs[0]->size[1] % blobs[0].size[1] == 0,
|
||||||
outputs.size() == 1, inputs[0]->data != outputs[0].data);
|
outputs.size() == 1, inputs[0]->data != outputs[0].data);
|
||||||
|
|
||||||
int ngroups = inputs[0]->size[1]/blobs[0].size[1];
|
int ngroups = inputs[0]->size[1]/blobs[0].size[1];
|
||||||
CV_Assert(outputs[0].size[1] % ngroups == 0);
|
CV_Assert(outputs[0].size[1] % ngroups == 0);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CropAndResizeLayerImpl CV_FINAL : public CropAndResizeLayer
|
|||||||
public:
|
public:
|
||||||
CropAndResizeLayerImpl(const LayerParams& params)
|
CropAndResizeLayerImpl(const LayerParams& params)
|
||||||
{
|
{
|
||||||
CV_Assert(params.has("width"), params.has("height"));
|
CV_Assert_N(params.has("width"), params.has("height"));
|
||||||
outWidth = params.get<float>("width");
|
outWidth = params.get<float>("width");
|
||||||
outHeight = params.get<float>("height");
|
outHeight = params.get<float>("height");
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
std::vector<MatShape> &outputs,
|
std::vector<MatShape> &outputs,
|
||||||
std::vector<MatShape> &internals) const CV_OVERRIDE
|
std::vector<MatShape> &internals) const CV_OVERRIDE
|
||||||
{
|
{
|
||||||
CV_Assert(inputs.size() == 2, inputs[0].size() == 4);
|
CV_Assert_N(inputs.size() == 2, inputs[0].size() == 4);
|
||||||
if (inputs[0][0] != 1)
|
if (inputs[0][0] != 1)
|
||||||
CV_Error(Error::StsNotImplemented, "");
|
CV_Error(Error::StsNotImplemented, "");
|
||||||
outputs.resize(1, MatShape(4));
|
outputs.resize(1, MatShape(4));
|
||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
const int inpWidth = inp.size[3];
|
const int inpWidth = inp.size[3];
|
||||||
const int inpSpatialSize = inpHeight * inpWidth;
|
const int inpSpatialSize = inpHeight * inpWidth;
|
||||||
const int outSpatialSize = outHeight * outWidth;
|
const int outSpatialSize = outHeight * outWidth;
|
||||||
CV_Assert(inp.isContinuous(), out.isContinuous());
|
CV_Assert_N(inp.isContinuous(), out.isContinuous());
|
||||||
|
|
||||||
for (int b = 0; b < boxes.rows; ++b)
|
for (int b = 0; b < boxes.rows; ++b)
|
||||||
{
|
{
|
||||||
@@ -99,6 +99,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (boxes.rows < out.size[0])
|
||||||
|
{
|
||||||
|
// left = top = right = bottom = 0
|
||||||
|
std::vector<cv::Range> dstRanges(4, Range::all());
|
||||||
|
dstRanges[0] = Range(boxes.rows, out.size[0]);
|
||||||
|
out(dstRanges).setTo(inp.ptr<float>(0, 0, 0)[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ public:
|
|||||||
// It's true whenever predicted bounding boxes and proposals are normalized to [0, 1].
|
// It's true whenever predicted bounding boxes and proposals are normalized to [0, 1].
|
||||||
bool _bboxesNormalized;
|
bool _bboxesNormalized;
|
||||||
bool _clip;
|
bool _clip;
|
||||||
|
bool _groupByClasses;
|
||||||
|
|
||||||
enum { _numAxes = 4 };
|
enum { _numAxes = 4 };
|
||||||
static const std::string _layerName;
|
static const std::string _layerName;
|
||||||
@@ -183,6 +184,7 @@ public:
|
|||||||
_locPredTransposed = getParameter<bool>(params, "loc_pred_transposed", 0, false, false);
|
_locPredTransposed = getParameter<bool>(params, "loc_pred_transposed", 0, false, false);
|
||||||
_bboxesNormalized = getParameter<bool>(params, "normalized_bbox", 0, false, true);
|
_bboxesNormalized = getParameter<bool>(params, "normalized_bbox", 0, false, true);
|
||||||
_clip = getParameter<bool>(params, "clip", 0, false, false);
|
_clip = getParameter<bool>(params, "clip", 0, false, false);
|
||||||
|
_groupByClasses = getParameter<bool>(params, "group_by_classes", 0, false, true);
|
||||||
|
|
||||||
getCodeType(params);
|
getCodeType(params);
|
||||||
|
|
||||||
@@ -381,7 +383,7 @@ public:
|
|||||||
{
|
{
|
||||||
count += outputDetections_(i, &outputsData[count * 7],
|
count += outputDetections_(i, &outputsData[count * 7],
|
||||||
allDecodedBBoxes[i], allConfidenceScores[i],
|
allDecodedBBoxes[i], allConfidenceScores[i],
|
||||||
allIndices[i]);
|
allIndices[i], _groupByClasses);
|
||||||
}
|
}
|
||||||
CV_Assert(count == numKept);
|
CV_Assert(count == numKept);
|
||||||
}
|
}
|
||||||
@@ -497,7 +499,7 @@ public:
|
|||||||
{
|
{
|
||||||
count += outputDetections_(i, &outputsData[count * 7],
|
count += outputDetections_(i, &outputsData[count * 7],
|
||||||
allDecodedBBoxes[i], allConfidenceScores[i],
|
allDecodedBBoxes[i], allConfidenceScores[i],
|
||||||
allIndices[i]);
|
allIndices[i], _groupByClasses);
|
||||||
}
|
}
|
||||||
CV_Assert(count == numKept);
|
CV_Assert(count == numKept);
|
||||||
}
|
}
|
||||||
@@ -505,9 +507,36 @@ public:
|
|||||||
size_t outputDetections_(
|
size_t outputDetections_(
|
||||||
const int i, float* outputsData,
|
const int i, float* outputsData,
|
||||||
const LabelBBox& decodeBBoxes, Mat& confidenceScores,
|
const LabelBBox& decodeBBoxes, Mat& confidenceScores,
|
||||||
const std::map<int, std::vector<int> >& indicesMap
|
const std::map<int, std::vector<int> >& indicesMap,
|
||||||
|
bool groupByClasses
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
std::vector<int> dstIndices;
|
||||||
|
std::vector<std::pair<float, int> > allScores;
|
||||||
|
for (std::map<int, std::vector<int> >::const_iterator it = indicesMap.begin(); it != indicesMap.end(); ++it)
|
||||||
|
{
|
||||||
|
int label = it->first;
|
||||||
|
if (confidenceScores.rows <= label)
|
||||||
|
CV_Error_(cv::Error::StsError, ("Could not find confidence predictions for label %d", label));
|
||||||
|
const std::vector<float>& scores = confidenceScores.row(label);
|
||||||
|
const std::vector<int>& indices = it->second;
|
||||||
|
|
||||||
|
const int numAllScores = allScores.size();
|
||||||
|
allScores.reserve(numAllScores + indices.size());
|
||||||
|
for (size_t j = 0; j < indices.size(); ++j)
|
||||||
|
{
|
||||||
|
allScores.push_back(std::make_pair(scores[indices[j]], numAllScores + j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!groupByClasses)
|
||||||
|
std::sort(allScores.begin(), allScores.end(), util::SortScorePairDescend<int>);
|
||||||
|
|
||||||
|
dstIndices.resize(allScores.size());
|
||||||
|
for (size_t j = 0; j < dstIndices.size(); ++j)
|
||||||
|
{
|
||||||
|
dstIndices[allScores[j].second] = j;
|
||||||
|
}
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (std::map<int, std::vector<int> >::const_iterator it = indicesMap.begin(); it != indicesMap.end(); ++it)
|
for (std::map<int, std::vector<int> >::const_iterator it = indicesMap.begin(); it != indicesMap.end(); ++it)
|
||||||
{
|
{
|
||||||
@@ -524,14 +553,15 @@ public:
|
|||||||
for (size_t j = 0; j < indices.size(); ++j, ++count)
|
for (size_t j = 0; j < indices.size(); ++j, ++count)
|
||||||
{
|
{
|
||||||
int idx = indices[j];
|
int idx = indices[j];
|
||||||
|
int dstIdx = dstIndices[count];
|
||||||
const util::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
|
const util::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
|
||||||
outputsData[count * 7] = i;
|
outputsData[dstIdx * 7] = i;
|
||||||
outputsData[count * 7 + 1] = label;
|
outputsData[dstIdx * 7 + 1] = label;
|
||||||
outputsData[count * 7 + 2] = scores[idx];
|
outputsData[dstIdx * 7 + 2] = scores[idx];
|
||||||
outputsData[count * 7 + 3] = decode_bbox.xmin;
|
outputsData[dstIdx * 7 + 3] = decode_bbox.xmin;
|
||||||
outputsData[count * 7 + 4] = decode_bbox.ymin;
|
outputsData[dstIdx * 7 + 4] = decode_bbox.ymin;
|
||||||
outputsData[count * 7 + 5] = decode_bbox.xmax;
|
outputsData[dstIdx * 7 + 5] = decode_bbox.xmax;
|
||||||
outputsData[count * 7 + 6] = decode_bbox.ymax;
|
outputsData[dstIdx * 7 + 6] = decode_bbox.ymax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@@ -599,7 +599,8 @@ struct ELUFunctor
|
|||||||
|
|
||||||
bool supportBackend(int backendId, int)
|
bool supportBackend(int backendId, int)
|
||||||
{
|
{
|
||||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
|
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
|
||||||
|
backendId == DNN_BACKEND_INFERENCE_ENGINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||||
@@ -653,8 +654,8 @@ struct ELUFunctor
|
|||||||
#ifdef HAVE_INF_ENGINE
|
#ifdef HAVE_INF_ENGINE
|
||||||
InferenceEngine::CNNLayerPtr initInfEngine(InferenceEngine::LayerParams& lp)
|
InferenceEngine::CNNLayerPtr initInfEngine(InferenceEngine::LayerParams& lp)
|
||||||
{
|
{
|
||||||
CV_Error(Error::StsNotImplemented, "ELU");
|
lp.type = "ELU";
|
||||||
return InferenceEngine::CNNLayerPtr();
|
return InferenceEngine::CNNLayerPtr(new InferenceEngine::CNNLayer(lp));
|
||||||
}
|
}
|
||||||
#endif // HAVE_INF_ENGINE
|
#endif // HAVE_INF_ENGINE
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
const std::vector<float>& coeffs, EltwiseOp op,
|
const std::vector<float>& coeffs, EltwiseOp op,
|
||||||
const ActivationLayer* activ, int nstripes)
|
const ActivationLayer* activ, int nstripes)
|
||||||
{
|
{
|
||||||
CV_Assert(1 < dst.dims && dst.dims <= 4, dst.type() == CV_32F, dst.isContinuous());
|
CV_Check(dst.dims, 1 < dst.dims && dst.dims <= 4, ""); CV_CheckTypeEQ(dst.type(), CV_32FC1, ""); CV_Assert(dst.isContinuous());
|
||||||
CV_Assert(coeffs.empty() || coeffs.size() == (size_t)nsrcs);
|
CV_Assert(coeffs.empty() || coeffs.size() == (size_t)nsrcs);
|
||||||
|
|
||||||
for( int i = 0; i > nsrcs; i++ )
|
for( int i = 0; i > nsrcs; i++ )
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ public:
|
|||||||
virtual bool supportBackend(int backendId) CV_OVERRIDE
|
virtual bool supportBackend(int backendId) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
return backendId == DNN_BACKEND_OPENCV ||
|
return backendId == DNN_BACKEND_OPENCV ||
|
||||||
backendId == DNN_BACKEND_HALIDE && haveHalide() ||
|
backendId == DNN_BACKEND_HALIDE ||
|
||||||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine();
|
backendId == DNN_BACKEND_INFERENCE_ENGINE && (preferableTarget != DNN_TARGET_MYRIAD || type == CHANNEL_NRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
{
|
{
|
||||||
paddings[i].first = paddingsParam.get<int>(i * 2); // Pad before.
|
paddings[i].first = paddingsParam.get<int>(i * 2); // Pad before.
|
||||||
paddings[i].second = paddingsParam.get<int>(i * 2 + 1); // Pad after.
|
paddings[i].second = paddingsParam.get<int>(i * 2 + 1); // Pad after.
|
||||||
CV_Assert(paddings[i].first >= 0, paddings[i].second >= 0);
|
CV_Assert_N(paddings[i].first >= 0, paddings[i].second >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +127,8 @@ public:
|
|||||||
const int padBottom = outHeight - dstRanges[2].end;
|
const int padBottom = outHeight - dstRanges[2].end;
|
||||||
const int padLeft = dstRanges[3].start;
|
const int padLeft = dstRanges[3].start;
|
||||||
const int padRight = outWidth - dstRanges[3].end;
|
const int padRight = outWidth - dstRanges[3].end;
|
||||||
CV_Assert(padTop < inpHeight, padBottom < inpHeight,
|
CV_CheckLT(padTop, inpHeight, ""); CV_CheckLT(padBottom, inpHeight, "");
|
||||||
padLeft < inpWidth, padRight < inpWidth);
|
CV_CheckLT(padLeft, inpWidth, ""); CV_CheckLT(padRight, inpWidth, "");
|
||||||
|
|
||||||
for (size_t n = 0; n < inputs[0]->size[0]; ++n)
|
for (size_t n = 0; n < inputs[0]->size[0]; ++n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -216,15 +216,15 @@ public:
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case MAX:
|
case MAX:
|
||||||
CV_Assert(inputs.size() == 1, outputs.size() == 2);
|
CV_Assert_N(inputs.size() == 1, outputs.size() == 2);
|
||||||
maxPooling(*inputs[0], outputs[0], outputs[1]);
|
maxPooling(*inputs[0], outputs[0], outputs[1]);
|
||||||
break;
|
break;
|
||||||
case AVE:
|
case AVE:
|
||||||
CV_Assert(inputs.size() == 1, outputs.size() == 1);
|
CV_Assert_N(inputs.size() == 1, outputs.size() == 1);
|
||||||
avePooling(*inputs[0], outputs[0]);
|
avePooling(*inputs[0], outputs[0]);
|
||||||
break;
|
break;
|
||||||
case ROI: case PSROI:
|
case ROI: case PSROI:
|
||||||
CV_Assert(inputs.size() == 2, outputs.size() == 1);
|
CV_Assert_N(inputs.size() == 2, outputs.size() == 1);
|
||||||
roiPooling(*inputs[0], *inputs[1], outputs[0]);
|
roiPooling(*inputs[0], *inputs[1], outputs[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -311,7 +311,8 @@ public:
|
|||||||
Size stride, Size pad, bool avePoolPaddedArea, int poolingType, float spatialScale,
|
Size stride, Size pad, bool avePoolPaddedArea, int poolingType, float spatialScale,
|
||||||
bool computeMaxIdx, int nstripes)
|
bool computeMaxIdx, int nstripes)
|
||||||
{
|
{
|
||||||
CV_Assert(src.isContinuous(), dst.isContinuous(),
|
CV_Assert_N(
|
||||||
|
src.isContinuous(), dst.isContinuous(),
|
||||||
src.type() == CV_32F, src.type() == dst.type(),
|
src.type() == CV_32F, src.type() == dst.type(),
|
||||||
src.dims == 4, dst.dims == 4,
|
src.dims == 4, dst.dims == 4,
|
||||||
((poolingType == ROI || poolingType == PSROI) && dst.size[0] ==rois.size[0] || src.size[0] == dst.size[0]),
|
((poolingType == ROI || poolingType == PSROI) && dst.size[0] ==rois.size[0] || src.size[0] == dst.size[0]),
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public:
|
|||||||
}
|
}
|
||||||
if (params.has("offset_h") || params.has("offset_w"))
|
if (params.has("offset_h") || params.has("offset_w"))
|
||||||
{
|
{
|
||||||
CV_Assert(!params.has("offset"), params.has("offset_h"), params.has("offset_w"));
|
CV_Assert_N(!params.has("offset"), params.has("offset_h"), params.has("offset_w"));
|
||||||
getParams("offset_h", params, &_offsetsY);
|
getParams("offset_h", params, &_offsetsY);
|
||||||
getParams("offset_w", params, &_offsetsX);
|
getParams("offset_w", params, &_offsetsX);
|
||||||
CV_Assert(_offsetsX.size() == _offsetsY.size());
|
CV_Assert(_offsetsX.size() == _offsetsY.size());
|
||||||
@@ -299,7 +299,8 @@ public:
|
|||||||
|
|
||||||
void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs) CV_OVERRIDE
|
void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
CV_Assert(inputs.size() > 1, inputs[0]->dims == 4, inputs[1]->dims == 4);
|
CV_CheckGT(inputs.size(), (size_t)1, "");
|
||||||
|
CV_CheckEQ(inputs[0]->dims, 4, ""); CV_CheckEQ(inputs[1]->dims, 4, "");
|
||||||
int layerWidth = inputs[0]->size[3];
|
int layerWidth = inputs[0]->size[3];
|
||||||
int layerHeight = inputs[0]->size[2];
|
int layerHeight = inputs[0]->size[2];
|
||||||
|
|
||||||
@@ -486,8 +487,8 @@ public:
|
|||||||
|
|
||||||
if (_explicitSizes)
|
if (_explicitSizes)
|
||||||
{
|
{
|
||||||
CV_Assert(!_boxWidths.empty(), !_boxHeights.empty(),
|
CV_Assert(!_boxWidths.empty()); CV_Assert(!_boxHeights.empty());
|
||||||
_boxWidths.size() == _boxHeights.size());
|
CV_Assert(_boxWidths.size() == _boxHeights.size());
|
||||||
ieLayer->params["width"] = format("%f", _boxWidths[0]);
|
ieLayer->params["width"] = format("%f", _boxWidths[0]);
|
||||||
ieLayer->params["height"] = format("%f", _boxHeights[0]);
|
ieLayer->params["height"] = format("%f", _boxHeights[0]);
|
||||||
for (int i = 1; i < _boxWidths.size(); ++i)
|
for (int i = 1; i < _boxWidths.size(); ++i)
|
||||||
@@ -529,7 +530,7 @@ public:
|
|||||||
ieLayer->params["step_h"] = format("%f", _stepY);
|
ieLayer->params["step_h"] = format("%f", _stepY);
|
||||||
ieLayer->params["step_w"] = format("%f", _stepX);
|
ieLayer->params["step_w"] = format("%f", _stepX);
|
||||||
}
|
}
|
||||||
CV_Assert(_offsetsX.size() == 1, _offsetsY.size() == 1, _offsetsX[0] == _offsetsY[0]);
|
CV_CheckEQ(_offsetsX.size(), (size_t)1, ""); CV_CheckEQ(_offsetsY.size(), (size_t)1, ""); CV_CheckEQ(_offsetsX[0], _offsetsY[0], "");
|
||||||
ieLayer->params["offset"] = format("%f", _offsetsX[0]);
|
ieLayer->params["offset"] = format("%f", _offsetsX[0]);
|
||||||
|
|
||||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_Assert(inputs.size() == 2, total(inputs[0]) == total(inputs[1]));
|
CV_Assert_N(inputs.size() == 2, total(inputs[0]) == total(inputs[1]));
|
||||||
outputs.assign(1, inputs[1]);
|
outputs.assign(1, inputs[1]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ public:
|
|||||||
interpolation = params.get<String>("interpolation");
|
interpolation = params.get<String>("interpolation");
|
||||||
CV_Assert(interpolation == "nearest" || interpolation == "bilinear");
|
CV_Assert(interpolation == "nearest" || interpolation == "bilinear");
|
||||||
|
|
||||||
bool alignCorners = params.get<bool>("align_corners", false);
|
alignCorners = params.get<bool>("align_corners", false);
|
||||||
if (alignCorners)
|
|
||||||
CV_Error(Error::StsNotImplemented, "Resize with align_corners=true is not implemented");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||||
@@ -43,7 +41,7 @@ public:
|
|||||||
std::vector<MatShape> &outputs,
|
std::vector<MatShape> &outputs,
|
||||||
std::vector<MatShape> &internals) const CV_OVERRIDE
|
std::vector<MatShape> &internals) const CV_OVERRIDE
|
||||||
{
|
{
|
||||||
CV_Assert(inputs.size() == 1, inputs[0].size() == 4);
|
CV_Assert_N(inputs.size() == 1, inputs[0].size() == 4);
|
||||||
outputs.resize(1, inputs[0]);
|
outputs.resize(1, inputs[0]);
|
||||||
outputs[0][2] = outHeight > 0 ? outHeight : (outputs[0][2] * zoomFactorHeight);
|
outputs[0][2] = outHeight > 0 ? outHeight : (outputs[0][2] * zoomFactorHeight);
|
||||||
outputs[0][3] = outWidth > 0 ? outWidth : (outputs[0][3] * zoomFactorWidth);
|
outputs[0][3] = outWidth > 0 ? outWidth : (outputs[0][3] * zoomFactorWidth);
|
||||||
@@ -66,8 +64,15 @@ public:
|
|||||||
outHeight = outputs[0].size[2];
|
outHeight = outputs[0].size[2];
|
||||||
outWidth = outputs[0].size[3];
|
outWidth = outputs[0].size[3];
|
||||||
}
|
}
|
||||||
scaleHeight = static_cast<float>(inputs[0]->size[2]) / outHeight;
|
if (alignCorners && outHeight > 1)
|
||||||
scaleWidth = static_cast<float>(inputs[0]->size[3]) / outWidth;
|
scaleHeight = static_cast<float>(inputs[0]->size[2] - 1) / (outHeight - 1);
|
||||||
|
else
|
||||||
|
scaleHeight = static_cast<float>(inputs[0]->size[2]) / outHeight;
|
||||||
|
|
||||||
|
if (alignCorners && outWidth > 1)
|
||||||
|
scaleWidth = static_cast<float>(inputs[0]->size[3] - 1) / (outWidth - 1);
|
||||||
|
else
|
||||||
|
scaleWidth = static_cast<float>(inputs[0]->size[3]) / outWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
|
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
|
||||||
@@ -106,7 +111,7 @@ public:
|
|||||||
const int inpSpatialSize = inpHeight * inpWidth;
|
const int inpSpatialSize = inpHeight * inpWidth;
|
||||||
const int outSpatialSize = outHeight * outWidth;
|
const int outSpatialSize = outHeight * outWidth;
|
||||||
const int numPlanes = inp.size[0] * inp.size[1];
|
const int numPlanes = inp.size[0] * inp.size[1];
|
||||||
CV_Assert(inp.isContinuous(), out.isContinuous());
|
CV_Assert_N(inp.isContinuous(), out.isContinuous());
|
||||||
|
|
||||||
Mat inpPlanes = inp.reshape(1, numPlanes * inpHeight);
|
Mat inpPlanes = inp.reshape(1, numPlanes * inpHeight);
|
||||||
Mat outPlanes = out.reshape(1, numPlanes * outHeight);
|
Mat outPlanes = out.reshape(1, numPlanes * outHeight);
|
||||||
@@ -166,6 +171,7 @@ protected:
|
|||||||
int outWidth, outHeight, zoomFactorWidth, zoomFactorHeight;
|
int outWidth, outHeight, zoomFactorWidth, zoomFactorHeight;
|
||||||
String interpolation;
|
String interpolation;
|
||||||
float scaleWidth, scaleHeight;
|
float scaleWidth, scaleHeight;
|
||||||
|
bool alignCorners;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -184,7 +190,7 @@ public:
|
|||||||
std::vector<MatShape> &outputs,
|
std::vector<MatShape> &outputs,
|
||||||
std::vector<MatShape> &internals) const CV_OVERRIDE
|
std::vector<MatShape> &internals) const CV_OVERRIDE
|
||||||
{
|
{
|
||||||
CV_Assert(inputs.size() == 1, inputs[0].size() == 4);
|
CV_Assert_N(inputs.size() == 1, inputs[0].size() == 4);
|
||||||
outputs.resize(1, inputs[0]);
|
outputs.resize(1, inputs[0]);
|
||||||
outputs[0][2] = outHeight > 0 ? outHeight : (1 + zoomFactorHeight * (outputs[0][2] - 1));
|
outputs[0][2] = outHeight > 0 ? outHeight : (1 + zoomFactorHeight * (outputs[0][2] - 1));
|
||||||
outputs[0][3] = outWidth > 0 ? outWidth : (1 + zoomFactorWidth * (outputs[0][3] - 1));
|
outputs[0][3] = outWidth > 0 ? outWidth : (1 + zoomFactorWidth * (outputs[0][3] - 1));
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||||
CV_Assert(outputs.size() == 1, !blobs.empty() || inputs.size() == 2);
|
CV_Assert_N(outputs.size() == 1, !blobs.empty() || inputs.size() == 2);
|
||||||
|
|
||||||
Mat &inpBlob = *inputs[0];
|
Mat &inpBlob = *inputs[0];
|
||||||
Mat &outBlob = outputs[0];
|
Mat &outBlob = outputs[0];
|
||||||
@@ -76,7 +76,9 @@ public:
|
|||||||
weights = weights.reshape(1, 1);
|
weights = weights.reshape(1, 1);
|
||||||
MatShape inpShape = shape(inpBlob);
|
MatShape inpShape = shape(inpBlob);
|
||||||
const int numWeights = !weights.empty() ? weights.total() : bias.total();
|
const int numWeights = !weights.empty() ? weights.total() : bias.total();
|
||||||
CV_Assert(numWeights != 0, !hasWeights || !hasBias || weights.total() == bias.total());
|
CV_Assert(numWeights != 0);
|
||||||
|
if (hasWeights && hasBias)
|
||||||
|
CV_CheckEQ(weights.total(), bias.total(), "Incompatible weights/bias blobs");
|
||||||
|
|
||||||
int endAxis;
|
int endAxis;
|
||||||
for (endAxis = axis + 1; endAxis <= inpBlob.dims; ++endAxis)
|
for (endAxis = axis + 1; endAxis <= inpBlob.dims; ++endAxis)
|
||||||
@@ -84,9 +86,9 @@ public:
|
|||||||
if (total(inpShape, axis, endAxis) == numWeights)
|
if (total(inpShape, axis, endAxis) == numWeights)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CV_Assert(total(inpShape, axis, endAxis) == numWeights,
|
CV_Assert(total(inpShape, axis, endAxis) == numWeights);
|
||||||
!hasBias || numWeights == bias.total(),
|
CV_Assert(!hasBias || numWeights == bias.total());
|
||||||
inpBlob.type() == CV_32F && outBlob.type() == CV_32F);
|
CV_CheckTypeEQ(inpBlob.type(), CV_32FC1, ""); CV_CheckTypeEQ(outBlob.type(), CV_32FC1, "");
|
||||||
|
|
||||||
int numSlices = total(inpShape, 0, axis);
|
int numSlices = total(inpShape, 0, axis);
|
||||||
float* inpData = (float*)inpBlob.data;
|
float* inpData = (float*)inpBlob.data;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
|
|||||||
const float score_threshold, const float nms_threshold,
|
const float score_threshold, const float nms_threshold,
|
||||||
std::vector<int>& indices, const float eta, const int top_k)
|
std::vector<int>& indices, const float eta, const int top_k)
|
||||||
{
|
{
|
||||||
CV_Assert(bboxes.size() == scores.size(), score_threshold >= 0,
|
CV_Assert_N(bboxes.size() == scores.size(), score_threshold >= 0,
|
||||||
nms_threshold >= 0, eta > 0);
|
nms_threshold >= 0, eta > 0);
|
||||||
NMSFast_(bboxes, scores, score_threshold, nms_threshold, eta, top_k, indices, rectOverlap);
|
NMSFast_(bboxes, scores, score_threshold, nms_threshold, eta, top_k, indices, rectOverlap);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ void NMSBoxes(const std::vector<RotatedRect>& bboxes, const std::vector<float>&
|
|||||||
const float score_threshold, const float nms_threshold,
|
const float score_threshold, const float nms_threshold,
|
||||||
std::vector<int>& indices, const float eta, const int top_k)
|
std::vector<int>& indices, const float eta, const int top_k)
|
||||||
{
|
{
|
||||||
CV_Assert(bboxes.size() == scores.size(), score_threshold >= 0,
|
CV_Assert_N(bboxes.size() == scores.size(), score_threshold >= 0,
|
||||||
nms_threshold >= 0, eta > 0);
|
nms_threshold >= 0, eta > 0);
|
||||||
NMSFast_(bboxes, scores, score_threshold, nms_threshold, eta, top_k, indices, rotatedRectIOU);
|
NMSFast_(bboxes, scores, score_threshold, nms_threshold, eta, top_k, indices, rotatedRectIOU);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))
|
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))
|
||||||
|
#define INF_ENGINE_VER_MAJOR_GE(ver) (((INF_ENGINE_RELEASE) / 10000) >= ((ver) / 10000))
|
||||||
|
|
||||||
#endif // HAVE_INF_ENGINE
|
#endif // HAVE_INF_ENGINE
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public:
|
|||||||
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
Mat epsMat = getTensorContent(inputNodes.back()->attr().at("value").tensor());
|
Mat epsMat = getTensorContent(inputNodes.back()->attr().at("value").tensor());
|
||||||
CV_Assert(epsMat.total() == 1, epsMat.type() == CV_32FC1);
|
CV_CheckEQ(epsMat.total(), (size_t)1, ""); CV_CheckTypeEQ(epsMat.type(), CV_32FC1, "");
|
||||||
|
|
||||||
fusedNode->mutable_input()->RemoveLast();
|
fusedNode->mutable_input()->RemoveLast();
|
||||||
fusedNode->clear_attr();
|
fusedNode->clear_attr();
|
||||||
@@ -256,7 +256,7 @@ public:
|
|||||||
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
Mat epsMat = getTensorContent(inputNodes.back()->attr().at("value").tensor());
|
Mat epsMat = getTensorContent(inputNodes.back()->attr().at("value").tensor());
|
||||||
CV_Assert(epsMat.total() == 1, epsMat.type() == CV_32FC1);
|
CV_CheckEQ(epsMat.total(), (size_t)1, ""); CV_CheckTypeEQ(epsMat.type(), CV_32FC1, "");
|
||||||
|
|
||||||
fusedNode->mutable_input()->RemoveLast();
|
fusedNode->mutable_input()->RemoveLast();
|
||||||
fusedNode->clear_attr();
|
fusedNode->clear_attr();
|
||||||
@@ -593,7 +593,7 @@ public:
|
|||||||
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
std::vector<tensorflow::NodeDef*>& inputNodes) CV_OVERRIDE
|
||||||
{
|
{
|
||||||
Mat factorsMat = getTensorContent(inputNodes[1]->attr().at("value").tensor());
|
Mat factorsMat = getTensorContent(inputNodes[1]->attr().at("value").tensor());
|
||||||
CV_Assert(factorsMat.total() == 2, factorsMat.type() == CV_32SC1);
|
CV_CheckEQ(factorsMat.total(), (size_t)2, ""); CV_CheckTypeEQ(factorsMat.type(), CV_32SC1, "");
|
||||||
|
|
||||||
// Height scale factor
|
// Height scale factor
|
||||||
tensorflow::TensorProto* factorY = inputNodes[1]->mutable_attr()->at("value").mutable_tensor();
|
tensorflow::TensorProto* factorY = inputNodes[1]->mutable_attr()->at("value").mutable_tensor();
|
||||||
|
|||||||
@@ -545,8 +545,8 @@ const tensorflow::TensorProto& TFImporter::getConstBlob(const tensorflow::NodeDe
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_Assert(nodeIdx < netTxt.node_size(),
|
CV_Assert_N(nodeIdx < netTxt.node_size(),
|
||||||
netTxt.node(nodeIdx).name() == kernel_inp.name);
|
netTxt.node(nodeIdx).name() == kernel_inp.name);
|
||||||
return netTxt.node(nodeIdx).attr().at("value").tensor();
|
return netTxt.node(nodeIdx).attr().at("value").tensor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,8 +587,8 @@ static void addConstNodes(tensorflow::GraphDef& net, std::map<String, int>& cons
|
|||||||
|
|
||||||
Mat qMin = getTensorContent(net.node(minId).attr().at("value").tensor());
|
Mat qMin = getTensorContent(net.node(minId).attr().at("value").tensor());
|
||||||
Mat qMax = getTensorContent(net.node(maxId).attr().at("value").tensor());
|
Mat qMax = getTensorContent(net.node(maxId).attr().at("value").tensor());
|
||||||
CV_Assert(qMin.total() == 1, qMin.type() == CV_32FC1,
|
CV_Assert_N(qMin.total() == 1, qMin.type() == CV_32FC1,
|
||||||
qMax.total() == 1, qMax.type() == CV_32FC1);
|
qMax.total() == 1, qMax.type() == CV_32FC1);
|
||||||
|
|
||||||
Mat content = getTensorContent(*tensor);
|
Mat content = getTensorContent(*tensor);
|
||||||
|
|
||||||
@@ -737,11 +737,18 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
int predictedLayout = predictOutputDataLayout(net, layer, data_layouts);
|
int predictedLayout = predictOutputDataLayout(net, layer, data_layouts);
|
||||||
data_layouts[name] = predictedLayout;
|
data_layouts[name] = predictedLayout;
|
||||||
|
|
||||||
if (type == "Conv2D" || type == "SpaceToBatchND" || type == "DepthwiseConv2dNative")
|
if (type == "Conv2D" || type == "SpaceToBatchND" || type == "DepthwiseConv2dNative" || type == "Pad")
|
||||||
{
|
{
|
||||||
// The first node of dilated convolution subgraph.
|
// The first node of dilated convolution subgraph.
|
||||||
// Extract input node, dilation rate and paddings.
|
// Extract input node, dilation rate and paddings.
|
||||||
std::string input = layer.input(0);
|
std::string input = layer.input(0);
|
||||||
|
StrIntVector next_layers;
|
||||||
|
if (type == "SpaceToBatchND" || type == "Pad")
|
||||||
|
{
|
||||||
|
next_layers = getNextLayers(net, name, "Conv2D");
|
||||||
|
if (next_layers.empty())
|
||||||
|
next_layers = getNextLayers(net, name, "DepthwiseConv2dNative");
|
||||||
|
}
|
||||||
if (type == "SpaceToBatchND")
|
if (type == "SpaceToBatchND")
|
||||||
{
|
{
|
||||||
// op: "SpaceToBatchND"
|
// op: "SpaceToBatchND"
|
||||||
@@ -762,17 +769,57 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
layerParams.set("pad_h", paddings.at<float>(0));
|
layerParams.set("pad_h", paddings.at<float>(0));
|
||||||
layerParams.set("pad_w", paddings.at<float>(2));
|
layerParams.set("pad_w", paddings.at<float>(2));
|
||||||
|
|
||||||
StrIntVector next_layers = getNextLayers(net, name, "Conv2D");
|
|
||||||
if (next_layers.empty())
|
|
||||||
{
|
|
||||||
next_layers = getNextLayers(net, name, "DepthwiseConv2dNative");
|
|
||||||
}
|
|
||||||
CV_Assert(next_layers.size() == 1);
|
CV_Assert(next_layers.size() == 1);
|
||||||
layer = net.node(next_layers[0].second);
|
layer = net.node(next_layers[0].second);
|
||||||
layers_to_ignore.insert(next_layers[0].first);
|
layers_to_ignore.insert(next_layers[0].first);
|
||||||
name = layer.name();
|
name = layer.name();
|
||||||
type = layer.op();
|
type = layer.op();
|
||||||
}
|
}
|
||||||
|
else if (type == "Pad")
|
||||||
|
{
|
||||||
|
Mat paddings = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||||
|
CV_Assert(paddings.type() == CV_32SC1);
|
||||||
|
if (paddings.total() == 8)
|
||||||
|
{
|
||||||
|
// Perhabs, we have NHWC padding dimensions order.
|
||||||
|
// N H W C
|
||||||
|
// 0 1 2 3 4 5 6 7
|
||||||
|
std::swap(paddings.at<int32_t>(2), paddings.at<int32_t>(6));
|
||||||
|
std::swap(paddings.at<int32_t>(3), paddings.at<int32_t>(7));
|
||||||
|
// N C W H
|
||||||
|
// 0 1 2 3 4 5 6 7
|
||||||
|
std::swap(paddings.at<int32_t>(4), paddings.at<int32_t>(6));
|
||||||
|
std::swap(paddings.at<int32_t>(5), paddings.at<int32_t>(7));
|
||||||
|
// N C H W
|
||||||
|
// 0 1 2 3 4 5 6 7
|
||||||
|
}
|
||||||
|
if (next_layers.empty() || paddings.total() != 8 ||
|
||||||
|
paddings.at<int32_t>(4) != paddings.at<int32_t>(5) ||
|
||||||
|
paddings.at<int32_t>(6) != paddings.at<int32_t>(7))
|
||||||
|
{
|
||||||
|
// Just a single padding layer.
|
||||||
|
layerParams.set("paddings", DictValue::arrayInt<int*>((int*)paddings.data, paddings.total()));
|
||||||
|
|
||||||
|
int id = dstNet.addLayer(name, "Padding", layerParams);
|
||||||
|
layer_id[name] = id;
|
||||||
|
|
||||||
|
connect(layer_id, dstNet, parsePin(input), id, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Merge with subsequent convolutional layer.
|
||||||
|
CV_Assert(next_layers.size() == 1);
|
||||||
|
|
||||||
|
layerParams.set("pad_h", paddings.at<int32_t>(4));
|
||||||
|
layerParams.set("pad_w", paddings.at<int32_t>(6));
|
||||||
|
|
||||||
|
layer = net.node(next_layers[0].second);
|
||||||
|
layers_to_ignore.insert(next_layers[0].first);
|
||||||
|
name = layer.name();
|
||||||
|
type = layer.op();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For the object detection networks, TensorFlow Object Detection API
|
// For the object detection networks, TensorFlow Object Detection API
|
||||||
// predicts deltas for bounding boxes in yxYX (ymin, xmin, ymax, xmax)
|
// predicts deltas for bounding boxes in yxYX (ymin, xmin, ymax, xmax)
|
||||||
@@ -784,7 +831,7 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
layerParams.set("bias_term", false);
|
layerParams.set("bias_term", false);
|
||||||
layerParams.blobs.resize(1);
|
layerParams.blobs.resize(1);
|
||||||
|
|
||||||
StrIntVector next_layers = getNextLayers(net, name, "BiasAdd");
|
next_layers = getNextLayers(net, name, "BiasAdd");
|
||||||
if (next_layers.size() == 1) {
|
if (next_layers.size() == 1) {
|
||||||
layerParams.set("bias_term", true);
|
layerParams.set("bias_term", true);
|
||||||
layerParams.blobs.resize(2);
|
layerParams.blobs.resize(2);
|
||||||
@@ -1295,8 +1342,9 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
CV_Assert(layer.input_size() == 3);
|
CV_Assert(layer.input_size() == 3);
|
||||||
Mat begins = getTensorContent(getConstBlob(layer, value_id, 1));
|
Mat begins = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||||
Mat sizes = getTensorContent(getConstBlob(layer, value_id, 2));
|
Mat sizes = getTensorContent(getConstBlob(layer, value_id, 2));
|
||||||
CV_Assert(!begins.empty(), !sizes.empty(), begins.type() == CV_32SC1,
|
CV_Assert_N(!begins.empty(), !sizes.empty());
|
||||||
sizes.type() == CV_32SC1);
|
CV_CheckTypeEQ(begins.type(), CV_32SC1, "");
|
||||||
|
CV_CheckTypeEQ(sizes.type(), CV_32SC1, "");
|
||||||
|
|
||||||
if (begins.total() == 4 && getDataLayout(name, data_layouts) == DATA_LAYOUT_NHWC)
|
if (begins.total() == 4 && getDataLayout(name, data_layouts) == DATA_LAYOUT_NHWC)
|
||||||
{
|
{
|
||||||
@@ -1415,31 +1463,6 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == "Pad")
|
|
||||||
{
|
|
||||||
Mat paddings = getTensorContent(getConstBlob(layer, value_id, 1));
|
|
||||||
CV_Assert(paddings.type() == CV_32SC1);
|
|
||||||
if (paddings.total() == 8)
|
|
||||||
{
|
|
||||||
// Perhabs, we have NHWC padding dimensions order.
|
|
||||||
// N H W C
|
|
||||||
// 0 1 2 3 4 5 6 7
|
|
||||||
std::swap(*paddings.ptr<int32_t>(0, 2), *paddings.ptr<int32_t>(0, 6));
|
|
||||||
std::swap(*paddings.ptr<int32_t>(0, 3), *paddings.ptr<int32_t>(0, 7));
|
|
||||||
// N C W H
|
|
||||||
// 0 1 2 3 4 5 6 7
|
|
||||||
std::swap(*paddings.ptr<int32_t>(0, 4), *paddings.ptr<int32_t>(0, 6));
|
|
||||||
std::swap(*paddings.ptr<int32_t>(0, 5), *paddings.ptr<int32_t>(0, 7));
|
|
||||||
// N C H W
|
|
||||||
// 0 1 2 3 4 5 6 7
|
|
||||||
}
|
|
||||||
layerParams.set("paddings", DictValue::arrayInt<int*>((int*)paddings.data, paddings.total()));
|
|
||||||
|
|
||||||
int id = dstNet.addLayer(name, "Padding", layerParams);
|
|
||||||
layer_id[name] = id;
|
|
||||||
|
|
||||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
|
||||||
}
|
|
||||||
else if (type == "FusedBatchNorm")
|
else if (type == "FusedBatchNorm")
|
||||||
{
|
{
|
||||||
// op: "FusedBatchNorm"
|
// op: "FusedBatchNorm"
|
||||||
@@ -1665,7 +1688,7 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
if (layer.input_size() == 2)
|
if (layer.input_size() == 2)
|
||||||
{
|
{
|
||||||
Mat outSize = getTensorContent(getConstBlob(layer, value_id, 1));
|
Mat outSize = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||||
CV_Assert(outSize.type() == CV_32SC1, outSize.total() == 2);
|
CV_CheckTypeEQ(outSize.type(), CV_32SC1, ""); CV_CheckEQ(outSize.total(), (size_t)2, "");
|
||||||
layerParams.set("height", outSize.at<int>(0, 0));
|
layerParams.set("height", outSize.at<int>(0, 0));
|
||||||
layerParams.set("width", outSize.at<int>(0, 1));
|
layerParams.set("width", outSize.at<int>(0, 1));
|
||||||
}
|
}
|
||||||
@@ -1673,8 +1696,8 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
{
|
{
|
||||||
Mat factorHeight = getTensorContent(getConstBlob(layer, value_id, 1));
|
Mat factorHeight = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||||
Mat factorWidth = getTensorContent(getConstBlob(layer, value_id, 2));
|
Mat factorWidth = getTensorContent(getConstBlob(layer, value_id, 2));
|
||||||
CV_Assert(factorHeight.type() == CV_32SC1, factorHeight.total() == 1,
|
CV_CheckTypeEQ(factorHeight.type(), CV_32SC1, ""); CV_CheckEQ(factorHeight.total(), (size_t)1, "");
|
||||||
factorWidth.type() == CV_32SC1, factorWidth.total() == 1);
|
CV_CheckTypeEQ(factorWidth.type(), CV_32SC1, ""); CV_CheckEQ(factorWidth.total(), (size_t)1, "");
|
||||||
layerParams.set("zoom_factor_x", factorWidth.at<int>(0));
|
layerParams.set("zoom_factor_x", factorWidth.at<int>(0));
|
||||||
layerParams.set("zoom_factor_y", factorHeight.at<int>(0));
|
layerParams.set("zoom_factor_y", factorHeight.at<int>(0));
|
||||||
}
|
}
|
||||||
@@ -1772,7 +1795,7 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
CV_Assert(layer.input_size() == 3);
|
CV_Assert(layer.input_size() == 3);
|
||||||
|
|
||||||
Mat cropSize = getTensorContent(getConstBlob(layer, value_id, 2));
|
Mat cropSize = getTensorContent(getConstBlob(layer, value_id, 2));
|
||||||
CV_Assert(cropSize.type() == CV_32SC1, cropSize.total() == 2);
|
CV_CheckTypeEQ(cropSize.type(), CV_32SC1, ""); CV_CheckEQ(cropSize.total(), (size_t)2, "");
|
||||||
|
|
||||||
layerParams.set("height", cropSize.at<int>(0));
|
layerParams.set("height", cropSize.at<int>(0));
|
||||||
layerParams.set("width", cropSize.at<int>(1));
|
layerParams.set("width", cropSize.at<int>(1));
|
||||||
@@ -1826,8 +1849,8 @@ void TFImporter::populateNet(Net dstNet)
|
|||||||
|
|
||||||
Mat minValue = getTensorContent(getConstBlob(layer, value_id, 1));
|
Mat minValue = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||||
Mat maxValue = getTensorContent(getConstBlob(layer, value_id, 2));
|
Mat maxValue = getTensorContent(getConstBlob(layer, value_id, 2));
|
||||||
CV_Assert(minValue.total() == 1, minValue.type() == CV_32F,
|
CV_CheckEQ(minValue.total(), (size_t)1, ""); CV_CheckTypeEQ(minValue.type(), CV_32FC1, "");
|
||||||
maxValue.total() == 1, maxValue.type() == CV_32F);
|
CV_CheckEQ(maxValue.total(), (size_t)1, ""); CV_CheckTypeEQ(maxValue.type(), CV_32FC1, "");
|
||||||
|
|
||||||
layerParams.set("min_value", minValue.at<float>(0));
|
layerParams.set("min_value", minValue.at<float>(0));
|
||||||
layerParams.set("max_value", maxValue.at<float>(0));
|
layerParams.set("max_value", maxValue.at<float>(0));
|
||||||
|
|||||||
@@ -896,8 +896,8 @@ struct TorchImporter
|
|||||||
else if (nnName == "SpatialZeroPadding" || nnName == "SpatialReflectionPadding")
|
else if (nnName == "SpatialZeroPadding" || nnName == "SpatialReflectionPadding")
|
||||||
{
|
{
|
||||||
readTorchTable(scalarParams, tensorParams);
|
readTorchTable(scalarParams, tensorParams);
|
||||||
CV_Assert(scalarParams.has("pad_l"), scalarParams.has("pad_r"),
|
CV_Assert_N(scalarParams.has("pad_l"), scalarParams.has("pad_r"),
|
||||||
scalarParams.has("pad_t"), scalarParams.has("pad_b"));
|
scalarParams.has("pad_t"), scalarParams.has("pad_b"));
|
||||||
int padTop = scalarParams.get<int>("pad_t");
|
int padTop = scalarParams.get<int>("pad_t");
|
||||||
int padLeft = scalarParams.get<int>("pad_l");
|
int padLeft = scalarParams.get<int>("pad_l");
|
||||||
int padRight = scalarParams.get<int>("pad_r");
|
int padRight = scalarParams.get<int>("pad_r");
|
||||||
|
|||||||
@@ -222,9 +222,12 @@ TEST_P(DNNTestNetwork, OpenPose_pose_mpi_faster_4_stages)
|
|||||||
|
|
||||||
TEST_P(DNNTestNetwork, OpenFace)
|
TEST_P(DNNTestNetwork, OpenFace)
|
||||||
{
|
{
|
||||||
|
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_RELEASE < 2018030000
|
||||||
|
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
|
||||||
|
throw SkipTestException("Test is enabled starts from OpenVINO 2018R3");
|
||||||
|
#endif
|
||||||
if (backend == DNN_BACKEND_HALIDE ||
|
if (backend == DNN_BACKEND_HALIDE ||
|
||||||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16) ||
|
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16))
|
||||||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
|
|
||||||
throw SkipTestException("");
|
throw SkipTestException("");
|
||||||
processNet("dnn/openface_nn4.small2.v1.t7", "", Size(96, 96), "");
|
processNet("dnn/openface_nn4.small2.v1.t7", "", Size(96, 96), "");
|
||||||
}
|
}
|
||||||
@@ -253,12 +256,19 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
|
|||||||
|
|
||||||
TEST_P(DNNTestNetwork, DenseNet_121)
|
TEST_P(DNNTestNetwork, DenseNet_121)
|
||||||
{
|
{
|
||||||
if ((backend == DNN_BACKEND_HALIDE) ||
|
if (backend == DNN_BACKEND_HALIDE)
|
||||||
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ||
|
|
||||||
(backend == DNN_BACKEND_INFERENCE_ENGINE && (target == DNN_TARGET_OPENCL_FP16 ||
|
|
||||||
target == DNN_TARGET_MYRIAD)))
|
|
||||||
throw SkipTestException("");
|
throw SkipTestException("");
|
||||||
processNet("dnn/DenseNet_121.caffemodel", "dnn/DenseNet_121.prototxt", Size(224, 224), "", "caffe");
|
|
||||||
|
float l1 = 0.0, lInf = 0.0;
|
||||||
|
if (target == DNN_TARGET_OPENCL_FP16)
|
||||||
|
{
|
||||||
|
l1 = 9e-3; lInf = 5e-2;
|
||||||
|
}
|
||||||
|
else if (target == DNN_TARGET_MYRIAD)
|
||||||
|
{
|
||||||
|
l1 = 6e-2; lInf = 0.27;
|
||||||
|
}
|
||||||
|
processNet("dnn/DenseNet_121.caffemodel", "dnn/DenseNet_121.prototxt", Size(224, 224), "", "", l1, lInf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
|
TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
|
||||||
|
|||||||
@@ -374,14 +374,6 @@ TEST(Reproducibility_GoogLeNet_fp16, Accuracy)
|
|||||||
TEST_P(Test_Caffe_nets, Colorization)
|
TEST_P(Test_Caffe_nets, Colorization)
|
||||||
{
|
{
|
||||||
checkBackend();
|
checkBackend();
|
||||||
if ((backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16) ||
|
|
||||||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD) ||
|
|
||||||
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
|
|
||||||
throw SkipTestException("");
|
|
||||||
|
|
||||||
const float l1 = 4e-4;
|
|
||||||
const float lInf = 3e-3;
|
|
||||||
|
|
||||||
Mat inp = blobFromNPY(_tf("colorization_inp.npy"));
|
Mat inp = blobFromNPY(_tf("colorization_inp.npy"));
|
||||||
Mat ref = blobFromNPY(_tf("colorization_out.npy"));
|
Mat ref = blobFromNPY(_tf("colorization_out.npy"));
|
||||||
Mat kernel = blobFromNPY(_tf("colorization_pts_in_hull.npy"));
|
Mat kernel = blobFromNPY(_tf("colorization_pts_in_hull.npy"));
|
||||||
@@ -398,11 +390,15 @@ TEST_P(Test_Caffe_nets, Colorization)
|
|||||||
net.setInput(inp);
|
net.setInput(inp);
|
||||||
Mat out = net.forward();
|
Mat out = net.forward();
|
||||||
|
|
||||||
|
// Reference output values are in range [-29.1, 69.5]
|
||||||
|
const double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.21 : 4e-4;
|
||||||
|
const double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5.3 : 3e-3;
|
||||||
normAssert(out, ref, "", l1, lInf);
|
normAssert(out, ref, "", l1, lInf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Reproducibility_DenseNet_121, Accuracy)
|
TEST_P(Test_Caffe_nets, DenseNet_121)
|
||||||
{
|
{
|
||||||
|
checkBackend();
|
||||||
const string proto = findDataFile("dnn/DenseNet_121.prototxt", false);
|
const string proto = findDataFile("dnn/DenseNet_121.prototxt", false);
|
||||||
const string model = findDataFile("dnn/DenseNet_121.caffemodel", false);
|
const string model = findDataFile("dnn/DenseNet_121.caffemodel", false);
|
||||||
|
|
||||||
@@ -411,12 +407,23 @@ TEST(Reproducibility_DenseNet_121, Accuracy)
|
|||||||
Mat ref = blobFromNPY(_tf("densenet_121_output.npy"));
|
Mat ref = blobFromNPY(_tf("densenet_121_output.npy"));
|
||||||
|
|
||||||
Net net = readNetFromCaffe(proto, model);
|
Net net = readNetFromCaffe(proto, model);
|
||||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
net.setPreferableBackend(backend);
|
||||||
|
net.setPreferableTarget(target);
|
||||||
|
|
||||||
net.setInput(inp);
|
net.setInput(inp);
|
||||||
Mat out = net.forward();
|
Mat out = net.forward();
|
||||||
|
|
||||||
normAssert(out, ref);
|
// Reference is an array of 1000 values from a range [-6.16, 7.9]
|
||||||
|
float l1 = default_l1, lInf = default_lInf;
|
||||||
|
if (target == DNN_TARGET_OPENCL_FP16)
|
||||||
|
{
|
||||||
|
l1 = 0.017; lInf = 0.067;
|
||||||
|
}
|
||||||
|
else if (target == DNN_TARGET_MYRIAD)
|
||||||
|
{
|
||||||
|
l1 = 0.097; lInf = 0.52;
|
||||||
|
}
|
||||||
|
normAssert(out, ref, "", l1, lInf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Test_Caffe, multiple_inputs)
|
TEST(Test_Caffe, multiple_inputs)
|
||||||
|
|||||||
@@ -113,7 +113,11 @@ TEST_P(Convolution, Accuracy)
|
|||||||
bool skipCheck = false;
|
bool skipCheck = false;
|
||||||
if (cvtest::skipUnstableTests && backendId == DNN_BACKEND_OPENCV &&
|
if (cvtest::skipUnstableTests && backendId == DNN_BACKEND_OPENCV &&
|
||||||
(targetId == DNN_TARGET_OPENCL || targetId == DNN_TARGET_OPENCL_FP16) &&
|
(targetId == DNN_TARGET_OPENCL || targetId == DNN_TARGET_OPENCL_FP16) &&
|
||||||
kernel == Size(3, 1) && stride == Size(1, 1) && pad == Size(0, 1))
|
(
|
||||||
|
(kernel == Size(3, 1) && stride == Size(1, 1) && pad == Size(0, 1)) ||
|
||||||
|
(stride.area() > 1 && !(pad.width == 0 && pad.height == 0))
|
||||||
|
)
|
||||||
|
)
|
||||||
skipCheck = true;
|
skipCheck = true;
|
||||||
|
|
||||||
int sz[] = {outChannels, inChannels / group, kernel.height, kernel.width};
|
int sz[] = {outChannels, inChannels / group, kernel.height, kernel.width};
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ TEST_P(DNNTestOpenVINO, models)
|
|||||||
Target target = (dnn::Target)(int)get<0>(GetParam());
|
Target target = (dnn::Target)(int)get<0>(GetParam());
|
||||||
std::string modelName = get<1>(GetParam());
|
std::string modelName = get<1>(GetParam());
|
||||||
|
|
||||||
if (modelName == "semantic-segmentation-adas-0001" && target == DNN_TARGET_OPENCL_FP16)
|
if ((modelName == "semantic-segmentation-adas-0001" && target == DNN_TARGET_OPENCL_FP16) ||
|
||||||
|
(modelName == "vehicle-license-plate-detection-barrier-0106"))
|
||||||
throw SkipTestException("");
|
throw SkipTestException("");
|
||||||
|
|
||||||
std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? "FP16" : "FP32";
|
std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? "FP16" : "FP32";
|
||||||
|
|||||||
@@ -127,15 +127,9 @@ TEST_P(Test_Caffe_layers, Softmax)
|
|||||||
testLayerUsingCaffeModels("layer_softmax");
|
testLayerUsingCaffeModels("layer_softmax");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Test_Caffe_layers, LRN_spatial)
|
TEST_P(Test_Caffe_layers, LRN)
|
||||||
{
|
{
|
||||||
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
|
|
||||||
throw SkipTestException("");
|
|
||||||
testLayerUsingCaffeModels("layer_lrn_spatial");
|
testLayerUsingCaffeModels("layer_lrn_spatial");
|
||||||
}
|
|
||||||
|
|
||||||
TEST_P(Test_Caffe_layers, LRN_channels)
|
|
||||||
{
|
|
||||||
testLayerUsingCaffeModels("layer_lrn_channels");
|
testLayerUsingCaffeModels("layer_lrn_channels");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,7 +808,7 @@ TEST_P(Layer_Test_DWconv_Prelu, Accuracy)
|
|||||||
const int group = 3; //outChannels=group when group>1
|
const int group = 3; //outChannels=group when group>1
|
||||||
const int num_output = get<1>(GetParam());
|
const int num_output = get<1>(GetParam());
|
||||||
const int kernel_depth = num_input/group;
|
const int kernel_depth = num_input/group;
|
||||||
CV_Assert(num_output >= group, num_output % group == 0, num_input % group == 0);
|
CV_Assert_N(num_output >= group, num_output % group == 0, num_input % group == 0);
|
||||||
|
|
||||||
Net net;
|
Net net;
|
||||||
//layer 1: dwconv
|
//layer 1: dwconv
|
||||||
|
|||||||
@@ -399,8 +399,10 @@ TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
|
|||||||
TEST_P(Test_TensorFlow_nets, EAST_text_detection)
|
TEST_P(Test_TensorFlow_nets, EAST_text_detection)
|
||||||
{
|
{
|
||||||
checkBackend();
|
checkBackend();
|
||||||
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
|
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_RELEASE < 2018030000
|
||||||
throw SkipTestException("");
|
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
|
||||||
|
throw SkipTestException("Test is enabled starts from OpenVINO 2018R3");
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string netPath = findDataFile("dnn/frozen_east_text_detection.pb", false);
|
std::string netPath = findDataFile("dnn/frozen_east_text_detection.pb", false);
|
||||||
std::string imgPath = findDataFile("cv/ximgproc/sources/08.png", false);
|
std::string imgPath = findDataFile("cv/ximgproc/sources/08.png", false);
|
||||||
@@ -425,8 +427,25 @@ TEST_P(Test_TensorFlow_nets, EAST_text_detection)
|
|||||||
Mat scores = outs[0];
|
Mat scores = outs[0];
|
||||||
Mat geometry = outs[1];
|
Mat geometry = outs[1];
|
||||||
|
|
||||||
normAssert(scores, blobFromNPY(refScoresPath), "scores");
|
// Scores are in range [0, 1]. Geometry values are in range [-0.23, 290]
|
||||||
normAssert(geometry, blobFromNPY(refGeometryPath), "geometry", 1e-4, 3e-3);
|
double l1_scores = default_l1, lInf_scores = default_lInf;
|
||||||
|
double l1_geometry = default_l1, lInf_geometry = default_lInf;
|
||||||
|
if (target == DNN_TARGET_OPENCL_FP16)
|
||||||
|
{
|
||||||
|
lInf_scores = 0.11;
|
||||||
|
l1_geometry = 0.28; lInf_geometry = 5.94;
|
||||||
|
}
|
||||||
|
else if (target == DNN_TARGET_MYRIAD)
|
||||||
|
{
|
||||||
|
lInf_scores = 0.214;
|
||||||
|
l1_geometry = 0.47; lInf_geometry = 15.34;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l1_geometry = 1e-4, lInf_geometry = 3e-3;
|
||||||
|
}
|
||||||
|
normAssert(scores, blobFromNPY(refScoresPath), "scores", l1_scores, lInf_scores);
|
||||||
|
normAssert(geometry, blobFromNPY(refGeometryPath), "geometry", l1_geometry, lInf_geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_nets, dnnBackendsAndTargets());
|
INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_nets, dnnBackendsAndTargets());
|
||||||
@@ -537,4 +556,56 @@ TEST(Test_TensorFlow, two_inputs)
|
|||||||
normAssert(out, firstInput + secondInput);
|
normAssert(out, firstInput + secondInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Test_TensorFlow, Mask_RCNN)
|
||||||
|
{
|
||||||
|
std::string proto = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pbtxt", false);
|
||||||
|
std::string model = findDataFile("dnn/mask_rcnn_inception_v2_coco_2018_01_28.pb", false);
|
||||||
|
|
||||||
|
Net net = readNetFromTensorflow(model, proto);
|
||||||
|
Mat img = imread(findDataFile("dnn/street.png", false));
|
||||||
|
Mat refDetections = blobFromNPY(path("mask_rcnn_inception_v2_coco_2018_01_28.detection_out.npy"));
|
||||||
|
Mat refMasks = blobFromNPY(path("mask_rcnn_inception_v2_coco_2018_01_28.detection_masks.npy"));
|
||||||
|
Mat blob = blobFromImage(img, 1.0f, Size(800, 800), Scalar(), true, false);
|
||||||
|
|
||||||
|
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
||||||
|
|
||||||
|
net.setInput(blob);
|
||||||
|
|
||||||
|
// Mask-RCNN predicts bounding boxes and segmentation masks.
|
||||||
|
std::vector<String> outNames(2);
|
||||||
|
outNames[0] = "detection_out_final";
|
||||||
|
outNames[1] = "detection_masks";
|
||||||
|
|
||||||
|
std::vector<Mat> outs;
|
||||||
|
net.forward(outs, outNames);
|
||||||
|
|
||||||
|
Mat outDetections = outs[0];
|
||||||
|
Mat outMasks = outs[1];
|
||||||
|
normAssertDetections(refDetections, outDetections, "", /*threshold for zero confidence*/1e-5);
|
||||||
|
|
||||||
|
// Output size of masks is NxCxHxW where
|
||||||
|
// N - number of detected boxes
|
||||||
|
// C - number of classes (excluding background)
|
||||||
|
// HxW - segmentation shape
|
||||||
|
const int numDetections = outDetections.size[2];
|
||||||
|
|
||||||
|
int masksSize[] = {1, numDetections, outMasks.size[2], outMasks.size[3]};
|
||||||
|
Mat masks(4, &masksSize[0], CV_32F);
|
||||||
|
|
||||||
|
std::vector<cv::Range> srcRanges(4, cv::Range::all());
|
||||||
|
std::vector<cv::Range> dstRanges(4, cv::Range::all());
|
||||||
|
|
||||||
|
outDetections = outDetections.reshape(1, outDetections.total() / 7);
|
||||||
|
for (int i = 0; i < numDetections; ++i)
|
||||||
|
{
|
||||||
|
// Get a class id for this bounding box and copy mask only for that class.
|
||||||
|
int classId = static_cast<int>(outDetections.at<float>(i, 1));
|
||||||
|
srcRanges[0] = dstRanges[1] = cv::Range(i, i + 1);
|
||||||
|
srcRanges[1] = cv::Range(classId, classId + 1);
|
||||||
|
outMasks(srcRanges).copyTo(masks(dstRanges));
|
||||||
|
}
|
||||||
|
cv::Range topRefMasks[] = {Range::all(), Range(0, numDetections), Range::all(), Range::all()};
|
||||||
|
normAssert(masks, refMasks(&topRefMasks[0]));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,15 +242,23 @@ TEST_P(Test_Torch_layers, net_residual)
|
|||||||
runTorchNet("net_residual", "", false, true);
|
runTorchNet("net_residual", "", false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef testing::TestWithParam<Target> Test_Torch_nets;
|
class Test_Torch_nets : public DNNTestLayer {};
|
||||||
|
|
||||||
TEST_P(Test_Torch_nets, OpenFace_accuracy)
|
TEST_P(Test_Torch_nets, OpenFace_accuracy)
|
||||||
{
|
{
|
||||||
|
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_RELEASE < 2018030000
|
||||||
|
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
|
||||||
|
throw SkipTestException("Test is enabled starts from OpenVINO 2018R3");
|
||||||
|
#endif
|
||||||
|
checkBackend();
|
||||||
|
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL_FP16)
|
||||||
|
throw SkipTestException("");
|
||||||
|
|
||||||
const string model = findDataFile("dnn/openface_nn4.small2.v1.t7", false);
|
const string model = findDataFile("dnn/openface_nn4.small2.v1.t7", false);
|
||||||
Net net = readNetFromTorch(model);
|
Net net = readNetFromTorch(model);
|
||||||
|
|
||||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
net.setPreferableBackend(backend);
|
||||||
net.setPreferableTarget(GetParam());
|
net.setPreferableTarget(target);
|
||||||
|
|
||||||
Mat sample = imread(findDataFile("cv/shared/lena.png", false));
|
Mat sample = imread(findDataFile("cv/shared/lena.png", false));
|
||||||
Mat sampleF32(sample.size(), CV_32FC3);
|
Mat sampleF32(sample.size(), CV_32FC3);
|
||||||
@@ -264,11 +272,16 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy)
|
|||||||
Mat out = net.forward();
|
Mat out = net.forward();
|
||||||
|
|
||||||
Mat outRef = readTorchBlob(_tf("net_openface_output.dat"), true);
|
Mat outRef = readTorchBlob(_tf("net_openface_output.dat"), true);
|
||||||
normAssert(out, outRef);
|
normAssert(out, outRef, "", default_l1, default_lInf);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Test_Torch_nets, ENet_accuracy)
|
TEST_P(Test_Torch_nets, ENet_accuracy)
|
||||||
{
|
{
|
||||||
|
checkBackend();
|
||||||
|
if (backend == DNN_BACKEND_INFERENCE_ENGINE ||
|
||||||
|
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
|
||||||
|
throw SkipTestException("");
|
||||||
|
|
||||||
Net net;
|
Net net;
|
||||||
{
|
{
|
||||||
const string model = findDataFile("dnn/Enet-model-best.net", false);
|
const string model = findDataFile("dnn/Enet-model-best.net", false);
|
||||||
@@ -276,8 +289,8 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
|
|||||||
ASSERT_TRUE(!net.empty());
|
ASSERT_TRUE(!net.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
net.setPreferableBackend(backend);
|
||||||
net.setPreferableTarget(GetParam());
|
net.setPreferableTarget(target);
|
||||||
|
|
||||||
Mat sample = imread(_tf("street.png", false));
|
Mat sample = imread(_tf("street.png", false));
|
||||||
Mat inputBlob = blobFromImage(sample, 1./255);
|
Mat inputBlob = blobFromImage(sample, 1./255);
|
||||||
@@ -314,6 +327,7 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
|
|||||||
// -model models/instance_norm/feathers.t7
|
// -model models/instance_norm/feathers.t7
|
||||||
TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
|
TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
|
||||||
{
|
{
|
||||||
|
checkBackend();
|
||||||
std::string models[] = {"dnn/fast_neural_style_eccv16_starry_night.t7",
|
std::string models[] = {"dnn/fast_neural_style_eccv16_starry_night.t7",
|
||||||
"dnn/fast_neural_style_instance_norm_feathers.t7"};
|
"dnn/fast_neural_style_instance_norm_feathers.t7"};
|
||||||
std::string targets[] = {"dnn/lena_starry_night.png", "dnn/lena_feathers.png"};
|
std::string targets[] = {"dnn/lena_starry_night.png", "dnn/lena_feathers.png"};
|
||||||
@@ -323,8 +337,8 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
|
|||||||
const string model = findDataFile(models[i], false);
|
const string model = findDataFile(models[i], false);
|
||||||
Net net = readNetFromTorch(model);
|
Net net = readNetFromTorch(model);
|
||||||
|
|
||||||
net.setPreferableBackend(DNN_BACKEND_OPENCV);
|
net.setPreferableBackend(backend);
|
||||||
net.setPreferableTarget(GetParam());
|
net.setPreferableTarget(target);
|
||||||
|
|
||||||
Mat img = imread(findDataFile("dnn/googlenet_1.png", false));
|
Mat img = imread(findDataFile("dnn/googlenet_1.png", false));
|
||||||
Mat inputBlob = blobFromImage(img, 1.0, Size(), Scalar(103.939, 116.779, 123.68), false);
|
Mat inputBlob = blobFromImage(img, 1.0, Size(), Scalar(103.939, 116.779, 123.68), false);
|
||||||
@@ -341,12 +355,20 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
|
|||||||
Mat ref = imread(findDataFile(targets[i]));
|
Mat ref = imread(findDataFile(targets[i]));
|
||||||
Mat refBlob = blobFromImage(ref, 1.0, Size(), Scalar(), false);
|
Mat refBlob = blobFromImage(ref, 1.0, Size(), Scalar(), false);
|
||||||
|
|
||||||
normAssert(out, refBlob, "", 0.5, 1.1);
|
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
|
||||||
|
{
|
||||||
|
double normL1 = cvtest::norm(refBlob, out, cv::NORM_L1) / refBlob.total();
|
||||||
|
if (target == DNN_TARGET_MYRIAD)
|
||||||
|
EXPECT_LE(normL1, 4.0f);
|
||||||
|
else
|
||||||
|
EXPECT_LE(normL1, 0.6f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
normAssert(out, refBlob, "", 0.5, 1.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_nets, availableDnnTargets());
|
INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_nets, dnnBackendsAndTargets());
|
||||||
|
|
||||||
|
|
||||||
// Test a custom layer
|
// Test a custom layer
|
||||||
// https://github.com/torch/nn/blob/master/doc/convolution.md#nn.SpatialUpSamplingNearest
|
// https://github.com/torch/nn/blob/master/doc/convolution.md#nn.SpatialUpSamplingNearest
|
||||||
|
|||||||
@@ -452,12 +452,13 @@ The function getWindowImageRect returns the client screen coordinates, width and
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W Rect getWindowImageRect(const String& winname);
|
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
|
/** @brief Sets mouse handler for the specified window
|
||||||
|
|
||||||
@param winname Name of the window.
|
@param winname Name of the window.
|
||||||
@param onMouse Mouse callback. See OpenCV samples, such as
|
@param onMouse Callback function for mouse events. See OpenCV samples on how to specify and use the callback.
|
||||||
<https://github.com/opencv/opencv/tree/3.4/samples/cpp/ffilldemo.cpp>, on how to specify and
|
|
||||||
use the callback.
|
|
||||||
@param userdata The optional parameter passed to the callback.
|
@param userdata The optional parameter passed to the callback.
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
|
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
|
||||||
|
|||||||
@@ -1500,7 +1500,7 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||||||
rgn = CreateRectRgn(0, 0, wrc.right, wrc.bottom);
|
rgn = CreateRectRgn(0, 0, wrc.right, wrc.bottom);
|
||||||
rgn1 = CreateRectRgn(cr.left, cr.top, cr.right, cr.bottom);
|
rgn1 = CreateRectRgn(cr.left, cr.top, cr.right, cr.bottom);
|
||||||
rgn2 = CreateRectRgn(tr.left, tr.top, tr.right, tr.bottom);
|
rgn2 = CreateRectRgn(tr.left, tr.top, tr.right, tr.bottom);
|
||||||
CV_Assert(rgn != 0, rgn1 != 0, rgn2 != 0);
|
CV_Assert_N(rgn != 0, rgn1 != 0, rgn2 != 0);
|
||||||
|
|
||||||
ret = CombineRgn(rgn, rgn, rgn1, RGN_DIFF);
|
ret = CombineRgn(rgn, rgn, rgn1, RGN_DIFF);
|
||||||
ret = CombineRgn(rgn, rgn, rgn2, RGN_DIFF);
|
ret = CombineRgn(rgn, rgn, rgn2, RGN_DIFF);
|
||||||
|
|||||||
@@ -50,8 +50,8 @@
|
|||||||
//! @addtogroup imgcodecs_ios
|
//! @addtogroup imgcodecs_ios
|
||||||
//! @{
|
//! @{
|
||||||
|
|
||||||
UIImage* MatToUIImage(const cv::Mat& image);
|
CV_EXPORTS UIImage* MatToUIImage(const cv::Mat& image);
|
||||||
void UIImageToMat(const UIImage* image,
|
CV_EXPORTS void UIImageToMat(const UIImage* image,
|
||||||
cv::Mat& m, bool alphaExist = false);
|
cv::Mat& m, bool alphaExist = false);
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||