Merge remote-tracking branch 'origin/2.4'

Conflicts:
	3rdparty/ffmpeg/ffmpeg_version.cmake
	cmake/OpenCVFindLibsGrfmt.cmake
	cmake/templates/cvconfig.h.cmake
	modules/bioinspired/doc/retina/index.rst
	modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
	modules/calib3d/src/precomp.hpp
	modules/contrib/src/inputoutput.cpp
	modules/contrib/src/precomp.hpp
	modules/core/include/opencv2/core/internal.hpp
	modules/core/include/opencv2/core/types_c.h
	modules/core/src/drawing.cpp
	modules/core/src/precomp.hpp
	modules/core/src/system.cpp
	modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst
	modules/features2d/doc/common_interfaces_of_feature_detectors.rst
	modules/features2d/include/opencv2/features2d/features2d.hpp
	modules/features2d/src/precomp.hpp
	modules/flann/src/precomp.hpp
	modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst
	modules/gpu/doc/image_filtering.rst
	modules/gpu/doc/image_processing.rst
	modules/gpu/doc/video.rst
	modules/gpu/perf/perf_imgproc.cpp
	modules/gpu/perf4au/main.cpp
	modules/gpu/src/imgproc.cpp
	modules/gpu/src/precomp.hpp
	modules/gpu/test/test_imgproc.cpp
	modules/highgui/CMakeLists.txt
	modules/highgui/test/test_precomp.hpp
	modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst
	modules/imgproc/src/precomp.hpp
	modules/java/generator/src/cpp/Mat.cpp
	modules/legacy/src/precomp.hpp
	modules/ml/doc/k_nearest_neighbors.rst
	modules/ml/src/precomp.hpp
	modules/nonfree/doc/feature_detection.rst
	modules/nonfree/src/precomp.hpp
	modules/objdetect/include/opencv2/objdetect/objdetect.hpp
	modules/objdetect/src/cascadedetect.cpp
	modules/objdetect/src/hog.cpp
	modules/objdetect/src/precomp.hpp
	modules/objdetect/test/test_latentsvmdetector.cpp
	modules/ocl/src/hog.cpp
	modules/ocl/src/opencl/objdetect_hog.cl
	modules/ocl/src/precomp.hpp
	modules/photo/src/precomp.hpp
	modules/stitching/src/precomp.hpp
	modules/superres/perf/perf_precomp.hpp
	modules/superres/src/optical_flow.cpp
	modules/superres/src/precomp.hpp
	modules/superres/test/test_precomp.hpp
	modules/ts/include/opencv2/ts.hpp
	modules/video/src/precomp.hpp
	modules/videostab/src/precomp.hpp
	modules/world/src/precomp.hpp
This commit is contained in:
Roman Donchenko
2013-08-06 13:56:49 +04:00
119 changed files with 3713 additions and 2281 deletions

View File

@@ -2,6 +2,10 @@ set(the_description "The Core Functionality")
ocv_add_module(core ${ZLIB_LIBRARIES})
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
if (HAVE_WINRT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
endif()
if(HAVE_CUDA)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
endif()

View File

@@ -884,6 +884,9 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including ``std::sort()`` .
.. Sample code::
* : An example demonstrating the serial out capabilities of cv::Mat can be found at opencv_source_code/samples/cpp/cout_mat.cpp
.. _MatrixExpressions:

View File

@@ -64,6 +64,12 @@ Basically, you can use only the core of the function, set the number of
attempts to 1, initialize labels each time using a custom algorithm, pass them with the
( ``flags`` = ``KMEANS_USE_INITIAL_LABELS`` ) flag, and then choose the best (most-compact) clustering.
.. Sample code::
* : An example on K-means clustering can be found at opencv_source_code/samples/cpp/kmeans.cpp
* : PYTHON : An example on K-means clustering can be found at opencv_source_code/samples/python2/kmeans.py
partition
-------------
Splits an element set into equivalency classes.

View File

@@ -15,4 +15,5 @@ core. The Core Functionality
old_xml_yaml_persistence
clustering
utility_and_system_functions_and_macros
opengl_interop

View File

@@ -26,6 +26,10 @@ If a drawn figure is partially or completely outside the image, the drawing func
.. note:: The functions do not support alpha-transparency when the target image is 4-channel. In this case, the ``color[3]`` is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.
.. Sample code::
* : An example on using variate drawing functions like line, rectangle, ... can be found at opencv_source_code/samples/cpp/drawing.cpp
circle
----------
Draws a circle.
@@ -555,6 +559,12 @@ The function draws contour outlines in the image if
waitKey(0);
}
.. Sample code::
* : An example using the drawContour functionality can be found at opencv_source_code/samples/cpp/contours2.cpp
* : An example using drawContours to clean up a background segmentation result at opencv_source_code/samples/cpp/segment_objects.cpp
* : PYTHON : An example using the drawContour functionality can be found at opencv_source/samples/python2/contours.py
putText
@@ -592,4 +602,3 @@ The function ``putText`` renders the specified text string in the image.
Symbols that cannot be rendered using the specified font are
replaced by question marks. See
:ocv:func:`getTextSize` for a text rendering code example.

View File

@@ -0,0 +1,543 @@
OpenGL interoperability
=======================
.. highlight:: cpp
General Information
-------------------
This section describes OpenGL interoperability.
To enable OpenGL support, configure OpenCV using ``CMake`` with ``WITH_OPENGL=ON`` .
Currently OpenGL is supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not supported).
For GTK backend ``gtkglext-1.0`` library is required.
To use OpenGL functionality you should first create OpenGL context (window or frame buffer).
You can do this with :ocv:func:`namedWindow` function or with other OpenGL toolkit (GLUT, for example).
ogl::Buffer
-----------
Smart pointer for OpenGL buffer object with reference counting.
.. ocv:class:: ogl::Buffer
Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL context.
These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things.
``ogl::Buffer`` has interface similar with :ocv:class:`Mat` interface and represents 2D array memory.
``ogl::Buffer`` supports memory transfers between host and device and also can be mapped to CUDA memory.
ogl::Buffer::Target
-------------------
The target defines how you intend to use the buffer object.
.. ocv:enum:: ogl::Buffer::Target
.. ocv:emember:: ARRAY_BUFFER
The buffer will be used as a source for vertex data.
.. ocv:emember:: ELEMENT_ARRAY_BUFFER
The buffer will be used for indices (in ``glDrawElements`` or :ocv:func:`ogl::render`, for example).
.. ocv:emember:: PIXEL_PACK_BUFFER
The buffer will be used for reading from OpenGL textures.
.. ocv:emember:: PIXEL_UNPACK_BUFFER
The buffer will be used for writing to OpenGL textures.
ogl::Buffer::Buffer
-------------------
The constructors.
.. ocv:function:: ogl::Buffer::Buffer()
.. ocv:function:: ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false)
.. ocv:function:: ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false)
.. ocv:function:: ogl::Buffer::Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false)
.. ocv:function:: ogl::Buffer::Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false)
.. ocv:function:: ogl::Buffer::Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false)
:param arows: Number of rows in a 2D array.
:param acols: Number of columns in a 2D array.
:param asize: 2D array size.
:param atype: Array type ( ``CV_8UC1, ..., CV_64FC4`` ). See :ocv:class:`Mat` for details.
:param abufId: Buffer object name.
:param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or ``std::vector`` ).
:param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` .
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
Creates empty ``ogl::Buffer`` object, creates ``ogl::Buffer`` object from existed buffer ( ``abufId`` parameter),
allocates memory for ``ogl::Buffer`` object or copies from host/device memory.
ogl::Buffer::create
-------------------
Allocates memory for ``ogl::Buffer`` object.
.. ocv:function:: void ogl::Buffer::create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false)
.. ocv:function:: void ogl::Buffer::create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false)
:param arows: Number of rows in a 2D array.
:param acols: Number of columns in a 2D array.
:param asize: 2D array size.
:param atype: Array type ( ``CV_8UC1, ..., CV_64FC4`` ). See :ocv:class:`Mat` for details.
:param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` .
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
ogl::Buffer::release
--------------------
Decrements the reference counter and destroys the buffer object if needed.
.. ocv:function:: void ogl::Buffer::release()
ogl::Buffer::setAutoRelease
---------------------------
Sets auto release mode.
.. ocv:function:: void ogl::Buffer::setAutoRelease(bool flag)
:param flag: Auto release mode (if true, release will be called in object's destructor).
The lifetime of the OpenGL object is tied to the lifetime of the context.
If OpenGL context was bound to a window it could be released at any time (user can close a window).
If object's destructor is called after destruction of the context it will cause an error.
Thus ``ogl::Buffer`` doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context).
This function can force ``ogl::Buffer`` destructor to destroy OpenGL object.
ogl::Buffer::copyFrom
---------------------
Copies from host/device memory to OpenGL buffer.
.. ocv:function:: void ogl::Buffer::copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false)
:param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or ``std::vector`` ).
:param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` .
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
ogl::Buffer::copyTo
-------------------
Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.
.. ocv:function:: void ogl::Buffer::copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const
:param arr: Destination array (host or device memory, can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` , ``std::vector`` or ``ogl::Buffer`` ).
:param target: Buffer usage for destination buffer (if ``arr`` is OpenGL buffer).
:param autoRelease: Auto release mode for destination buffer (if ``arr`` is OpenGL buffer).
ogl::Buffer::clone
------------------
Creates a full copy of the buffer object and the underlying data.
.. ocv:function:: Buffer ogl::Buffer::clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const
:param target: Buffer usage for destination buffer.
:param autoRelease: Auto release mode for destination buffer.
ogl::Buffer::bind
-----------------
Binds OpenGL buffer to the specified buffer binding point.
.. ocv:function:: void ogl::Buffer::bind(Target target) const
:param target: Binding point. See :ocv:enum:`ogl::Buffer::Target` .
ogl::Buffer::unbind
-------------------
Unbind any buffers from the specified binding point.
.. ocv:function:: static void ogl::Buffer::unbind(Target target)
:param target: Binding point. See :ocv:enum:`ogl::Buffer::Target` .
ogl::Buffer::mapHost
--------------------
Maps OpenGL buffer to host memory.
.. ocv:function:: Mat ogl::Buffer::mapHost(Access access)
:param access: Access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. The symbolic constant must be ``ogl::Buffer::READ_ONLY`` , ``ogl::Buffer::WRITE_ONLY`` or ``ogl::Buffer::READ_WRITE`` .
``mapHost`` maps to the client's address space the entire data store of the buffer object.
The data can then be directly read and/or written relative to the returned pointer, depending on the specified ``access`` policy.
A mapped data store must be unmapped with :ocv:func:`ogl::Buffer::unmapHost` before its buffer object is used.
This operation can lead to memory transfers between host and device.
Only one buffer object can be mapped at a time.
ogl::Buffer::unmapHost
----------------------
Unmaps OpenGL buffer.
.. ocv:function:: void ogl::Buffer::unmapHost()
ogl::Buffer::mapDevice
----------------------
Maps OpenGL buffer to CUDA device memory.
.. ocv:function:: gpu::GpuMat ogl::Buffer::mapDevice()
This operatation doesn't copy data.
Several buffer objects can be mapped to CUDA memory at a time.
A mapped data store must be unmapped with :ocv:func:`ogl::Buffer::unmapDevice` before its buffer object is used.
ogl::Buffer::unmapDevice
------------------------
Unmaps OpenGL buffer.
.. ocv:function:: void ogl::Buffer::unmapDevice()
ogl::Texture2D
--------------
Smart pointer for OpenGL 2D texture memory with reference counting.
.. ocv:class:: ogl::Texture2D
ogl::Texture2D::Format
----------------------
An Image Format describes the way that the images in Textures store their data.
.. ocv:enum:: ogl::Texture2D::Format
.. ocv:emember:: NONE
.. ocv:emember:: DEPTH_COMPONENT
.. ocv:emember:: RGB
.. ocv:emember:: RGBA
ogl::Texture2D::Texture2D
-------------------------
The constructors.
.. ocv:function:: ogl::Texture2D::Texture2D()
.. ocv:function:: ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false)
.. ocv:function:: ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false)
.. ocv:function:: ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease = false)
.. ocv:function:: ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease = false)
.. ocv:function:: ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease = false)
:param arows: Number of rows.
:param acols: Number of columns.
:param asize: 2D array size.
:param aformat: Image format. See :ocv:enum:`ogl::Texture2D::Format` .
:param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or :ocv:class:`ogl::Buffer` ).
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
Creates empty ``ogl::Texture2D`` object, allocates memory for ``ogl::Texture2D`` object or copies from host/device memory.
ogl::Texture2D::create
----------------------
Allocates memory for ``ogl::Texture2D`` object.
.. ocv:function:: void ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoRelease = false)
.. ocv:function:: void ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease = false)
:param arows: Number of rows.
:param acols: Number of columns.
:param asize: 2D array size.
:param aformat: Image format. See :ocv:enum:`ogl::Texture2D::Format` .
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
ogl::Texture2D::release
-----------------------
Decrements the reference counter and destroys the texture object if needed.
.. ocv:function:: void ogl::Texture2D::release()
ogl::Texture2D::setAutoRelease
------------------------------
Sets auto release mode.
.. ocv:function:: void ogl::Texture2D::setAutoRelease(bool flag)
:param flag: Auto release mode (if true, release will be called in object's destructor).
The lifetime of the OpenGL object is tied to the lifetime of the context.
If OpenGL context was bound to a window it could be released at any time (user can close a window).
If object's destructor is called after destruction of the context it will cause an error.
Thus ``ogl::Texture2D`` doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context).
This function can force ``ogl::Texture2D`` destructor to destroy OpenGL object.
ogl::Texture2D::copyFrom
------------------------
Copies from host/device memory to OpenGL texture.
.. ocv:function:: void ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease = false)
:param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or :ocv:class:`ogl::Buffer` ).
:param autoRelease: Auto release mode (if true, release will be called in object's destructor).
ogl::Texture2D::copyTo
----------------------
Copies from OpenGL texture to host/device memory or another OpenGL texture object.
.. ocv:function:: void ogl::Texture2D::copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const
:param arr: Destination array (host or device memory, can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` , :ocv:class:`ogl::Buffer` or ``ogl::Texture2D`` ).
:param ddepth: Destination depth.
:param autoRelease: Auto release mode for destination buffer (if ``arr`` is OpenGL buffer or texture).
ogl::Texture2D::bind
--------------------
Binds texture to current active texture unit for ``GL_TEXTURE_2D`` target.
.. ocv:function:: void ogl::Texture2D::bind() const
ogl::Arrays
-----------
Wrapper for OpenGL Client-Side Vertex arrays.
.. ocv:class:: ogl::Arrays
``ogl::Arrays`` stores vertex data in :ocv:class:`ogl::Buffer` objects.
ogl::Arrays::setVertexArray
---------------------------
Sets an array of vertex coordinates.
.. ocv:function:: void ogl::Arrays::setVertexArray(InputArray vertex)
:param vertex: array with vertex coordinates, can be both host and device memory.
ogl::Arrays::resetVertexArray
-----------------------------
Resets vertex coordinates.
.. ocv:function:: void ogl::Arrays::resetVertexArray()
ogl::Arrays::setColorArray
--------------------------
Sets an array of vertex colors.
.. ocv:function:: void ogl::Arrays::setColorArray(InputArray color)
:param color: array with vertex colors, can be both host and device memory.
ogl::Arrays::resetColorArray
----------------------------
Resets vertex colors.
.. ocv:function:: void ogl::Arrays::resetColorArray()
ogl::Arrays::setNormalArray
---------------------------
Sets an array of vertex normals.
.. ocv:function:: void ogl::Arrays::setNormalArray(InputArray normal)
:param normal: array with vertex normals, can be both host and device memory.
ogl::Arrays::resetNormalArray
-----------------------------
Resets vertex normals.
.. ocv:function:: void ogl::Arrays::resetNormalArray()
ogl::Arrays::setTexCoordArray
-----------------------------
Sets an array of vertex texture coordinates.
.. ocv:function:: void ogl::Arrays::setTexCoordArray(InputArray texCoord)
:param texCoord: array with vertex texture coordinates, can be both host and device memory.
ogl::Arrays::resetTexCoordArray
-------------------------------
Resets vertex texture coordinates.
.. ocv:function:: void ogl::Arrays::resetTexCoordArray()
ogl::Arrays::release
--------------------
Releases all inner buffers.
.. ocv:function:: void ogl::Arrays::release()
ogl::Arrays::setAutoRelease
---------------------------
Sets auto release mode all inner buffers.
.. ocv:function:: void ogl::Arrays::setAutoRelease(bool flag)
:param flag: Auto release mode.
ogl::Arrays::bind
-----------------
Binds all vertex arrays.
.. ocv:function:: void ogl::Arrays::bind() const
ogl::Arrays::size
-----------------
Returns the vertex count.
.. ocv:function:: int ogl::Arrays::size() const
ogl::render
-----------
Render OpenGL texture or primitives.
.. ocv:function:: void ogl::render(const Texture2D& tex, Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0), Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0))
.. ocv:function:: void ogl::render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255))
.. ocv:function:: void ogl::render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255))
:param tex: Texture to draw.
:param wndRect: Region of window, where to draw a texture (normalized coordinates).
:param texRect: Region of texture to draw (normalized coordinates).
:param arr: Array of privitives vertices.
:param indices: Array of vertices indices (host or device memory).
:param mode: Render mode. Available options:
* **POINTS**
* **LINES**
* **LINE_LOOP**
* **LINE_STRIP**
* **TRIANGLES**
* **TRIANGLE_STRIP**
* **TRIANGLE_FAN**
* **QUADS**
* **QUAD_STRIP**
* **POLYGON**
:param color: Color for all vertices. Will be used if ``arr`` doesn't contain color array.
gpu::setGlDevice
----------------
Sets a CUDA device and initializes it for the current thread with OpenGL interoperability.
.. ocv:function:: void gpu::setGlDevice( int device = 0 )
:param device: System index of a GPU device starting with 0.
This function should be explicitly called after OpenGL context creation and before any CUDA calls.

View File

@@ -512,7 +512,7 @@ Performs the per-element comparison of two arrays or an array and scalar value.
:param value: scalar value.
:param dst: output array that has the same size as the input arrays and type= ``CV_8UC1`` .
:param dst: output array that has the same size and type as the input arrays.
:param cmpop: a flag, that specifies correspondence between the arrays:
@@ -971,6 +971,12 @@ All of the above improvements have been implemented in :ocv:func:`matchTemplate`
.. seealso:: :ocv:func:`dct` , :ocv:func:`getOptimalDFTSize` , :ocv:func:`mulSpectrums`, :ocv:func:`filter2D` , :ocv:func:`matchTemplate` , :ocv:func:`flip` , :ocv:func:`cartToPolar` , :ocv:func:`magnitude` , :ocv:func:`phase`
.. Sample code::
* : An example using the discrete fourier transform can be found at opencv_source_code/samples/cpp/dft.cpp
* : PYTHON : An example using the dft functionality to perform Wiener deconvolution can be found at opencv_source/samples/python2/deconvolution.py
* : PYTHON : An example rearranging the quadrants of a Fourier image can be found at opencv_source/samples/python2/dft.py
divide
@@ -2161,7 +2167,9 @@ The sample below is the function that takes two matrices. The first function sto
:ocv:func:`dft`,
:ocv:func:`dct`
.. Sample code::
* : An example using PCA for dimensionality reduction while maintaining an amount of variance can be found at opencv_source_code/samples/cpp/pca.cpp
PCA::PCA
--------

View File

@@ -91,6 +91,10 @@ Several things can be noted by looking at the sample code and the output:
*
In YAML (but not XML), mappings and sequences can be written in a compact Python-like inline form. In the sample above matrix elements, as well as each feature, including its lbp value, is stored in such inline form. To store a mapping/sequence in a compact form, put ":" after the opening character, e.g. use **"{:"** instead of **"{"** and **"[:"** instead of **"["**. When the data is written to XML, those extra ":" are ignored.
.. Sample code::
* : A complete example using the FileStorage interface can be found at opencv_source_code/samples/cpp/filestorage.cpp
Reading data from a file storage.
---------------------------------

View File

@@ -149,7 +149,12 @@
# endif
#endif
#ifdef __ARM_NEON__
#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
# include <Intrin.h>
# include "arm_neon.h"
# define CV_NEON 1
# define CPU_HAS_NEON_FEATURE (true)
#elif defined(__ARM_NEON__)
# include <arm_neon.h>
# define CV_NEON 1
#endif
@@ -364,7 +369,7 @@ CV_INLINE int cvRound( double value )
return t;
#elif defined _MSC_VER && defined _M_ARM && defined HAVE_TEGRA_OPTIMIZATION
TEGRA_ROUND(value);
#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
#elif defined CV_ICC || defined __GNUC__
# ifdef HAVE_TEGRA_OPTIMIZATION
TEGRA_ROUND(value);
# else

View File

@@ -94,9 +94,20 @@ void fastFree(void* ptr)
#define STAT(stmt)
#ifdef WIN32
#if (_WIN32_WINNT >= 0x0602)
#include <synchapi.h>
#endif
struct CriticalSection
{
CriticalSection() { InitializeCriticalSection(&cs); }
CriticalSection()
{
#if (_WIN32_WINNT >= 0x0600)
InitializeCriticalSectionEx(&cs, 1000, 0);
#else
InitializeCriticalSection(&cs);
#endif
}
~CriticalSection() { DeleteCriticalSection(&cs); }
void lock() { EnterCriticalSection(&cs); }
void unlock() { LeaveCriticalSection(&cs); }

View File

@@ -886,12 +886,14 @@ void ellipse2Poly( Point center, Size axes, int angle,
Point pt;
pt.x = cvRound( cx + x * alpha - y * beta );
pt.y = cvRound( cy + x * beta + y * alpha );
if( pt != prevPt )
if( pt != prevPt ){
pts.push_back(pt);
prevPt = pt;
}
}
// If there are no points, it's a zero-size polygon
if( pts.size() < 2) {
if( pts.size() == 1) {
pts.assign(2,center);
}
}

View File

@@ -56,16 +56,39 @@ namespace
struct DIR
{
#ifdef HAVE_WINRT
WIN32_FIND_DATAW data;
#else
WIN32_FIND_DATA data;
#endif
HANDLE handle;
dirent ent;
#ifdef HAVE_WINRT
DIR() {};
~DIR()
{
if (ent.d_name)
delete[] ent.d_name;
}
#endif
};
DIR* opendir(const char* path)
{
DIR* dir = new DIR;
dir->ent.d_name = 0;
dir->handle = ::FindFirstFileA((cv::String(path) + "\\*").c_str(), &dir->data);
#ifdef HAVE_WINRT
cv::String full_path = cv::String(path) + "\\*";
size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size());
cv::Ptr<wchar_t> wfull_path = new wchar_t[size+1];
wfull_path[size] = 0;
mbstowcs(wfull_path, full_path.c_str(), full_path.size());
dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard,
&dir->data, FindExSearchNameMatch, NULL, 0);
#else
dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(),
FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0);
#endif
if(dir->handle == INVALID_HANDLE_VALUE)
{
/*closedir will do all cleanup*/
@@ -76,12 +99,25 @@ namespace
dirent* readdir(DIR* dir)
{
#ifdef HAVE_WINRT
if (dir->ent.d_name != 0)
{
if (::FindNextFile(dir->handle, &dir->data) != TRUE)
if (::FindNextFileW(dir->handle, &dir->data) != TRUE)
return 0;
}
size_t asize = wcstombs(NULL, dir->data.cFileName, 0);
char* aname = new char[asize+1];
aname[asize] = 0;
wcstombs(aname, dir->data.cFileName, asize);
dir->ent.d_name = aname;
#else
if (dir->ent.d_name != 0)
{
if (::FindNextFileA(dir->handle, &dir->data) != TRUE)
return 0;
}
dir->ent.d_name = dir->data.cFileName;
#endif
return &dir->ent;
}
@@ -107,7 +143,19 @@ static bool isDir(const cv::String& path, DIR* dir)
if (dir)
attributes = dir->data.dwFileAttributes;
else
attributes = ::GetFileAttributes(path.c_str());
{
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
#ifdef HAVE_WINRT
size_t size = mbstowcs(NULL, path.c_str(), path.size());
cv::Ptr<wchar_t> wpath = new wchar_t[size+1];
wpath[size] = 0;
mbstowcs(wpath, path.c_str(), path.size());
::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
#else
::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
#endif
attributes = all_attrs.dwFileAttributes;
}
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
#else
@@ -241,4 +289,4 @@ void cv::glob(String pattern, std::vector<String>& result, bool recursive)
glob_rec(path, wildchart, result, recursive);
std::sort(result.begin(), result.end());
}
}

View File

@@ -453,7 +453,11 @@ int cv::getNumberOfCPUs(void)
{
#if defined WIN32 || defined _WIN32
SYSTEM_INFO sysinfo;
#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT)
GetNativeSystemInfo( &sysinfo );
#else
GetSystemInfo( &sysinfo );
#endif
return (int)sysinfo.dwNumberOfProcessors;
#elif defined ANDROID

View File

@@ -58,7 +58,6 @@
#endif
#if USE_ZLIB
# undef HAVE_UNISTD_H //to avoid redefinition
# ifndef _LFS64_LARGEFILE
# define _LFS64_LARGEFILE 0
# endif

View File

@@ -728,33 +728,54 @@ void RNG::fill( InputOutputArray _mat, int disttype,
}
#ifdef WIN32
#ifdef HAVE_WINRT
// using C++11 thread attribute for local thread data
__declspec( thread ) RNG* rng = NULL;
void deleteThreadRNGData()
{
if (rng)
delete rng;
}
RNG& theRNG()
{
if (!rng)
{
rng = new RNG;
}
return *rng;
}
#else
#ifdef WINCE
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
#endif
static DWORD tlsRNGKey = TLS_OUT_OF_INDEXES;
void deleteThreadRNGData()
{
if( tlsRNGKey != TLS_OUT_OF_INDEXES )
delete (RNG*)TlsGetValue( tlsRNGKey );
void deleteThreadRNGData()
{
if( tlsRNGKey != TLS_OUT_OF_INDEXES )
delete (RNG*)TlsGetValue( tlsRNGKey );
}
RNG& theRNG()
{
if( tlsRNGKey == TLS_OUT_OF_INDEXES )
{
tlsRNGKey = TlsAlloc();
CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES);
tlsRNGKey = TlsAlloc();
CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES);
}
RNG* rng = (RNG*)TlsGetValue( tlsRNGKey );
if( !rng )
{
rng = new RNG;
TlsSetValue( tlsRNGKey, rng );
rng = new RNG;
TlsSetValue( tlsRNGKey, rng );
}
return *rng;
}
#endif //HAVE_WINRT
#else
static pthread_key_t tlsRNGKey = 0;

View File

@@ -47,6 +47,9 @@
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
#endif
#include <windows.h>
#if (_WIN32_WINNT >= 0x0602)
#include <synchapi.h>
#endif
#undef small
#undef min
#undef max
@@ -75,6 +78,30 @@
}
#endif
#endif
#ifdef HAVE_WINRT
#include <wrl/client.h>
std::wstring GetTempPathWinRT()
{
return std::wstring(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data());
}
std::wstring GetTempFileNameWinRT(std::wstring prefix)
{
wchar_t guidStr[40];
GUID g;
CoCreateGuid(&g);
wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x";
swprintf(&guidStr[0], sizeof(guidStr)/sizeof(wchar_t), mask,
g.Data1, g.Data2, g.Data3, UINT(g.Data4[0]), UINT(g.Data4[1]),
UINT(g.Data4[2]), UINT(g.Data4[3]), UINT(g.Data4[4]),
UINT(g.Data4[5]), UINT(g.Data4[6]), UINT(g.Data4[7]));
return prefix + std::wstring(guidStr);
}
#endif
#else
#include <pthread.h>
#include <sys/time.h>
@@ -371,10 +398,38 @@ String format( const char* fmt, ... )
String tempfile( const char* suffix )
{
#ifdef HAVE_WINRT
std::wstring temp_dir = L"";
const wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH");
if (opencv_temp_dir)
temp_dir = std::wstring(opencv_temp_dir);
#else
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
String fname;
#endif
#if defined WIN32 || defined _WIN32
#ifdef HAVE_WINRT
RoInitialize(RO_INIT_MULTITHREADED);
std::wstring temp_dir2;
if (temp_dir.empty())
temp_dir = GetTempPathWinRT();
std::wstring temp_file;
temp_file = GetTempFileNameWinRT(L"ocv");
if (temp_file.empty())
return std::string();
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
DeleteFileW(temp_file.c_str());
size_t asize = wcstombs(NULL, temp_file.c_str(), 0);
Ptr<char> aname = new char[asize+1];
aname[asize] = 0;
wcstombs(aname, temp_file.c_str(), asize);
fname = std::string(aname);
RoUninitialize();
#else
char temp_dir2[MAX_PATH + 1] = { 0 };
char temp_file[MAX_PATH + 1] = { 0 };
@@ -389,6 +444,7 @@ String tempfile( const char* suffix )
DeleteFileA(temp_file);
fname = temp_file;
#endif
# else
# ifdef ANDROID
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
@@ -486,40 +542,6 @@ redirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
}
/*CV_IMPL int
cvGuiBoxReport( int code, const char *func_name, const char *err_msg,
const char *file, int line, void* )
{
#if (!defined WIN32 && !defined _WIN32) || defined WINCE
return cvStdErrReport( code, func_name, err_msg, file, line, 0 );
#else
if( code != CV_StsBackTrace && code != CV_StsAutoTrace )
{
size_t msg_len = strlen(err_msg ? err_msg : "") + 1024;
char* message = (char*)alloca(msg_len);
char title[100];
wsprintf( message, "%s (%s)\nin function %s, %s(%d)\n\n"
"Press \"Abort\" to terminate application.\n"
"Press \"Retry\" to debug (if the app is running under debugger).\n"
"Press \"Ignore\" to continue (this is not safe).\n",
cvErrorStr(code), err_msg ? err_msg : "no description",
func_name, file, line );
wsprintf( title, "OpenCV GUI Error Handler" );
int answer = MessageBox( NULL, message, title, MB_ICONERROR|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL );
if( answer == IDRETRY )
{
CV_DBG_BREAK();
}
return answer != IDIGNORE;
}
return 0;
#endif
}*/
CV_IMPL int cvCheckHardwareSupport(int feature)
{
CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE );
@@ -677,7 +699,11 @@ cvErrorFromIppStatus( int status )
}
#if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
@@ -698,7 +724,15 @@ namespace cv
struct Mutex::Impl
{
Impl() { InitializeCriticalSection(&cs); refcount = 1; }
Impl()
{
#if (_WIN32_WINNT >= 0x0600)
::InitializeCriticalSectionEx(&cs, 1000, 0);
#else
::InitializeCriticalSection(&cs);
#endif
refcount = 1;
}
~Impl() { DeleteCriticalSection(&cs); }
void lock() { EnterCriticalSection(&cs); }
@@ -791,4 +825,4 @@ bool Mutex::trylock() { return impl->trylock(); }
}
/* End of file. */
/* End of file. */

View File

@@ -1,3 +1,7 @@
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")