Starting the move to OpenCV 3.4
This commit is contained in:
parent
a15a8419ad
commit
bb7a5f197b
218 changed files with 14632 additions and 3677 deletions
|
|
@ -58,34 +58,34 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -58,34 +58,34 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -57,34 +57,34 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
|
|
|||
|
|
@ -57,34 +57,34 @@
|
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -55,23 +55,23 @@
|
|||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.1\openCV3.1.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
#ifndef _HAL_INTERFACE_HPP_INCLUDED_
|
||||
#define _HAL_INTERFACE_HPP_INCLUDED_
|
||||
|
||||
//! @addtogroup core_hal_interface
|
||||
//! @{
|
||||
|
||||
#define CV_HAL_ERROR_OK 0
|
||||
#define CV_HAL_ERROR_NOT_IMPLEMENTED 1
|
||||
#define CV_HAL_ERROR_UNKNOWN -1
|
||||
|
||||
#define CV_HAL_CMP_EQ 0
|
||||
#define CV_HAL_CMP_GT 1
|
||||
#define CV_HAL_CMP_GE 2
|
||||
#define CV_HAL_CMP_LT 3
|
||||
#define CV_HAL_CMP_LE 4
|
||||
#define CV_HAL_CMP_NE 5
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* primitive types */
|
||||
/*
|
||||
schar - signed 1 byte integer
|
||||
uchar - unsigned 1 byte integer
|
||||
short - signed 2 byte integer
|
||||
ushort - unsigned 2 byte integer
|
||||
int - signed 4 byte integer
|
||||
uint - unsigned 4 byte integer
|
||||
int64 - signed 8 byte integer
|
||||
uint64 - unsigned 8 byte integer
|
||||
*/
|
||||
|
||||
#if !defined _MSC_VER && !defined __BORLANDC__
|
||||
# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__
|
||||
# include <cstdint>
|
||||
typedef std::uint32_t uint;
|
||||
# else
|
||||
# include <stdint.h>
|
||||
typedef uint32_t uint;
|
||||
# endif
|
||||
#else
|
||||
typedef unsigned uint;
|
||||
#endif
|
||||
|
||||
typedef signed char schar;
|
||||
|
||||
#ifndef __IPL_H__
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
# define CV_BIG_INT(n) n##I64
|
||||
# define CV_BIG_UINT(n) n##UI64
|
||||
#else
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
# define CV_BIG_INT(n) n##LL
|
||||
# define CV_BIG_UINT(n) n##ULL
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_PRIVATE_CUDA_HPP__
|
||||
#define __OPENCV_CORE_PRIVATE_CUDA_HPP__
|
||||
|
||||
#ifndef __OPENCV_BUILD
|
||||
# error this is a private header which should not be used from outside of the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/base.hpp"
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
# include <cuda.h>
|
||||
# include <cuda_runtime.h>
|
||||
# include <npp.h>
|
||||
# include "opencv2/core/cuda_stream_accessor.hpp"
|
||||
# include "opencv2/core/cuda/common.hpp"
|
||||
|
||||
# define NPP_VERSION (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD)
|
||||
|
||||
# define CUDART_MINIMUM_REQUIRED_VERSION 4020
|
||||
|
||||
# if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION)
|
||||
# error "Insufficient Cuda Runtime library version, please update it."
|
||||
# endif
|
||||
|
||||
# if defined(CUDA_ARCH_BIN_OR_PTX_10)
|
||||
# error "OpenCV CUDA module doesn't support NVIDIA compute capability 1.0"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda {
|
||||
CV_EXPORTS cv::String getNppErrorMessage(int code);
|
||||
CV_EXPORTS cv::String getCudaDriverApiErrorMessage(int code);
|
||||
|
||||
CV_EXPORTS GpuMat getInputMat(InputArray _src, Stream& stream);
|
||||
|
||||
CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream);
|
||||
static inline GpuMat getOutputMat(OutputArray _dst, Size size, int type, Stream& stream)
|
||||
{
|
||||
return getOutputMat(_dst, size.height, size.width, type, stream);
|
||||
}
|
||||
|
||||
CV_EXPORTS void syncOutput(const GpuMat& dst, OutputArray _dst, Stream& stream);
|
||||
}}
|
||||
|
||||
#ifndef HAVE_CUDA
|
||||
|
||||
static inline void throw_no_cuda() { CV_Error(cv::Error::GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
|
||||
#else // HAVE_CUDA
|
||||
|
||||
static inline void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||
|
||||
namespace cv { namespace cuda
|
||||
{
|
||||
class CV_EXPORTS BufferPool
|
||||
{
|
||||
public:
|
||||
explicit BufferPool(Stream& stream);
|
||||
|
||||
GpuMat getBuffer(int rows, int cols, int type);
|
||||
GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
|
||||
|
||||
GpuMat::Allocator* getAllocator() const { return allocator_; }
|
||||
|
||||
private:
|
||||
GpuMat::Allocator* allocator_;
|
||||
};
|
||||
|
||||
static inline void checkNppError(int code, const char* file, const int line, const char* func)
|
||||
{
|
||||
if (code < 0)
|
||||
cv::error(cv::Error::GpuApiCallError, getNppErrorMessage(code), func, file, line);
|
||||
}
|
||||
|
||||
static inline void checkCudaDriverApiError(int code, const char* file, const int line, const char* func)
|
||||
{
|
||||
if (code != CUDA_SUCCESS)
|
||||
cv::error(cv::Error::GpuApiCallError, getCudaDriverApiErrorMessage(code), func, file, line);
|
||||
}
|
||||
|
||||
template<int n> struct NPPTypeTraits;
|
||||
template<> struct NPPTypeTraits<CV_8U> { typedef Npp8u npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_8S> { typedef Npp8s npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_16U> { typedef Npp16u npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_16S> { typedef Npp16s npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_32S> { typedef Npp32s npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_32F> { typedef Npp32f npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_64F> { typedef Npp64f npp_type; };
|
||||
|
||||
class NppStreamHandler
|
||||
{
|
||||
public:
|
||||
inline explicit NppStreamHandler(Stream& newStream)
|
||||
{
|
||||
oldStream = nppGetStream();
|
||||
nppSetStream(StreamAccessor::getStream(newStream));
|
||||
}
|
||||
|
||||
inline explicit NppStreamHandler(cudaStream_t newStream)
|
||||
{
|
||||
oldStream = nppGetStream();
|
||||
nppSetStream(newStream);
|
||||
}
|
||||
|
||||
inline ~NppStreamHandler()
|
||||
{
|
||||
nppSetStream(oldStream);
|
||||
}
|
||||
|
||||
private:
|
||||
cudaStream_t oldStream;
|
||||
};
|
||||
}}
|
||||
|
||||
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
|
||||
#define cuSafeCall(expr) cv::cuda::checkCudaDriverApiError(expr, __FILE__, __LINE__, CV_Func)
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_CUDA_PRIVATE_HPP__
|
||||
|
|
@ -1,425 +0,0 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_PRIVATE_HPP__
|
||||
#define __OPENCV_CORE_PRIVATE_HPP__
|
||||
|
||||
#ifndef __OPENCV_BUILD
|
||||
# error this is a private header which should not be used from outside of the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "cvconfig.h"
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
# if defined __GNUC__ && defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
# endif
|
||||
# include <Eigen/Core>
|
||||
# include "opencv2/core/eigen.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
# include "tbb/tbb_stddef.h"
|
||||
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
# include "tbb/tbb.h"
|
||||
# include "tbb/task.h"
|
||||
# undef min
|
||||
# undef max
|
||||
# else
|
||||
# undef HAVE_TBB
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
#else
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
|
||||
class Split {};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns a static string if there is a parallel framework,
|
||||
// NULL otherwise.
|
||||
CV_EXPORTS const char* currentParallelFramework();
|
||||
} //namespace cv
|
||||
|
||||
/****************************************************************************************\
|
||||
* Common declarations *
|
||||
\****************************************************************************************/
|
||||
|
||||
/* the alignment of all the allocated buffers */
|
||||
#define CV_MALLOC_ALIGN 16
|
||||
|
||||
/* IEEE754 constants and macros */
|
||||
#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
|
||||
#define CV_TOGGLE_DBL(x) ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
|
||||
|
||||
static inline void* cvAlignPtr( const void* ptr, int align = 32 )
|
||||
{
|
||||
CV_DbgAssert ( (align & (align-1)) == 0 );
|
||||
return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
|
||||
}
|
||||
|
||||
static inline int cvAlign( int size, int align )
|
||||
{
|
||||
CV_DbgAssert( (align & (align-1)) == 0 && size < INT_MAX );
|
||||
return (size + align - 1) & -align;
|
||||
}
|
||||
|
||||
#ifdef IPL_DEPTH_8U
|
||||
static inline cv::Size cvGetMatSize( const CvMat* mat )
|
||||
{
|
||||
return cv::Size(mat->cols, mat->rows);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int unroll_to = 0);
|
||||
}
|
||||
|
||||
// property implementation macros
|
||||
|
||||
#define CV_IMPL_PROPERTY_RO(type, name, member) \
|
||||
inline type get##name() const { return member; }
|
||||
|
||||
#define CV_HELP_IMPL_PROPERTY(r_type, w_type, name, member) \
|
||||
CV_IMPL_PROPERTY_RO(r_type, name, member) \
|
||||
inline void set##name(w_type val) { member = val; }
|
||||
|
||||
#define CV_HELP_WRAP_PROPERTY(r_type, w_type, name, internal_name, internal_obj) \
|
||||
r_type get##name() const { return internal_obj.get##internal_name(); } \
|
||||
void set##name(w_type val) { internal_obj.set##internal_name(val); }
|
||||
|
||||
#define CV_IMPL_PROPERTY(type, name, member) CV_HELP_IMPL_PROPERTY(type, type, name, member)
|
||||
#define CV_IMPL_PROPERTY_S(type, name, member) CV_HELP_IMPL_PROPERTY(type, const type &, name, member)
|
||||
|
||||
#define CV_WRAP_PROPERTY(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, type, name, internal_name, internal_obj)
|
||||
#define CV_WRAP_PROPERTY_S(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, const type &, name, internal_name, internal_obj)
|
||||
|
||||
#define CV_WRAP_SAME_PROPERTY(type, name, internal_obj) CV_WRAP_PROPERTY(type, name, name, internal_obj)
|
||||
#define CV_WRAP_SAME_PROPERTY_S(type, name, internal_obj) CV_WRAP_PROPERTY_S(type, name, name, internal_obj)
|
||||
|
||||
/****************************************************************************************\
|
||||
* Structures and macros for integration with IPP *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#include "ipp.h"
|
||||
|
||||
#ifndef IPP_VERSION_UPDATE // prior to 7.1
|
||||
#define IPP_VERSION_UPDATE 0
|
||||
#endif
|
||||
|
||||
#define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE)
|
||||
|
||||
// General define for ipp function disabling
|
||||
#define IPP_DISABLE_BLOCK 0
|
||||
|
||||
#ifdef CV_MALLOC_ALIGN
|
||||
#undef CV_MALLOC_ALIGN
|
||||
#endif
|
||||
#define CV_MALLOC_ALIGN 32 // required for AVX optimization
|
||||
|
||||
#define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__)
|
||||
|
||||
static inline IppiSize ippiSize(int width, int height)
|
||||
{
|
||||
IppiSize size = { width, height };
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline IppiSize ippiSize(const cv::Size & _size)
|
||||
{
|
||||
IppiSize size = { _size.width, _size.height };
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
|
||||
{
|
||||
return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
|
||||
borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap :
|
||||
borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
|
||||
borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
|
||||
borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1;
|
||||
}
|
||||
|
||||
static inline IppDataType ippiGetDataType(int depth)
|
||||
{
|
||||
return depth == CV_8U ? ipp8u :
|
||||
depth == CV_8S ? ipp8s :
|
||||
depth == CV_16U ? ipp16u :
|
||||
depth == CV_16S ? ipp16s :
|
||||
depth == CV_32S ? ipp32s :
|
||||
depth == CV_32F ? ipp32f :
|
||||
depth == CV_64F ? ipp64f : (IppDataType)-1;
|
||||
}
|
||||
|
||||
// IPP temporary buffer hepler
|
||||
template<typename T>
|
||||
class IppAutoBuffer
|
||||
{
|
||||
public:
|
||||
IppAutoBuffer() { m_pBuffer = NULL; }
|
||||
IppAutoBuffer(int size) { Alloc(size); }
|
||||
~IppAutoBuffer() { Release(); }
|
||||
T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
|
||||
void Release() { if(m_pBuffer) ippFree(m_pBuffer); }
|
||||
inline operator T* () { return (T*)m_pBuffer;}
|
||||
inline operator const T* () const { return (const T*)m_pBuffer;}
|
||||
private:
|
||||
// Disable copy operations
|
||||
IppAutoBuffer(IppAutoBuffer &) {};
|
||||
IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;};
|
||||
|
||||
T* m_pBuffer;
|
||||
};
|
||||
|
||||
#else
|
||||
#define IPP_VERSION_X100 0
|
||||
#endif
|
||||
|
||||
// There shoud be no API difference in OpenCV between ICV and IPP since 9.0
|
||||
#if (defined HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 900
|
||||
#undef HAVE_IPP_ICV_ONLY
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP_ICV_ONLY
|
||||
#define HAVE_ICV 1
|
||||
#else
|
||||
#define HAVE_ICV 0
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
if(FEAT) \
|
||||
ippSetCpuFeatures(FEAT); \
|
||||
else \
|
||||
ippInit(); \
|
||||
}
|
||||
#elif IPP_VERSION_X100 >= 800
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
ippInit(); \
|
||||
}
|
||||
#else
|
||||
#define IPP_INITIALIZER(FEAT) \
|
||||
{ \
|
||||
ippStaticInit(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CVAPI_EXPORTS
|
||||
#define IPP_INITIALIZER_AUTO \
|
||||
struct __IppInitializer__ \
|
||||
{ \
|
||||
__IppInitializer__() \
|
||||
{IPP_INITIALIZER(cv::ipp::getIppFeatures())} \
|
||||
}; \
|
||||
static struct __IppInitializer__ __ipp_initializer__;
|
||||
#else
|
||||
#define IPP_INITIALIZER_AUTO
|
||||
#endif
|
||||
#else
|
||||
#define IPP_INITIALIZER
|
||||
#define IPP_INITIALIZER_AUTO
|
||||
#endif
|
||||
|
||||
#define CV_IPP_CHECK_COND (cv::ipp::useIPP())
|
||||
#define CV_IPP_CHECK() if(CV_IPP_CHECK_COND)
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
|
||||
#ifdef CV_IPP_RUN_VERBOSE
|
||||
#define CV_IPP_RUN_(condition, func, ...) \
|
||||
{ \
|
||||
if (cv::ipp::useIPP() && (condition) && func) \
|
||||
{ \
|
||||
printf("%s: IPP implementation is running\n", CV_Func); \
|
||||
fflush(stdout); \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
printf("%s: Plain implementation is running\n", CV_Func); \
|
||||
fflush(stdout); \
|
||||
} \
|
||||
}
|
||||
#elif defined CV_IPP_RUN_ASSERT
|
||||
#define CV_IPP_RUN_(condition, func, ...) \
|
||||
{ \
|
||||
if (cv::ipp::useIPP() && (condition)) \
|
||||
{ \
|
||||
if(func) \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
setIppErrorStatus(); \
|
||||
CV_Error(cv::Error::StsAssert, #func); \
|
||||
} \
|
||||
return __VA_ARGS__; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define CV_IPP_RUN_(condition, func, ...) \
|
||||
if (cv::ipp::useIPP() && (condition) && func) \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
return __VA_ARGS__; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define CV_IPP_RUN_(condition, func, ...)
|
||||
#endif
|
||||
|
||||
#define CV_IPP_RUN(condition, func, ...) CV_IPP_RUN_(condition, func, __VA_ARGS__)
|
||||
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#endif
|
||||
|
||||
/* IPP-compatible return codes */
|
||||
typedef enum CvStatus
|
||||
{
|
||||
CV_BADMEMBLOCK_ERR = -113,
|
||||
CV_INPLACE_NOT_SUPPORTED_ERR= -112,
|
||||
CV_UNMATCHED_ROI_ERR = -111,
|
||||
CV_NOTFOUND_ERR = -110,
|
||||
CV_BADCONVERGENCE_ERR = -109,
|
||||
|
||||
CV_BADDEPTH_ERR = -107,
|
||||
CV_BADROI_ERR = -106,
|
||||
CV_BADHEADER_ERR = -105,
|
||||
CV_UNMATCHED_FORMATS_ERR = -104,
|
||||
CV_UNSUPPORTED_COI_ERR = -103,
|
||||
CV_UNSUPPORTED_CHANNELS_ERR = -102,
|
||||
CV_UNSUPPORTED_DEPTH_ERR = -101,
|
||||
CV_UNSUPPORTED_FORMAT_ERR = -100,
|
||||
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
}
|
||||
CvStatus;
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
namespace tegra {
|
||||
|
||||
CV_EXPORTS bool useTegra();
|
||||
CV_EXPORTS void setUseTegra(bool flag);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_PRIVATE_HPP__
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
|
||||
#ifndef OPENCV_FLANN_DUMMY_H_
|
||||
#define OPENCV_FLANN_DUMMY_H_
|
||||
|
||||
namespace cvflann
|
||||
{
|
||||
|
||||
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void dummyfunc();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* OPENCV_FLANN_DUMMY_H_ */
|
||||
680
lib/3rdParty/OpenCV3.1/include/opencv2/videoio.hpp
vendored
680
lib/3rdParty/OpenCV3.1/include/opencv2/videoio.hpp
vendored
|
|
@ -1,680 +0,0 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_VIDEOIO_HPP__
|
||||
#define __OPENCV_VIDEOIO_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
/**
|
||||
@defgroup videoio Media I/O
|
||||
@{
|
||||
@defgroup videoio_c C API
|
||||
@defgroup videoio_ios iOS glue
|
||||
@defgroup videoio_winrt WinRT glue
|
||||
@}
|
||||
*/
|
||||
|
||||
////////////////////////////////// video io /////////////////////////////////
|
||||
|
||||
typedef struct CvCapture CvCapture;
|
||||
typedef struct CvVideoWriter CvVideoWriter;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup videoio
|
||||
//! @{
|
||||
|
||||
// Camera API
|
||||
enum { CAP_ANY = 0, // autodetect
|
||||
CAP_VFW = 200, // platform native
|
||||
CAP_V4L = 200,
|
||||
CAP_V4L2 = CAP_V4L,
|
||||
CAP_FIREWARE = 300, // IEEE 1394 drivers
|
||||
CAP_FIREWIRE = CAP_FIREWARE,
|
||||
CAP_IEEE1394 = CAP_FIREWARE,
|
||||
CAP_DC1394 = CAP_FIREWARE,
|
||||
CAP_CMU1394 = CAP_FIREWARE,
|
||||
CAP_QT = 500, // QuickTime
|
||||
CAP_UNICAP = 600, // Unicap drivers
|
||||
CAP_DSHOW = 700, // DirectShow (via videoInput)
|
||||
CAP_PVAPI = 800, // PvAPI, Prosilica GigE SDK
|
||||
CAP_OPENNI = 900, // OpenNI (for Kinect)
|
||||
CAP_OPENNI_ASUS = 910, // OpenNI (for Asus Xtion)
|
||||
CAP_ANDROID = 1000, // Android - not used
|
||||
CAP_XIAPI = 1100, // XIMEA Camera API
|
||||
CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK
|
||||
CAP_MSMF = 1400, // Microsoft Media Foundation (via videoInput)
|
||||
CAP_WINRT = 1410, // Microsoft Windows Runtime using Media Foundation
|
||||
CAP_INTELPERC = 1500, // Intel Perceptual Computing SDK
|
||||
CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect)
|
||||
CAP_OPENNI2_ASUS = 1610, // OpenNI2 (for Asus Xtion and Occipital Structure sensors)
|
||||
CAP_GPHOTO2 = 1700, // gPhoto2 connection
|
||||
CAP_GSTREAMER = 1800, // GStreamer
|
||||
CAP_FFMPEG = 1900, // FFMPEG
|
||||
CAP_IMAGES = 2000 // OpenCV Image Sequence (e.g. img_%02d.jpg)
|
||||
};
|
||||
|
||||
// generic properties (based on DC1394 properties)
|
||||
enum { CAP_PROP_POS_MSEC =0,
|
||||
CAP_PROP_POS_FRAMES =1,
|
||||
CAP_PROP_POS_AVI_RATIO =2,
|
||||
CAP_PROP_FRAME_WIDTH =3,
|
||||
CAP_PROP_FRAME_HEIGHT =4,
|
||||
CAP_PROP_FPS =5,
|
||||
CAP_PROP_FOURCC =6,
|
||||
CAP_PROP_FRAME_COUNT =7,
|
||||
CAP_PROP_FORMAT =8,
|
||||
CAP_PROP_MODE =9,
|
||||
CAP_PROP_BRIGHTNESS =10,
|
||||
CAP_PROP_CONTRAST =11,
|
||||
CAP_PROP_SATURATION =12,
|
||||
CAP_PROP_HUE =13,
|
||||
CAP_PROP_GAIN =14,
|
||||
CAP_PROP_EXPOSURE =15,
|
||||
CAP_PROP_CONVERT_RGB =16,
|
||||
CAP_PROP_WHITE_BALANCE_BLUE_U =17,
|
||||
CAP_PROP_RECTIFICATION =18,
|
||||
CAP_PROP_MONOCHROME =19,
|
||||
CAP_PROP_SHARPNESS =20,
|
||||
CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature
|
||||
CAP_PROP_GAMMA =22,
|
||||
CAP_PROP_TEMPERATURE =23,
|
||||
CAP_PROP_TRIGGER =24,
|
||||
CAP_PROP_TRIGGER_DELAY =25,
|
||||
CAP_PROP_WHITE_BALANCE_RED_V =26,
|
||||
CAP_PROP_ZOOM =27,
|
||||
CAP_PROP_FOCUS =28,
|
||||
CAP_PROP_GUID =29,
|
||||
CAP_PROP_ISO_SPEED =30,
|
||||
CAP_PROP_BACKLIGHT =32,
|
||||
CAP_PROP_PAN =33,
|
||||
CAP_PROP_TILT =34,
|
||||
CAP_PROP_ROLL =35,
|
||||
CAP_PROP_IRIS =36,
|
||||
CAP_PROP_SETTINGS =37,
|
||||
CAP_PROP_BUFFERSIZE =38,
|
||||
CAP_PROP_AUTOFOCUS =39
|
||||
};
|
||||
|
||||
|
||||
// Generic camera output modes.
|
||||
// Currently, these are supported through the libv4l interface only.
|
||||
enum { CAP_MODE_BGR = 0, // BGR24 (default)
|
||||
CAP_MODE_RGB = 1, // RGB24
|
||||
CAP_MODE_GRAY = 2, // Y8
|
||||
CAP_MODE_YUYV = 3 // YUYV
|
||||
};
|
||||
|
||||
|
||||
// DC1394 only
|
||||
// modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
|
||||
// every feature can have only one mode turned on at a time
|
||||
enum { CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically)
|
||||
CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user
|
||||
CAP_PROP_DC1394_MODE_AUTO = -2,
|
||||
CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1,
|
||||
CAP_PROP_DC1394_MAX = 31
|
||||
};
|
||||
|
||||
|
||||
// OpenNI map generators
|
||||
enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
|
||||
CAP_OPENNI_IMAGE_GENERATOR = 1 << 30,
|
||||
CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
// Properties of cameras available through OpenNI interfaces
|
||||
enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100,
|
||||
CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm
|
||||
CAP_PROP_OPENNI_BASELINE = 102, // in mm
|
||||
CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels
|
||||
CAP_PROP_OPENNI_REGISTRATION = 104, // flag that synchronizes the remapping depth map to image map
|
||||
// by changing depth generator's view point (if the flag is "on") or
|
||||
// sets this view point to its normal one (if the flag is "off").
|
||||
CAP_PROP_OPENNI_REGISTRATION_ON = CAP_PROP_OPENNI_REGISTRATION,
|
||||
CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105,
|
||||
CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106,
|
||||
CAP_PROP_OPENNI_CIRCLE_BUFFER = 107,
|
||||
CAP_PROP_OPENNI_MAX_TIME_DURATION = 108,
|
||||
CAP_PROP_OPENNI_GENERATOR_PRESENT = 109,
|
||||
CAP_PROP_OPENNI2_SYNC = 110,
|
||||
CAP_PROP_OPENNI2_MIRROR = 111
|
||||
};
|
||||
|
||||
// OpenNI shortcats
|
||||
enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
|
||||
CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION,
|
||||
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION
|
||||
};
|
||||
|
||||
// OpenNI data given from depth generator
|
||||
enum { CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1)
|
||||
CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3)
|
||||
CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1)
|
||||
CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1)
|
||||
CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1
|
||||
|
||||
// Data given from RGB image generator
|
||||
CAP_OPENNI_BGR_IMAGE = 5,
|
||||
CAP_OPENNI_GRAY_IMAGE = 6
|
||||
};
|
||||
|
||||
// Supported output modes of OpenNI image generator
|
||||
enum { CAP_OPENNI_VGA_30HZ = 0,
|
||||
CAP_OPENNI_SXGA_15HZ = 1,
|
||||
CAP_OPENNI_SXGA_30HZ = 2,
|
||||
CAP_OPENNI_QVGA_30HZ = 3,
|
||||
CAP_OPENNI_QVGA_60HZ = 4
|
||||
};
|
||||
|
||||
|
||||
// GStreamer
|
||||
enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 // default is 1
|
||||
};
|
||||
|
||||
|
||||
// PVAPI
|
||||
enum { CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast
|
||||
CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated
|
||||
CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image
|
||||
CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image
|
||||
CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor
|
||||
CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor
|
||||
CAP_PROP_PVAPI_PIXELFORMAT = 306 // Pixel format
|
||||
};
|
||||
|
||||
// PVAPI: FrameStartTriggerMode
|
||||
enum { CAP_PVAPI_FSTRIGMODE_FREERUN = 0, // Freerun
|
||||
CAP_PVAPI_FSTRIGMODE_SYNCIN1 = 1, // SyncIn1
|
||||
CAP_PVAPI_FSTRIGMODE_SYNCIN2 = 2, // SyncIn2
|
||||
CAP_PVAPI_FSTRIGMODE_FIXEDRATE = 3, // FixedRate
|
||||
CAP_PVAPI_FSTRIGMODE_SOFTWARE = 4 // Software
|
||||
};
|
||||
|
||||
// PVAPI: DecimationHorizontal, DecimationVertical
|
||||
enum { CAP_PVAPI_DECIMATION_OFF = 1, // Off
|
||||
CAP_PVAPI_DECIMATION_2OUTOF4 = 2, // 2 out of 4 decimation
|
||||
CAP_PVAPI_DECIMATION_2OUTOF8 = 4, // 2 out of 8 decimation
|
||||
CAP_PVAPI_DECIMATION_2OUTOF16 = 8 // 2 out of 16 decimation
|
||||
};
|
||||
|
||||
// PVAPI: PixelFormat
|
||||
enum { CAP_PVAPI_PIXELFORMAT_MONO8 = 1, // Mono8
|
||||
CAP_PVAPI_PIXELFORMAT_MONO16 = 2, // Mono16
|
||||
CAP_PVAPI_PIXELFORMAT_BAYER8 = 3, // Bayer8
|
||||
CAP_PVAPI_PIXELFORMAT_BAYER16 = 4, // Bayer16
|
||||
CAP_PVAPI_PIXELFORMAT_RGB24 = 5, // Rgb24
|
||||
CAP_PVAPI_PIXELFORMAT_BGR24 = 6, // Bgr24
|
||||
CAP_PVAPI_PIXELFORMAT_RGBA32 = 7, // Rgba32
|
||||
CAP_PVAPI_PIXELFORMAT_BGRA32 = 8, // Bgra32
|
||||
};
|
||||
|
||||
// Properties of cameras available through XIMEA SDK interface
|
||||
enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping.
|
||||
CAP_PROP_XI_DATA_FORMAT = 401, // Output data format.
|
||||
CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels).
|
||||
CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels).
|
||||
CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger.
|
||||
CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE.
|
||||
CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input
|
||||
CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode
|
||||
CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level
|
||||
CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output
|
||||
CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode
|
||||
CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED
|
||||
CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality
|
||||
CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition)
|
||||
CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance
|
||||
CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain
|
||||
CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%).
|
||||
CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure
|
||||
CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure
|
||||
CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %)
|
||||
CAP_PROP_XI_TIMEOUT = 420 // Image capture timeout in milliseconds
|
||||
};
|
||||
|
||||
// Properties of cameras available through AVFOUNDATION interface
|
||||
enum { CAP_PROP_IOS_DEVICE_FOCUS = 9001,
|
||||
CAP_PROP_IOS_DEVICE_EXPOSURE = 9002,
|
||||
CAP_PROP_IOS_DEVICE_FLASH = 9003,
|
||||
CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004,
|
||||
CAP_PROP_IOS_DEVICE_TORCH = 9005
|
||||
};
|
||||
|
||||
|
||||
// Properties of cameras available through Smartek Giganetix Ethernet Vision interface
|
||||
/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */
|
||||
enum { CAP_PROP_GIGA_FRAME_OFFSET_X = 10001,
|
||||
CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002,
|
||||
CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003,
|
||||
CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004,
|
||||
CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005,
|
||||
CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006
|
||||
};
|
||||
|
||||
enum { CAP_PROP_INTELPERC_PROFILE_COUNT = 11001,
|
||||
CAP_PROP_INTELPERC_PROFILE_IDX = 11002,
|
||||
CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003,
|
||||
CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004,
|
||||
CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005,
|
||||
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006,
|
||||
CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007
|
||||
};
|
||||
|
||||
// Intel PerC streams
|
||||
enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29,
|
||||
CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28,
|
||||
CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR
|
||||
};
|
||||
|
||||
enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth.
|
||||
CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates.
|
||||
CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam.
|
||||
CAP_INTELPERC_IMAGE = 3
|
||||
};
|
||||
|
||||
enum { VIDEOWRITER_PROP_QUALITY = 1, // Quality (0..100%) of the videostream encoded
|
||||
VIDEOWRITER_PROP_FRAMEBYTES = 2, // (Read-only): Size of just encoded video frame
|
||||
VIDEOWRITER_PROP_NSTRIPES = 3 // Number of stripes for parallel encoding. -1 for auto detection
|
||||
};
|
||||
|
||||
// gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID
|
||||
// Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE.
|
||||
// @see CvCaptureCAM_GPHOTO2 for more info
|
||||
enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode.
|
||||
CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *).
|
||||
CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings.
|
||||
CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set.
|
||||
CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details.
|
||||
CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *).
|
||||
CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program.
|
||||
CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program.
|
||||
CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program.
|
||||
CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode.
|
||||
};
|
||||
|
||||
//enum {
|
||||
|
||||
class IVideoCapture;
|
||||
|
||||
/** @brief Class for video capturing from video files, image sequences or cameras. The class provides C++ API
|
||||
for capturing video from cameras or for reading video files and image sequences. Here is how the
|
||||
class can be used: :
|
||||
@code
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
VideoCapture cap(0); // open the default camera
|
||||
if(!cap.isOpened()) // check if we succeeded
|
||||
return -1;
|
||||
|
||||
Mat edges;
|
||||
namedWindow("edges",1);
|
||||
for(;;)
|
||||
{
|
||||
Mat frame;
|
||||
cap >> frame; // get a new frame from camera
|
||||
cvtColor(frame, edges, COLOR_BGR2GRAY);
|
||||
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
|
||||
Canny(edges, edges, 0, 30, 3);
|
||||
imshow("edges", edges);
|
||||
if(waitKey(30) >= 0) break;
|
||||
}
|
||||
// the camera will be deinitialized automatically in VideoCapture destructor
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
@note In C API the black-box structure CvCapture is used instead of VideoCapture.
|
||||
|
||||
@note
|
||||
- A basic sample on using the VideoCapture interface can be found at
|
||||
opencv_source_code/samples/cpp/starter_video.cpp
|
||||
- Another basic video processing sample can be found at
|
||||
opencv_source_code/samples/cpp/video_dmtx.cpp
|
||||
- (Python) A basic sample on using the VideoCapture interface can be found at
|
||||
opencv_source_code/samples/python/video.py
|
||||
- (Python) Another basic video processing sample can be found at
|
||||
opencv_source_code/samples/python/video_dmtx.py
|
||||
- (Python) A multi threaded video processing sample can be found at
|
||||
opencv_source_code/samples/python/video_threaded.py
|
||||
*/
|
||||
class CV_EXPORTS_W VideoCapture
|
||||
{
|
||||
public:
|
||||
/** @brief
|
||||
@note In C API, when you finished working with video, release CvCapture structure with
|
||||
cvReleaseCapture(), or use Ptr\<CvCapture\> that calls cvReleaseCapture() automatically in the
|
||||
destructor.
|
||||
*/
|
||||
CV_WRAP VideoCapture();
|
||||
|
||||
/** @overload
|
||||
@param filename name of the opened video file (eg. video.avi) or image sequence (eg.
|
||||
img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
|
||||
*/
|
||||
CV_WRAP VideoCapture(const String& filename);
|
||||
|
||||
/** @overload
|
||||
@param filename name of the opened video file (eg. video.avi) or image sequence (eg.
|
||||
img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
|
||||
|
||||
@param apiPreference preferred Capture API to use. Can be used to enforce a specific reader
|
||||
implementation if multiple are available: e.g. CAP_FFMPEG or CAP_IMAGES
|
||||
*/
|
||||
CV_WRAP VideoCapture(const String& filename, int apiPreference);
|
||||
|
||||
/** @overload
|
||||
@param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single
|
||||
camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + CAP_MSMF
|
||||
*/
|
||||
CV_WRAP VideoCapture(int index);
|
||||
|
||||
virtual ~VideoCapture();
|
||||
|
||||
/** @brief Open video file or a capturing device for video capturing
|
||||
|
||||
@param filename name of the opened video file (eg. video.avi) or image sequence (eg.
|
||||
img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
|
||||
|
||||
The methods first call VideoCapture::release to close the already opened file or camera.
|
||||
*/
|
||||
CV_WRAP virtual bool open(const String& filename);
|
||||
|
||||
/** @overload
|
||||
@param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single
|
||||
camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + CAP_MSMF
|
||||
*/
|
||||
CV_WRAP virtual bool open(int index);
|
||||
|
||||
/** @brief Returns true if video capturing has been initialized already.
|
||||
|
||||
If the previous call to VideoCapture constructor or VideoCapture::open succeeded, the method returns
|
||||
true.
|
||||
*/
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
|
||||
/** @brief Closes video file or capturing device.
|
||||
|
||||
The methods are automatically called by subsequent VideoCapture::open and by VideoCapture
|
||||
destructor.
|
||||
|
||||
The C function also deallocates memory and clears \*capture pointer.
|
||||
*/
|
||||
CV_WRAP virtual void release();
|
||||
|
||||
/** @brief Grabs the next frame from video file or capturing device.
|
||||
|
||||
The methods/functions grab the next frame from video file or camera and return true (non-zero) in
|
||||
the case of success.
|
||||
|
||||
The primary use of the function is in multi-camera environments, especially when the cameras do not
|
||||
have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that
|
||||
call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way
|
||||
the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames
|
||||
from different cameras will be closer in time.
|
||||
|
||||
Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the
|
||||
correct way of retrieving data from it is to call VideoCapture::grab first and then call
|
||||
VideoCapture::retrieve one or more times with different values of the channel parameter. See
|
||||
<https://github.com/Itseez/opencv/tree/master/samples/cpp/openni_capture.cpp>
|
||||
*/
|
||||
CV_WRAP virtual bool grab();
|
||||
|
||||
/** @brief Decodes and returns the grabbed video frame.
|
||||
|
||||
The methods/functions decode and return the just grabbed frame. If no frames has been grabbed
|
||||
(camera has been disconnected, or there are no more frames in video file), the methods return false
|
||||
and the functions return NULL pointer.
|
||||
|
||||
@note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video
|
||||
capturing structure. It is not allowed to modify or release the image! You can copy the frame using
|
||||
:ocvcvCloneImage and then do whatever you want with the copy.
|
||||
*/
|
||||
CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0);
|
||||
virtual VideoCapture& operator >> (CV_OUT Mat& image);
|
||||
virtual VideoCapture& operator >> (CV_OUT UMat& image);
|
||||
|
||||
/** @brief Grabs, decodes and returns the next video frame.
|
||||
|
||||
The methods/functions combine VideoCapture::grab and VideoCapture::retrieve in one call. This is the
|
||||
most convenient method for reading video files or capturing data from decode and return the just
|
||||
grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more
|
||||
frames in video file), the methods return false and the functions return NULL pointer.
|
||||
|
||||
@note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video
|
||||
capturing structure. It is not allowed to modify or release the image! You can copy the frame using
|
||||
:ocvcvCloneImage and then do whatever you want with the copy.
|
||||
*/
|
||||
CV_WRAP virtual bool read(OutputArray image);
|
||||
|
||||
/** @brief Sets a property in the VideoCapture.
|
||||
|
||||
@param propId Property identifier. It can be one of the following:
|
||||
- **CAP_PROP_POS_MSEC** Current position of the video file in milliseconds.
|
||||
- **CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
|
||||
- **CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the
|
||||
film, 1 - end of the film.
|
||||
- **CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream.
|
||||
- **CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream.
|
||||
- **CAP_PROP_FPS** Frame rate.
|
||||
- **CAP_PROP_FOURCC** 4-character code of codec.
|
||||
- **CAP_PROP_FRAME_COUNT** Number of frames in the video file.
|
||||
- **CAP_PROP_FORMAT** Format of the Mat objects returned by retrieve() .
|
||||
- **CAP_PROP_MODE** Backend-specific value indicating the current capture mode.
|
||||
- **CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras).
|
||||
- **CAP_PROP_CONTRAST** Contrast of the image (only for cameras).
|
||||
- **CAP_PROP_SATURATION** Saturation of the image (only for cameras).
|
||||
- **CAP_PROP_HUE** Hue of the image (only for cameras).
|
||||
- **CAP_PROP_GAIN** Gain of the image (only for cameras).
|
||||
- **CAP_PROP_EXPOSURE** Exposure (only for cameras).
|
||||
- **CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted
|
||||
to RGB.
|
||||
- **CAP_PROP_WHITE_BALANCE** Currently unsupported
|
||||
- **CAP_PROP_RECTIFICATION** Rectification flag for stereo cameras (note: only supported
|
||||
by DC1394 v 2.x backend currently)
|
||||
@param value Value of the property.
|
||||
*/
|
||||
CV_WRAP virtual bool set(int propId, double value);
|
||||
|
||||
/** @brief Returns the specified VideoCapture property
|
||||
|
||||
@param propId Property identifier. It can be one of the following:
|
||||
- **CAP_PROP_POS_MSEC** Current position of the video file in milliseconds or video
|
||||
capture timestamp.
|
||||
- **CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
|
||||
- **CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the
|
||||
film, 1 - end of the film.
|
||||
- **CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream.
|
||||
- **CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream.
|
||||
- **CAP_PROP_FPS** Frame rate.
|
||||
- **CAP_PROP_FOURCC** 4-character code of codec.
|
||||
- **CAP_PROP_FRAME_COUNT** Number of frames in the video file.
|
||||
- **CAP_PROP_FORMAT** Format of the Mat objects returned by retrieve() .
|
||||
- **CAP_PROP_MODE** Backend-specific value indicating the current capture mode.
|
||||
- **CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras).
|
||||
- **CAP_PROP_CONTRAST** Contrast of the image (only for cameras).
|
||||
- **CAP_PROP_SATURATION** Saturation of the image (only for cameras).
|
||||
- **CAP_PROP_HUE** Hue of the image (only for cameras).
|
||||
- **CAP_PROP_GAIN** Gain of the image (only for cameras).
|
||||
- **CAP_PROP_EXPOSURE** Exposure (only for cameras).
|
||||
- **CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted
|
||||
to RGB.
|
||||
- **CAP_PROP_WHITE_BALANCE** Currently not supported
|
||||
- **CAP_PROP_RECTIFICATION** Rectification flag for stereo cameras (note: only supported
|
||||
by DC1394 v 2.x backend currently)
|
||||
|
||||
@note When querying a property that is not supported by the backend used by the VideoCapture
|
||||
class, value 0 is returned.
|
||||
*/
|
||||
CV_WRAP virtual double get(int propId) const;
|
||||
|
||||
/** @overload
|
||||
|
||||
@param filename name of the opened video file (eg. video.avi) or image sequence (eg.
|
||||
img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
|
||||
|
||||
@param apiPreference preferred Capture API to use. Can be used to enforce a specific reader
|
||||
implementation if multiple are available: e.g. CAP_FFMPEG or CAP_IMAGES
|
||||
|
||||
The methods first call VideoCapture::release to close the already opened file or camera.
|
||||
*/
|
||||
CV_WRAP virtual bool open(const String& filename, int apiPreference);
|
||||
|
||||
protected:
|
||||
Ptr<CvCapture> cap;
|
||||
Ptr<IVideoCapture> icap;
|
||||
};
|
||||
|
||||
class IVideoWriter;
|
||||
|
||||
/** @brief Video writer class.
|
||||
*/
|
||||
class CV_EXPORTS_W VideoWriter
|
||||
{
|
||||
public:
|
||||
/** @brief VideoWriter constructors
|
||||
|
||||
The constructors/functions initialize video writers. On Linux FFMPEG is used to write videos; on
|
||||
Windows FFMPEG or VFW is used; on MacOSX QTKit is used.
|
||||
*/
|
||||
CV_WRAP VideoWriter();
|
||||
|
||||
/** @overload
|
||||
@param filename Name of the output video file.
|
||||
@param fourcc 4-character code of codec used to compress the frames. For example,
|
||||
VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a
|
||||
motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by
|
||||
FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses
|
||||
other values as fourcc code: see [ObjectType](http://www.mp4ra.org/codecs.html),
|
||||
so you may receive a warning message from OpenCV about fourcc code conversion.
|
||||
@param fps Framerate of the created video stream.
|
||||
@param frameSize Size of the video frames.
|
||||
@param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
|
||||
will work with grayscale frames (the flag is currently supported on Windows only).
|
||||
*/
|
||||
CV_WRAP VideoWriter(const String& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor = true);
|
||||
|
||||
virtual ~VideoWriter();
|
||||
|
||||
/** @brief Initializes or reinitializes video writer.
|
||||
|
||||
The method opens video writer. Parameters are the same as in the constructor
|
||||
VideoWriter::VideoWriter.
|
||||
*/
|
||||
CV_WRAP virtual bool open(const String& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor = true);
|
||||
|
||||
/** @brief Returns true if video writer has been successfully initialized.
|
||||
*/
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
|
||||
/** @brief Closes the video writer.
|
||||
|
||||
The methods are automatically called by subsequent VideoWriter::open and by the VideoWriter
|
||||
destructor.
|
||||
*/
|
||||
CV_WRAP virtual void release();
|
||||
virtual VideoWriter& operator << (const Mat& image);
|
||||
|
||||
/** @brief Writes the next video frame
|
||||
|
||||
@param image The written frame
|
||||
|
||||
The functions/methods write the specified image to video file. It must have the same size as has
|
||||
been specified when opening the video writer.
|
||||
*/
|
||||
CV_WRAP virtual void write(const Mat& image);
|
||||
|
||||
/** @brief Sets a property in the VideoWriter.
|
||||
|
||||
@param propId Property identifier. It can be one of the following:
|
||||
- **VIDEOWRITER_PROP_QUALITY** Quality (0..100%) of the videostream encoded. Can be adjusted dynamically in some codecs.
|
||||
- **VIDEOWRITER_PROP_NSTRIPES** Number of stripes for parallel encoding
|
||||
@param value Value of the property.
|
||||
*/
|
||||
CV_WRAP virtual bool set(int propId, double value);
|
||||
|
||||
/** @brief Returns the specified VideoWriter property
|
||||
|
||||
@param propId Property identifier. It can be one of the following:
|
||||
- **VIDEOWRITER_PROP_QUALITY** Current quality of the encoded videostream.
|
||||
- **VIDEOWRITER_PROP_FRAMEBYTES** (Read-only) Size of just encoded video frame; note that the encoding order may be different from representation order.
|
||||
- **VIDEOWRITER_PROP_NSTRIPES** Number of stripes for parallel encoding
|
||||
|
||||
@note When querying a property that is not supported by the backend used by the VideoWriter
|
||||
class, value 0 is returned.
|
||||
*/
|
||||
CV_WRAP virtual double get(int propId) const;
|
||||
|
||||
/** @brief Concatenates 4 chars to a fourcc code
|
||||
|
||||
This static method constructs the fourcc code of the codec to be used in the constructor
|
||||
VideoWriter::VideoWriter or VideoWriter::open.
|
||||
*/
|
||||
CV_WRAP static int fourcc(char c1, char c2, char c3, char c4);
|
||||
|
||||
protected:
|
||||
Ptr<CvVideoWriter> writer;
|
||||
Ptr<IVideoWriter> iwriter;
|
||||
|
||||
static Ptr<IVideoWriter> create(const String& filename, int fourcc, double fps,
|
||||
Size frameSize, bool isColor = true);
|
||||
};
|
||||
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const;
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const;
|
||||
|
||||
//! @} videoio
|
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_VIDEOIO_HPP__
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_CV_H__
|
||||
#define __OPENCV_OLD_CV_H__
|
||||
#ifndef OPENCV_OLD_CV_H
|
||||
#define OPENCV_OLD_CV_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define CV_DO_PRAGMA(x) __pragma(x)
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_CV_HPP__
|
||||
#define __OPENCV_OLD_CV_HPP__
|
||||
#ifndef OPENCV_OLD_CV_HPP
|
||||
#define OPENCV_OLD_CV_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_AUX_H__
|
||||
#define __OPENCV_OLD_AUX_H__
|
||||
#ifndef OPENCV_OLD_AUX_H
|
||||
#define OPENCV_OLD_AUX_H
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_AUX_HPP__
|
||||
#define __OPENCV_OLD_AUX_HPP__
|
||||
#ifndef OPENCV_OLD_AUX_HPP
|
||||
#define OPENCV_OLD_AUX_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
|
|
@ -38,8 +38,8 @@
|
|||
// the use of this software, even if advised of the possibility of such damage.
|
||||
|
||||
|
||||
#ifndef __OPENCV_OLD_WIMAGE_HPP__
|
||||
#define __OPENCV_OLD_WIMAGE_HPP__
|
||||
#ifndef OPENCV_OLD_WIMAGE_HPP
|
||||
#define OPENCV_OLD_WIMAGE_HPP
|
||||
|
||||
#include "opencv2/core/wimage.hpp"
|
||||
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_CXCORE_H__
|
||||
#define __OPENCV_OLD_CXCORE_H__
|
||||
#ifndef OPENCV_OLD_CXCORE_H
|
||||
#define OPENCV_OLD_CXCORE_H
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_CXCORE_HPP__
|
||||
#define __OPENCV_OLD_CXCORE_HPP__
|
||||
#ifndef OPENCV_OLD_CXCORE_HPP
|
||||
#define OPENCV_OLD_CXCORE_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_EIGEN_HPP__
|
||||
#define __OPENCV_OLD_EIGEN_HPP__
|
||||
#ifndef OPENCV_OLD_EIGEN_HPP
|
||||
#define OPENCV_OLD_EIGEN_HPP
|
||||
|
||||
#include "opencv2/core/eigen.hpp"
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __OPENCV_OLD_CXMISC_H__
|
||||
#define __OPENCV_OLD_CXMISC_H__
|
||||
#ifndef OPENCV_OLD_CXMISC_H
|
||||
#define OPENCV_OLD_CXMISC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "opencv2/core/utility.hpp"
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_HIGHGUI_H__
|
||||
#define __OPENCV_OLD_HIGHGUI_H__
|
||||
#ifndef OPENCV_OLD_HIGHGUI_H
|
||||
#define OPENCV_OLD_HIGHGUI_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
|
|
@ -38,8 +38,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OLD_ML_H__
|
||||
#define __OPENCV_OLD_ML_H__
|
||||
#ifndef OPENCV_OLD_ML_H
|
||||
#define OPENCV_OLD_ML_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/ml.hpp"
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CALIB3D_HPP__
|
||||
#define __OPENCV_CALIB3D_HPP__
|
||||
#ifndef OPENCV_CALIB3D_HPP
|
||||
#define OPENCV_CALIB3D_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
|
|
@ -96,6 +96,10 @@ u = f_x*x' + c_x \\
|
|||
v = f_y*y' + c_y
|
||||
\end{array}\f]
|
||||
|
||||
The following figure illustrates the pinhole camera model.
|
||||
|
||||

|
||||
|
||||
Real lenses usually have some distortion, mostly radial distortion and slight tangential distortion.
|
||||
So, the above model is extended as:
|
||||
|
||||
|
|
@ -114,6 +118,10 @@ v = f_y*y'' + c_y
|
|||
tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
|
||||
coefficients. Higher-order coefficients are not considered in OpenCV.
|
||||
|
||||
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$ and pincushion distortion (typically \f$ k_1 < 0 \f$).
|
||||
|
||||

|
||||
|
||||
In some cases the image sensor may be tilted in order to focus an oblique plane in front of the
|
||||
camera (Scheimpfug condition). This can be useful for particle image velocimetry (PIV) or
|
||||
triangulation with a laser fan. The tilt causes a perspective distortion of \f$x''\f$ and
|
||||
|
|
@ -190,7 +198,7 @@ pattern (every view is described by several 3D-2D point correspondences).
|
|||
|
||||
\f[x = Xc_1 \\ y = Xc_2 \\ z = Xc_3\f]
|
||||
|
||||
The pinehole projection coordinates of P is [a; b] where
|
||||
The pinhole projection coordinates of P is [a; b] where
|
||||
|
||||
\f[a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r)\f]
|
||||
|
||||
|
|
@ -200,12 +208,12 @@ pattern (every view is described by several 3D-2D point correspondences).
|
|||
|
||||
The distorted point coordinates are [x'; y'] where
|
||||
|
||||
\f[x' = (\theta_d / r) x \\ y' = (\theta_d / r) y \f]
|
||||
\f[x' = (\theta_d / r) a \\ y' = (\theta_d / r) b \f]
|
||||
|
||||
Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
||||
|
||||
\f[u = f_x (x' + \alpha y') + c_x \\
|
||||
v = f_y yy + c_y\f]
|
||||
v = f_y y' + c_y\f]
|
||||
|
||||
@defgroup calib3d_c C API
|
||||
|
||||
|
|
@ -228,8 +236,9 @@ enum { SOLVEPNP_ITERATIVE = 0,
|
|||
SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp
|
||||
SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete
|
||||
SOLVEPNP_DLS = 3, //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct
|
||||
SOLVEPNP_UPNP = 4 //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
|
||||
|
||||
SOLVEPNP_UPNP = 4, //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
|
||||
SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
|
||||
SOLVEPNP_MAX_COUNT //!< Used for count
|
||||
};
|
||||
|
||||
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
|
||||
|
|
@ -259,6 +268,8 @@ enum { CALIB_USE_INTRINSIC_GUESS = 0x00001,
|
|||
CALIB_FIX_S1_S2_S3_S4 = 0x10000,
|
||||
CALIB_TILTED_MODEL = 0x40000,
|
||||
CALIB_FIX_TAUX_TAUY = 0x80000,
|
||||
CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise
|
||||
CALIB_FIX_TANGENT_DIST = 0x200000,
|
||||
// only for stereo
|
||||
CALIB_FIX_INTRINSIC = 0x00100,
|
||||
CALIB_SAME_FOCAL_LENGTH = 0x00200,
|
||||
|
|
@ -295,6 +306,12 @@ optimization procedures like calibrateCamera, stereoCalibrate, or solvePnP .
|
|||
*/
|
||||
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
|
||||
|
||||
/** @example pose_from_homography.cpp
|
||||
An example program about pose estimation from coplanar points
|
||||
|
||||
Check @ref tutorial_homography "the corresponding tutorial" for more details
|
||||
*/
|
||||
|
||||
/** @brief Finds a perspective transformation between two planes.
|
||||
|
||||
@param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
|
||||
|
|
@ -316,7 +333,7 @@ mask values are ignored.
|
|||
@param maxIters The maximum number of RANSAC iterations, 2000 is the maximum it can be.
|
||||
@param confidence Confidence level, between 0 and 1.
|
||||
|
||||
The functions find and return the perspective transformation \f$H\f$ between the source and the
|
||||
The function finds and returns the perspective transformation \f$H\f$ between the source and the
|
||||
destination planes:
|
||||
|
||||
\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f]
|
||||
|
|
@ -351,13 +368,8 @@ determined up to a scale. Thus, it is normalized so that \f$h_{33}=1\f$. Note th
|
|||
cannot be estimated, an empty one will be returned.
|
||||
|
||||
@sa
|
||||
getAffineTransform, getPerspectiveTransform, estimateRigidTransform, warpPerspective,
|
||||
perspectiveTransform
|
||||
|
||||
@note
|
||||
- A example on calculating a homography for image matching can be found at
|
||||
opencv_source_code/samples/cpp/video_homography.cpp
|
||||
|
||||
getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
|
||||
perspectiveTransform
|
||||
*/
|
||||
CV_EXPORTS_W Mat findHomography( InputArray srcPoints, InputArray dstPoints,
|
||||
int method = 0, double ransacReprojThreshold = 3,
|
||||
|
|
@ -383,8 +395,8 @@ and a rotation matrix.
|
|||
|
||||
It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
|
||||
degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
|
||||
sequence of rotations about the three principle axes that results in the same orientation of an
|
||||
object, eg. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angules
|
||||
sequence of rotations about the three principal axes that results in the same orientation of an
|
||||
object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
|
||||
are only one of the possible solutions.
|
||||
*/
|
||||
CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ,
|
||||
|
|
@ -409,8 +421,8 @@ matrix and the position of a camera.
|
|||
|
||||
It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
|
||||
be used in OpenGL. Note, there is always more than one sequence of rotations about the three
|
||||
principle axes that results in the same orientation of an object, eg. see @cite Slabaugh . Returned
|
||||
tree rotation matrices and corresponding three Euler angules are only one of the possible solutions.
|
||||
principal axes that results in the same orientation of an object, e.g. see @cite Slabaugh . Returned
|
||||
tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
|
||||
|
||||
The function is based on RQDecomp3x3 .
|
||||
*/
|
||||
|
|
@ -513,21 +525,27 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
|
|||
OutputArray jacobian = noArray(),
|
||||
double aspectRatio = 0 );
|
||||
|
||||
/** @example homography_from_camera_displacement.cpp
|
||||
An example program about homography from the camera displacement
|
||||
|
||||
Check @ref tutorial_homography "the corresponding tutorial" for more details
|
||||
*/
|
||||
|
||||
/** @brief Finds an object pose from 3D-2D point correspondences.
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, 3xN/Nx3 1-channel or
|
||||
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
|
||||
1xN/Nx1 3-channel, where N is the number of points. vector\<Point3f\> can be also passed here.
|
||||
@param imagePoints Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
where N is the number of points. vector\<Point2f\> can be also passed here.
|
||||
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
|
||||
@param distCoeffs Input vector of distortion coefficients
|
||||
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
|
||||
4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
|
||||
assumed.
|
||||
@param rvec Output rotation vector (see Rodrigues ) that, together with tvec , brings points from
|
||||
@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec , brings points from
|
||||
the model coordinate system to the camera coordinate system.
|
||||
@param tvec Output translation vector.
|
||||
@param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses
|
||||
@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
|
||||
the provided rvec and tvec values as initial approximations of the rotation and translation
|
||||
vectors, respectively, and further optimizes them.
|
||||
@param flags Method for solving a PnP problem:
|
||||
|
|
@ -536,20 +554,116 @@ this case the function finds such a pose that minimizes reprojection error, that
|
|||
of squared distances between the observed projections imagePoints and the projected (using
|
||||
projectPoints ) objectPoints .
|
||||
- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem". In this case the
|
||||
function requires exactly four object and image points.
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- **SOLVEPNP_AP3P** Method is based on the paper of T. Ke, S. Roumeliotis
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- **SOLVEPNP_EPNP** Method has been introduced by F.Moreno-Noguer, V.Lepetit and P.Fua in the
|
||||
paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation".
|
||||
paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
|
||||
- **SOLVEPNP_DLS** Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis.
|
||||
"A Direct Least-Squares (DLS) Method for PnP".
|
||||
"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
|
||||
- **SOLVEPNP_UPNP** Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto,
|
||||
F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
|
||||
Estimation". In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
|
||||
Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
|
||||
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
|
||||
focal length.
|
||||
- **SOLVEPNP_AP3P** Method is based on the paper of Tong Ke and Stergios I. Roumeliotis.
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17). In this case the
|
||||
function requires exactly four object and image points.
|
||||
|
||||
The function estimates the object pose given a set of object points, their corresponding image
|
||||
projections, as well as the camera matrix and the distortion coefficients.
|
||||
projections, as well as the camera matrix and the distortion coefficients, see the figure below
|
||||
(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
|
||||
and the Z-axis forward).
|
||||
|
||||

|
||||
|
||||
Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
|
||||
using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{M}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
f_x & 0 & c_x \\
|
||||
0 & f_y & c_y \\
|
||||
0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
1 & 0 & 0 & 0 \\
|
||||
0 & 1 & 0 & 0 \\
|
||||
0 & 0 & 1 & 0
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow to transform
|
||||
a 3D point expressed in the world frame into the camera frame:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\hspace{0.2em} ^{c}\bf{M}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
@note
|
||||
- An example of how to use solvePnP for planar augmented reality can be found at
|
||||
|
|
@ -564,6 +678,15 @@ projections, as well as the camera matrix and the distortion coefficients.
|
|||
- Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
|
||||
it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
|
||||
np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
|
||||
- The methods **SOLVEPNP_DLS** and **SOLVEPNP_UPNP** cannot be used as the current implementations are
|
||||
unstable and sometimes give completely wrong results. If you pass one of these two
|
||||
flags, **SOLVEPNP_EPNP** method will be used instead.
|
||||
- The minimum number of points is 4 in the general case. In the case of **SOLVEPNP_P3P** and **SOLVEPNP_AP3P**
|
||||
methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
|
||||
of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
|
||||
- With **SOLVEPNP_ITERATIVE** method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points
|
||||
are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
|
||||
global solution to converge.
|
||||
*/
|
||||
CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
|
||||
InputArray cameraMatrix, InputArray distCoeffs,
|
||||
|
|
@ -572,9 +695,9 @@ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
|
|||
|
||||
/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, 3xN/Nx3 1-channel or
|
||||
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
|
||||
1xN/Nx1 3-channel, where N is the number of points. vector\<Point3f\> can be also passed here.
|
||||
@param imagePoints Array of corresponding image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
where N is the number of points. vector\<Point2f\> can be also passed here.
|
||||
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
|
||||
@param distCoeffs Input vector of distortion coefficients
|
||||
|
|
@ -604,6 +727,13 @@ makes the function resistant to outliers.
|
|||
@note
|
||||
- An example of how to use solvePNPRansac for object detection can be found at
|
||||
opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
|
||||
- The default method used to estimate the camera pose for the Minimal Sample Sets step
|
||||
is #SOLVEPNP_EPNP. Exceptions are:
|
||||
- if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
|
||||
- if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
|
||||
- The method used to estimate the camera pose using all the inliers is defined by the
|
||||
flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
|
||||
the method #SOLVEPNP_EPNP will be used instead.
|
||||
*/
|
||||
CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints,
|
||||
InputArray cameraMatrix, InputArray distCoeffs,
|
||||
|
|
@ -611,6 +741,33 @@ CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoint
|
|||
bool useExtrinsicGuess = false, int iterationsCount = 100,
|
||||
float reprojectionError = 8.0, double confidence = 0.99,
|
||||
OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE );
|
||||
/** @brief Finds an object pose from 3 3D-2D point correspondences.
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
|
||||
1x3/3x1 3-channel. vector\<Point3f\> can be also passed here.
|
||||
@param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
|
||||
vector\<Point2f\> can be also passed here.
|
||||
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
|
||||
@param distCoeffs Input vector of distortion coefficients
|
||||
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
|
||||
4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
|
||||
assumed.
|
||||
@param rvecs Output rotation vectors (see Rodrigues ) that, together with tvecs , brings points from
|
||||
the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
|
||||
@param tvecs Output translation vectors.
|
||||
@param flags Method for solving a P3P problem:
|
||||
- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
- **SOLVEPNP_AP3P** Method is based on the paper of Tong Ke and Stergios I. Roumeliotis.
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
|
||||
|
||||
The function estimates the object pose given 3 object points, their corresponding image
|
||||
projections, as well as the camera matrix and the distortion coefficients.
|
||||
*/
|
||||
CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints,
|
||||
InputArray cameraMatrix, InputArray distCoeffs,
|
||||
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
|
||||
int flags );
|
||||
|
||||
/** @brief Finds an initial camera matrix from 3D-2D point correspondences.
|
||||
|
||||
|
|
@ -638,11 +795,11 @@ CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints,
|
|||
( patternSize = cvSize(points_per_row,points_per_colum) = cvSize(columns,rows) ).
|
||||
@param corners Output array of detected corners.
|
||||
@param flags Various operation flags that can be zero or a combination of the following values:
|
||||
- **CV_CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
|
||||
- **CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
|
||||
and white, rather than a fixed threshold level (computed from the average image brightness).
|
||||
- **CV_CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
|
||||
- **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
|
||||
applying fixed or adaptive thresholding.
|
||||
- **CV_CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
|
||||
- **CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
|
||||
square-like shape) to filter out false quads extracted at the contour retrieval stage.
|
||||
- **CALIB_CB_FAST_CHECK** Run a fast check on the image that looks for chessboard corners,
|
||||
and shortcut the call if none is found. This can drastically speed up the call in the
|
||||
|
|
@ -701,6 +858,38 @@ found, or as colored corners connected with lines if the board was found.
|
|||
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
|
||||
InputArray corners, bool patternWasFound );
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
|
||||
{
|
||||
CV_WRAP CirclesGridFinderParameters();
|
||||
CV_PROP_RW cv::Size2f densityNeighborhoodSize;
|
||||
CV_PROP_RW float minDensity;
|
||||
CV_PROP_RW int kmeansAttempts;
|
||||
CV_PROP_RW int minDistanceToAddKeypoint;
|
||||
CV_PROP_RW int keypointScale;
|
||||
CV_PROP_RW float minGraphConfidence;
|
||||
CV_PROP_RW float vertexGain;
|
||||
CV_PROP_RW float vertexPenalty;
|
||||
CV_PROP_RW float existingVertexGain;
|
||||
CV_PROP_RW float edgeGain;
|
||||
CV_PROP_RW float edgePenalty;
|
||||
CV_PROP_RW float convexHullFactor;
|
||||
CV_PROP_RW float minRNGEdgeSwitchDist;
|
||||
|
||||
enum GridType
|
||||
{
|
||||
SYMMETRIC_GRID, ASYMMETRIC_GRID
|
||||
};
|
||||
GridType gridType;
|
||||
};
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters2 : public CirclesGridFinderParameters
|
||||
{
|
||||
CV_WRAP CirclesGridFinderParameters2();
|
||||
|
||||
CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING.
|
||||
CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from predicion. Used by CALIB_CB_CLUSTERING.
|
||||
};
|
||||
|
||||
/** @brief Finds centers in the grid of circles.
|
||||
|
||||
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
|
||||
|
|
@ -713,6 +902,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz
|
|||
- **CALIB_CB_CLUSTERING** uses a special algorithm for grid detection. It is more robust to
|
||||
perspective distortions but much more sensitive to background clutter.
|
||||
@param blobDetector feature detector that finds blobs like dark circles on light background.
|
||||
@param parameters struct for finding circles in a grid pattern.
|
||||
|
||||
The function attempts to determine whether the input image contains a grid of circles. If it is, the
|
||||
function locates centers of the circles. The function returns a non-zero value if all of the centers
|
||||
|
|
@ -732,6 +922,18 @@ Sample usage of detecting and drawing the centers of circles: :
|
|||
@note The function requires white space (like a square-thick border, the wider the better) around
|
||||
the board to make the detection more robust in various environments.
|
||||
*/
|
||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters parameters);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W bool findCirclesGrid2( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters2 parameters);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
|
||||
const Ptr<FeatureDetector> &blobDetector = SimpleBlobDetector::create());
|
||||
|
|
@ -756,7 +958,7 @@ together.
|
|||
@param imageSize Size of the image used only to initialize the intrinsic camera matrix.
|
||||
@param cameraMatrix Output 3x3 floating-point camera matrix
|
||||
\f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
|
||||
and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
|
||||
and/or CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
|
||||
initialized before calling the function.
|
||||
@param distCoeffs Output vector of distortion coefficients
|
||||
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
|
||||
|
|
@ -767,25 +969,33 @@ k-th translation vector (see the next output parameter description) brings the c
|
|||
from the model coordinate space (in which object points are specified) to the world coordinate
|
||||
space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
|
||||
@param tvecs Output vector of translation vectors estimated for each pattern view.
|
||||
@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
|
||||
Order of deviations values:
|
||||
\f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
|
||||
s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
|
||||
@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
|
||||
Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
|
||||
\f$R_i, T_i\f$ are concatenated 1x3 vectors.
|
||||
@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
|
||||
@param flags Different flags that may be zero or a combination of the following values:
|
||||
- **CV_CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
|
||||
- **CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
|
||||
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
|
||||
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
|
||||
Note, that if intrinsic parameters are known, there is no need to use this function just to
|
||||
estimate extrinsic parameters. Use solvePnP instead.
|
||||
- **CV_CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
|
||||
- **CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
|
||||
optimization. It stays at the center or at a different location specified when
|
||||
CV_CALIB_USE_INTRINSIC_GUESS is set too.
|
||||
- **CV_CALIB_FIX_ASPECT_RATIO** The functions considers only fy as a free parameter. The
|
||||
CALIB_USE_INTRINSIC_GUESS is set too.
|
||||
- **CALIB_FIX_ASPECT_RATIO** The functions considers only fy as a free parameter. The
|
||||
ratio fx/fy stays the same as in the input cameraMatrix . When
|
||||
CV_CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
|
||||
CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
|
||||
ignored, only their ratio is computed and used further.
|
||||
- **CV_CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
|
||||
- **CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
|
||||
to zeros and stay zero.
|
||||
- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** The corresponding radial distortion
|
||||
coefficient is not changed during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is
|
||||
- **CALIB_FIX_K1,...,CALIB_FIX_K6** The corresponding radial distortion
|
||||
coefficient is not changed during the optimization. If CALIB_USE_INTRINSIC_GUESS is
|
||||
set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- **CV_CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
|
||||
- **CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
|
||||
backward compatibility, this extra flag should be explicitly specified to make the
|
||||
calibration function use the rational model and return 8 coefficients. If the flag is not
|
||||
set, the function computes and returns only 5 distortion coefficients.
|
||||
|
|
@ -794,24 +1004,26 @@ backward compatibility, this extra flag should be explicitly specified to make t
|
|||
calibration function use the thin prism model and return 12 coefficients. If the flag is not
|
||||
set, the function computes and returns only 5 distortion coefficients.
|
||||
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
|
||||
the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
|
||||
backward compatibility, this extra flag should be explicitly specified to make the
|
||||
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
|
||||
set, the function computes and returns only 5 distortion coefficients.
|
||||
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
|
||||
the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
@param criteria Termination criteria for the iterative optimization algorithm.
|
||||
|
||||
@return the overall RMS re-projection error.
|
||||
|
||||
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
|
||||
views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object
|
||||
points and their corresponding 2D projections in each view must be specified. That may be achieved
|
||||
by using an object with a known geometry and easily detectable feature points. Such an object is
|
||||
called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
|
||||
a calibration rig (see findChessboardCorners ). Currently, initialization of intrinsic parameters
|
||||
(when CV_CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
|
||||
(when CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
|
||||
patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
|
||||
be used as long as initial cameraMatrix is provided.
|
||||
|
||||
|
|
@ -819,7 +1031,7 @@ The algorithm performs the following steps:
|
|||
|
||||
- Compute the initial intrinsic parameters (the option only available for planar calibration
|
||||
patterns) or read them from the input parameters. The distortion coefficients are all set to
|
||||
zeros initially unless some of CV_CALIB_FIX_K? are specified.
|
||||
zeros initially unless some of CALIB_FIX_K? are specified.
|
||||
|
||||
- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
|
||||
done using solvePnP .
|
||||
|
|
@ -829,8 +1041,6 @@ The algorithm performs the following steps:
|
|||
the projected (using the current estimates for camera parameters and the poses) object points
|
||||
objectPoints. See projectPoints for details.
|
||||
|
||||
The function returns the final re-projection error.
|
||||
|
||||
@note
|
||||
If you use a non-square (=non-NxN) grid and findChessboardCorners for calibration, and
|
||||
calibrateCamera returns bad values (zero distortion coefficients, an image center very far from
|
||||
|
|
@ -841,6 +1051,24 @@ The function returns the final re-projection error.
|
|||
@sa
|
||||
findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
|
||||
*/
|
||||
CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera( InputArrayOfArrays objectPoints,
|
||||
InputArrayOfArrays imagePoints, Size imageSize,
|
||||
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
|
||||
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
|
||||
OutputArray stdDeviationsIntrinsics,
|
||||
OutputArray stdDeviationsExtrinsics,
|
||||
OutputArray perViewErrors,
|
||||
int flags = 0, TermCriteria criteria = TermCriteria(
|
||||
TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) );
|
||||
|
||||
/** @overload double calibrateCamera( InputArrayOfArrays objectPoints,
|
||||
InputArrayOfArrays imagePoints, Size imageSize,
|
||||
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
|
||||
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
|
||||
OutputArray stdDeviations, OutputArray perViewErrors,
|
||||
int flags = 0, TermCriteria criteria = TermCriteria(
|
||||
TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) )
|
||||
*/
|
||||
CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
|
||||
InputArrayOfArrays imagePoints, Size imageSize,
|
||||
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
|
||||
|
|
@ -883,8 +1111,8 @@ observed by the first camera.
|
|||
observed by the second camera.
|
||||
@param cameraMatrix1 Input/output first camera matrix:
|
||||
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
|
||||
any of CV_CALIB_USE_INTRINSIC_GUESS , CV_CALIB_FIX_ASPECT_RATIO ,
|
||||
CV_CALIB_FIX_INTRINSIC , or CV_CALIB_FIX_FOCAL_LENGTH are specified, some or all of the
|
||||
any of CALIB_USE_INTRINSIC_GUESS , CALIB_FIX_ASPECT_RATIO ,
|
||||
CALIB_FIX_INTRINSIC , or CALIB_FIX_FOCAL_LENGTH are specified, some or all of the
|
||||
matrix components must be initialized. See the flags description for details.
|
||||
@param distCoeffs1 Input/output vector of distortion coefficients
|
||||
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
|
||||
|
|
@ -898,21 +1126,21 @@ is similar to distCoeffs1 .
|
|||
@param E Output essential matrix.
|
||||
@param F Output fundamental matrix.
|
||||
@param flags Different flags that may be zero or a combination of the following values:
|
||||
- **CV_CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F
|
||||
- **CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F
|
||||
matrices are estimated.
|
||||
- **CV_CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
|
||||
- **CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
|
||||
according to the specified flags. Initial values are provided by the user.
|
||||
- **CV_CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
|
||||
- **CV_CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
|
||||
- **CV_CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
|
||||
- **CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
|
||||
- **CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
|
||||
- **CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
|
||||
.
|
||||
- **CV_CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
|
||||
- **CV_CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
|
||||
- **CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
|
||||
- **CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
|
||||
zeros and fix there.
|
||||
- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** Do not change the corresponding radial
|
||||
distortion coefficient during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set,
|
||||
- **CALIB_FIX_K1,...,CALIB_FIX_K6** Do not change the corresponding radial
|
||||
distortion coefficient during the optimization. If CALIB_USE_INTRINSIC_GUESS is set,
|
||||
the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- **CV_CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
|
||||
- **CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
|
||||
compatibility, this extra flag should be explicitly specified to make the calibration
|
||||
function use the rational model and return 8 coefficients. If the flag is not set, the
|
||||
function computes and returns only 5 distortion coefficients.
|
||||
|
|
@ -921,14 +1149,14 @@ backward compatibility, this extra flag should be explicitly specified to make t
|
|||
calibration function use the thin prism model and return 12 coefficients. If the flag is not
|
||||
set, the function computes and returns only 5 distortion coefficients.
|
||||
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
|
||||
the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
|
||||
backward compatibility, this extra flag should be explicitly specified to make the
|
||||
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
|
||||
set, the function computes and returns only 5 distortion coefficients.
|
||||
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
|
||||
the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
@param criteria Termination criteria for the iterative optimization algorithm.
|
||||
|
||||
|
|
@ -940,8 +1168,8 @@ This means that, given ( \f$R_1\f$,\f$T_1\f$ ), it should be possible to compute
|
|||
need to know the position and orientation of the second camera relative to the first camera. This is
|
||||
what the described function does. It computes ( \f$R\f$,\f$T\f$ ) so that:
|
||||
|
||||
\f[R_2=R*R_1
|
||||
T_2=R*T_1 + T,\f]
|
||||
\f[R_2=R*R_1\f]
|
||||
\f[T_2=R*T_1 + T,\f]
|
||||
|
||||
Optionally, it computes the essential matrix E:
|
||||
|
||||
|
|
@ -956,10 +1184,10 @@ Besides the stereo-related information, the function can also perform a full cal
|
|||
two cameras. However, due to the high dimensionality of the parameter space and noise in the input
|
||||
data, the function can diverge from the correct solution. If the intrinsic parameters can be
|
||||
estimated with high accuracy for each of the cameras individually (for example, using
|
||||
calibrateCamera ), you are recommended to do so and then pass CV_CALIB_FIX_INTRINSIC flag to the
|
||||
calibrateCamera ), you are recommended to do so and then pass CALIB_FIX_INTRINSIC flag to the
|
||||
function along with the computed intrinsic parameters. Otherwise, if all the parameters are
|
||||
estimated at once, it makes sense to restrict some parameters, for example, pass
|
||||
CV_CALIB_SAME_FOCAL_LENGTH and CV_CALIB_ZERO_TANGENT_DIST flags, which is usually a
|
||||
CALIB_SAME_FOCAL_LENGTH and CALIB_ZERO_TANGENT_DIST flags, which is usually a
|
||||
reasonable assumption.
|
||||
|
||||
Similarly to calibrateCamera , the function minimizes the total re-projection error for all the
|
||||
|
|
@ -991,7 +1219,7 @@ camera.
|
|||
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
|
||||
camera.
|
||||
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
|
||||
@param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
|
||||
@param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
|
||||
the function makes the principal points of each camera have the same pixel coordinates in the
|
||||
rectified views. And if the flag is not set, the function may still shift the images in the
|
||||
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
|
||||
|
|
@ -1030,7 +1258,7 @@ coordinates. The function distinguishes the following two cases:
|
|||
\f[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x*f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\f]
|
||||
|
||||
where \f$T_x\f$ is a horizontal shift between the cameras and \f$cx_1=cx_2\f$ if
|
||||
CV_CALIB_ZERO_DISPARITY is set.
|
||||
CALIB_ZERO_DISPARITY is set.
|
||||
|
||||
- **Vertical stereo**: the first and the second camera views are shifted relative to each other
|
||||
mainly in vertical direction (and probably a bit in the horizontal direction too). The epipolar
|
||||
|
|
@ -1076,7 +1304,7 @@ findFundamentalMat .
|
|||
@param threshold Optional threshold used to filter out the outliers. If the parameter is greater
|
||||
than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
|
||||
for which \f$|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}\f$ ) are
|
||||
rejected prior to computing the homographies. Otherwise,all the points are considered inliers.
|
||||
rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
|
||||
|
||||
The function computes the rectification transformations without knowing intrinsic parameters of the
|
||||
cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
|
||||
|
|
@ -1120,7 +1348,7 @@ assumed.
|
|||
@param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
|
||||
valid) and 1 (when all the source image pixels are retained in the undistorted image). See
|
||||
stereoRectify for details.
|
||||
@param newImgSize Image size after rectification. By default,it is set to imageSize .
|
||||
@param newImgSize Image size after rectification. By default, it is set to imageSize .
|
||||
@param validPixROI Optional output rectangle that outlines all-good-pixels region in the
|
||||
undistorted image. See roi1, roi2 description in stereoRectify .
|
||||
@param centerPrincipalPoint Optional flag that indicates whether in the new camera matrix the
|
||||
|
|
@ -1131,7 +1359,7 @@ best fit a subset of the source image (determined by alpha) to the corrected ima
|
|||
The function computes and returns the optimal new camera matrix based on the free scaling parameter.
|
||||
By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
|
||||
image pixels if there is valuable information in the corners alpha=1 , or get something in between.
|
||||
When alpha\>0 , the undistortion result is likely to have some black pixels corresponding to
|
||||
When alpha\>0 , the undistorted result is likely to have some black pixels corresponding to
|
||||
"virtual" pixels outside of the captured distorted image. The original camera matrix, distortion
|
||||
coefficients, the computed new camera matrix, and newImageSize should be passed to
|
||||
initUndistortRectifyMap to produce the maps for remap .
|
||||
|
|
@ -1242,15 +1470,15 @@ be floating-point (single or double precision).
|
|||
@param cameraMatrix Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
|
||||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera matrix.
|
||||
@param method Method for computing a fundamental matrix.
|
||||
@param method Method for computing an essential matrix.
|
||||
- **RANSAC** for the RANSAC algorithm.
|
||||
- **MEDS** for the LMedS algorithm.
|
||||
- **LMEDS** for the LMedS algorithm.
|
||||
@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
|
||||
confidence (probability) that the estimated matrix is correct.
|
||||
@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
|
||||
line in pixels, beyond which the point is considered an outlier and is not used for computing the
|
||||
final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
|
||||
point localization, image resolution, and the image noise.
|
||||
@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
|
||||
confidence (probability) that the estimated matrix is correct.
|
||||
@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
|
||||
for the other points. The array is computed only in the RANSAC and LMedS methods.
|
||||
|
||||
|
|
@ -1273,8 +1501,8 @@ CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
|||
be floating-point (single or double precision).
|
||||
@param points2 Array of the second image points of the same size and format as points1 .
|
||||
@param focal focal length of the camera. Note that this function assumes that points1 and points2
|
||||
are feature points from cameras with same focal length and principle point.
|
||||
@param pp principle point of the camera.
|
||||
are feature points from cameras with same focal length and principal point.
|
||||
@param pp principal point of the camera.
|
||||
@param method Method for computing a fundamental matrix.
|
||||
- **RANSAC** for the RANSAC algorithm.
|
||||
- **LMEDS** for the LMedS algorithm.
|
||||
|
|
@ -1327,7 +1555,7 @@ floating-point (single or double precision).
|
|||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera matrix.
|
||||
@param R Recovered relative rotation.
|
||||
@param t Recoverd relative translation.
|
||||
@param t Recovered relative translation.
|
||||
@param mask Input/output mask for inliers in points1 and points2.
|
||||
: If it is not empty, then it marks inliers in points1 and points2 for then given essential
|
||||
matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
|
||||
|
|
@ -1370,10 +1598,10 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
|
|||
floating-point (single or double precision).
|
||||
@param points2 Array of the second image points of the same size and format as points1 .
|
||||
@param R Recovered relative rotation.
|
||||
@param t Recoverd relative translation.
|
||||
@param t Recovered relative translation.
|
||||
@param focal Focal length of the camera. Note that this function assumes that points1 and points2
|
||||
are feature points from cameras with same focal length and principle point.
|
||||
@param pp Principle point of the camera.
|
||||
are feature points from cameras with same focal length and principal point.
|
||||
@param pp principal point of the camera.
|
||||
@param mask Input/output mask for inliers in points1 and points2.
|
||||
: If it is not empty, then it marks inliers in points1 and points2 for then given essential
|
||||
matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
|
||||
|
|
@ -1394,6 +1622,28 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
|
|||
double focal = 1.0, Point2d pp = Point2d(0, 0),
|
||||
InputOutputArray mask = noArray() );
|
||||
|
||||
/** @overload
|
||||
@param E The input essential matrix.
|
||||
@param points1 Array of N 2D points from the first image. The point coordinates should be
|
||||
floating-point (single or double precision).
|
||||
@param points2 Array of the second image points of the same size and format as points1.
|
||||
@param cameraMatrix Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
|
||||
Note that this function assumes that points1 and points2 are feature points from cameras with the
|
||||
same camera matrix.
|
||||
@param R Recovered relative rotation.
|
||||
@param t Recovered relative translation.
|
||||
@param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite points).
|
||||
@param mask Input/output mask for inliers in points1 and points2.
|
||||
: If it is not empty, then it marks inliers in points1 and points2 for then given essential
|
||||
matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
|
||||
which pass the cheirality check.
|
||||
@param triangulatedPoints 3d points which were reconstructed by triangulation.
|
||||
*/
|
||||
|
||||
CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2,
|
||||
InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(),
|
||||
OutputArray triangulatedPoints = noArray());
|
||||
|
||||
/** @brief For points in an image of a stereo pair, computes the corresponding epilines in the other image.
|
||||
|
||||
@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or
|
||||
|
|
@ -1504,7 +1754,7 @@ to 3D points with a very large Z value (currently set to 10000).
|
|||
depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
|
||||
|
||||
The function transforms a single-channel disparity map to a 3-channel image representing a 3D
|
||||
surface. That is, for each pixel (x,y) andthe corresponding disparity d=disparity(x,y) , it
|
||||
surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
|
||||
computes:
|
||||
|
||||
\f[\begin{array}{l} [X \; Y \; Z \; W]^T = \texttt{Q} *[x \; y \; \texttt{disparity} (x,y) \; 1]^T \\ \texttt{\_3dImage} (x,y) = (X/W, \; Y/W, \; Z/W) \end{array}\f]
|
||||
|
|
@ -1548,6 +1798,99 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst,
|
|||
OutputArray out, OutputArray inliers,
|
||||
double ransacThreshold = 3, double confidence = 0.99);
|
||||
|
||||
/** @brief Computes an optimal affine transformation between two 2D point sets.
|
||||
|
||||
@param from First input 2D point set.
|
||||
@param to Second input 2D point set.
|
||||
@param inliers Output vector indicating which points are inliers.
|
||||
@param method Robust method used to compute transformation. The following methods are possible:
|
||||
- cv::RANSAC - RANSAC-based robust method
|
||||
- cv::LMEDS - Least-Median robust method
|
||||
RANSAC is the default method.
|
||||
@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
|
||||
a point as an inlier. Applies only to RANSAC.
|
||||
@param maxIters The maximum number of robust method iterations, 2000 is the maximum it can be.
|
||||
@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
|
||||
between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
|
||||
significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
|
||||
@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
|
||||
Passing 0 will disable refining, so the output matrix will be output of robust method.
|
||||
|
||||
@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation
|
||||
could not be estimated.
|
||||
|
||||
The function estimates an optimal 2D affine transformation between two 2D point sets using the
|
||||
selected robust algorithm.
|
||||
|
||||
The computed transformation is then refined further (using only inliers) with the
|
||||
Levenberg-Marquardt method to reduce the re-projection error even more.
|
||||
|
||||
@note
|
||||
The RANSAC method can handle practically any ratio of outliers but need a threshold to
|
||||
distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
|
||||
correctly only when there are more than 50% of inliers.
|
||||
|
||||
@sa estimateAffinePartial2D, getAffineTransform
|
||||
*/
|
||||
CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray from, InputArray to, OutputArray inliers = noArray(),
|
||||
int method = RANSAC, double ransacReprojThreshold = 3,
|
||||
size_t maxIters = 2000, double confidence = 0.99,
|
||||
size_t refineIters = 10);
|
||||
|
||||
/** @brief Computes an optimal limited affine transformation with 4 degrees of freedom between
|
||||
two 2D point sets.
|
||||
|
||||
@param from First input 2D point set.
|
||||
@param to Second input 2D point set.
|
||||
@param inliers Output vector indicating which points are inliers.
|
||||
@param method Robust method used to compute transformation. The following methods are possible:
|
||||
- cv::RANSAC - RANSAC-based robust method
|
||||
- cv::LMEDS - Least-Median robust method
|
||||
RANSAC is the default method.
|
||||
@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
|
||||
a point as an inlier. Applies only to RANSAC.
|
||||
@param maxIters The maximum number of robust method iterations, 2000 is the maximum it can be.
|
||||
@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
|
||||
between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
|
||||
significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
|
||||
@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
|
||||
Passing 0 will disable refining, so the output matrix will be output of robust method.
|
||||
|
||||
@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or
|
||||
empty matrix if transformation could not be estimated.
|
||||
|
||||
The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
|
||||
combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
|
||||
estimation.
|
||||
|
||||
The computed transformation is then refined further (using only inliers) with the
|
||||
Levenberg-Marquardt method to reduce the re-projection error even more.
|
||||
|
||||
Estimated transformation matrix is:
|
||||
\f[ \begin{bmatrix} \cos(\theta)s & -\sin(\theta)s & tx \\
|
||||
\sin(\theta)s & \cos(\theta)s & ty
|
||||
\end{bmatrix} \f]
|
||||
Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ tx, ty \f$ are
|
||||
translations in \f$ x, y \f$ axes respectively.
|
||||
|
||||
@note
|
||||
The RANSAC method can handle practically any ratio of outliers but need a threshold to
|
||||
distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
|
||||
correctly only when there are more than 50% of inliers.
|
||||
|
||||
@sa estimateAffine2D, getAffineTransform
|
||||
*/
|
||||
CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, OutputArray inliers = noArray(),
|
||||
int method = RANSAC, double ransacReprojThreshold = 3,
|
||||
size_t maxIters = 2000, double confidence = 0.99,
|
||||
size_t refineIters = 10);
|
||||
|
||||
/** @example decompose_homography.cpp
|
||||
An example program with homography decomposition.
|
||||
|
||||
Check @ref tutorial_homography "the corresponding tutorial" for more details.
|
||||
*/
|
||||
|
||||
/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
|
||||
|
||||
@param H The input homography matrix between two images.
|
||||
|
|
@ -1683,7 +2026,8 @@ public:
|
|||
{
|
||||
MODE_SGBM = 0,
|
||||
MODE_HH = 1,
|
||||
MODE_SGBM_3WAY = 2
|
||||
MODE_SGBM_3WAY = 2,
|
||||
MODE_HH4 = 3
|
||||
};
|
||||
|
||||
CV_WRAP virtual int getPreFilterCap() const = 0;
|
||||
|
|
@ -1738,7 +2082,7 @@ public:
|
|||
set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
|
||||
to a custom value.
|
||||
*/
|
||||
CV_WRAP static Ptr<StereoSGBM> create(int minDisparity, int numDisparities, int blockSize,
|
||||
CV_WRAP static Ptr<StereoSGBM> create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
|
||||
int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
|
||||
int preFilterCap = 0, int uniquenessRatio = 0,
|
||||
int speckleWindowSize = 0, int speckleRange = 0,
|
||||
|
|
@ -1756,15 +2100,16 @@ namespace fisheye
|
|||
//! @{
|
||||
|
||||
enum{
|
||||
CALIB_USE_INTRINSIC_GUESS = 1,
|
||||
CALIB_RECOMPUTE_EXTRINSIC = 2,
|
||||
CALIB_CHECK_COND = 4,
|
||||
CALIB_FIX_SKEW = 8,
|
||||
CALIB_FIX_K1 = 16,
|
||||
CALIB_FIX_K2 = 32,
|
||||
CALIB_FIX_K3 = 64,
|
||||
CALIB_FIX_K4 = 128,
|
||||
CALIB_FIX_INTRINSIC = 256
|
||||
CALIB_USE_INTRINSIC_GUESS = 1 << 0,
|
||||
CALIB_RECOMPUTE_EXTRINSIC = 1 << 1,
|
||||
CALIB_CHECK_COND = 1 << 2,
|
||||
CALIB_FIX_SKEW = 1 << 3,
|
||||
CALIB_FIX_K1 = 1 << 4,
|
||||
CALIB_FIX_K2 = 1 << 5,
|
||||
CALIB_FIX_K3 = 1 << 6,
|
||||
CALIB_FIX_K4 = 1 << 7,
|
||||
CALIB_FIX_INTRINSIC = 1 << 8,
|
||||
CALIB_FIX_PRINCIPAL_POINT = 1 << 9
|
||||
};
|
||||
|
||||
/** @brief Projects points using fisheye model
|
||||
|
|
@ -1802,6 +2147,10 @@ namespace fisheye
|
|||
@param D Input vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$.
|
||||
@param alpha The skew coefficient.
|
||||
@param distorted Output array of image points, 1xN/Nx1 2-channel, or vector\<Point2f\> .
|
||||
|
||||
Note that the function assumes the camera matrix of the undistorted points to be identity.
|
||||
This means if you want to transform back points undistorted with undistortPoints() you have to
|
||||
multiply them with \f$P^{-1}\f$.
|
||||
*/
|
||||
CV_EXPORTS_W void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0);
|
||||
|
||||
|
|
@ -1910,8 +2259,10 @@ namespace fisheye
|
|||
of intrinsic optimization.
|
||||
- **fisheye::CALIB_CHECK_COND** The functions will check validity of condition number.
|
||||
- **fisheye::CALIB_FIX_SKEW** Skew coefficient (alpha) is set to zero and stay zero.
|
||||
- **fisheye::CALIB_FIX_K1..4** Selected distortion coefficients are set to zeros and stay
|
||||
zero.
|
||||
- **fisheye::CALIB_FIX_K1..fisheye::CALIB_FIX_K4** Selected distortion coefficients
|
||||
are set to zeros and stay zero.
|
||||
- **fisheye::CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
|
||||
optimization. It stays at the center or at a different location specified when CALIB_USE_INTRINSIC_GUESS is set too.
|
||||
@param criteria Termination criteria for the iterative optimization algorithm.
|
||||
*/
|
||||
CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
|
||||
|
|
@ -1935,7 +2286,7 @@ namespace fisheye
|
|||
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
|
||||
camera.
|
||||
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
|
||||
@param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
|
||||
@param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
|
||||
the function makes the principal points of each camera have the same pixel coordinates in the
|
||||
rectified views. And if the flag is not set, the function may still shift the images in the
|
||||
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
|
||||
|
|
@ -1961,7 +2312,7 @@ namespace fisheye
|
|||
observed by the second camera.
|
||||
@param K1 Input/output first camera matrix:
|
||||
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
|
||||
any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CV_CALIB_FIX_INTRINSIC are specified,
|
||||
any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CALIB_FIX_INTRINSIC are specified,
|
||||
some or all of the matrix components must be initialized.
|
||||
@param D1 Input/output vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$ of 4 elements.
|
||||
@param K2 Input/output second camera matrix. The parameter is similar to K1 .
|
||||
|
|
@ -1971,7 +2322,7 @@ namespace fisheye
|
|||
@param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
|
||||
@param T Output translation vector between the coordinate systems of the cameras.
|
||||
@param flags Different flags that may be zero or a combination of the following values:
|
||||
- **fisheye::CV_CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
|
||||
- **fisheye::CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
|
||||
are estimated.
|
||||
- **fisheye::CALIB_USE_INTRINSIC_GUESS** K1, K2 contains valid initial values of
|
||||
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CALIB3D_C_H__
|
||||
#define __OPENCV_CALIB3D_C_H__
|
||||
#ifndef OPENCV_CALIB3D_C_H
|
||||
#define OPENCV_CALIB3D_C_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
|
|
@ -245,7 +245,9 @@ CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
|
|||
#define CV_CALIB_FIX_S1_S2_S3_S4 65536
|
||||
#define CV_CALIB_TILTED_MODEL 262144
|
||||
#define CV_CALIB_FIX_TAUX_TAUY 524288
|
||||
#define CV_CALIB_FIX_TANGENT_DIST 2097152
|
||||
|
||||
#define CV_CALIB_NINTRINSIC 18
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
|
|
@ -422,4 +424,4 @@ public:
|
|||
|
||||
#endif
|
||||
|
||||
#endif /* __OPENCV_CALIB3D_C_H__ */
|
||||
#endif /* OPENCV_CALIB3D_C_H */
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_HPP__
|
||||
#define __OPENCV_CORE_HPP__
|
||||
#ifndef OPENCV_CORE_HPP
|
||||
#define OPENCV_CORE_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error core.hpp header must be compiled as C++
|
||||
|
|
@ -74,6 +74,7 @@
|
|||
@{
|
||||
@defgroup core_utils_sse SSE utilities
|
||||
@defgroup core_utils_neon NEON utilities
|
||||
@defgroup core_utils_softfloat Softfloat support
|
||||
@}
|
||||
@defgroup core_opengl OpenGL interoperability
|
||||
@defgroup core_ipp Intel IPP Asynchronous C/C++ Converters
|
||||
|
|
@ -114,7 +115,7 @@ public:
|
|||
*/
|
||||
Exception();
|
||||
/*!
|
||||
Full constructor. Normally the constuctor is not called explicitly.
|
||||
Full constructor. Normally the constructor is not called explicitly.
|
||||
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
|
||||
*/
|
||||
Exception(int _code, const String& _err, const String& _func, const String& _file, int _line);
|
||||
|
|
@ -131,8 +132,8 @@ public:
|
|||
int code; ///< error code @see CVStatus
|
||||
String err; ///< error description
|
||||
String func; ///< function name. Available only when the compiler supports getting it
|
||||
String file; ///< source file name where the error has occured
|
||||
int line; ///< line number in the source file where the error has occured
|
||||
String file; ///< source file name where the error has occurred
|
||||
int line; ///< line number in the source file where the error has occurred
|
||||
};
|
||||
|
||||
/*! @brief Signals an error and raises the exception.
|
||||
|
|
@ -273,6 +274,9 @@ of p and len.
|
|||
*/
|
||||
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
|
||||
|
||||
/** @example copyMakeBorder_demo.cpp
|
||||
An example using copyMakeBorder function
|
||||
*/
|
||||
/** @brief Forms a border around an image.
|
||||
|
||||
The function copies the source image into the middle of the destination image. The areas to the
|
||||
|
|
@ -426,7 +430,7 @@ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2,
|
|||
|
||||
/** @brief Performs per-element division of two arrays or a scalar by an array.
|
||||
|
||||
The functions divide divide one array by another:
|
||||
The function cv::divide divides one array by another:
|
||||
\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
|
||||
or a scalar by an array when there is no src1 :
|
||||
\f[\texttt{dst(I) = saturate(scale/src2(I))}\f]
|
||||
|
|
@ -471,6 +475,9 @@ The function can also be emulated with a matrix expression, for example:
|
|||
*/
|
||||
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
|
||||
|
||||
/** @example AddingImagesTrackbar.cpp
|
||||
|
||||
*/
|
||||
/** @brief Calculates the weighted sum of two arrays.
|
||||
|
||||
The function addWeighted calculates the weighted sum of two arrays as follows:
|
||||
|
|
@ -524,6 +531,17 @@ For example:
|
|||
CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst,
|
||||
double alpha = 1, double beta = 0);
|
||||
|
||||
/** @brief Converts an array to half precision floating number.
|
||||
|
||||
This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). The input array has to have type of CV_32F or
|
||||
CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
|
||||
The format of half precision floating point is defined in IEEE 754-2008.
|
||||
|
||||
@param src input array.
|
||||
@param dst output array.
|
||||
*/
|
||||
CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst);
|
||||
|
||||
/** @brief Performs a look-up table transform of an array.
|
||||
|
||||
The function LUT fills the output array with values from the look-up table. Indices of the entries
|
||||
|
|
@ -542,7 +560,7 @@ CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
|
|||
|
||||
/** @brief Calculates the sum of array elements.
|
||||
|
||||
The functions sum calculate and return the sum of array elements,
|
||||
The function cv::sum calculates and returns the sum of array elements,
|
||||
independently for each channel.
|
||||
@param src input array that must have from 1 to 4 channels.
|
||||
@sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
|
||||
|
|
@ -588,10 +606,10 @@ CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );
|
|||
|
||||
/** @brief Calculates an average (mean) of array elements.
|
||||
|
||||
The function mean calculates the mean value M of array elements,
|
||||
The function cv::mean calculates the mean value M of array elements,
|
||||
independently for each channel, and return it:
|
||||
\f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\f]
|
||||
When all the mask elements are 0's, the functions return Scalar::all(0)
|
||||
When all the mask elements are 0's, the function returns Scalar::all(0)
|
||||
@param src input array that should have from 1 to 4 channels so that the result can be stored in
|
||||
Scalar_ .
|
||||
@param mask optional operation mask.
|
||||
|
|
@ -601,11 +619,11 @@ CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray());
|
|||
|
||||
/** Calculates a mean and standard deviation of array elements.
|
||||
|
||||
The function meanStdDev calculates the mean and the standard deviation M
|
||||
The function cv::meanStdDev calculates the mean and the standard deviation M
|
||||
of array elements independently for each channel and returns it via the
|
||||
output parameters:
|
||||
\f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f]
|
||||
When all the mask elements are 0's, the functions return
|
||||
When all the mask elements are 0's, the function returns
|
||||
mean=stddev=Scalar::all(0).
|
||||
@note The calculated standard deviation is only the diagonal of the
|
||||
complete normalized covariance matrix. If the full matrix is needed, you
|
||||
|
|
@ -615,50 +633,57 @@ then pass the matrix to calcCovarMatrix .
|
|||
@param src input array that should have from 1 to 4 channels so that the results can be stored in
|
||||
Scalar_ 's.
|
||||
@param mean output parameter: calculated mean value.
|
||||
@param stddev output parameter: calculateded standard deviation.
|
||||
@param stddev output parameter: calculated standard deviation.
|
||||
@param mask optional operation mask.
|
||||
@sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
|
||||
*/
|
||||
CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,
|
||||
InputArray mask=noArray());
|
||||
|
||||
/** @brief Calculates an absolute array norm, an absolute difference norm, or a
|
||||
relative difference norm.
|
||||
/** @brief Calculates the absolute norm of an array.
|
||||
|
||||
The functions norm calculate an absolute norm of src1 (when there is no
|
||||
src2 ):
|
||||
This version of cv::norm calculates the absolute norm of src1. The type of norm to calculate is specified using cv::NormTypes.
|
||||
|
||||
\f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{ \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
|
||||
|
||||
or an absolute or relative difference norm if src2 is there:
|
||||
|
||||
\f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
|
||||
|
||||
or
|
||||
|
||||
\f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
|
||||
|
||||
The functions norm return the calculated norm.
|
||||
As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
|
||||
The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
|
||||
is calculated as follows
|
||||
\f{align*}
|
||||
\| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
|
||||
\| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
|
||||
\| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
|
||||
\f}
|
||||
and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
|
||||
\f{align*}
|
||||
\| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
|
||||
\| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
|
||||
\| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
|
||||
\f}
|
||||
The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$.
|
||||
It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$.
|
||||

|
||||
|
||||
When the mask parameter is specified and it is not empty, the norm is
|
||||
|
||||
If normType is not specified, NORM_L2 is used.
|
||||
calculated only over the region specified by the mask.
|
||||
|
||||
A multi-channel input arrays are treated as a single-channel, that is,
|
||||
Multi-channel input arrays are treated as single-channel arrays, that is,
|
||||
the results for all channels are combined.
|
||||
|
||||
Hamming norms can only be calculated with CV_8U depth arrays.
|
||||
|
||||
@param src1 first input array.
|
||||
@param normType type of the norm (see cv::NormTypes).
|
||||
@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
|
||||
*/
|
||||
CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray());
|
||||
|
||||
/** @overload
|
||||
/** @brief Calculates an absolute difference norm or a relative difference norm.
|
||||
|
||||
This version of cv::norm calculates the absolute difference norm
|
||||
or the relative difference norm of arrays src1 and src2.
|
||||
The type of norm to calculate is specified using cv::NormTypes.
|
||||
|
||||
@param src1 first input array.
|
||||
@param src2 second input array of the same size and the same type as src1.
|
||||
@param normType type of the norm (cv::NormTypes).
|
||||
|
|
@ -672,10 +697,21 @@ CV_EXPORTS_W double norm(InputArray src1, InputArray src2,
|
|||
*/
|
||||
CV_EXPORTS double norm( const SparseMat& src, int normType );
|
||||
|
||||
/** @brief computes PSNR image/video quality metric
|
||||
/** @brief Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
|
||||
|
||||
This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB), between two input arrays src1 and src2. Arrays must have depth CV_8U.
|
||||
|
||||
The PSNR is calculated as follows:
|
||||
|
||||
\f[
|
||||
\texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
|
||||
\f]
|
||||
|
||||
where R is the maximum integer value of depth CV_8U (255) and MSE is the mean squared error between the two arrays.
|
||||
|
||||
@param src1 first input array.
|
||||
@param src2 second input array of the same size as src1.
|
||||
|
||||
see http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio for details
|
||||
@todo document
|
||||
*/
|
||||
CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2);
|
||||
|
||||
|
|
@ -692,7 +728,7 @@ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2,
|
|||
|
||||
/** @brief Normalizes the norm or value range of an array.
|
||||
|
||||
The functions normalize scale and shift the input array elements so that
|
||||
The function cv::normalize normalizes scale and shift the input array elements so that
|
||||
\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f]
|
||||
(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
|
||||
\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f]
|
||||
|
|
@ -762,11 +798,11 @@ CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, i
|
|||
|
||||
/** @brief Finds the global minimum and maximum in an array.
|
||||
|
||||
The functions minMaxLoc find the minimum and maximum element values and their positions. The
|
||||
The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The
|
||||
extremums are searched across the whole array or, if mask is not an empty array, in the specified
|
||||
array region.
|
||||
|
||||
The functions do not work with multi-channel arrays. If you need to find minimum or maximum
|
||||
The function do not work with multi-channel arrays. If you need to find minimum or maximum
|
||||
elements across all the channels, use Mat::reshape first to reinterpret the array as
|
||||
single-channel. Or you may extract the particular channel using either extractImageCOI , or
|
||||
mixChannels , or split .
|
||||
|
|
@ -785,7 +821,7 @@ CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal,
|
|||
|
||||
/** @brief Finds the global minimum and maximum in an array
|
||||
|
||||
The function minMaxIdx finds the minimum and maximum element values and their positions. The
|
||||
The function cv::minMaxIdx finds the minimum and maximum element values and their positions. The
|
||||
extremums are searched across the whole array or, if mask is not an empty array, in the specified
|
||||
array region. The function does not work with multi-channel arrays. If you need to find minimum or
|
||||
maximum elements across all the channels, use Mat::reshape first to reinterpret the array as
|
||||
|
|
@ -823,12 +859,19 @@ CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal,
|
|||
|
||||
/** @brief Reduces a matrix to a vector.
|
||||
|
||||
The function reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
|
||||
The function cv::reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
|
||||
1D vectors and performing the specified operation on the vectors until a single row/column is
|
||||
obtained. For example, the function can be used to compute horizontal and vertical projections of a
|
||||
raster image. In case of REDUCE_SUM and REDUCE_AVG , the output may have a larger element
|
||||
bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction
|
||||
modes.
|
||||
raster image. In case of REDUCE_MAX and REDUCE_MIN , the output image should have the same type as the source one.
|
||||
In case of REDUCE_SUM and REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
|
||||
And multi-channel arrays are also supported in these two reduction modes.
|
||||
|
||||
The following code demonstrates its usage for a single channel matrix.
|
||||
@snippet snippets/core_reduce.cpp example
|
||||
|
||||
And the following code demonstrates its usage for a two-channel matrix.
|
||||
@snippet snippets/core_reduce.cpp example2
|
||||
|
||||
@param src input 2D matrix.
|
||||
@param dst output vector. Its size and type is defined by dim and dtype parameters.
|
||||
@param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
|
||||
|
|
@ -842,12 +885,16 @@ CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, in
|
|||
|
||||
/** @brief Creates one multi-channel array out of several single-channel ones.
|
||||
|
||||
The function merge merges several arrays to make a single multi-channel array. That is, each
|
||||
The function cv::merge merges several arrays to make a single multi-channel array. That is, each
|
||||
element of the output array will be a concatenation of the elements of the input arrays, where
|
||||
elements of i-th input array are treated as mv[i].channels()-element vectors.
|
||||
|
||||
The function cv::split does the reverse operation. If you need to shuffle channels in some other
|
||||
advanced way, use cv::mixChannels.
|
||||
|
||||
The following example shows how to merge 3 single channel matrices into a single 3-channel matrix.
|
||||
@snippet snippets/core_merge.cpp example
|
||||
|
||||
@param mv input array of matrices to be merged; all the matrices in mv must have the same
|
||||
size and the same depth.
|
||||
@param count number of input matrices when mv is a plain C array; it must be greater than zero.
|
||||
|
|
@ -867,10 +914,14 @@ CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
|
|||
|
||||
/** @brief Divides a multi-channel array into several single-channel arrays.
|
||||
|
||||
The functions split split a multi-channel array into separate single-channel arrays:
|
||||
The function cv::split splits a multi-channel array into separate single-channel arrays:
|
||||
\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f]
|
||||
If you need to extract a single channel or do some other sophisticated channel permutation, use
|
||||
mixChannels .
|
||||
|
||||
The following example demonstrates how to split a 3-channel matrix into 3 single channel matrices.
|
||||
@snippet snippets/core_split.cpp example
|
||||
|
||||
@param src input multi-channel array.
|
||||
@param mvbegin output array; the number of arrays must match src.channels(); the arrays themselves are
|
||||
reallocated, if needed.
|
||||
|
|
@ -889,7 +940,7 @@ output arrays.
|
|||
|
||||
The function cv::mixChannels provides an advanced mechanism for shuffling image channels.
|
||||
|
||||
cv::split and cv::merge and some forms of cv::cvtColor are partial cases of cv::mixChannels .
|
||||
cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of cv::cvtColor are partial cases of cv::mixChannels.
|
||||
|
||||
In the example below, the code splits a 4-channel BGRA image into a 3-channel BGR (with B and R
|
||||
channels swapped) and a separate alpha-channel image:
|
||||
|
|
@ -923,7 +974,7 @@ src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for
|
|||
channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
|
||||
filled with zero .
|
||||
@param npairs number of index pairs in `fromTo`.
|
||||
@sa cv::split, cv::merge, cv::cvtColor
|
||||
@sa split, merge, extractChannel, insertChannel, cvtColor
|
||||
*/
|
||||
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
|
||||
const int* fromTo, size_t npairs);
|
||||
|
|
@ -961,19 +1012,25 @@ filled with zero .
|
|||
CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
|
||||
const std::vector<int>& fromTo);
|
||||
|
||||
/** @brief extracts a single channel from src (coi is 0-based index)
|
||||
@todo document
|
||||
/** @brief Extracts a single channel from src (coi is 0-based index)
|
||||
@param src input array
|
||||
@param dst output array
|
||||
@param coi index of channel to extract
|
||||
@sa mixChannels, split
|
||||
*/
|
||||
CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
|
||||
|
||||
/** @brief inserts a single channel to dst (coi is 0-based index)
|
||||
@todo document
|
||||
/** @brief Inserts a single channel to dst (coi is 0-based index)
|
||||
@param src input array
|
||||
@param dst output array
|
||||
@param coi index of channel for insertion
|
||||
@sa mixChannels, merge
|
||||
*/
|
||||
CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi);
|
||||
|
||||
/** @brief Flips a 2D array around vertical, horizontal, or both axes.
|
||||
|
||||
The function flip flips the array in one of three different ways (row
|
||||
The function cv::flip flips the array in one of three different ways (row
|
||||
and column indices are 0-based):
|
||||
\f[\texttt{dst} _{ij} =
|
||||
\left\{
|
||||
|
|
@ -1005,26 +1062,44 @@ around both axes.
|
|||
*/
|
||||
CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);
|
||||
|
||||
enum RotateFlags {
|
||||
ROTATE_90_CLOCKWISE = 0, //Rotate 90 degrees clockwise
|
||||
ROTATE_180 = 1, //Rotate 180 degrees clockwise
|
||||
ROTATE_90_COUNTERCLOCKWISE = 2, //Rotate 270 degrees clockwise
|
||||
};
|
||||
/** @brief Rotates a 2D array in multiples of 90 degrees.
|
||||
The function rotate rotates the array in one of three different ways:
|
||||
* Rotate by 90 degrees clockwise (rotateCode = ROTATE_90).
|
||||
* Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
|
||||
* Rotate by 270 degrees clockwise (rotateCode = ROTATE_270).
|
||||
@param src input array.
|
||||
@param dst output array of the same type as src. The size is the same with ROTATE_180,
|
||||
and the rows and cols are switched for ROTATE_90 and ROTATE_270.
|
||||
@param rotateCode an enum to specify how to rotate the array; see the enum RotateFlags
|
||||
@sa transpose , repeat , completeSymm, flip, RotateFlags
|
||||
*/
|
||||
CV_EXPORTS_W void rotate(InputArray src, OutputArray dst, int rotateCode);
|
||||
|
||||
/** @brief Fills the output array with repeated copies of the input array.
|
||||
|
||||
The functions repeat duplicate the input array one or more times along each of the two axes:
|
||||
The function cv::repeat duplicates the input array one or more times along each of the two axes:
|
||||
\f[\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\f]
|
||||
The second variant of the function is more convenient to use with @ref MatrixExpressions.
|
||||
@param src input array to replicate.
|
||||
@param dst output array of the same type as src.
|
||||
@param ny Flag to specify how many times the src is repeated along the
|
||||
@param ny Flag to specify how many times the `src` is repeated along the
|
||||
vertical axis.
|
||||
@param nx Flag to specify how many times the src is repeated along the
|
||||
@param nx Flag to specify how many times the `src` is repeated along the
|
||||
horizontal axis.
|
||||
@sa reduce
|
||||
@param dst output array of the same type as `src`.
|
||||
@sa cv::reduce
|
||||
*/
|
||||
CV_EXPORTS_W void repeat(InputArray src, int ny, int nx, OutputArray dst);
|
||||
|
||||
/** @overload
|
||||
@param src input array to replicate.
|
||||
@param ny Flag to specify how many times the src is repeated along the
|
||||
@param ny Flag to specify how many times the `src` is repeated along the
|
||||
vertical axis.
|
||||
@param nx Flag to specify how many times the src is repeated along the
|
||||
@param nx Flag to specify how many times the `src` is repeated along the
|
||||
horizontal axis.
|
||||
*/
|
||||
CV_EXPORTS Mat repeat(const Mat& src, int ny, int nx);
|
||||
|
|
@ -1160,7 +1235,7 @@ CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst);
|
|||
Calculates the per-element bit-wise conjunction of two arrays or an
|
||||
array and a scalar.
|
||||
|
||||
The function calculates the per-element bit-wise logical conjunction for:
|
||||
The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
|
||||
* Two arrays when src1 and src2 have the same size:
|
||||
\f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
|
||||
* An array and a scalar when src2 is constructed from Scalar or has
|
||||
|
|
@ -1187,7 +1262,7 @@ CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2,
|
|||
/** @brief Calculates the per-element bit-wise disjunction of two arrays or an
|
||||
array and a scalar.
|
||||
|
||||
The function calculates the per-element bit-wise logical disjunction for:
|
||||
The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
|
||||
* Two arrays when src1 and src2 have the same size:
|
||||
\f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
|
||||
* An array and a scalar when src2 is constructed from Scalar or has
|
||||
|
|
@ -1214,7 +1289,7 @@ CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2,
|
|||
/** @brief Calculates the per-element bit-wise "exclusive or" operation on two
|
||||
arrays or an array and a scalar.
|
||||
|
||||
The function calculates the per-element bit-wise logical "exclusive-or"
|
||||
The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
|
||||
operation for:
|
||||
* Two arrays when src1 and src2 have the same size:
|
||||
\f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f]
|
||||
|
|
@ -1241,7 +1316,7 @@ CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2,
|
|||
|
||||
/** @brief Inverts every bit of an array.
|
||||
|
||||
The function calculates per-element bit-wise inversion of the input
|
||||
The function cv::bitwise_not calculates per-element bit-wise inversion of the input
|
||||
array:
|
||||
\f[\texttt{dst} (I) = \neg \texttt{src} (I)\f]
|
||||
In case of a floating-point input array, its machine-specific bit
|
||||
|
|
@ -1258,7 +1333,7 @@ CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst,
|
|||
|
||||
/** @brief Calculates the per-element absolute difference between two arrays or between an array and a scalar.
|
||||
|
||||
The function absdiff calculates:
|
||||
The function cv::absdiff calculates:
|
||||
* Absolute difference between two arrays when they have the same
|
||||
size and type:
|
||||
\f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f]
|
||||
|
|
@ -1333,7 +1408,7 @@ CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst, int
|
|||
|
||||
/** @brief Calculates per-element minimum of two arrays or an array and a scalar.
|
||||
|
||||
The functions min calculate the per-element minimum of two arrays:
|
||||
The function cv::min calculates the per-element minimum of two arrays:
|
||||
\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f]
|
||||
or array and a scalar:
|
||||
\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\f]
|
||||
|
|
@ -1354,7 +1429,7 @@ CV_EXPORTS void min(const UMat& src1, const UMat& src2, UMat& dst);
|
|||
|
||||
/** @brief Calculates per-element maximum of two arrays or an array and a scalar.
|
||||
|
||||
The functions max calculate the per-element maximum of two arrays:
|
||||
The function cv::max calculates the per-element maximum of two arrays:
|
||||
\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f]
|
||||
or array and a scalar:
|
||||
\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\f]
|
||||
|
|
@ -1375,7 +1450,7 @@ CV_EXPORTS void max(const UMat& src1, const UMat& src2, UMat& dst);
|
|||
|
||||
/** @brief Calculates a square root of array elements.
|
||||
|
||||
The functions sqrt calculate a square root of each input array element.
|
||||
The function cv::sqrt calculates a square root of each input array element.
|
||||
In case of multi-channel arrays, each channel is processed
|
||||
independently. The accuracy is approximately the same as of the built-in
|
||||
std::sqrt .
|
||||
|
|
@ -1386,7 +1461,7 @@ CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst);
|
|||
|
||||
/** @brief Raises every array element to a power.
|
||||
|
||||
The function pow raises every element of the input array to power :
|
||||
The function cv::pow raises every element of the input array to power :
|
||||
\f[\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\f]
|
||||
|
||||
So, for a non-integer power exponent, the absolute values of input array
|
||||
|
|
@ -1411,7 +1486,7 @@ CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst);
|
|||
|
||||
/** @brief Calculates the exponent of every array element.
|
||||
|
||||
The function exp calculates the exponent of every element of the input
|
||||
The function cv::exp calculates the exponent of every element of the input
|
||||
array:
|
||||
\f[\texttt{dst} [I] = e^{ src(I) }\f]
|
||||
|
||||
|
|
@ -1427,14 +1502,11 @@ CV_EXPORTS_W void exp(InputArray src, OutputArray dst);
|
|||
|
||||
/** @brief Calculates the natural logarithm of every array element.
|
||||
|
||||
The function log calculates the natural logarithm of the absolute value
|
||||
of every element of the input array:
|
||||
\f[\texttt{dst} (I) = \fork{\log |\texttt{src}(I)|}{if \(\texttt{src}(I) \ne 0\) }{\texttt{C}}{otherwise}\f]
|
||||
The function cv::log calculates the natural logarithm of every element of the input array:
|
||||
\f[\texttt{dst} (I) = \log (\texttt{src}(I)) \f]
|
||||
|
||||
Output on zero, negative and special (NaN, Inf) values is undefined.
|
||||
|
||||
where C is a large negative number (about -700 in the current
|
||||
implementation). The maximum relative error is about 7e-6 for
|
||||
single-precision input and less than 1e-10 for double-precision input.
|
||||
Special values (NaN, Inf) are not handled.
|
||||
@param src input array.
|
||||
@param dst output array of the same size and type as src .
|
||||
@sa exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
|
||||
|
|
@ -1443,7 +1515,7 @@ CV_EXPORTS_W void log(InputArray src, OutputArray dst);
|
|||
|
||||
/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle.
|
||||
|
||||
The function polarToCart calculates the Cartesian coordinates of each 2D
|
||||
The function cv::polarToCart calculates the Cartesian coordinates of each 2D
|
||||
vector represented by the corresponding elements of magnitude and angle:
|
||||
\f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f]
|
||||
|
||||
|
|
@ -1466,7 +1538,7 @@ CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle,
|
|||
|
||||
/** @brief Calculates the magnitude and angle of 2D vectors.
|
||||
|
||||
The function cartToPolar calculates either the magnitude, angle, or both
|
||||
The function cv::cartToPolar calculates either the magnitude, angle, or both
|
||||
for every 2D vector (x(I),y(I)):
|
||||
\f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f]
|
||||
|
||||
|
|
@ -1488,7 +1560,7 @@ CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y,
|
|||
|
||||
/** @brief Calculates the rotation angle of 2D vectors.
|
||||
|
||||
The function phase calculates the rotation angle of each 2D vector that
|
||||
The function cv::phase calculates the rotation angle of each 2D vector that
|
||||
is formed from the corresponding elements of x and y :
|
||||
\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f]
|
||||
|
||||
|
|
@ -1507,7 +1579,7 @@ CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle,
|
|||
|
||||
/** @brief Calculates the magnitude of 2D vectors.
|
||||
|
||||
The function magnitude calculates the magnitude of 2D vectors formed
|
||||
The function cv::magnitude calculates the magnitude of 2D vectors formed
|
||||
from the corresponding elements of x and y arrays:
|
||||
\f[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\f]
|
||||
@param x floating-point array of x-coordinates of the vectors.
|
||||
|
|
@ -1520,11 +1592,11 @@ CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude);
|
|||
|
||||
/** @brief Checks every element of an input array for invalid values.
|
||||
|
||||
The functions checkRange check that every array element is neither NaN nor infinite. When minVal \>
|
||||
-DBL_MAX and maxVal \< DBL_MAX, the functions also check that each value is between minVal and
|
||||
The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal \>
|
||||
-DBL_MAX and maxVal \< DBL_MAX, the function also checks that each value is between minVal and
|
||||
maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
|
||||
are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
|
||||
functions either return false (when quiet=true) or throw an exception.
|
||||
function either returns false (when quiet=true) or throws an exception.
|
||||
@param a input array.
|
||||
@param quiet a flag, indicating whether the functions quietly return false when the array elements
|
||||
are out of range or they throw an exception.
|
||||
|
|
@ -1542,7 +1614,7 @@ CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0);
|
|||
|
||||
/** @brief Performs generalized matrix multiplication.
|
||||
|
||||
The function performs generalized matrix multiplication similar to the
|
||||
The function cv::gemm performs generalized matrix multiplication similar to the
|
||||
gemm functions in BLAS level 3. For example,
|
||||
`gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`
|
||||
corresponds to
|
||||
|
|
@ -1573,7 +1645,7 @@ CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
|
|||
|
||||
/** @brief Calculates the product of a matrix and its transposition.
|
||||
|
||||
The function mulTransposed calculates the product of src and its
|
||||
The function cv::mulTransposed calculates the product of src and its
|
||||
transposition:
|
||||
\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\f]
|
||||
if aTa=true , and
|
||||
|
|
@ -1605,9 +1677,9 @@ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
|
|||
|
||||
/** @brief Transposes a matrix.
|
||||
|
||||
The function transpose transposes the matrix src :
|
||||
The function cv::transpose transposes the matrix src :
|
||||
\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
|
||||
@note No complex conjugation is done in case of a complex matrix. It it
|
||||
@note No complex conjugation is done in case of a complex matrix. It
|
||||
should be done separately if needed.
|
||||
@param src input array.
|
||||
@param dst output array of the same type as src.
|
||||
|
|
@ -1616,7 +1688,7 @@ CV_EXPORTS_W void transpose(InputArray src, OutputArray dst);
|
|||
|
||||
/** @brief Performs the matrix transformation of every array element.
|
||||
|
||||
The function transform performs the matrix transformation of every
|
||||
The function cv::transform performs the matrix transformation of every
|
||||
element of the array src and stores the results in dst :
|
||||
\f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f]
|
||||
(when m.cols=src.channels() ), or
|
||||
|
|
@ -1636,13 +1708,13 @@ m.cols or m.cols-1.
|
|||
@param dst output array of the same size and depth as src; it has as
|
||||
many channels as m.rows.
|
||||
@param m transformation 2x2 or 2x3 floating-point matrix.
|
||||
@sa perspectiveTransform, getAffineTransform, estimateRigidTransform, warpAffine, warpPerspective
|
||||
@sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
|
||||
*/
|
||||
CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m );
|
||||
|
||||
/** @brief Performs the perspective matrix transformation of vectors.
|
||||
|
||||
The function perspectiveTransform transforms every element of src by
|
||||
The function cv::perspectiveTransform transforms every element of src by
|
||||
treating it as a 2D or 3D vector, in the following way:
|
||||
\f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f]
|
||||
where
|
||||
|
|
@ -1669,7 +1741,7 @@ CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArr
|
|||
|
||||
/** @brief Copies the lower or the upper half of a square matrix to another half.
|
||||
|
||||
The function completeSymm copies the lower half of a square matrix to
|
||||
The function cv::completeSymm copies the lower half of a square matrix to
|
||||
its another half. The matrix diagonal remains unchanged:
|
||||
* \f$\texttt{mtx}_{ij}=\texttt{mtx}_{ji}\f$ for \f$i > j\f$ if
|
||||
lowerToUpper=false
|
||||
|
|
@ -1684,7 +1756,7 @@ CV_EXPORTS_W void completeSymm(InputOutputArray mtx, bool lowerToUpper = false);
|
|||
|
||||
/** @brief Initializes a scaled identity matrix.
|
||||
|
||||
The function setIdentity initializes a scaled identity matrix:
|
||||
The function cv::setIdentity initializes a scaled identity matrix:
|
||||
\f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f]
|
||||
|
||||
The function can also be emulated using the matrix initializers and the
|
||||
|
|
@ -1701,7 +1773,7 @@ CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s = Scalar(1))
|
|||
|
||||
/** @brief Returns the determinant of a square floating-point matrix.
|
||||
|
||||
The function determinant calculates and returns the determinant of the
|
||||
The function cv::determinant calculates and returns the determinant of the
|
||||
specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the
|
||||
direct method is used. For larger matrices, the function uses LU
|
||||
factorization with partial pivoting.
|
||||
|
|
@ -1716,7 +1788,7 @@ CV_EXPORTS_W double determinant(InputArray mtx);
|
|||
|
||||
/** @brief Returns the trace of a matrix.
|
||||
|
||||
The function trace returns the sum of the diagonal elements of the
|
||||
The function cv::trace returns the sum of the diagonal elements of the
|
||||
matrix mtx .
|
||||
\f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f]
|
||||
@param mtx input matrix.
|
||||
|
|
@ -1725,7 +1797,7 @@ CV_EXPORTS_W Scalar trace(InputArray mtx);
|
|||
|
||||
/** @brief Finds the inverse or pseudo-inverse of a matrix.
|
||||
|
||||
The function invert inverts the matrix src and stores the result in dst
|
||||
The function cv::invert inverts the matrix src and stores the result in dst
|
||||
. When the matrix src is singular or non-square, the function calculates
|
||||
the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
|
||||
minimal, where I is an identity matrix.
|
||||
|
|
@ -1752,7 +1824,7 @@ CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_L
|
|||
|
||||
/** @brief Solves one or more linear systems or least-squares problems.
|
||||
|
||||
The function solve solves a linear system or least-squares problem (the
|
||||
The function cv::solve solves a linear system or least-squares problem (the
|
||||
latter is possible with SVD or QR methods, or by specifying the flag
|
||||
DECOMP_NORMAL ):
|
||||
\f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f]
|
||||
|
|
@ -1777,7 +1849,7 @@ CV_EXPORTS_W bool solve(InputArray src1, InputArray src2,
|
|||
|
||||
/** @brief Sorts each row or each column of a matrix.
|
||||
|
||||
The function sort sorts each matrix row or each matrix column in
|
||||
The function cv::sort sorts each matrix row or each matrix column in
|
||||
ascending or descending order. So you should pass two operation flags to
|
||||
get desired behaviour. If you want to sort matrix rows or columns
|
||||
lexicographically, you can use STL std::sort generic function with the
|
||||
|
|
@ -1792,7 +1864,7 @@ CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags);
|
|||
|
||||
/** @brief Sorts each row or each column of a matrix.
|
||||
|
||||
The function sortIdx sorts each matrix row or each matrix column in the
|
||||
The function cv::sortIdx sorts each matrix row or each matrix column in the
|
||||
ascending or descending order. So you should pass two operation flags to
|
||||
get desired behaviour. Instead of reordering the elements themselves, it
|
||||
stores the indices of sorted elements in the output array. For example:
|
||||
|
|
@ -1826,7 +1898,7 @@ CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots);
|
|||
|
||||
/** @brief Finds the real or complex roots of a polynomial equation.
|
||||
|
||||
The function solvePoly finds real and complex roots of a polynomial equation:
|
||||
The function cv::solvePoly finds real and complex roots of a polynomial equation:
|
||||
\f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f]
|
||||
@param coeffs array of polynomial coefficients.
|
||||
@param roots output (complex) array of roots.
|
||||
|
|
@ -1836,13 +1908,14 @@ CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters
|
|||
|
||||
/** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix.
|
||||
|
||||
The functions eigen calculate just eigenvalues, or eigenvalues and eigenvectors of the symmetric
|
||||
The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
|
||||
matrix src:
|
||||
@code
|
||||
src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
|
||||
@endcode
|
||||
@note in the new and the old interfaces different ordering of eigenvalues and eigenvectors
|
||||
parameters is used.
|
||||
|
||||
@note Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
|
||||
|
||||
@param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
|
||||
(src ^T^ == src).
|
||||
@param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
|
||||
|
|
@ -1850,14 +1923,31 @@ in the descending order.
|
|||
@param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the
|
||||
eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
|
||||
eigenvalues.
|
||||
@sa completeSymm , PCA
|
||||
@sa eigenNonSymmetric, completeSymm , PCA
|
||||
*/
|
||||
CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues,
|
||||
OutputArray eigenvectors = noArray());
|
||||
|
||||
/** @brief Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).
|
||||
|
||||
@note Assumes real eigenvalues.
|
||||
|
||||
The function calculates eigenvalues and eigenvectors (optional) of the square matrix src:
|
||||
@code
|
||||
src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
|
||||
@endcode
|
||||
|
||||
@param src input matrix (CV_32FC1 or CV_64FC1 type).
|
||||
@param eigenvalues output vector of eigenvalues (type is the same type as src).
|
||||
@param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
|
||||
@sa eigen
|
||||
*/
|
||||
CV_EXPORTS_W void eigenNonSymmetric(InputArray src, OutputArray eigenvalues,
|
||||
OutputArray eigenvectors);
|
||||
|
||||
/** @brief Calculates the covariance matrix of a set of vectors.
|
||||
|
||||
The functions calcCovarMatrix calculate the covariance matrix and, optionally, the mean vector of
|
||||
The function cv::calcCovarMatrix calculates the covariance matrix and, optionally, the mean vector of
|
||||
the set of input vectors.
|
||||
@param samples samples stored as separate matrices
|
||||
@param nsamples number of samples
|
||||
|
|
@ -1907,7 +1997,7 @@ CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt,
|
|||
|
||||
/** @brief Calculates the Mahalanobis distance between two vectors.
|
||||
|
||||
The function Mahalanobis calculates and returns the weighted distance between two vectors:
|
||||
The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
|
||||
\f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f]
|
||||
The covariance matrix may be calculated using the cv::calcCovarMatrix function and then inverted using
|
||||
the invert function (preferably using the cv::DECOMP_SVD method, as the most accurate).
|
||||
|
|
@ -1919,7 +2009,7 @@ CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar)
|
|||
|
||||
/** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
|
||||
|
||||
The function performs one of the following:
|
||||
The function cv::dft performs one of the following:
|
||||
- Forward the Fourier transform of a 1D vector of N elements:
|
||||
\f[Y = F^{(N)} \cdot X,\f]
|
||||
where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$
|
||||
|
|
@ -2067,7 +2157,7 @@ CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0, int nonze
|
|||
|
||||
/** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
|
||||
|
||||
The function dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
|
||||
The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
|
||||
floating-point array:
|
||||
- Forward Cosine transform of a 1D vector of N elements:
|
||||
\f[Y = C^{(N)} \cdot X\f]
|
||||
|
|
@ -2118,7 +2208,7 @@ CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0);
|
|||
|
||||
/** @brief Performs the per-element multiplication of two Fourier spectrums.
|
||||
|
||||
The function mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
|
||||
The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
|
||||
matrices that are results of a real or complex Fourier transform.
|
||||
|
||||
The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
|
||||
|
|
@ -2145,7 +2235,7 @@ original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the
|
|||
Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2)
|
||||
are also processed quite efficiently.
|
||||
|
||||
The function getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
|
||||
The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
|
||||
so that the DFT of a vector of size N can be processed efficiently. In the current implementation N
|
||||
= 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r.
|
||||
|
||||
|
|
@ -2161,7 +2251,7 @@ CV_EXPORTS_W int getOptimalDFTSize(int vecsize);
|
|||
|
||||
/** @brief Returns the default random number generator.
|
||||
|
||||
The function theRNG returns the default random number generator. For each thread, there is a
|
||||
The function cv::theRNG returns the default random number generator. For each thread, there is a
|
||||
separate random number generator, so you can use the function safely in multi-thread environments.
|
||||
If you just need to get a single random number using this generator or initialize an array, you can
|
||||
use randu or randn instead. But if you are going to generate many random numbers inside a loop, it
|
||||
|
|
@ -2170,6 +2260,14 @@ is much faster to use this function to retrieve the generator and then use RNG::
|
|||
*/
|
||||
CV_EXPORTS RNG& theRNG();
|
||||
|
||||
/** @brief Sets state of default random number generator.
|
||||
|
||||
The function cv::setRNGSeed sets state of default random number generator to custom value.
|
||||
@param seed new state for default random number generator
|
||||
@sa RNG, randu, randn
|
||||
*/
|
||||
CV_EXPORTS_W void setRNGSeed(int seed);
|
||||
|
||||
/** @brief Generates a single uniformly-distributed random number or an array of random numbers.
|
||||
|
||||
Non-template variant of the function fills the matrix dst with uniformly-distributed
|
||||
|
|
@ -2184,7 +2282,7 @@ CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high);
|
|||
|
||||
/** @brief Fills the array with normally distributed random numbers.
|
||||
|
||||
The function randn fills the matrix dst with normally distributed random numbers with the specified
|
||||
The function cv::randn fills the matrix dst with normally distributed random numbers with the specified
|
||||
mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the
|
||||
value range of the output array data type.
|
||||
@param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels.
|
||||
|
|
@ -2197,7 +2295,7 @@ CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev
|
|||
|
||||
/** @brief Shuffles the array elements randomly.
|
||||
|
||||
The function randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
|
||||
The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
|
||||
swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
|
||||
@param dst input/output numerical 1D array.
|
||||
@param iterFactor scale factor that determines the number of random swap operations (see the details
|
||||
|
|
@ -2316,11 +2414,11 @@ public:
|
|||
The operator performs %PCA of the supplied dataset. It is safe to reuse
|
||||
the same PCA structure for multiple datasets. That is, if the structure
|
||||
has been previously used with another dataset, the existing internal
|
||||
data is reclaimed and the new eigenvalues, @ref eigenvectors , and @ref
|
||||
data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref
|
||||
mean are allocated and computed.
|
||||
|
||||
The computed eigenvalues are sorted from the largest to the smallest and
|
||||
the corresponding eigenvectors are stored as eigenvectors rows.
|
||||
The computed @ref eigenvalues are sorted from the largest to the smallest and
|
||||
the corresponding @ref eigenvectors are stored as eigenvectors rows.
|
||||
|
||||
@param data input samples stored as the matrix rows or as the matrix
|
||||
columns.
|
||||
|
|
@ -2400,11 +2498,17 @@ public:
|
|||
*/
|
||||
void backProject(InputArray vec, OutputArray result) const;
|
||||
|
||||
/** @brief write and load PCA matrix
|
||||
/** @brief write PCA objects
|
||||
|
||||
*/
|
||||
void write(FileStorage& fs ) const;
|
||||
void read(const FileNode& fs);
|
||||
Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage
|
||||
*/
|
||||
void write(FileStorage& fs) const;
|
||||
|
||||
/** @brief load PCA objects
|
||||
|
||||
Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode
|
||||
*/
|
||||
void read(const FileNode& fn);
|
||||
|
||||
Mat eigenvectors; //!< eigenvectors of the covariation matrix
|
||||
Mat eigenvalues; //!< eigenvalues of the covariation matrix
|
||||
|
|
@ -2716,7 +2820,7 @@ public:
|
|||
double a1 = rng.uniform((double)0, (double)1);
|
||||
|
||||
// produces float from [0, 1)
|
||||
double b = rng.uniform(0.f, 1.f);
|
||||
float b = rng.uniform(0.f, 1.f);
|
||||
|
||||
// produces double from [0, 1)
|
||||
double c = rng.uniform(0., 1.);
|
||||
|
|
@ -2732,8 +2836,8 @@ public:
|
|||
want a floating-point random number, but the range boundaries are
|
||||
integer numbers, either put dots in the end, if they are constants, or
|
||||
use explicit type cast operators, as in the a1 initialization above.
|
||||
@param a lower inclusive boundary of the returned random numbers.
|
||||
@param b upper non-inclusive boundary of the returned random numbers.
|
||||
@param a lower inclusive boundary of the returned random number.
|
||||
@param b upper non-inclusive boundary of the returned random number.
|
||||
*/
|
||||
int uniform(int a, int b);
|
||||
/** @overload */
|
||||
|
|
@ -2788,6 +2892,8 @@ public:
|
|||
double gaussian(double sigma);
|
||||
|
||||
uint64 state;
|
||||
|
||||
bool operator ==(const RNG& other) const;
|
||||
};
|
||||
|
||||
/** @brief Mersenne Twister random number generator
|
||||
|
|
@ -2987,19 +3093,25 @@ public:
|
|||
*/
|
||||
virtual void write(FileStorage& fs) const { (void)fs; }
|
||||
|
||||
/** @brief simplified API for language bindings
|
||||
* @overload
|
||||
*/
|
||||
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
||||
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
*/
|
||||
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
|
||||
*/
|
||||
virtual bool empty() const { return false; }
|
||||
CV_WRAP virtual bool empty() const { return false; }
|
||||
|
||||
/** @brief Reads algorithm from the file node
|
||||
|
||||
This is static template method of Algorithm. It's usage is following (in the case of SVM):
|
||||
@code
|
||||
Ptr<SVM> svm = Algorithm::read<SVM>(fn);
|
||||
cv::FileStorage fsRead("example.xml", FileStorage::READ);
|
||||
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
|
||||
@endcode
|
||||
In order to make this method work, the derived class must overwrite Algorithm::read(const
|
||||
FileNode& fn) and also have static create() method without parameters
|
||||
|
|
@ -3027,7 +3139,9 @@ public:
|
|||
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
|
||||
{
|
||||
FileStorage fs(filename, FileStorage::READ);
|
||||
CV_Assert(fs.isOpened());
|
||||
FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
|
||||
if (fn.empty()) return Ptr<_Tp>();
|
||||
Ptr<_Tp> obj = _Tp::create();
|
||||
obj->read(fn);
|
||||
return !obj->empty() ? obj : Ptr<_Tp>();
|
||||
|
|
@ -3059,6 +3173,9 @@ public:
|
|||
/** 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. */
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
|
||||
protected:
|
||||
void writeFormat(FileStorage& fs) const;
|
||||
};
|
||||
|
||||
struct Param {
|
||||
|
|
@ -3164,5 +3281,6 @@ template<> struct ParamType<uchar>
|
|||
#include "opencv2/core/cvstd.inl.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/core/optim.hpp"
|
||||
#include "opencv2/core/ovx.hpp"
|
||||
|
||||
#endif /*__OPENCV_CORE_HPP__*/
|
||||
#endif /*OPENCV_CORE_HPP*/
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_AFFINE3_HPP__
|
||||
#define __OPENCV_CORE_AFFINE3_HPP__
|
||||
#ifndef OPENCV_CORE_AFFINE3_HPP
|
||||
#define OPENCV_CORE_AFFINE3_HPP
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
@ -153,15 +153,24 @@ namespace cv
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 16,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; };
|
||||
} // namespace
|
||||
|
||||
//! @} core
|
||||
|
||||
}
|
||||
|
|
@ -202,7 +211,7 @@ cv::Affine3<T>::Affine3(const Vec3& _rvec, const Vec3& t)
|
|||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
CV_Assert(data.type() == cv::traits::Type<T>::value);
|
||||
|
||||
if (data.cols == 4 && data.rows == 4)
|
||||
{
|
||||
|
|
@ -213,11 +222,13 @@ cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
|||
{
|
||||
rotation(data(Rect(0, 0, 3, 3)));
|
||||
translation(data(Rect(3, 0, 1, 3)));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation(data);
|
||||
translation(t);
|
||||
}
|
||||
|
||||
rotation(data);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
|
@ -241,30 +252,25 @@ void cv::Affine3<T>::rotation(const Mat3& R)
|
|||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Vec3& _rvec)
|
||||
{
|
||||
double rx = _rvec[0], ry = _rvec[1], rz = _rvec[2];
|
||||
double theta = std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
double theta = norm(_rvec);
|
||||
|
||||
if (theta < DBL_EPSILON)
|
||||
rotation(Mat3::eye());
|
||||
else
|
||||
{
|
||||
const double I[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
|
||||
|
||||
double c = std::cos(theta);
|
||||
double s = std::sin(theta);
|
||||
double c1 = 1. - c;
|
||||
double itheta = (theta != 0) ? 1./theta : 0.;
|
||||
|
||||
rx *= itheta; ry *= itheta; rz *= itheta;
|
||||
Point3_<T> r = _rvec*itheta;
|
||||
|
||||
double rrt[] = { rx*rx, rx*ry, rx*rz, rx*ry, ry*ry, ry*rz, rx*rz, ry*rz, rz*rz };
|
||||
double _r_x_[] = { 0, -rz, ry, rz, 0, -rx, -ry, rx, 0 };
|
||||
Mat3 R;
|
||||
Mat3 rrt( r.x*r.x, r.x*r.y, r.x*r.z, r.x*r.y, r.y*r.y, r.y*r.z, r.x*r.z, r.y*r.z, r.z*r.z );
|
||||
Mat3 r_x( 0, -r.z, r.y, r.z, 0, -r.x, -r.y, r.x, 0 );
|
||||
|
||||
// R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x]
|
||||
// where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0]
|
||||
for(int k = 0; k < 9; ++k)
|
||||
R.val[k] = static_cast<float_type>(c*I[k] + c1*rrt[k] + s*_r_x_[k]);
|
||||
Mat3 R = c*Mat3::eye() + c1*rrt + s*r_x;
|
||||
|
||||
rotation(R);
|
||||
}
|
||||
|
|
@ -274,7 +280,7 @@ void cv::Affine3<T>::rotation(const Vec3& _rvec)
|
|||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const cv::Mat& data)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
CV_Assert(data.type() == cv::traits::Type<T>::value);
|
||||
|
||||
if (data.cols == 3 && data.rows == 3)
|
||||
{
|
||||
|
|
@ -488,21 +494,21 @@ cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v)
|
|||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine)
|
||||
{
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, affine.matrix().data()).copyTo(matrix);
|
||||
cv::Mat(4, 4, cv::traits::Type<T>::value, affine.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine)
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> a = affine;
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, a.matrix().data()).copyTo(matrix);
|
||||
cv::Mat(4, 4, cv::traits::Type<T>::value, a.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> r;
|
||||
cv::Mat hdr(4, 4, cv::DataType<T>::type, r.matrix().data());
|
||||
cv::Mat hdr(4, 4, cv::traits::Type<T>::value, r.matrix().data());
|
||||
cv::Mat(matrix, false).copyTo(hdr);
|
||||
return r;
|
||||
}
|
||||
|
|
@ -519,4 +525,4 @@ cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine>() const
|
|||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __OPENCV_CORE_AFFINE3_HPP__ */
|
||||
#endif /* OPENCV_CORE_AFFINE3_HPP */
|
||||
|
|
@ -42,13 +42,15 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_BASE_HPP__
|
||||
#define __OPENCV_CORE_BASE_HPP__
|
||||
#ifndef OPENCV_CORE_BASE_HPP
|
||||
#define OPENCV_CORE_BASE_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error base.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -64,38 +66,38 @@ namespace cv
|
|||
namespace Error {
|
||||
//! error codes
|
||||
enum Code {
|
||||
StsOk= 0, //!< everithing is ok
|
||||
StsOk= 0, //!< everything is ok
|
||||
StsBackTrace= -1, //!< pseudo error for back trace
|
||||
StsError= -2, //!< unknown /unspecified error
|
||||
StsInternal= -3, //!< internal error (bad state)
|
||||
StsNoMem= -4, //!< insufficient memory
|
||||
StsBadArg= -5, //!< function arg/param is bad
|
||||
StsBadFunc= -6, //!< unsupported function
|
||||
StsNoConv= -7, //!< iter. didn't converge
|
||||
StsNoConv= -7, //!< iteration didn't converge
|
||||
StsAutoTrace= -8, //!< tracing
|
||||
HeaderIsNull= -9, //!< image header is NULL
|
||||
BadImageSize= -10, //!< image size is invalid
|
||||
BadOffset= -11, //!< offset is invalid
|
||||
BadDataPtr= -12, //!<
|
||||
BadStep= -13, //!<
|
||||
BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix.
|
||||
BadModelOrChSeq= -14, //!<
|
||||
BadNumChannels= -15, //!<
|
||||
BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices.
|
||||
BadNumChannel1U= -16, //!<
|
||||
BadDepth= -17, //!<
|
||||
BadDepth= -17, //!< input image depth is not supported by the function
|
||||
BadAlphaChannel= -18, //!<
|
||||
BadOrder= -19, //!<
|
||||
BadOrigin= -20, //!<
|
||||
BadAlign= -21, //!<
|
||||
BadOrder= -19, //!< number of dimensions is out of range
|
||||
BadOrigin= -20, //!< incorrect input origin
|
||||
BadAlign= -21, //!< incorrect input align
|
||||
BadCallBack= -22, //!<
|
||||
BadTileSize= -23, //!<
|
||||
BadCOI= -24, //!<
|
||||
BadROISize= -25, //!<
|
||||
BadCOI= -24, //!< input COI is not supported
|
||||
BadROISize= -25, //!< incorrect input roi
|
||||
MaskIsTiled= -26, //!<
|
||||
StsNullPtr= -27, //!< null pointer
|
||||
StsVecLengthErr= -28, //!< incorrect vector length
|
||||
StsFilterStructContentErr= -29, //!< incorr. filter structure content
|
||||
StsKernelStructContentErr= -30, //!< incorr. transform kernel content
|
||||
StsFilterOffsetErr= -31, //!< incorrect filter ofset value
|
||||
StsFilterStructContentErr= -29, //!< incorrect filter structure content
|
||||
StsKernelStructContentErr= -30, //!< incorrect transform kernel content
|
||||
StsFilterOffsetErr= -31, //!< incorrect filter offset value
|
||||
StsBadSize= -201, //!< the input/output structure size is incorrect
|
||||
StsDivByZero= -202, //!< division by zero
|
||||
StsInplaceNotSupported= -203, //!< in-place operation is not supported
|
||||
|
|
@ -111,13 +113,13 @@ enum Code {
|
|||
StsNotImplemented= -213, //!< the requested function/feature is not implemented
|
||||
StsBadMemBlock= -214, //!< an allocated block has been corrupted
|
||||
StsAssert= -215, //!< assertion failed
|
||||
GpuNotSupported= -216,
|
||||
GpuApiCallError= -217,
|
||||
OpenGlNotSupported= -218,
|
||||
OpenGlApiCallError= -219,
|
||||
OpenCLApiCallError= -220,
|
||||
GpuNotSupported= -216, //!< no CUDA support
|
||||
GpuApiCallError= -217, //!< GPU API call error
|
||||
OpenGlNotSupported= -218, //!< no OpenGL support
|
||||
OpenGlApiCallError= -219, //!< OpenGL API call error
|
||||
OpenCLApiCallError= -220, //!< OpenCL API call error
|
||||
OpenCLDoubleNotSupported= -221,
|
||||
OpenCLInitError= -222,
|
||||
OpenCLInitError= -222, //!< OpenCL initialization error
|
||||
OpenCLNoAMDBlasFft= -223
|
||||
};
|
||||
} //Error
|
||||
|
|
@ -150,46 +152,57 @@ enum DecompTypes {
|
|||
};
|
||||
|
||||
/** norm types
|
||||
- For one array:
|
||||
\f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{ \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
|
||||
|
||||
- Absolute norm for two arrays
|
||||
\f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
|
||||
src1 and src2 denote input arrays.
|
||||
*/
|
||||
|
||||
- Relative norm for two arrays
|
||||
\f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
|
||||
|
||||
As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
|
||||
The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
|
||||
is calculated as follows
|
||||
\f{align*}
|
||||
\| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
|
||||
\| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
|
||||
\| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
|
||||
\f}
|
||||
and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
|
||||
\f{align*}
|
||||
\| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
|
||||
\| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
|
||||
\| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
|
||||
\f}
|
||||
The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$.
|
||||
It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$.
|
||||

|
||||
*/
|
||||
enum NormTypes { NORM_INF = 1,
|
||||
enum NormTypes {
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_INF = 1,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{\| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\)}
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) }
|
||||
\f]*/
|
||||
NORM_L1 = 2,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_L2 = 4,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{ \| \texttt{src1} \| _{L_2} ^{2} = \sum_I \texttt{src1}(I)^2} {if \(\texttt{normType} = \texttt{NORM_L2SQR}\)}
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} ^{2} = \sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2 }{if \(\texttt{normType} = \texttt{NORM_L2SQR}\) }
|
||||
{ \left(\frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}}\right)^2 }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_L2SQR = 5,
|
||||
/**
|
||||
In the case of one input array, calculates the Hamming distance of the array from zero,
|
||||
In the case of two input arrays, calculates the Hamming distance between the arrays.
|
||||
*/
|
||||
NORM_HAMMING = 6,
|
||||
/**
|
||||
Similar to NORM_HAMMING, but in the calculation, each two bits of the input sequence will
|
||||
be added and treated as a single bit to be used in the same calculation as NORM_HAMMING.
|
||||
*/
|
||||
NORM_HAMMING2 = 7,
|
||||
NORM_TYPE_MASK = 7,
|
||||
NORM_TYPE_MASK = 7, //!< bit-mask which can be used to separate norm type from norm flags
|
||||
NORM_RELATIVE = 8, //!< flag
|
||||
NORM_MINMAX = 32 //!< flag
|
||||
};
|
||||
|
|
@ -237,6 +250,10 @@ enum DftFlags {
|
|||
into a real array and inverse transformation is executed, the function treats the input as a
|
||||
packed complex-conjugate symmetrical array, and the output will also be a real array). */
|
||||
DFT_REAL_OUTPUT = 32,
|
||||
/** specifies that input is complex input. If this flag is set, the input must have 2 channels.
|
||||
On the other hand, for backwards compatibility reason, if input has 2 channels, input is
|
||||
already considered complex. */
|
||||
DFT_COMPLEX_INPUT = 64,
|
||||
/** performs an inverse 1D or 2D transform instead of the default forward transform. */
|
||||
DCT_INVERSE = DFT_INVERSE,
|
||||
/** performs a forward or inverse transform of every individual row of the input
|
||||
|
|
@ -325,7 +342,23 @@ enum BorderTypes {
|
|||
#define CV_SUPPRESS_DEPRECATED_START
|
||||
#define CV_SUPPRESS_DEPRECATED_END
|
||||
#endif
|
||||
|
||||
#define CV_UNUSED(name) (void)name
|
||||
|
||||
#if defined __GNUC__ && !defined __EXCEPTIONS
|
||||
#define CV_TRY
|
||||
#define CV_CATCH(A, B) for (A B; false; )
|
||||
#define CV_CATCH_ALL if (false)
|
||||
#define CV_THROW(A) abort()
|
||||
#define CV_RETHROW() abort()
|
||||
#else
|
||||
#define CV_TRY try
|
||||
#define CV_CATCH(A, B) catch(const A & B)
|
||||
#define CV_CATCH_ALL catch(...)
|
||||
#define CV_THROW(A) throw A
|
||||
#define CV_RETHROW() throw
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
/*! @brief Signals an error and raises the exception.
|
||||
|
|
@ -336,8 +369,8 @@ It is possible to alternate error processing by using redirectError().
|
|||
@param _code - error code (Error::Code)
|
||||
@param _err - error description
|
||||
@param _func - function name. Available only when the compiler supports getting it
|
||||
@param _file - source file name where the error has occured
|
||||
@param _line - line number in the source file where the error has occured
|
||||
@param _file - source file name where the error has occurred
|
||||
@param _line - line number in the source file where the error has occurred
|
||||
@see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
|
||||
*/
|
||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||
|
|
@ -375,6 +408,17 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
|
|||
#define CV_Func ""
|
||||
#endif
|
||||
|
||||
#ifdef CV_STATIC_ANALYSIS
|
||||
// In practice, some macro are not processed correctly (noreturn is not detected).
|
||||
// We need to use simplified definition for them.
|
||||
#define CV_Error(...) do { abort(); } while (0)
|
||||
#define CV_Error_(...) do { abort(); } while (0)
|
||||
#define CV_Assert(cond) do { if (!(cond)) abort(); } while (0)
|
||||
#define CV_ErrorNoReturn(...) do { abort(); } while (0)
|
||||
#define CV_ErrorNoReturn_(...) do { abort(); } while (0)
|
||||
|
||||
#else // CV_STATIC_ANALYSIS
|
||||
|
||||
/** @brief Call the error handler.
|
||||
|
||||
Currently, the error handler prints the error code and the error message to the standard
|
||||
|
|
@ -407,7 +451,22 @@ The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression.
|
|||
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 ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
#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)
|
||||
|
||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
#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_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
||||
#define CV_Assert_5( expr1, expr2, expr3, expr4, expr5 ) CV_Assert_4(expr1, expr2, expr3, expr4); CV_Assert_1(expr5)
|
||||
#define CV_Assert_6( expr1, expr2, expr3, expr4, expr5, expr6 ) CV_Assert_5(expr1, expr2, expr3, expr4, expr5); CV_Assert_1(expr6)
|
||||
#define CV_Assert_7( expr1, expr2, expr3, expr4, expr5, expr6, expr7 ) CV_Assert_6(expr1, expr2, expr3, expr4, expr5, expr6 ); CV_Assert_1(expr7)
|
||||
#define CV_Assert_8( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ) CV_Assert_7(expr1, expr2, expr3, expr4, expr5, expr6, expr7 ); CV_Assert_1(expr8)
|
||||
#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(...) CVAUX_CONCAT(CV_Assert_, CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__)
|
||||
|
||||
/** same as CV_Error(code,msg), but does not return */
|
||||
#define CV_ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
|
|
@ -415,6 +474,8 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
|
|||
/** same as CV_Error_(code,args), but does not return */
|
||||
#define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
#endif // CV_STATIC_ANALYSIS
|
||||
|
||||
/** replaced with CV_Assert(expr) in Debug configuration */
|
||||
#ifdef _DEBUG
|
||||
# define CV_DbgAssert(expr) CV_Assert(expr)
|
||||
|
|
@ -665,13 +726,23 @@ namespace cudev
|
|||
|
||||
namespace ipp
|
||||
{
|
||||
CV_EXPORTS int getIppFeatures();
|
||||
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
CV_EXPORTS unsigned long long getIppFeatures();
|
||||
#else
|
||||
CV_EXPORTS int getIppFeatures();
|
||||
#endif
|
||||
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
|
||||
int line = 0);
|
||||
CV_EXPORTS int getIppStatus();
|
||||
CV_EXPORTS String getIppErrorLocation();
|
||||
CV_EXPORTS bool useIPP();
|
||||
CV_EXPORTS void setUseIPP(bool flag);
|
||||
CV_EXPORTS int getIppStatus();
|
||||
CV_EXPORTS String getIppErrorLocation();
|
||||
CV_EXPORTS_W bool useIPP();
|
||||
CV_EXPORTS_W void setUseIPP(bool flag);
|
||||
CV_EXPORTS_W String getIppVersion();
|
||||
|
||||
// IPP Not-Exact mode. This function may force use of IPP then both IPP and OpenCV provide proper results
|
||||
// but have internal accuracy differences which have to much direct or indirect impact on accuracy tests.
|
||||
CV_EXPORTS_W bool useIPP_NE();
|
||||
CV_EXPORTS_W void setUseIPP_NE(bool flag);
|
||||
|
||||
} // ipp
|
||||
|
||||
|
|
@ -685,5 +756,6 @@ CV_EXPORTS void setUseIPP(bool flag);
|
|||
} // cv
|
||||
|
||||
#include "opencv2/core/neon_utils.hpp"
|
||||
#include "opencv2/core/vsx_utils.hpp"
|
||||
|
||||
#endif //__OPENCV_CORE_BASE_HPP__
|
||||
#endif //OPENCV_CORE_BASE_HPP
|
||||
|
|
@ -4,8 +4,13 @@
|
|||
//
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
#ifndef __OPENCV_CORE_BUFFER_POOL_HPP__
|
||||
#define __OPENCV_CORE_BUFFER_POOL_HPP__
|
||||
#ifndef OPENCV_CORE_BUFFER_POOL_HPP
|
||||
#define OPENCV_CORE_BUFFER_POOL_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4265)
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
|
@ -28,4 +33,8 @@ public:
|
|||
|
||||
}
|
||||
|
||||
#endif // __OPENCV_CORE_BUFFER_POOL_HPP__
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_CORE_BUFFER_POOL_HPP
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//M*/
|
||||
|
||||
|
||||
#ifndef __OPENCV_CORE_C_H__
|
||||
#define __OPENCV_CORE_C_H__
|
||||
#ifndef OPENCV_CORE_C_H
|
||||
#define OPENCV_CORE_C_H
|
||||
|
||||
#include "opencv2/core/types_c.h"
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect );
|
|||
|
||||
/** @brief Returns array row or row span.
|
||||
|
||||
The functions return the header, corresponding to a specified row/row span of the input array.
|
||||
The function returns the header, corresponding to a specified row/row span of the input array.
|
||||
cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1).
|
||||
@param arr Input array
|
||||
@param submat Pointer to the resulting sub-array header
|
||||
|
|
@ -385,7 +385,7 @@ CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row )
|
|||
|
||||
/** @brief Returns one of more array columns.
|
||||
|
||||
The functions return the header, corresponding to a specified column span of the input array. That
|
||||
The function returns the header, corresponding to a specified column span of the input array. That
|
||||
|
||||
is, no data is copied. Therefore, any modifications of the submatrix will affect the original array.
|
||||
If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for
|
||||
|
|
@ -1976,8 +1976,16 @@ CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header,
|
|||
|
||||
The function opens file storage for reading or writing data. In the latter case, a new file is
|
||||
created or an existing file is rewritten. The type of the read or written file is determined by the
|
||||
filename extension: .xml for XML and .yml or .yaml for YAML. The function returns a pointer to the
|
||||
CvFileStorage structure. If the file cannot be opened then the function returns NULL.
|
||||
filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON.
|
||||
|
||||
At the same time, it also supports adding parameters like "example.xml?base64". The three ways
|
||||
are the same:
|
||||
@snippet samples/cpp/filestorage_base64.cpp suffix_in_file_name
|
||||
@snippet samples/cpp/filestorage_base64.cpp flag_write_base64
|
||||
@snippet samples/cpp/filestorage_base64.cpp flag_write_and_flag_base64
|
||||
|
||||
The function returns a pointer to the CvFileStorage structure.
|
||||
If the file cannot be opened then the function returns NULL.
|
||||
@param filename Name of the file associated with the storage
|
||||
@param memstorage Memory storage used for temporary data and for
|
||||
: storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory
|
||||
|
|
@ -1985,6 +1993,7 @@ CvFileStorage structure. If the file cannot be opened then the function returns
|
|||
@param flags Can be one of the following:
|
||||
> - **CV_STORAGE_READ** the storage is open for reading
|
||||
> - **CV_STORAGE_WRITE** the storage is open for writing
|
||||
(use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64)
|
||||
@param encoding
|
||||
*/
|
||||
CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage,
|
||||
|
|
@ -2022,7 +2031,8 @@ One and only one of the two above flags must be specified
|
|||
@param type_name Optional parameter - the object type name. In
|
||||
case of XML it is written as a type_id attribute of the structure opening tag. In the case of
|
||||
YAML it is written after a colon following the structure name (see the example in
|
||||
CvFileStorage description). Mainly it is used with user objects. When the storage is read, the
|
||||
CvFileStorage description). In case of JSON it is written as a name/value pair.
|
||||
Mainly it is used with user objects. When the storage is read, the
|
||||
encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ).
|
||||
@param attributes This parameter is not used in the current implementation
|
||||
*/
|
||||
|
|
@ -2162,7 +2172,7 @@ the file with multiple streams looks like this:
|
|||
@endcode
|
||||
The YAML file will look like this:
|
||||
@code{.yaml}
|
||||
%YAML:1.0
|
||||
%YAML 1.0
|
||||
# stream #1 data
|
||||
...
|
||||
---
|
||||
|
|
@ -2187,6 +2197,28 @@ to a sequence rather than a map.
|
|||
CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src,
|
||||
int len, const char* dt );
|
||||
|
||||
/** @brief Writes multiple numbers in Base64.
|
||||
|
||||
If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used,
|
||||
this function will be the same as cvWriteRawData. If neither, the main
|
||||
difference is that it outputs a sequence in Base64 encoding rather than
|
||||
in plain text.
|
||||
|
||||
This function can only be used to write a sequence with a type "binary".
|
||||
|
||||
Consider the following two examples where their output is the same:
|
||||
@snippet samples/cpp/filestorage_base64.cpp without_base64_flag
|
||||
and
|
||||
@snippet samples/cpp/filestorage_base64.cpp with_write_base64_flag
|
||||
|
||||
@param fs File storage
|
||||
@param src Pointer to the written array
|
||||
@param len Number of the array elements to write
|
||||
@param dt Specification of each array element, see @ref format_spec "format specification"
|
||||
*/
|
||||
CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src,
|
||||
int len, const char* dt );
|
||||
|
||||
/** @brief Returns a unique pointer for a given name.
|
||||
|
||||
The function returns a unique pointer for each particular file node name. This pointer can be then
|
||||
|
|
@ -2468,7 +2500,7 @@ CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src,
|
|||
/** @brief Writes a file node to another file storage.
|
||||
|
||||
The function writes a copy of a file node to file storage. Possible applications of the function are
|
||||
merging several file storages into one and conversion between XML and YAML formats.
|
||||
merging several file storages into one and conversion between XML, YAML and JSON formats.
|
||||
@param fs Destination file storage
|
||||
@param new_node_name New name of the file node in the destination file storage. To keep the
|
||||
existing name, use cvcvGetFileNodeName
|
||||
|
|
@ -2622,7 +2654,7 @@ CVAPI(int) cvGetErrMode( void );
|
|||
/** Sets error processing mode, returns previously used mode */
|
||||
CVAPI(int) cvSetErrMode( int mode );
|
||||
|
||||
/** Sets error status and performs some additonal actions (displaying message box,
|
||||
/** Sets error status and performs some additional actions (displaying message box,
|
||||
writing message to stderr, terminating application etc.)
|
||||
depending on the current error mode */
|
||||
CVAPI(void) cvError( int status, const char* func_name,
|
||||
|
|
@ -2631,7 +2663,7 @@ CVAPI(void) cvError( int status, const char* func_name,
|
|||
/** Retrieves textual description of the error given its code */
|
||||
CVAPI(const char*) cvErrorStr( int status );
|
||||
|
||||
/** Retrieves detailed information about the last error occured */
|
||||
/** Retrieves detailed information about the last error occurred */
|
||||
CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description,
|
||||
const char** filename, int* line );
|
||||
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CUDA_HPP__
|
||||
#define __OPENCV_CORE_CUDA_HPP__
|
||||
#ifndef OPENCV_CORE_CUDA_HPP
|
||||
#define OPENCV_CORE_CUDA_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error cuda.hpp header must be compiled as C++
|
||||
|
|
@ -327,6 +327,34 @@ The function does not reallocate memory if the matrix has proper attributes alre
|
|||
*/
|
||||
CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr);
|
||||
|
||||
/** @brief BufferPool for use with CUDA streams
|
||||
|
||||
* BufferPool utilizes cuda::Stream's allocator to create new buffers. It is
|
||||
* particularly useful when BufferPoolUsage is set to true, or a custom
|
||||
* allocator is specified for the cuda::Stream, and you want to implement your
|
||||
* own stream based functions utilizing the same underlying GPU memory
|
||||
* management.
|
||||
*/
|
||||
class CV_EXPORTS BufferPool
|
||||
{
|
||||
public:
|
||||
|
||||
//! Gets the BufferPool for the given stream.
|
||||
explicit BufferPool(Stream& stream);
|
||||
|
||||
//! Allocates a new GpuMat of given size and type.
|
||||
GpuMat getBuffer(int rows, int cols, int type);
|
||||
|
||||
//! Allocates a new GpuMat of given size and type.
|
||||
GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
|
||||
|
||||
//! Returns the allocator associated with the stream.
|
||||
Ptr<GpuMat::Allocator> getAllocator() const { return allocator_; }
|
||||
|
||||
private:
|
||||
Ptr<GpuMat::Allocator> allocator_;
|
||||
};
|
||||
|
||||
//! BufferPool management (must be called before Stream creation)
|
||||
CV_EXPORTS void setBufferPoolUsage(bool on);
|
||||
CV_EXPORTS void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount);
|
||||
|
|
@ -447,7 +475,26 @@ CV_EXPORTS void unregisterPageLocked(Mat& m);
|
|||
functions use the constant GPU memory, and next call may update the memory before the previous one
|
||||
has been finished. But calling different operations asynchronously is safe because each operation
|
||||
has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are
|
||||
also safe. :
|
||||
also safe.
|
||||
|
||||
@note The Stream class is not thread-safe. Please use different Stream objects for different CPU threads.
|
||||
|
||||
@code
|
||||
void thread1()
|
||||
{
|
||||
cv::cuda::Stream stream1;
|
||||
cv::cuda::func1(..., stream1);
|
||||
}
|
||||
|
||||
void thread2()
|
||||
{
|
||||
cv::cuda::Stream stream2;
|
||||
cv::cuda::func2(..., stream2);
|
||||
}
|
||||
@endcode
|
||||
|
||||
@note By default all CUDA routines are launched in Stream::Null() object, if the stream is not specified by user.
|
||||
In multi-threading environment the stream objects must be passed explicitly (see previous note).
|
||||
*/
|
||||
class CV_EXPORTS Stream
|
||||
{
|
||||
|
|
@ -460,6 +507,9 @@ public:
|
|||
//! creates a new asynchronous stream
|
||||
Stream();
|
||||
|
||||
//! creates a new asynchronous stream with custom allocator
|
||||
Stream(const Ptr<GpuMat::Allocator>& allocator);
|
||||
|
||||
/** @brief Returns true if the current stream queue is finished. Otherwise, it returns false.
|
||||
*/
|
||||
bool queryIfComplete() const;
|
||||
|
|
@ -545,7 +595,8 @@ private:
|
|||
/** @brief Returns the number of installed CUDA-enabled devices.
|
||||
|
||||
Use this function before any other CUDA functions calls. If OpenCV is compiled without CUDA support,
|
||||
this function returns 0.
|
||||
this function returns 0. If the CUDA driver is not installed, or is incompatible, this function
|
||||
returns -1.
|
||||
*/
|
||||
CV_EXPORTS int getCudaEnabledDeviceCount();
|
||||
|
||||
|
|
@ -836,6 +887,15 @@ private:
|
|||
CV_EXPORTS void printCudaDeviceInfo(int device);
|
||||
CV_EXPORTS void printShortCudaDeviceInfo(int device);
|
||||
|
||||
/** @brief Converts an array to half precision floating number.
|
||||
|
||||
@param _src input array.
|
||||
@param _dst output array.
|
||||
@param stream Stream for the asynchronous version.
|
||||
@sa convertFp16
|
||||
*/
|
||||
CV_EXPORTS void convertFp16(InputArray _src, OutputArray _dst, Stream& stream = Stream::Null());
|
||||
|
||||
//! @} cudacore_init
|
||||
|
||||
}} // namespace cv { namespace cuda {
|
||||
|
|
@ -843,4 +903,4 @@ CV_EXPORTS void printShortCudaDeviceInfo(int device);
|
|||
|
||||
#include "opencv2/core/cuda.inl.hpp"
|
||||
|
||||
#endif /* __OPENCV_CORE_CUDA_HPP__ */
|
||||
#endif /* OPENCV_CORE_CUDA_HPP */
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CUDAINL_HPP__
|
||||
#define __OPENCV_CORE_CUDAINL_HPP__
|
||||
#ifndef OPENCV_CORE_CUDAINL_HPP
|
||||
#define OPENCV_CORE_CUDAINL_HPP
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
|
|
@ -628,4 +628,4 @@ Mat::Mat(const cuda::GpuMat& m)
|
|||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_CUDAINL_HPP__
|
||||
#endif // OPENCV_CORE_CUDAINL_HPP
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP__
|
||||
#define __OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP__
|
||||
#ifndef OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP
|
||||
#define OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error cuda_stream_accessor.hpp header must be compiled as C++
|
||||
|
|
@ -83,4 +83,4 @@ namespace cv
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* __OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP__ */
|
||||
#endif /* OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP */
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CUDA_TYPES_HPP__
|
||||
#define __OPENCV_CORE_CUDA_TYPES_HPP__
|
||||
#ifndef OPENCV_CORE_CUDA_TYPES_HPP
|
||||
#define OPENCV_CORE_CUDA_TYPES_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error cuda_types.hpp header must be compiled as C++
|
||||
|
|
@ -132,4 +132,4 @@ namespace cv
|
|||
|
||||
//! @endcond
|
||||
|
||||
#endif /* __OPENCV_CORE_CUDA_TYPES_HPP__ */
|
||||
#endif /* OPENCV_CORE_CUDA_TYPES_HPP */
|
||||
228
lib/3rdParty/OpenCV3.4/include/opencv2/core/cv_cpu_dispatch.h
vendored
Normal file
228
lib/3rdParty/OpenCV3.4/include/opencv2/core/cv_cpu_dispatch.h
vendored
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
// 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.
|
||||
|
||||
#if defined __OPENCV_BUILD \
|
||||
|
||||
#include "cv_cpu_config.h"
|
||||
#include "cv_cpu_helper.h"
|
||||
|
||||
#ifdef CV_CPU_DISPATCH_MODE
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE)
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
|
||||
#else
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline {
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
|
||||
#endif
|
||||
|
||||
|
||||
#define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */
|
||||
#define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
#define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__))
|
||||
#define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros
|
||||
|
||||
|
||||
#if defined CV_ENABLE_INTRINSICS \
|
||||
&& !defined CV_DISABLE_OPTIMIZATION \
|
||||
&& !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \
|
||||
|
||||
#ifdef CV_CPU_COMPILE_SSE2
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE3
|
||||
# include <pmmintrin.h>
|
||||
# define CV_SSE3 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSSE3
|
||||
# include <tmmintrin.h>
|
||||
# define CV_SSSE3 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE4_1
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE4_2
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_POPCNT
|
||||
# ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# if defined(_M_X64)
|
||||
# define CV_POPCNT_U64 _mm_popcnt_u64
|
||||
# endif
|
||||
# define CV_POPCNT_U32 _mm_popcnt_u32
|
||||
# else
|
||||
# include <popcntintrin.h>
|
||||
# if defined(__x86_64__)
|
||||
# define CV_POPCNT_U64 __builtin_popcountll
|
||||
# endif
|
||||
# define CV_POPCNT_U32 __builtin_popcount
|
||||
# endif
|
||||
# define CV_POPCNT 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_AVX
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_FP16
|
||||
# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
|
||||
# include <arm_neon.h>
|
||||
# else
|
||||
# include <immintrin.h>
|
||||
# endif
|
||||
# define CV_FP16 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_AVX2
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_FMA3
|
||||
# define CV_FMA3 1
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_NEON__) || defined(__aarch64__)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
|
||||
# include <altivec.h>
|
||||
# undef vector
|
||||
# undef pixel
|
||||
# undef bool
|
||||
# define CV_VSX 1
|
||||
#endif
|
||||
|
||||
#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
|
||||
|
||||
#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
|
||||
struct VZeroUpperGuard {
|
||||
#ifdef __GNUC__
|
||||
__attribute__((always_inline))
|
||||
#endif
|
||||
inline ~VZeroUpperGuard() { _mm256_zeroupper(); }
|
||||
};
|
||||
#define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard; (void)__vzeroupper_guard;
|
||||
#endif
|
||||
|
||||
#ifdef __CV_AVX_GUARD
|
||||
#define CV_AVX_GUARD __CV_AVX_GUARD
|
||||
#else
|
||||
#define CV_AVX_GUARD
|
||||
#endif
|
||||
|
||||
#endif // __OPENCV_BUILD
|
||||
|
||||
|
||||
|
||||
#if !defined __OPENCV_BUILD /* Compatibility code */ \
|
||||
&& !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
#elif defined _WIN32 && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
|
||||
# include <altivec.h>
|
||||
# undef vector
|
||||
# undef pixel
|
||||
# undef bool
|
||||
# define CV_VSX 1
|
||||
#endif
|
||||
|
||||
#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code)
|
||||
|
||||
|
||||
|
||||
#ifndef CV_MMX
|
||||
# define CV_MMX 0
|
||||
#endif
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_POPCNT
|
||||
# define CV_POPCNT 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_FP16
|
||||
# define CV_FP16 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_FMA3
|
||||
# define CV_FMA3 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512F
|
||||
# define CV_AVX_512F 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512BW
|
||||
# define CV_AVX_512BW 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512CD
|
||||
# define CV_AVX_512CD 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512DQ
|
||||
# define CV_AVX_512DQ 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512ER
|
||||
# define CV_AVX_512ER 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512IFMA512
|
||||
# define CV_AVX_512IFMA512 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512PF
|
||||
# define CV_AVX_512PF 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VBMI
|
||||
# define CV_AVX_512VBMI 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VL
|
||||
# define CV_AVX_512VL 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_VSX
|
||||
# define CV_VSX 0
|
||||
#endif
|
||||
199
lib/3rdParty/OpenCV3.4/include/opencv2/core/cv_cpu_helper.h
vendored
Normal file
199
lib/3rdParty/OpenCV3.4/include/opencv2/core/cv_cpu_helper.h
vendored
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
// AUTOGENERATED, DO NOT EDIT
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE
|
||||
# define CV_TRY_SSE 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE 1
|
||||
# define CV_CPU_CALL_SSE(fn, args) return (opt_SSE::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE
|
||||
# define CV_TRY_SSE 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE))
|
||||
# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSE 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSE 0
|
||||
# define CV_CPU_CALL_SSE(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2
|
||||
# define CV_TRY_SSE2 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 1
|
||||
# define CV_CPU_CALL_SSE2(fn, args) return (opt_SSE2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2
|
||||
# define CV_TRY_SSE2 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2))
|
||||
# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSE2 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 0
|
||||
# define CV_CPU_CALL_SSE2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3
|
||||
# define CV_TRY_SSE3 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 1
|
||||
# define CV_CPU_CALL_SSE3(fn, args) return (opt_SSE3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3
|
||||
# define CV_TRY_SSE3 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3))
|
||||
# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSE3 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 0
|
||||
# define CV_CPU_CALL_SSE3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3
|
||||
# define CV_TRY_SSSE3 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 1
|
||||
# define CV_CPU_CALL_SSSE3(fn, args) return (opt_SSSE3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3
|
||||
# define CV_TRY_SSSE3 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3))
|
||||
# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSSE3 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 0
|
||||
# define CV_CPU_CALL_SSSE3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1
|
||||
# define CV_TRY_SSE4_1 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 1
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args) return (opt_SSE4_1::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1
|
||||
# define CV_TRY_SSE4_1 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1))
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSE4_1 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 0
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2
|
||||
# define CV_TRY_SSE4_2 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 1
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args) return (opt_SSE4_2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2
|
||||
# define CV_TRY_SSE4_2 1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2))
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args)
|
||||
#else
|
||||
# define CV_TRY_SSE4_2 0
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 0
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT
|
||||
# define CV_TRY_POPCNT 1
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT 1
|
||||
# define CV_CPU_CALL_POPCNT(fn, args) return (opt_POPCNT::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT
|
||||
# define CV_TRY_POPCNT 1
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT))
|
||||
# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args)
|
||||
#else
|
||||
# define CV_TRY_POPCNT 0
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT 0
|
||||
# define CV_CPU_CALL_POPCNT(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX
|
||||
# define CV_TRY_AVX 1
|
||||
# define CV_CPU_HAS_SUPPORT_AVX 1
|
||||
# define CV_CPU_CALL_AVX(fn, args) return (opt_AVX::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX
|
||||
# define CV_TRY_AVX 1
|
||||
# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX))
|
||||
# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args)
|
||||
#else
|
||||
# define CV_TRY_AVX 0
|
||||
# define CV_CPU_HAS_SUPPORT_AVX 0
|
||||
# define CV_CPU_CALL_AVX(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16
|
||||
# define CV_TRY_FP16 1
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 1
|
||||
# define CV_CPU_CALL_FP16(fn, args) return (opt_FP16::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16
|
||||
# define CV_TRY_FP16 1
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16))
|
||||
# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args)
|
||||
#else
|
||||
# define CV_TRY_FP16 0
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 0
|
||||
# define CV_CPU_CALL_FP16(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2
|
||||
# define CV_TRY_AVX2 1
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 1
|
||||
# define CV_CPU_CALL_AVX2(fn, args) return (opt_AVX2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2
|
||||
# define CV_TRY_AVX2 1
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
|
||||
# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args)
|
||||
#else
|
||||
# define CV_TRY_AVX2 0
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 0
|
||||
# define CV_CPU_CALL_AVX2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3
|
||||
# define CV_TRY_FMA3 1
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 1
|
||||
# define CV_CPU_CALL_FMA3(fn, args) return (opt_FMA3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3
|
||||
# define CV_TRY_FMA3 1
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3))
|
||||
# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args)
|
||||
#else
|
||||
# define CV_TRY_FMA3 0
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 0
|
||||
# define CV_CPU_CALL_FMA3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON
|
||||
# define CV_TRY_NEON 1
|
||||
# define CV_CPU_HAS_SUPPORT_NEON 1
|
||||
# define CV_CPU_CALL_NEON(fn, args) return (opt_NEON::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON
|
||||
# define CV_TRY_NEON 1
|
||||
# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON))
|
||||
# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args)
|
||||
#else
|
||||
# define CV_TRY_NEON 0
|
||||
# define CV_CPU_HAS_SUPPORT_NEON 0
|
||||
# define CV_CPU_CALL_NEON(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX
|
||||
# define CV_TRY_VSX 1
|
||||
# define CV_CPU_HAS_SUPPORT_VSX 1
|
||||
# define CV_CPU_CALL_VSX(fn, args) return (opt_VSX::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX
|
||||
# define CV_TRY_VSX 1
|
||||
# define CV_CPU_HAS_SUPPORT_VSX (cv::checkHardwareSupport(CV_CPU_VSX))
|
||||
# define CV_CPU_CALL_VSX(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args)
|
||||
#else
|
||||
# define CV_TRY_VSX 0
|
||||
# define CV_CPU_HAS_SUPPORT_VSX 0
|
||||
# define CV_CPU_CALL_VSX(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
|
||||
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
|
||||
|
|
@ -42,15 +42,43 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVDEF_H__
|
||||
#define __OPENCV_CORE_CVDEF_H__
|
||||
#ifndef OPENCV_CORE_CVDEF_H
|
||||
#define OPENCV_CORE_CVDEF_H
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
|
||||
#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD
|
||||
#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \
|
||||
(defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC))
|
||||
// Guard to prevent using of binary incompatible binaries / runtimes
|
||||
// https://github.com/opencv/opencv/pull/9161
|
||||
#define CV__DEBUG_NS_BEGIN namespace debug_build_guard {
|
||||
#define CV__DEBUG_NS_END }
|
||||
namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CV__DEBUG_NS_BEGIN
|
||||
#define CV__DEBUG_NS_BEGIN
|
||||
#define CV__DEBUG_NS_END
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#include "cvconfig.h"
|
||||
#endif
|
||||
|
||||
#ifndef __CV_EXPAND
|
||||
#define __CV_EXPAND(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __CV_CAT
|
||||
#define __CV_CAT__(x, y) x ## y
|
||||
#define __CV_CAT_(x, y) __CV_CAT__(x, y)
|
||||
#define __CV_CAT(x, y) __CV_CAT_(x, y)
|
||||
#endif
|
||||
|
||||
|
||||
// undef problematic defines sometimes defined by system headers (windows.h in particular)
|
||||
#undef small
|
||||
|
|
@ -59,10 +87,6 @@
|
|||
#undef abs
|
||||
#undef Complex
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include "opencv2/core/hal/interface.h"
|
||||
|
||||
|
|
@ -88,7 +112,7 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined CV_ICC && !defined CV_ENABLE_UNROLLED
|
||||
#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED)
|
||||
# define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
# define CV_ENABLE_UNROLLED 1
|
||||
|
|
@ -112,7 +136,7 @@
|
|||
#define CV_CPU_SSE4_1 6
|
||||
#define CV_CPU_SSE4_2 7
|
||||
#define CV_CPU_POPCNT 8
|
||||
|
||||
#define CV_CPU_FP16 9
|
||||
#define CV_CPU_AVX 10
|
||||
#define CV_CPU_AVX2 11
|
||||
#define CV_CPU_FMA3 12
|
||||
|
|
@ -129,6 +153,8 @@
|
|||
|
||||
#define CV_CPU_NEON 100
|
||||
|
||||
#define CV_CPU_VSX 200
|
||||
|
||||
// when adding to this list remember to update the following enum
|
||||
#define CV_HARDWARE_MAX_FEATURE 255
|
||||
|
||||
|
|
@ -143,7 +169,7 @@ enum CpuFeatures {
|
|||
CPU_SSE4_1 = 6,
|
||||
CPU_SSE4_2 = 7,
|
||||
CPU_POPCNT = 8,
|
||||
|
||||
CPU_FP16 = 9,
|
||||
CPU_AVX = 10,
|
||||
CPU_AVX2 = 11,
|
||||
CPU_FMA3 = 12,
|
||||
|
|
@ -158,156 +184,53 @@ enum CpuFeatures {
|
|||
CPU_AVX_512VBMI = 20,
|
||||
CPU_AVX_512VL = 21,
|
||||
|
||||
CPU_NEON = 100
|
||||
CPU_NEON = 100,
|
||||
|
||||
CPU_VSX = 200
|
||||
};
|
||||
|
||||
// do not include SSE/AVX/NEON headers for NVCC compiler
|
||||
#ifndef __CUDACC__
|
||||
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <pmmintrin.h>
|
||||
# define CV_SSE3 1
|
||||
# endif
|
||||
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <tmmintrin.h>
|
||||
# define CV_SSSE3 1
|
||||
# endif
|
||||
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
# endif
|
||||
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
# endif
|
||||
# if defined __POPCNT__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# else
|
||||
# include <popcntintrin.h>
|
||||
# endif
|
||||
# define CV_POPCNT 1
|
||||
# endif
|
||||
# if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600 && 0)
|
||||
// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
|
||||
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
# if defined(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# else
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# if defined __AVX2__ || (defined _MSC_VER && _MSC_VER >= 1800 && 0)
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
# if defined __FMA__
|
||||
# define CV_FMA3 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#include "cv_cpu_dispatch.h"
|
||||
|
||||
#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__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
|
||||
# define CV_VFP 1
|
||||
#endif
|
||||
|
||||
#endif // __CUDACC__
|
||||
|
||||
#ifndef CV_POPCNT
|
||||
#define CV_POPCNT 0
|
||||
#endif
|
||||
#ifndef CV_MMX
|
||||
# define CV_MMX 0
|
||||
#endif
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_FMA3
|
||||
# define CV_FMA3 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512F
|
||||
# define CV_AVX_512F 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512BW
|
||||
# define CV_AVX_512BW 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512CD
|
||||
# define CV_AVX_512CD 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512DQ
|
||||
# define CV_AVX_512DQ 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512ER
|
||||
# define CV_AVX_512ER 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512IFMA512
|
||||
# define CV_AVX_512IFMA512 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512PF
|
||||
# define CV_AVX_512PF 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VBMI
|
||||
# define CV_AVX_512VBMI 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VL
|
||||
# define CV_AVX_512VL 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_VFP
|
||||
# define CV_VFP 0
|
||||
#endif
|
||||
|
||||
/* fundamental constants */
|
||||
#define CV_PI 3.1415926535897932384626433832795
|
||||
#define CV_2PI 6.283185307179586476925286766559
|
||||
#define CV_2PI 6.283185307179586476925286766559
|
||||
#define CV_LOG2 0.69314718055994530941723212145818
|
||||
|
||||
#if defined __ARM_FP16_FORMAT_IEEE \
|
||||
&& !defined __CUDACC__
|
||||
# define CV_FP16_TYPE 1
|
||||
#else
|
||||
# define CV_FP16_TYPE 0
|
||||
#endif
|
||||
|
||||
typedef union Cv16suf
|
||||
{
|
||||
short i;
|
||||
#if CV_FP16_TYPE
|
||||
__fp16 h;
|
||||
#endif
|
||||
struct _fp16Format
|
||||
{
|
||||
unsigned int significand : 10;
|
||||
unsigned int exponent : 5;
|
||||
unsigned int sign : 1;
|
||||
} fmt;
|
||||
}
|
||||
Cv16suf;
|
||||
|
||||
typedef union Cv32suf
|
||||
{
|
||||
int i;
|
||||
unsigned u;
|
||||
float f;
|
||||
struct _fp32Format
|
||||
{
|
||||
unsigned int significand : 23;
|
||||
unsigned int exponent : 8;
|
||||
unsigned int sign : 1;
|
||||
} fmt;
|
||||
}
|
||||
Cv32suf;
|
||||
|
||||
|
|
@ -325,12 +248,32 @@ Cv64suf;
|
|||
# define DISABLE_OPENCV_24_COMPATIBILITY
|
||||
#endif
|
||||
|
||||
#if (defined WIN32 || defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
|
||||
# define CV_EXPORTS __declspec(dllexport)
|
||||
#elif defined __GNUC__ && __GNUC__ >= 4
|
||||
# define CV_EXPORTS __attribute__ ((visibility ("default")))
|
||||
#ifdef CVAPI_EXPORTS
|
||||
# if (defined _WIN32 || defined WINCE || defined __CYGWIN__)
|
||||
# define CV_EXPORTS __declspec(dllexport)
|
||||
# elif defined __GNUC__ && __GNUC__ >= 4
|
||||
# define CV_EXPORTS __attribute__ ((visibility ("default")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXPORTS
|
||||
# define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define CV_EXPORTS_TEMPLATE
|
||||
#else
|
||||
# define CV_EXPORTS
|
||||
# define CV_EXPORTS_TEMPLATE CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#ifndef CV_DEPRECATED
|
||||
# if defined(__GNUC__)
|
||||
# define CV_DEPRECATED __attribute__ ((deprecated))
|
||||
# elif defined(_MSC_VER)
|
||||
# define CV_DEPRECATED __declspec(deprecated)
|
||||
# else
|
||||
# define CV_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXTERN_C
|
||||
|
|
@ -357,67 +300,6 @@ Cv64suf;
|
|||
* Matrix type (Mat) *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define CV_CN_MAX 512
|
||||
#define CV_CN_SHIFT 3
|
||||
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
|
||||
|
||||
#define CV_8U 0
|
||||
#define CV_8S 1
|
||||
#define CV_16U 2
|
||||
#define CV_16S 3
|
||||
#define CV_32S 4
|
||||
#define CV_32F 5
|
||||
#define CV_64F 6
|
||||
#define CV_USRTYPE1 7
|
||||
|
||||
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
|
||||
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
|
||||
|
||||
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
|
||||
#define CV_MAKE_TYPE CV_MAKETYPE
|
||||
|
||||
#define CV_8UC1 CV_MAKETYPE(CV_8U,1)
|
||||
#define CV_8UC2 CV_MAKETYPE(CV_8U,2)
|
||||
#define CV_8UC3 CV_MAKETYPE(CV_8U,3)
|
||||
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
|
||||
#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
|
||||
|
||||
#define CV_8SC1 CV_MAKETYPE(CV_8S,1)
|
||||
#define CV_8SC2 CV_MAKETYPE(CV_8S,2)
|
||||
#define CV_8SC3 CV_MAKETYPE(CV_8S,3)
|
||||
#define CV_8SC4 CV_MAKETYPE(CV_8S,4)
|
||||
#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
|
||||
|
||||
#define CV_16UC1 CV_MAKETYPE(CV_16U,1)
|
||||
#define CV_16UC2 CV_MAKETYPE(CV_16U,2)
|
||||
#define CV_16UC3 CV_MAKETYPE(CV_16U,3)
|
||||
#define CV_16UC4 CV_MAKETYPE(CV_16U,4)
|
||||
#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
|
||||
|
||||
#define CV_16SC1 CV_MAKETYPE(CV_16S,1)
|
||||
#define CV_16SC2 CV_MAKETYPE(CV_16S,2)
|
||||
#define CV_16SC3 CV_MAKETYPE(CV_16S,3)
|
||||
#define CV_16SC4 CV_MAKETYPE(CV_16S,4)
|
||||
#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
|
||||
|
||||
#define CV_32SC1 CV_MAKETYPE(CV_32S,1)
|
||||
#define CV_32SC2 CV_MAKETYPE(CV_32S,2)
|
||||
#define CV_32SC3 CV_MAKETYPE(CV_32S,3)
|
||||
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
|
||||
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
|
||||
|
||||
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
|
||||
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
|
||||
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
|
||||
#define CV_32FC4 CV_MAKETYPE(CV_32F,4)
|
||||
#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
|
||||
|
||||
#define CV_64FC1 CV_MAKETYPE(CV_64F,1)
|
||||
#define CV_64FC2 CV_MAKETYPE(CV_64F,2)
|
||||
#define CV_64FC3 CV_MAKETYPE(CV_64F,3)
|
||||
#define CV_64FC4 CV_MAKETYPE(CV_64F,4)
|
||||
#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
|
||||
|
||||
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
||||
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
||||
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
||||
|
|
@ -431,7 +313,7 @@ Cv64suf;
|
|||
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
|
||||
|
||||
/** Size of each channel item,
|
||||
0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
|
||||
0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
|
||||
#define CV_ELEM_SIZE1(type) \
|
||||
((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
|
||||
|
||||
|
|
@ -447,14 +329,36 @@ Cv64suf;
|
|||
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* static analysys *
|
||||
\****************************************************************************************/
|
||||
|
||||
// In practice, some macro are not processed correctly (noreturn is not detected).
|
||||
// We need to use simplified definition for them.
|
||||
#ifndef CV_STATIC_ANALYSIS
|
||||
# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
|
||||
# define CV_STATIC_ANALYSIS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* Thread sanitizer *
|
||||
\****************************************************************************************/
|
||||
#ifndef CV_THREAD_SANITIZER
|
||||
# if defined(__has_feature)
|
||||
# if __has_feature(thread_sanitizer)
|
||||
# define CV_THREAD_SANITIZER
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* exchange-add operation for atomic operations on reference counters *
|
||||
\****************************************************************************************/
|
||||
|
||||
#if defined __INTEL_COMPILER && !(defined WIN32 || defined _WIN32)
|
||||
// atomic increment on the linux version of the Intel(tm) compiler
|
||||
# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta)
|
||||
#elif defined __GNUC__
|
||||
#ifdef CV_XADD
|
||||
// allow to use user-defined macro
|
||||
#elif defined __GNUC__ || defined __clang__
|
||||
# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__)
|
||||
# ifdef __ATOMIC_ACQ_REL
|
||||
# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
|
||||
|
|
@ -492,12 +396,26 @@ Cv64suf;
|
|||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* C++ 11 *
|
||||
\****************************************************************************************/
|
||||
#ifndef CV_CXX11
|
||||
# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||
# define CV_CXX11 1
|
||||
# endif
|
||||
#else
|
||||
# if CV_CXX11 == 0
|
||||
# undef CV_CXX11
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* C++ Move semantics *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifndef CV_CXX_MOVE_SEMANTICS
|
||||
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) && _MSC_VER >= 1600
|
||||
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
# define CV_CXX_MOVE_SEMANTICS 1
|
||||
# elif defined(__clang)
|
||||
# if __has_feature(cxx_rvalue_references)
|
||||
|
|
@ -510,6 +428,21 @@ Cv64suf;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* C++11 std::array *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifndef CV_CXX_STD_ARRAY
|
||||
# if __cplusplus >= 201103L
|
||||
# define CV_CXX_STD_ARRAY 1
|
||||
# include <array>
|
||||
# endif
|
||||
#else
|
||||
# if CV_CXX_STD_ARRAY == 0
|
||||
# undef CV_CXX_STD_ARRAY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // __OPENCV_CORE_CVDEF_H__
|
||||
#endif // OPENCV_CORE_CVDEF_H
|
||||
|
|
@ -41,25 +41,21 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVSTD_HPP__
|
||||
#define __OPENCV_CORE_CVSTD_HPP__
|
||||
#ifndef OPENCV_CORE_CVSTD_HPP
|
||||
#define OPENCV_CORE_CVSTD_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error cvstd.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <string>
|
||||
#endif
|
||||
#include <string>
|
||||
|
||||
// import useful primitives from stl
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
# include <algorithm>
|
||||
# include <utility>
|
||||
# include <cstdlib> //for abs(int)
|
||||
|
|
@ -67,6 +63,11 @@
|
|||
|
||||
namespace cv
|
||||
{
|
||||
static inline uchar abs(uchar a) { return a; }
|
||||
static inline ushort abs(ushort a) { return a; }
|
||||
static inline unsigned abs(unsigned a) { return a; }
|
||||
static inline uint64 abs(uint64 a) { return a; }
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::abs;
|
||||
|
|
@ -77,29 +78,6 @@ namespace cv
|
|||
using std::log;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
static inline uchar abs(uchar a) { return a; }
|
||||
static inline ushort abs(ushort a) { return a; }
|
||||
static inline unsigned abs(unsigned a) { return a; }
|
||||
static inline uint64 abs(uint64 a) { return a; }
|
||||
}
|
||||
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
template<typename T> static inline T min(T a, T b) { return a < b ? a : b; }
|
||||
template<typename T> static inline T max(T a, T b) { return a > b ? a : b; }
|
||||
template<typename T> static inline T abs(T a) { return a < 0 ? -a : a; }
|
||||
template<typename T> static inline void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||
|
||||
template<> inline uchar abs(uchar a) { return a; }
|
||||
template<> inline ushort abs(ushort a) { return a; }
|
||||
template<> inline unsigned abs(unsigned a) { return a; }
|
||||
template<> inline uint64 abs(uint64 a) { return a; }
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup core_utils
|
||||
|
|
@ -492,7 +470,7 @@ public:
|
|||
|
||||
static const size_t npos = size_t(-1);
|
||||
|
||||
explicit String();
|
||||
String();
|
||||
String(const String& str);
|
||||
String(const String& str, size_t pos, size_t len = npos);
|
||||
String(const char* s);
|
||||
|
|
@ -559,7 +537,6 @@ public:
|
|||
|
||||
String toLowerCase() const;
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
String(const std::string& str);
|
||||
String(const std::string& str, size_t pos, size_t len = npos);
|
||||
String& operator=(const std::string& str);
|
||||
|
|
@ -568,7 +545,6 @@ public:
|
|||
|
||||
friend String operator+ (const String& lhs, const std::string& rhs);
|
||||
friend String operator+ (const std::string& lhs, const String& rhs);
|
||||
#endif
|
||||
|
||||
private:
|
||||
char* cstr_;
|
||||
|
|
@ -622,6 +598,7 @@ String::String(const char* s)
|
|||
{
|
||||
if (!s) return;
|
||||
size_t len = strlen(s);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), s, len);
|
||||
}
|
||||
|
||||
|
|
@ -630,6 +607,7 @@ String::String(const char* s, size_t n)
|
|||
: cstr_(0), len_(0)
|
||||
{
|
||||
if (!n) return;
|
||||
if (!s) return;
|
||||
memcpy(allocate(n), s, n);
|
||||
}
|
||||
|
||||
|
|
@ -637,6 +615,7 @@ inline
|
|||
String::String(size_t n, char c)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
if (!n) return;
|
||||
memset(allocate(n), c, n);
|
||||
}
|
||||
|
||||
|
|
@ -645,6 +624,7 @@ String::String(const char* first, const char* last)
|
|||
: cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), first, len);
|
||||
}
|
||||
|
||||
|
|
@ -653,6 +633,7 @@ String::String(Iterator first, Iterator last)
|
|||
: cstr_(0), len_(0)
|
||||
{
|
||||
size_t len = (size_t)(last - first);
|
||||
if (!len) return;
|
||||
char* str = allocate(len);
|
||||
while (first != last)
|
||||
{
|
||||
|
|
@ -685,7 +666,7 @@ String& String::operator=(const char* s)
|
|||
deallocate();
|
||||
if (!s) return *this;
|
||||
size_t len = strlen(s);
|
||||
memcpy(allocate(len), s, len);
|
||||
if (len) memcpy(allocate(len), s, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -751,7 +732,7 @@ const char* String::begin() const
|
|||
inline
|
||||
const char* String::end() const
|
||||
{
|
||||
return len_ ? cstr_ + 1 : 0;
|
||||
return len_ ? cstr_ + len_ : NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
@ -958,8 +939,9 @@ size_t String::find_last_of(const char* s, size_t pos) const
|
|||
inline
|
||||
String String::toLowerCase() const
|
||||
{
|
||||
if (!cstr_)
|
||||
return String();
|
||||
String res(cstr_, len_);
|
||||
|
||||
for (size_t i = 0; i < len_; ++i)
|
||||
res.cstr_[i] = (char) ::tolower(cstr_[i]);
|
||||
|
||||
|
|
@ -978,8 +960,8 @@ String operator + (const String& lhs, const String& rhs)
|
|||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + rhs.len_);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs.cstr_, rhs.len_);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (rhs.len_) memcpy(s.cstr_ + lhs.len_, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -989,8 +971,8 @@ String operator + (const String& lhs, const char* rhs)
|
|||
String s;
|
||||
size_t rhslen = strlen(rhs);
|
||||
s.allocate(lhs.len_ + rhslen);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs, rhslen);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (rhslen) memcpy(s.cstr_ + lhs.len_, rhs, rhslen);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -1000,8 +982,8 @@ String operator + (const char* lhs, const String& rhs)
|
|||
String s;
|
||||
size_t lhslen = strlen(lhs);
|
||||
s.allocate(lhslen + rhs.len_);
|
||||
memcpy(s.cstr_, lhs, lhslen);
|
||||
memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
if (lhslen) memcpy(s.cstr_, lhs, lhslen);
|
||||
if (rhs.len_) memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -1010,7 +992,7 @@ String operator + (const String& lhs, char rhs)
|
|||
{
|
||||
String s;
|
||||
s.allocate(lhs.len_ + 1);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
s.cstr_[lhs.len_] = rhs;
|
||||
return s;
|
||||
}
|
||||
|
|
@ -1021,7 +1003,7 @@ String operator + (char lhs, const String& rhs)
|
|||
String s;
|
||||
s.allocate(rhs.len_ + 1);
|
||||
s.cstr_[0] = lhs;
|
||||
memcpy(s.cstr_ + 1, rhs.cstr_, rhs.len_);
|
||||
if (rhs.len_) memcpy(s.cstr_ + 1, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -1048,22 +1030,11 @@ static inline bool operator>= (const String& lhs, const char* rhs) { return lh
|
|||
|
||||
} // cv
|
||||
|
||||
#ifndef OPENCV_NOSTL_TRANSITIONAL
|
||||
namespace std
|
||||
{
|
||||
static inline void swap(cv::String& a, cv::String& b) { a.swap(b); }
|
||||
}
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
template<> inline
|
||||
void swap<cv::String>(cv::String& a, cv::String& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/ptr.inl.hpp"
|
||||
|
||||
#endif //__OPENCV_CORE_CVSTD_HPP__
|
||||
#endif //OPENCV_CORE_CVSTD_HPP
|
||||
|
|
@ -41,19 +41,21 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_CVSTDINL_HPP__
|
||||
#define __OPENCV_CORE_CVSTDINL_HPP__
|
||||
#ifndef OPENCV_CORE_CVSTDINL_HPP
|
||||
#define OPENCV_CORE_CVSTDINL_HPP
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
# include <complex>
|
||||
# include <ostream>
|
||||
#endif
|
||||
#include <complex>
|
||||
#include <ostream>
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4127 )
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifndef OPENCV_NOSTL
|
||||
|
||||
template<typename _Tp> class DataType< std::complex<_Tp> >
|
||||
{
|
||||
|
|
@ -78,7 +80,7 @@ String::String(const std::string& str)
|
|||
if (!str.empty())
|
||||
{
|
||||
size_t len = str.size();
|
||||
memcpy(allocate(len), str.c_str(), len);
|
||||
if (len) memcpy(allocate(len), str.c_str(), len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +102,7 @@ String& String::operator = (const std::string& str)
|
|||
if (!str.empty())
|
||||
{
|
||||
size_t len = str.size();
|
||||
memcpy(allocate(len), str.c_str(), len);
|
||||
if (len) memcpy(allocate(len), str.c_str(), len);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -124,8 +126,8 @@ String operator + (const String& lhs, const std::string& rhs)
|
|||
String s;
|
||||
size_t rhslen = rhs.size();
|
||||
s.allocate(lhs.len_ + rhslen);
|
||||
memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
memcpy(s.cstr_ + lhs.len_, rhs.c_str(), rhslen);
|
||||
if (lhs.len_) memcpy(s.cstr_, lhs.cstr_, lhs.len_);
|
||||
if (rhslen) memcpy(s.cstr_ + lhs.len_, rhs.c_str(), rhslen);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -135,8 +137,8 @@ String operator + (const std::string& lhs, const String& rhs)
|
|||
String s;
|
||||
size_t lhslen = lhs.size();
|
||||
s.allocate(lhslen + rhs.len_);
|
||||
memcpy(s.cstr_, lhs.c_str(), lhslen);
|
||||
memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
if (lhslen) memcpy(s.cstr_, lhs.c_str(), lhslen);
|
||||
if (rhs.len_) memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -151,9 +153,7 @@ FileNode::operator std::string() const
|
|||
template<> inline
|
||||
void operator >> (const FileNode& n, std::string& value)
|
||||
{
|
||||
String val;
|
||||
read(n, val, val);
|
||||
value = val;
|
||||
read(n, value, std::string());
|
||||
}
|
||||
|
||||
template<> inline
|
||||
|
|
@ -183,6 +183,18 @@ std::ostream& operator << (std::ostream& out, const Mat& mtx)
|
|||
return out << Formatter::get()->format(mtx);
|
||||
}
|
||||
|
||||
static inline
|
||||
std::ostream& operator << (std::ostream& out, const UMat& m)
|
||||
{
|
||||
return out << m.getMat(ACCESS_READ);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
std::ostream& operator << (std::ostream& out, const Complex<_Tp>& c)
|
||||
{
|
||||
return out << "(" << c.re << "," << c.im << ")";
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec)
|
||||
{
|
||||
|
|
@ -221,14 +233,7 @@ template<typename _Tp, int n> static inline
|
|||
std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec)
|
||||
{
|
||||
out << "[";
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4127 )
|
||||
#endif
|
||||
if(Vec<_Tp, n>::depth < CV_32F)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
if (cv::traits::Depth<_Tp>::value <= CV_32S)
|
||||
{
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
out << (int)vec[i] << ", ";
|
||||
|
|
@ -258,10 +263,24 @@ std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
|
|||
return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
|
||||
}
|
||||
|
||||
static inline std::ostream& operator << (std::ostream& out, const MatSize& msize)
|
||||
{
|
||||
int i, dims = msize.p[-1];
|
||||
for( i = 0; i < dims; i++ )
|
||||
{
|
||||
out << msize.p[i];
|
||||
if( i < dims-1 )
|
||||
out << " x ";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // OPENCV_NOSTL
|
||||
} // cv
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_CVSTDINL_HPP__
|
||||
#endif // OPENCV_CORE_CVSTDINL_HPP
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_DIRECTX_HPP__
|
||||
#define __OPENCV_CORE_DIRECTX_HPP__
|
||||
#ifndef OPENCV_CORE_DIRECTX_HPP
|
||||
#define OPENCV_CORE_DIRECTX_HPP
|
||||
|
||||
#include "mat.hpp"
|
||||
#include "ocl.hpp"
|
||||
|
|
@ -181,4 +181,4 @@ CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D
|
|||
|
||||
} } // namespace cv::directx
|
||||
|
||||
#endif // __OPENCV_CORE_DIRECTX_HPP__
|
||||
#endif // OPENCV_CORE_DIRECTX_HPP
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//M*/
|
||||
|
||||
|
||||
#ifndef __OPENCV_CORE_EIGEN_HPP__
|
||||
#define __OPENCV_CORE_EIGEN_HPP__
|
||||
#ifndef OPENCV_CORE_EIGEN_HPP
|
||||
#define OPENCV_CORE_EIGEN_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
|
|
@ -64,14 +64,14 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo
|
|||
{
|
||||
if( !(src.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
Mat _src(src.cols(), src.rows(), DataType<_Tp>::type,
|
||||
(void*)src.data(), src.stride()*sizeof(_Tp));
|
||||
Mat _src(src.cols(), src.rows(), traits::Type<_Tp>::value,
|
||||
(void*)src.data(), src.outerStride()*sizeof(_Tp));
|
||||
transpose(_src, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat _src(src.rows(), src.cols(), DataType<_Tp>::type,
|
||||
(void*)src.data(), src.stride()*sizeof(_Tp));
|
||||
Mat _src(src.rows(), src.cols(), traits::Type<_Tp>::value,
|
||||
(void*)src.data(), src.outerStride()*sizeof(_Tp));
|
||||
_src.copyTo(dst);
|
||||
}
|
||||
}
|
||||
|
|
@ -98,8 +98,8 @@ void cv2eigen( const Mat& src,
|
|||
CV_DbgAssert(src.rows == _rows && src.cols == _cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else if( src.cols == src.rows )
|
||||
|
|
@ -112,8 +112,8 @@ void cv2eigen( const Mat& src,
|
|||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
}
|
||||
}
|
||||
|
|
@ -125,14 +125,14 @@ void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
|
|||
{
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(_cols, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_cols, _rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(_rows, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_rows, _cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
}
|
||||
}
|
||||
|
|
@ -144,8 +144,8 @@ void cv2eigen( const Mat& src,
|
|||
dst.resize(src.rows, src.cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else if( src.cols == src.rows )
|
||||
|
|
@ -158,8 +158,8 @@ void cv2eigen( const Mat& src,
|
|||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
}
|
||||
}
|
||||
|
|
@ -172,14 +172,14 @@ void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
|
|||
dst.resize(_rows, _cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(_cols, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_cols, _rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(_rows, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_rows, _cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
}
|
||||
}
|
||||
|
|
@ -193,8 +193,8 @@ void cv2eigen( const Mat& src,
|
|||
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else
|
||||
|
|
@ -202,8 +202,8 @@ void cv2eigen( const Mat& src,
|
|||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
}
|
||||
}
|
||||
|
|
@ -217,14 +217,14 @@ void cv2eigen( const Matx<_Tp, _rows, 1>& src,
|
|||
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(1, _rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(1, _rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(_rows, 1, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_rows, 1, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
src.copyTo(_dst);
|
||||
}
|
||||
}
|
||||
|
|
@ -238,8 +238,8 @@ void cv2eigen( const Mat& src,
|
|||
dst.resize(src.cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(src.cols, src.rows, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
if( src.type() == _dst.type() )
|
||||
transpose(src, _dst);
|
||||
else
|
||||
|
|
@ -247,8 +247,8 @@ void cv2eigen( const Mat& src,
|
|||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(src.rows, src.cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
src.convertTo(_dst, _dst.type());
|
||||
}
|
||||
}
|
||||
|
|
@ -261,14 +261,14 @@ void cv2eigen( const Matx<_Tp, 1, _cols>& src,
|
|||
dst.resize(_cols);
|
||||
if( !(dst.Flags & Eigen::RowMajorBit) )
|
||||
{
|
||||
const Mat _dst(_cols, 1, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(_cols, 1, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
transpose(src, _dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat _dst(1, _cols, DataType<_Tp>::type,
|
||||
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
|
||||
const Mat _dst(1, _cols, traits::Type<_Tp>::value,
|
||||
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
|
||||
Mat(src).copyTo(_dst);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,11 +42,17 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_FAST_MATH_HPP__
|
||||
#define __OPENCV_CORE_FAST_MATH_HPP__
|
||||
#ifndef OPENCV_CORE_FAST_MATH_HPP
|
||||
#define OPENCV_CORE_FAST_MATH_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
|
|
@ -54,24 +60,27 @@
|
|||
* fast math *
|
||||
\****************************************************************************************/
|
||||
|
||||
#if defined __BORLANDC__
|
||||
# include <fastmath.h>
|
||||
#elif defined __cplusplus
|
||||
#ifdef __cplusplus
|
||||
# include <cmath>
|
||||
#else
|
||||
# include <math.h>
|
||||
# ifdef __BORLANDC__
|
||||
# include <fastmath.h>
|
||||
# else
|
||||
# include <math.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
# include "tegra_round.hpp"
|
||||
#endif
|
||||
|
||||
#if CV_VFP
|
||||
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ && !defined(__CUDACC__)
|
||||
// 1. general scheme
|
||||
#define ARM_ROUND(_value, _asm_string) \
|
||||
int res; \
|
||||
float temp; \
|
||||
asm(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
|
||||
(void)temp; \
|
||||
__asm__(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
|
||||
return res
|
||||
// 2. version for double
|
||||
#ifdef __clang__
|
||||
|
|
@ -81,7 +90,7 @@
|
|||
#endif
|
||||
// 3. version for float
|
||||
#define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
|
||||
#endif // CV_VFP
|
||||
#endif
|
||||
|
||||
/** @brief Rounds floating-point number to the nearest integer
|
||||
|
||||
|
|
@ -92,7 +101,7 @@ CV_INLINE int
|
|||
cvRound( double value )
|
||||
{
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
return _mm_cvtsd_si32(t);
|
||||
#elif defined _MSC_VER && defined _M_IX86
|
||||
|
|
@ -107,7 +116,7 @@ cvRound( double value )
|
|||
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND_DBL(value);
|
||||
#elif defined CV_ICC || defined __GNUC__
|
||||
# if CV_VFP
|
||||
# if defined ARM_ROUND_DBL
|
||||
ARM_ROUND_DBL(value);
|
||||
# else
|
||||
return (int)lrint(value);
|
||||
|
|
@ -129,18 +138,8 @@ cvRound( double value )
|
|||
*/
|
||||
CV_INLINE int cvFloor( double value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
int i = _mm_cvtsd_si32(t);
|
||||
return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i)));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(value - i);
|
||||
return i - (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Rounds floating-point number to the nearest integer not smaller than the original.
|
||||
|
|
@ -152,18 +151,8 @@ CV_INLINE int cvFloor( double value )
|
|||
*/
|
||||
CV_INLINE int cvCeil( double value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
int i = _mm_cvtsd_si32(t);
|
||||
return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i + (i < value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(i - value);
|
||||
return i + (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Determines if the argument is Not A Number.
|
||||
|
|
@ -199,8 +188,8 @@ CV_INLINE int cvIsInf( double value )
|
|||
/** @overload */
|
||||
CV_INLINE int cvRound(float value)
|
||||
{
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && \
|
||||
defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
return _mm_cvtss_si32(t);
|
||||
#elif defined _MSC_VER && defined _M_IX86
|
||||
|
|
@ -215,7 +204,7 @@ CV_INLINE int cvRound(float value)
|
|||
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND_FLT(value);
|
||||
#elif defined CV_ICC || defined __GNUC__
|
||||
# if CV_VFP
|
||||
# if defined ARM_ROUND_FLT
|
||||
ARM_ROUND_FLT(value);
|
||||
# else
|
||||
return (int)lrintf(value);
|
||||
|
|
@ -236,18 +225,8 @@ CV_INLINE int cvRound( int value )
|
|||
/** @overload */
|
||||
CV_INLINE int cvFloor( float value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
int i = _mm_cvtss_si32(t);
|
||||
return i - _mm_movemask_ps(_mm_cmplt_ss(t, _mm_cvtsi32_ss(t,i)));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(value - i);
|
||||
return i - (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
|
|
@ -259,18 +238,8 @@ CV_INLINE int cvFloor( int value )
|
|||
/** @overload */
|
||||
CV_INLINE int cvCeil( float value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
int i = _mm_cvtss_si32(t);
|
||||
return i + _mm_movemask_ps(_mm_cmplt_ss(_mm_cvtsi32_ss(t,i), t));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i + (i < value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(i - value);
|
||||
return i + (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
|
|
@ -42,23 +42,13 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_HPP__
|
||||
#define __OPENCV_HAL_HPP__
|
||||
#ifndef OPENCV_HAL_HPP
|
||||
#define OPENCV_HAL_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
#include "opencv2/core/hal/interface.h"
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CALL_HAL(name, fun, ...) \
|
||||
int res = fun(__VA_ARGS__); \
|
||||
if (res == CV_HAL_ERROR_OK) \
|
||||
return; \
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||
CV_Error_(cv::Error::StsInternal, \
|
||||
("HAL implementation " CVAUX_STR(name) " ==> " CVAUX_STR(fun) " returned %d (0x%08x)", res, res));
|
||||
//! @endcond
|
||||
|
||||
|
||||
namespace cv { namespace hal {
|
||||
|
||||
//! @addtogroup core_hal_functions
|
||||
|
|
@ -74,6 +64,23 @@ CV_EXPORTS int LU32f(float* A, size_t astep, int m, float* b, size_t bstep, int
|
|||
CV_EXPORTS int LU64f(double* A, size_t astep, int m, double* b, size_t bstep, int n);
|
||||
CV_EXPORTS bool Cholesky32f(float* A, size_t astep, int m, float* b, size_t bstep, int n);
|
||||
CV_EXPORTS bool Cholesky64f(double* A, size_t astep, int m, double* b, size_t bstep, int n);
|
||||
CV_EXPORTS void SVD32f(float* At, size_t astep, float* W, float* U, size_t ustep, float* Vt, size_t vstep, int m, int n, int flags);
|
||||
CV_EXPORTS void SVD64f(double* At, size_t astep, double* W, double* U, size_t ustep, double* Vt, size_t vstep, int m, int n, int flags);
|
||||
CV_EXPORTS int QR32f(float* A, size_t astep, int m, int n, int k, float* b, size_t bstep, float* hFactors);
|
||||
CV_EXPORTS int QR64f(double* A, size_t astep, int m, int n, int k, double* b, size_t bstep, double* hFactors);
|
||||
|
||||
CV_EXPORTS void gemm32f(const float* src1, size_t src1_step, const float* src2, size_t src2_step,
|
||||
float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step,
|
||||
int m_a, int n_a, int n_d, int flags);
|
||||
CV_EXPORTS void gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step,
|
||||
double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step,
|
||||
int m_a, int n_a, int n_d, int flags);
|
||||
CV_EXPORTS void gemm32fc(const float* src1, size_t src1_step, const float* src2, size_t src2_step,
|
||||
float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step,
|
||||
int m_a, int n_a, int n_d, int flags);
|
||||
CV_EXPORTS void gemm64fc(const double* src1, size_t src1_step, const double* src2, size_t src2_step,
|
||||
double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step,
|
||||
int m_a, int n_a, int n_d, int flags);
|
||||
|
||||
CV_EXPORTS int normL1_(const uchar* a, const uchar* b, int n);
|
||||
CV_EXPORTS float normL1_(const float* a, const float* b, int n);
|
||||
|
|
@ -84,7 +91,8 @@ CV_EXPORTS void exp64f(const double* src, double* dst, int n);
|
|||
CV_EXPORTS void log32f(const float* src, float* dst, int n);
|
||||
CV_EXPORTS void log64f(const double* src, double* dst, int n);
|
||||
|
||||
CV_EXPORTS void fastAtan2(const float* y, const float* x, float* dst, int n, bool angleInDegrees);
|
||||
CV_EXPORTS void fastAtan32f(const float* y, const float* x, float* dst, int n, bool angleInDegrees);
|
||||
CV_EXPORTS void fastAtan64f(const double* y, const double* x, double* dst, int n, bool angleInDegrees);
|
||||
CV_EXPORTS void magnitude32f(const float* x, const float* y, float* dst, int n);
|
||||
CV_EXPORTS void magnitude64f(const double* x, const double* y, double* dst, int n);
|
||||
CV_EXPORTS void sqrt32f(const float* src, float* dst, int len);
|
||||
|
|
@ -171,13 +179,13 @@ CV_EXPORTS void div32s( const int* src1, size_t step1, const int* src2, size_t s
|
|||
CV_EXPORTS void div32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void div64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
|
||||
|
||||
CV_EXPORTS void recip8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip8u( const uchar *, size_t, const uchar * src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip8s( const schar *, size_t, const schar * src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip16u( const ushort *, size_t, const ushort * src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip16s( const short *, size_t, const short * src2, size_t step2, short* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip32s( const int *, size_t, const int * src2, size_t step2, int* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip32f( const float *, size_t, const float * src2, size_t step2, float* dst, size_t step, int width, int height, void* scale);
|
||||
CV_EXPORTS void recip64f( const double *, size_t, const double * src2, size_t step2, double* dst, size_t step, int width, int height, void* scale);
|
||||
|
||||
CV_EXPORTS void addWeighted8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _scalars );
|
||||
CV_EXPORTS void addWeighted8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scalars );
|
||||
|
|
@ -187,6 +195,29 @@ CV_EXPORTS void addWeighted32s( const int* src1, size_t step1, const int* src2,
|
|||
CV_EXPORTS void addWeighted32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scalars );
|
||||
CV_EXPORTS void addWeighted64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scalars );
|
||||
|
||||
struct CV_EXPORTS DFT1D
|
||||
{
|
||||
static Ptr<DFT1D> create(int len, int count, int depth, int flags, bool * useBuffer = 0);
|
||||
virtual void apply(const uchar *src, uchar *dst) = 0;
|
||||
virtual ~DFT1D() {}
|
||||
};
|
||||
|
||||
struct CV_EXPORTS DFT2D
|
||||
{
|
||||
static Ptr<DFT2D> create(int width, int height, int depth,
|
||||
int src_channels, int dst_channels,
|
||||
int flags, int nonzero_rows = 0);
|
||||
virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0;
|
||||
virtual ~DFT2D() {}
|
||||
};
|
||||
|
||||
struct CV_EXPORTS DCT2D
|
||||
{
|
||||
static Ptr<DCT2D> create(int width, int height, int depth, int flags);
|
||||
virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0;
|
||||
virtual ~DCT2D() {}
|
||||
};
|
||||
|
||||
//! @} core_hal
|
||||
|
||||
//=============================================================================
|
||||
|
|
@ -204,6 +235,7 @@ CV_EXPORTS void exp(const double* src, double* dst, int n);
|
|||
CV_EXPORTS void log(const float* src, float* dst, int n);
|
||||
CV_EXPORTS void log(const double* src, double* dst, int n);
|
||||
|
||||
CV_EXPORTS void fastAtan2(const float* y, const float* x, float* dst, int n, bool angleInDegrees);
|
||||
CV_EXPORTS void magnitude(const float* x, const float* y, float* dst, int n);
|
||||
CV_EXPORTS void magnitude(const double* x, const double* y, double* dst, int n);
|
||||
CV_EXPORTS void sqrt(const float* src, float* dst, int len);
|
||||
|
|
@ -215,4 +247,4 @@ CV_EXPORTS void invSqrt(const double* src, double* dst, int len);
|
|||
|
||||
}} //cv::hal
|
||||
|
||||
#endif //__OPENCV_HAL_HPP__
|
||||
#endif //OPENCV_HAL_HPP
|
||||
182
lib/3rdParty/OpenCV3.4/include/opencv2/core/hal/interface.h
vendored
Normal file
182
lib/3rdParty/OpenCV3.4/include/opencv2/core/hal/interface.h
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
#ifndef OPENCV_CORE_HAL_INTERFACE_H
|
||||
#define OPENCV_CORE_HAL_INTERFACE_H
|
||||
|
||||
//! @addtogroup core_hal_interface
|
||||
//! @{
|
||||
|
||||
//! @name Return codes
|
||||
//! @{
|
||||
#define CV_HAL_ERROR_OK 0
|
||||
#define CV_HAL_ERROR_NOT_IMPLEMENTED 1
|
||||
#define CV_HAL_ERROR_UNKNOWN -1
|
||||
//! @}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
//! @name Data types
|
||||
//! primitive types
|
||||
//! - schar - signed 1 byte integer
|
||||
//! - uchar - unsigned 1 byte integer
|
||||
//! - short - signed 2 byte integer
|
||||
//! - ushort - unsigned 2 byte integer
|
||||
//! - int - signed 4 byte integer
|
||||
//! - uint - unsigned 4 byte integer
|
||||
//! - int64 - signed 8 byte integer
|
||||
//! - uint64 - unsigned 8 byte integer
|
||||
//! @{
|
||||
#if !defined _MSC_VER && !defined __BORLANDC__
|
||||
# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__
|
||||
# include <cstdint>
|
||||
# ifdef __NEWLIB__
|
||||
typedef unsigned int uint;
|
||||
# else
|
||||
typedef std::uint32_t uint;
|
||||
# endif
|
||||
# else
|
||||
# include <stdint.h>
|
||||
typedef uint32_t uint;
|
||||
# endif
|
||||
#else
|
||||
typedef unsigned uint;
|
||||
#endif
|
||||
|
||||
typedef signed char schar;
|
||||
|
||||
#ifndef __IPL_H__
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
# define CV_BIG_INT(n) n##I64
|
||||
# define CV_BIG_UINT(n) n##UI64
|
||||
#else
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
# define CV_BIG_INT(n) n##LL
|
||||
# define CV_BIG_UINT(n) n##ULL
|
||||
#endif
|
||||
|
||||
#define CV_CN_MAX 512
|
||||
#define CV_CN_SHIFT 3
|
||||
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
|
||||
|
||||
#define CV_8U 0
|
||||
#define CV_8S 1
|
||||
#define CV_16U 2
|
||||
#define CV_16S 3
|
||||
#define CV_32S 4
|
||||
#define CV_32F 5
|
||||
#define CV_64F 6
|
||||
#define CV_USRTYPE1 7
|
||||
|
||||
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
|
||||
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
|
||||
|
||||
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
|
||||
#define CV_MAKE_TYPE CV_MAKETYPE
|
||||
|
||||
#define CV_8UC1 CV_MAKETYPE(CV_8U,1)
|
||||
#define CV_8UC2 CV_MAKETYPE(CV_8U,2)
|
||||
#define CV_8UC3 CV_MAKETYPE(CV_8U,3)
|
||||
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
|
||||
#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
|
||||
|
||||
#define CV_8SC1 CV_MAKETYPE(CV_8S,1)
|
||||
#define CV_8SC2 CV_MAKETYPE(CV_8S,2)
|
||||
#define CV_8SC3 CV_MAKETYPE(CV_8S,3)
|
||||
#define CV_8SC4 CV_MAKETYPE(CV_8S,4)
|
||||
#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
|
||||
|
||||
#define CV_16UC1 CV_MAKETYPE(CV_16U,1)
|
||||
#define CV_16UC2 CV_MAKETYPE(CV_16U,2)
|
||||
#define CV_16UC3 CV_MAKETYPE(CV_16U,3)
|
||||
#define CV_16UC4 CV_MAKETYPE(CV_16U,4)
|
||||
#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
|
||||
|
||||
#define CV_16SC1 CV_MAKETYPE(CV_16S,1)
|
||||
#define CV_16SC2 CV_MAKETYPE(CV_16S,2)
|
||||
#define CV_16SC3 CV_MAKETYPE(CV_16S,3)
|
||||
#define CV_16SC4 CV_MAKETYPE(CV_16S,4)
|
||||
#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
|
||||
|
||||
#define CV_32SC1 CV_MAKETYPE(CV_32S,1)
|
||||
#define CV_32SC2 CV_MAKETYPE(CV_32S,2)
|
||||
#define CV_32SC3 CV_MAKETYPE(CV_32S,3)
|
||||
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
|
||||
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
|
||||
|
||||
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
|
||||
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
|
||||
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
|
||||
#define CV_32FC4 CV_MAKETYPE(CV_32F,4)
|
||||
#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
|
||||
|
||||
#define CV_64FC1 CV_MAKETYPE(CV_64F,1)
|
||||
#define CV_64FC2 CV_MAKETYPE(CV_64F,2)
|
||||
#define CV_64FC3 CV_MAKETYPE(CV_64F,3)
|
||||
#define CV_64FC4 CV_MAKETYPE(CV_64F,4)
|
||||
#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
|
||||
//! @}
|
||||
|
||||
//! @name Comparison operation
|
||||
//! @sa cv::CmpTypes
|
||||
//! @{
|
||||
#define CV_HAL_CMP_EQ 0
|
||||
#define CV_HAL_CMP_GT 1
|
||||
#define CV_HAL_CMP_GE 2
|
||||
#define CV_HAL_CMP_LT 3
|
||||
#define CV_HAL_CMP_LE 4
|
||||
#define CV_HAL_CMP_NE 5
|
||||
//! @}
|
||||
|
||||
//! @name Border processing modes
|
||||
//! @sa cv::BorderTypes
|
||||
//! @{
|
||||
#define CV_HAL_BORDER_CONSTANT 0
|
||||
#define CV_HAL_BORDER_REPLICATE 1
|
||||
#define CV_HAL_BORDER_REFLECT 2
|
||||
#define CV_HAL_BORDER_WRAP 3
|
||||
#define CV_HAL_BORDER_REFLECT_101 4
|
||||
#define CV_HAL_BORDER_TRANSPARENT 5
|
||||
#define CV_HAL_BORDER_ISOLATED 16
|
||||
//! @}
|
||||
|
||||
//! @name DFT flags
|
||||
//! @{
|
||||
#define CV_HAL_DFT_INVERSE 1
|
||||
#define CV_HAL_DFT_SCALE 2
|
||||
#define CV_HAL_DFT_ROWS 4
|
||||
#define CV_HAL_DFT_COMPLEX_OUTPUT 16
|
||||
#define CV_HAL_DFT_REAL_OUTPUT 32
|
||||
#define CV_HAL_DFT_TWO_STAGE 64
|
||||
#define CV_HAL_DFT_STAGE_COLS 128
|
||||
#define CV_HAL_DFT_IS_CONTINUOUS 512
|
||||
#define CV_HAL_DFT_IS_INPLACE 1024
|
||||
//! @}
|
||||
|
||||
//! @name SVD flags
|
||||
//! @{
|
||||
#define CV_HAL_SVD_NO_UV 1
|
||||
#define CV_HAL_SVD_SHORT_UV 2
|
||||
#define CV_HAL_SVD_MODIFY_A 4
|
||||
#define CV_HAL_SVD_FULL_UV 8
|
||||
//! @}
|
||||
|
||||
//! @name Gemm flags
|
||||
//! @{
|
||||
#define CV_HAL_GEMM_1_T 1
|
||||
#define CV_HAL_GEMM_2_T 2
|
||||
#define CV_HAL_GEMM_3_T 4
|
||||
//! @}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_INTRIN_HPP__
|
||||
#define __OPENCV_HAL_INTRIN_HPP__
|
||||
#ifndef OPENCV_HAL_INTRIN_HPP
|
||||
#define OPENCV_HAL_INTRIN_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
|
|
@ -60,6 +60,25 @@
|
|||
// access from within opencv code more accessible
|
||||
namespace cv {
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
|
||||
#ifdef CV_CPU_DISPATCH_MODE
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE)
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) {
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
|
||||
#else
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline {
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
|
||||
#endif
|
||||
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
//! @addtogroup core_hal_intrin
|
||||
//! @{
|
||||
|
||||
|
|
@ -281,11 +300,15 @@ template <typename T> struct V_SIMD128Traits
|
|||
|
||||
//! @}
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CV_DOXYGEN
|
||||
# undef CV_SSE2
|
||||
# undef CV_NEON
|
||||
# undef CV_VSX
|
||||
#endif
|
||||
|
||||
#if CV_SSE2
|
||||
|
|
@ -296,6 +319,10 @@ template <typename T> struct V_SIMD128Traits
|
|||
|
||||
#include "opencv2/core/hal/intrin_neon.hpp"
|
||||
|
||||
#elif CV_VSX
|
||||
|
||||
#include "opencv2/core/hal/intrin_vsx.hpp"
|
||||
|
||||
#else
|
||||
|
||||
#include "opencv2/core/hal/intrin_cpp.hpp"
|
||||
|
|
@ -317,4 +344,129 @@ template <typename T> struct V_SIMD128Traits
|
|||
|
||||
//! @}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv {
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
template <typename R> struct V_RegTrait128;
|
||||
|
||||
template <> struct V_RegTrait128<uchar> {
|
||||
typedef v_uint8x16 reg;
|
||||
typedef v_uint16x8 w_reg;
|
||||
typedef v_uint32x4 q_reg;
|
||||
typedef v_uint8x16 u_reg;
|
||||
static v_uint8x16 zero() { return v_setzero_u8(); }
|
||||
static v_uint8x16 all(uchar val) { return v_setall_u8(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<schar> {
|
||||
typedef v_int8x16 reg;
|
||||
typedef v_int16x8 w_reg;
|
||||
typedef v_int32x4 q_reg;
|
||||
typedef v_uint8x16 u_reg;
|
||||
static v_int8x16 zero() { return v_setzero_s8(); }
|
||||
static v_int8x16 all(schar val) { return v_setall_s8(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<ushort> {
|
||||
typedef v_uint16x8 reg;
|
||||
typedef v_uint32x4 w_reg;
|
||||
typedef v_int16x8 int_reg;
|
||||
typedef v_uint16x8 u_reg;
|
||||
static v_uint16x8 zero() { return v_setzero_u16(); }
|
||||
static v_uint16x8 all(ushort val) { return v_setall_u16(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<short> {
|
||||
typedef v_int16x8 reg;
|
||||
typedef v_int32x4 w_reg;
|
||||
typedef v_uint16x8 u_reg;
|
||||
static v_int16x8 zero() { return v_setzero_s16(); }
|
||||
static v_int16x8 all(short val) { return v_setall_s16(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<unsigned> {
|
||||
typedef v_uint32x4 reg;
|
||||
typedef v_uint64x2 w_reg;
|
||||
typedef v_int32x4 int_reg;
|
||||
typedef v_uint32x4 u_reg;
|
||||
static v_uint32x4 zero() { return v_setzero_u32(); }
|
||||
static v_uint32x4 all(unsigned val) { return v_setall_u32(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<int> {
|
||||
typedef v_int32x4 reg;
|
||||
typedef v_int64x2 w_reg;
|
||||
typedef v_uint32x4 u_reg;
|
||||
static v_int32x4 zero() { return v_setzero_s32(); }
|
||||
static v_int32x4 all(int val) { return v_setall_s32(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<uint64> {
|
||||
typedef v_uint64x2 reg;
|
||||
static v_uint64x2 zero() { return v_setzero_u64(); }
|
||||
static v_uint64x2 all(uint64 val) { return v_setall_u64(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<int64> {
|
||||
typedef v_int64x2 reg;
|
||||
static v_int64x2 zero() { return v_setzero_s64(); }
|
||||
static v_int64x2 all(int64 val) { return v_setall_s64(val); }
|
||||
};
|
||||
|
||||
template <> struct V_RegTrait128<float> {
|
||||
typedef v_float32x4 reg;
|
||||
typedef v_int32x4 int_reg;
|
||||
typedef v_float32x4 u_reg;
|
||||
static v_float32x4 zero() { return v_setzero_f32(); }
|
||||
static v_float32x4 all(float val) { return v_setall_f32(val); }
|
||||
};
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
template <> struct V_RegTrait128<double> {
|
||||
typedef v_float64x2 reg;
|
||||
typedef v_int32x4 int_reg;
|
||||
typedef v_float64x2 u_reg;
|
||||
static v_float64x2 zero() { return v_setzero_f64(); }
|
||||
static v_float64x2 all(double val) { return v_setall_f64(val); }
|
||||
};
|
||||
#endif
|
||||
|
||||
inline unsigned int trailingZeros32(unsigned int value) {
|
||||
#if defined(_MSC_VER)
|
||||
#if (_MSC_VER < 1700) || defined(_M_ARM)
|
||||
unsigned long index = 0;
|
||||
_BitScanForward(&index, value);
|
||||
return (unsigned int)index;
|
||||
#else
|
||||
return _tzcnt_u32(value);
|
||||
#endif
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
return __builtin_ctz(value);
|
||||
#elif defined(__ICC) || defined(__INTEL_COMPILER)
|
||||
return _bit_scan_forward(value);
|
||||
#elif defined(__clang__)
|
||||
return llvm.cttz.i32(value, true);
|
||||
#else
|
||||
static const int MultiplyDeBruijnBitPosition[32] = {
|
||||
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
|
||||
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };
|
||||
return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
} // cv::
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_INTRIN_CPP_HPP__
|
||||
#define __OPENCV_HAL_INTRIN_CPP_HPP__
|
||||
#ifndef OPENCV_HAL_INTRIN_CPP_HPP
|
||||
#define OPENCV_HAL_INTRIN_CPP_HPP
|
||||
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
|
|
@ -53,6 +53,10 @@
|
|||
namespace cv
|
||||
{
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
/** @addtogroup core_hal_intrin
|
||||
|
||||
"Universal intrinsics" is a types and functions set intended to simplify vectorization of code on
|
||||
|
|
@ -95,7 +99,7 @@ block and to save contents of the register to memory block.
|
|||
@ref v_setall_s8, @ref v_setall_u8, ...,
|
||||
@ref v_setzero_u8, @ref v_setzero_s8, ...
|
||||
- Memory operations:
|
||||
@ref v_load, @ref v_load_aligned, @ref v_load_halves,
|
||||
@ref v_load, @ref v_load_aligned, @ref v_load_low, @ref v_load_halves,
|
||||
@ref v_store, @ref v_store_aligned,
|
||||
@ref v_store_high, @ref v_store_low
|
||||
|
||||
|
|
@ -103,7 +107,7 @@ block and to save contents of the register to memory block.
|
|||
|
||||
These operations allow to reorder or recombine elements in one or multiple vectors.
|
||||
|
||||
- Interleave, deinterleave (3 and 4 channels): @ref v_load_deinterleave, @ref v_store_interleave
|
||||
- Interleave, deinterleave (2, 3 and 4 channels): @ref v_load_deinterleave, @ref v_store_interleave
|
||||
- Expand: @ref v_load_expand, @ref v_load_expand_q, @ref v_expand
|
||||
- Pack: @ref v_pack, @ref v_pack_u, @ref v_rshr_pack, @ref v_rshr_pack_u,
|
||||
@ref v_pack_store, @ref v_pack_u_store, @ref v_rshr_pack_store, @ref v_rshr_pack_u_store
|
||||
|
|
@ -116,32 +120,32 @@ These operations allow to reorder or recombine elements in one or multiple vecto
|
|||
Element-wise binary and unary operations.
|
||||
|
||||
- Arithmetics:
|
||||
@ref operator+(const v_reg &a, const v_reg &b) "+",
|
||||
@ref operator-(const v_reg &a, const v_reg &b) "-",
|
||||
@ref operator*(const v_reg &a, const v_reg &b) "*",
|
||||
@ref operator/(const v_reg &a, const v_reg &b) "/",
|
||||
@ref operator +(const v_reg &a, const v_reg &b) "+",
|
||||
@ref operator -(const v_reg &a, const v_reg &b) "-",
|
||||
@ref operator *(const v_reg &a, const v_reg &b) "*",
|
||||
@ref operator /(const v_reg &a, const v_reg &b) "/",
|
||||
@ref v_mul_expand
|
||||
|
||||
- Non-saturating arithmetics: @ref v_add_wrap, @ref v_sub_wrap
|
||||
|
||||
- Bitwise shifts:
|
||||
@ref operator<<(const v_reg &a, int s) "<<",
|
||||
@ref operator>>(const v_reg &a, int s) ">>",
|
||||
@ref operator <<(const v_reg &a, int s) "<<",
|
||||
@ref operator >>(const v_reg &a, int s) ">>",
|
||||
@ref v_shl, @ref v_shr
|
||||
|
||||
- Bitwise logic:
|
||||
@ref operator&(const v_reg &a, const v_reg &b) "&",
|
||||
@ref operator|(const v_reg &a, const v_reg &b) "|",
|
||||
@ref operator^(const v_reg &a, const v_reg &b) "^",
|
||||
@ref operator~(const v_reg &a) "~"
|
||||
@ref operator |(const v_reg &a, const v_reg &b) "|",
|
||||
@ref operator ^(const v_reg &a, const v_reg &b) "^",
|
||||
@ref operator ~(const v_reg &a) "~"
|
||||
|
||||
- Comparison:
|
||||
@ref operator>(const v_reg &a, const v_reg &b) ">",
|
||||
@ref operator>=(const v_reg &a, const v_reg &b) ">=",
|
||||
@ref operator<(const v_reg &a, const v_reg &b) "<",
|
||||
@ref operator<=(const v_reg &a, const v_reg &b) "<=",
|
||||
@ref operator >(const v_reg &a, const v_reg &b) ">",
|
||||
@ref operator >=(const v_reg &a, const v_reg &b) ">=",
|
||||
@ref operator <(const v_reg &a, const v_reg &b) "<",
|
||||
@ref operator <=(const v_reg &a, const v_reg &b) "<=",
|
||||
@ref operator==(const v_reg &a, const v_reg &b) "==",
|
||||
@ref operator!=(const v_reg &a, const v_reg &b) "!="
|
||||
@ref operator !=(const v_reg &a, const v_reg &b) "!="
|
||||
|
||||
- min/max: @ref v_min, @ref v_max
|
||||
|
||||
|
|
@ -149,7 +153,7 @@ Element-wise binary and unary operations.
|
|||
|
||||
Most of these operations return only one value.
|
||||
|
||||
- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum
|
||||
- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum, @ref v_popcount
|
||||
- Mask: @ref v_signmask, @ref v_check_all, @ref v_check_any, @ref v_select
|
||||
|
||||
### Other math
|
||||
|
|
@ -455,8 +459,10 @@ template<typename _Tp, int n> inline v_reg<_Tp, n> operator ~ (const v_reg<_Tp,
|
|||
{
|
||||
v_reg<_Tp, n> c;
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int(~V_TypeTraits<_Tp>::reinterpret_int(a.s[i]));
|
||||
return c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
//! @brief Helper macro
|
||||
|
|
@ -572,6 +578,49 @@ Scheme:
|
|||
For 32-bit integer and 32-bit floating point types. */
|
||||
OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_max, std::max)
|
||||
|
||||
static const unsigned char popCountTable[] =
|
||||
{
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
||||
};
|
||||
/** @brief Count the 1 bits in the vector and return 4 values
|
||||
|
||||
Scheme:
|
||||
@code
|
||||
{A1 A2 A3 ...} => popcount(A1)
|
||||
@endcode
|
||||
Any types but result will be in v_uint32x4*/
|
||||
template<typename _Tp, int n> inline v_uint32x4 v_popcount(const v_reg<_Tp, n>& a)
|
||||
{
|
||||
v_uint8x16 b;
|
||||
b = v_reinterpret_as_u8(a);
|
||||
for( int i = 0; i < v_uint8x16::nlanes; i++ )
|
||||
{
|
||||
b.s[i] = popCountTable[b.s[i]];
|
||||
}
|
||||
v_uint32x4 c;
|
||||
for( int i = 0; i < v_uint32x4::nlanes; i++ )
|
||||
{
|
||||
c.s[i] = b.s[i*4] + b.s[i*4+1] + b.s[i*4+2] + b.s[i*4+3];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
//! @cond IGNORED
|
||||
template<typename _Tp, int n>
|
||||
inline void v_minmax( const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b,
|
||||
|
|
@ -672,7 +721,7 @@ inline v_reg<typename V_TypeTraits<_Tp>::abs_type, n> v_absdiff(const v_reg<_Tp,
|
|||
{
|
||||
typedef typename V_TypeTraits<_Tp>::abs_type rtype;
|
||||
v_reg<rtype, n> c;
|
||||
const rtype mask = std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0;
|
||||
const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0);
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
rtype ua = a.s[i] ^ mask;
|
||||
|
|
@ -836,12 +885,59 @@ template<typename _Tp, int n> inline v_reg<_Tp, n> operator shift_op(const v_reg
|
|||
/** @brief Bitwise shift left
|
||||
|
||||
For 16-, 32- and 64-bit integer values. */
|
||||
OPENCV_HAL_IMPL_SHIFT_OP(<<)
|
||||
OPENCV_HAL_IMPL_SHIFT_OP(<< )
|
||||
|
||||
/** @brief Bitwise shift right
|
||||
|
||||
For 16-, 32- and 64-bit integer values. */
|
||||
OPENCV_HAL_IMPL_SHIFT_OP(>>)
|
||||
OPENCV_HAL_IMPL_SHIFT_OP(>> )
|
||||
|
||||
/** @brief Element shift left among vector
|
||||
|
||||
For all type */
|
||||
#define OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(suffix,opA,opB) \
|
||||
template<int imm, typename _Tp, int n> inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a) \
|
||||
{ \
|
||||
v_reg<_Tp, n> b; \
|
||||
for (int i = 0; i < n; i++) \
|
||||
{ \
|
||||
int sIndex = i opA imm; \
|
||||
if (0 <= sIndex && sIndex < n) \
|
||||
{ \
|
||||
b.s[i] = a.s[sIndex]; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
b.s[i] = 0; \
|
||||
} \
|
||||
} \
|
||||
return b; \
|
||||
} \
|
||||
template<int imm, typename _Tp, int n> inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \
|
||||
{ \
|
||||
v_reg<_Tp, n> c; \
|
||||
for (int i = 0; i < n; i++) \
|
||||
{ \
|
||||
int aIndex = i opA imm; \
|
||||
int bIndex = i opA imm opB n; \
|
||||
if (0 <= bIndex && bIndex < n) \
|
||||
{ \
|
||||
c.s[i] = b.s[bIndex]; \
|
||||
} \
|
||||
else if (0 <= aIndex && aIndex < n) \
|
||||
{ \
|
||||
c.s[i] = a.s[aIndex]; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
c.s[i] = 0; \
|
||||
} \
|
||||
} \
|
||||
return c; \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(left, -, +)
|
||||
OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(right, +, -)
|
||||
|
||||
/** @brief Sum packed values
|
||||
|
||||
|
|
@ -858,6 +954,27 @@ template<typename _Tp, int n> inline typename V_TypeTraits<_Tp>::sum_type v_redu
|
|||
return c;
|
||||
}
|
||||
|
||||
/** @brief Sums all elements of each input vector, returns the vector of sums
|
||||
|
||||
Scheme:
|
||||
@code
|
||||
result[0] = a[0] + a[1] + a[2] + a[3]
|
||||
result[1] = b[0] + b[1] + b[2] + b[3]
|
||||
result[2] = c[0] + c[1] + c[2] + c[3]
|
||||
result[3] = d[0] + d[1] + d[2] + d[3]
|
||||
@endcode
|
||||
*/
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
{
|
||||
v_float32x4 r;
|
||||
r.s[0] = a.s[0] + a.s[1] + a.s[2] + a.s[3];
|
||||
r.s[1] = b.s[0] + b.s[1] + b.s[2] + b.s[3];
|
||||
r.s[2] = c.s[0] + c.s[1] + c.s[2] + c.s[3];
|
||||
r.s[3] = d.s[0] + d.s[1] + d.s[2] + d.s[3];
|
||||
return r;
|
||||
}
|
||||
|
||||
/** @brief Get negative values mask
|
||||
|
||||
Returned value is a bit mask with bits set to 1 on places corresponding to negative packed values indexes.
|
||||
|
|
@ -1010,6 +1127,26 @@ inline v_reg<_Tp, V_SIMD128Traits<_Tp>::nlanes> v_load_aligned(const _Tp* ptr)
|
|||
return v_reg<_Tp, V_SIMD128Traits<_Tp>::nlanes>(ptr);
|
||||
}
|
||||
|
||||
/** @brief Load 64-bits of data to lower part (high part is undefined).
|
||||
|
||||
@param ptr memory block containing data for first half (0..n/2)
|
||||
|
||||
@code{.cpp}
|
||||
int lo[2] = { 1, 2 };
|
||||
v_int32x4 r = v_load_low(lo);
|
||||
@endcode
|
||||
*/
|
||||
template<typename _Tp>
|
||||
inline v_reg<_Tp, V_SIMD128Traits<_Tp>::nlanes> v_load_low(const _Tp* ptr)
|
||||
{
|
||||
v_reg<_Tp, V_SIMD128Traits<_Tp>::nlanes> c;
|
||||
for( int i = 0; i < c.nlanes/2; i++ )
|
||||
{
|
||||
c.s[i] = ptr[i];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/** @brief Load register contents from two memory blocks
|
||||
|
||||
@param loptr memory block containing data for first half (0..n/2)
|
||||
|
|
@ -1075,12 +1212,31 @@ v_load_expand_q(const _Tp* ptr)
|
|||
return c;
|
||||
}
|
||||
|
||||
/** @brief Load and deinterleave (4 channels)
|
||||
/** @brief Load and deinterleave (2 channels)
|
||||
|
||||
Load data from memory deinterleave and store to 4 registers.
|
||||
Load data from memory deinterleave and store to 2 registers.
|
||||
Scheme:
|
||||
@code
|
||||
{A1 B1 C1 D1 A2 B2 C2 D2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...}
|
||||
{A1 B1 A2 B2 ...} ==> {A1 A2 ...}, {B1 B2 ...}
|
||||
@endcode
|
||||
For all types except 64-bit. */
|
||||
template<typename _Tp, int n> inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a,
|
||||
v_reg<_Tp, n>& b)
|
||||
{
|
||||
int i, i2;
|
||||
for( i = i2 = 0; i < n; i++, i2 += 2 )
|
||||
{
|
||||
a.s[i] = ptr[i2];
|
||||
b.s[i] = ptr[i2+1];
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Load and deinterleave (3 channels)
|
||||
|
||||
Load data from memory deinterleave and store to 3 registers.
|
||||
Scheme:
|
||||
@code
|
||||
{A1 B1 C1 A2 B2 C2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}
|
||||
@endcode
|
||||
For all types except 64-bit. */
|
||||
template<typename _Tp, int n> inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a,
|
||||
|
|
@ -1095,12 +1251,12 @@ template<typename _Tp, int n> inline void v_load_deinterleave(const _Tp* ptr, v_
|
|||
}
|
||||
}
|
||||
|
||||
/** @brief Load and deinterleave (3 channels)
|
||||
/** @brief Load and deinterleave (4 channels)
|
||||
|
||||
Load data from memory deinterleave and store to 3 registers.
|
||||
Load data from memory deinterleave and store to 4 registers.
|
||||
Scheme:
|
||||
@code
|
||||
{A1 B1 C1 A2 B2 C2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}
|
||||
{A1 B1 C1 D1 A2 B2 C2 D2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...}
|
||||
@endcode
|
||||
For all types except 64-bit. */
|
||||
template<typename _Tp, int n>
|
||||
|
|
@ -1118,12 +1274,32 @@ inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a,
|
|||
}
|
||||
}
|
||||
|
||||
/** @brief Interleave and store (2 channels)
|
||||
|
||||
Interleave and store data from 2 registers to memory.
|
||||
Scheme:
|
||||
@code
|
||||
{A1 A2 ...}, {B1 B2 ...} ==> {A1 B1 A2 B2 ...}
|
||||
@endcode
|
||||
For all types except 64-bit. */
|
||||
template<typename _Tp, int n>
|
||||
inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a,
|
||||
const v_reg<_Tp, n>& b)
|
||||
{
|
||||
int i, i2;
|
||||
for( i = i2 = 0; i < n; i++, i2 += 2 )
|
||||
{
|
||||
ptr[i2] = a.s[i];
|
||||
ptr[i2+1] = b.s[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Interleave and store (3 channels)
|
||||
|
||||
Interleave and store data from 3 registers to memory.
|
||||
Scheme:
|
||||
@code
|
||||
{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...} ==> {A1 B1 C1 D1 A2 B2 C2 D2 ...}
|
||||
{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...} ==> {A1 B1 C1 A2 B2 C2 ...}
|
||||
@endcode
|
||||
For all types except 64-bit. */
|
||||
template<typename _Tp, int n>
|
||||
|
|
@ -1586,14 +1762,14 @@ OPENCV_HAL_IMPL_C_RSHIFTR(v_int64x2, int64)
|
|||
|
||||
//! @brief Helper macro
|
||||
//! @ingroup core_hal_intrin_impl
|
||||
#define OPENCV_HAL_IMPL_C_PACK(_Tpvec, _Tpnvec, _Tpn, pack_suffix) \
|
||||
#define OPENCV_HAL_IMPL_C_PACK(_Tpvec, _Tpnvec, _Tpn, pack_suffix, cast) \
|
||||
inline _Tpnvec v_##pack_suffix(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
_Tpnvec c; \
|
||||
for( int i = 0; i < _Tpvec::nlanes; i++ ) \
|
||||
{ \
|
||||
c.s[i] = saturate_cast<_Tpn>(a.s[i]); \
|
||||
c.s[i+_Tpvec::nlanes] = saturate_cast<_Tpn>(b.s[i]); \
|
||||
c.s[i] = cast<_Tpn>(a.s[i]); \
|
||||
c.s[i+_Tpvec::nlanes] = cast<_Tpn>(b.s[i]); \
|
||||
} \
|
||||
return c; \
|
||||
}
|
||||
|
|
@ -1607,26 +1783,28 @@ inline _Tpnvec v_##pack_suffix(const _Tpvec& a, const _Tpvec& b) \
|
|||
//!
|
||||
//! - pack: for 16-, 32- and 64-bit integer input types
|
||||
//! - pack_u: for 16- and 32-bit signed integer input types
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint16x8, v_uint8x16, uchar, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int16x8, v_int8x16, schar, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint32x4, v_uint16x8, ushort, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int32x4, v_int16x8, short, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint64x2, v_uint32x4, unsigned, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int64x2, v_int32x4, int, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int16x8, v_uint8x16, uchar, pack_u)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int32x4, v_uint16x8, ushort, pack_u)
|
||||
//!
|
||||
//! @note All variants except 64-bit use saturation.
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint16x8, v_uint8x16, uchar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int16x8, v_int8x16, schar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint32x4, v_uint16x8, ushort, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int32x4, v_int16x8, short, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_uint64x2, v_uint32x4, unsigned, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int64x2, v_int32x4, int, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int16x8, v_uint8x16, uchar, pack_u, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK(v_int32x4, v_uint16x8, ushort, pack_u, saturate_cast)
|
||||
//! @}
|
||||
|
||||
//! @brief Helper macro
|
||||
//! @ingroup core_hal_intrin_impl
|
||||
#define OPENCV_HAL_IMPL_C_RSHR_PACK(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix) \
|
||||
#define OPENCV_HAL_IMPL_C_RSHR_PACK(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix, cast) \
|
||||
template<int n> inline _Tpnvec v_rshr_##pack_suffix(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
_Tpnvec c; \
|
||||
for( int i = 0; i < _Tpvec::nlanes; i++ ) \
|
||||
{ \
|
||||
c.s[i] = saturate_cast<_Tpn>((a.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
c.s[i+_Tpvec::nlanes] = saturate_cast<_Tpn>((b.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
c.s[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
c.s[i+_Tpvec::nlanes] = cast<_Tpn>((b.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
} \
|
||||
return c; \
|
||||
}
|
||||
|
|
@ -1640,51 +1818,55 @@ template<int n> inline _Tpnvec v_rshr_##pack_suffix(const _Tpvec& a, const _Tpve
|
|||
//!
|
||||
//! - pack: for 16-, 32- and 64-bit integer input types
|
||||
//! - pack_u: for 16- and 32-bit signed integer input types
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint16x8, ushort, v_uint8x16, uchar, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int16x8, short, v_int8x16, schar, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint32x4, unsigned, v_uint16x8, ushort, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int32x4, int, v_int16x8, short, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint64x2, uint64, v_uint32x4, unsigned, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int64x2, int64, v_int32x4, int, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int16x8, short, v_uint8x16, uchar, pack_u)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int32x4, int, v_uint16x8, ushort, pack_u)
|
||||
//!
|
||||
//! @note All variants except 64-bit use saturation.
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint16x8, ushort, v_uint8x16, uchar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int16x8, short, v_int8x16, schar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint32x4, unsigned, v_uint16x8, ushort, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int32x4, int, v_int16x8, short, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_uint64x2, uint64, v_uint32x4, unsigned, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int64x2, int64, v_int32x4, int, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int16x8, short, v_uint8x16, uchar, pack_u, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK(v_int32x4, int, v_uint16x8, ushort, pack_u, saturate_cast)
|
||||
//! @}
|
||||
|
||||
//! @brief Helper macro
|
||||
//! @ingroup core_hal_intrin_impl
|
||||
#define OPENCV_HAL_IMPL_C_PACK_STORE(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix) \
|
||||
#define OPENCV_HAL_IMPL_C_PACK_STORE(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix, cast) \
|
||||
inline void v_##pack_suffix##_store(_Tpn* ptr, const _Tpvec& a) \
|
||||
{ \
|
||||
for( int i = 0; i < _Tpvec::nlanes; i++ ) \
|
||||
ptr[i] = saturate_cast<_Tpn>(a.s[i]); \
|
||||
ptr[i] = cast<_Tpn>(a.s[i]); \
|
||||
}
|
||||
|
||||
//! @name Pack and store
|
||||
//! @{
|
||||
//! @brief Store values from the input vector into memory with pack
|
||||
//!
|
||||
//! Values will be stored into memory with saturating conversion to narrower type.
|
||||
//! Values will be stored into memory with conversion to narrower type.
|
||||
//! Variant with _u_ suffix converts to corresponding unsigned type.
|
||||
//!
|
||||
//! - pack: for 16-, 32- and 64-bit integer input types
|
||||
//! - pack_u: for 16- and 32-bit signed integer input types
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint16x8, ushort, v_uint8x16, uchar, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int16x8, short, v_int8x16, schar, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint32x4, unsigned, v_uint16x8, ushort, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int32x4, int, v_int16x8, short, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint64x2, uint64, v_uint32x4, unsigned, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int64x2, int64, v_int32x4, int, pack)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int16x8, short, v_uint8x16, uchar, pack_u)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int32x4, int, v_uint16x8, ushort, pack_u)
|
||||
//!
|
||||
//! @note All variants except 64-bit use saturation.
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint16x8, ushort, v_uint8x16, uchar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int16x8, short, v_int8x16, schar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint32x4, unsigned, v_uint16x8, ushort, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int32x4, int, v_int16x8, short, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_uint64x2, uint64, v_uint32x4, unsigned, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int64x2, int64, v_int32x4, int, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int16x8, short, v_uint8x16, uchar, pack_u, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_PACK_STORE(v_int32x4, int, v_uint16x8, ushort, pack_u, saturate_cast)
|
||||
//! @}
|
||||
|
||||
//! @brief Helper macro
|
||||
//! @ingroup core_hal_intrin_impl
|
||||
#define OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix) \
|
||||
#define OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(_Tpvec, _Tp, _Tpnvec, _Tpn, pack_suffix, cast) \
|
||||
template<int n> inline void v_rshr_##pack_suffix##_store(_Tpn* ptr, const _Tpvec& a) \
|
||||
{ \
|
||||
for( int i = 0; i < _Tpvec::nlanes; i++ ) \
|
||||
ptr[i] = saturate_cast<_Tpn>((a.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
ptr[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (n - 1))) >> n); \
|
||||
}
|
||||
|
||||
//! @name Pack and store with rounding shift
|
||||
|
|
@ -1696,14 +1878,16 @@ template<int n> inline void v_rshr_##pack_suffix##_store(_Tpn* ptr, const _Tpvec
|
|||
//!
|
||||
//! - pack: for 16-, 32- and 64-bit integer input types
|
||||
//! - pack_u: for 16- and 32-bit signed integer input types
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint16x8, ushort, v_uint8x16, uchar, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int16x8, short, v_int8x16, schar, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint32x4, unsigned, v_uint16x8, ushort, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int32x4, int, v_int16x8, short, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint64x2, uint64, v_uint32x4, unsigned, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int64x2, int64, v_int32x4, int, pack)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int16x8, short, v_uint8x16, uchar, pack_u)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int32x4, int, v_uint16x8, ushort, pack_u)
|
||||
//!
|
||||
//! @note All variants except 64-bit use saturation.
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint16x8, ushort, v_uint8x16, uchar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int16x8, short, v_int8x16, schar, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint32x4, unsigned, v_uint16x8, ushort, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int32x4, int, v_int16x8, short, pack, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_uint64x2, uint64, v_uint32x4, unsigned, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int64x2, int64, v_int32x4, int, pack, static_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int16x8, short, v_uint8x16, uchar, pack_u, saturate_cast)
|
||||
OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(v_int32x4, int, v_uint16x8, ushort, pack_u, saturate_cast)
|
||||
//! @}
|
||||
|
||||
/** @brief Matrix multiplication
|
||||
|
|
@ -1731,8 +1915,45 @@ inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
|||
v.s[0]*m0.s[3] + v.s[1]*m1.s[3] + v.s[2]*m2.s[3] + v.s[3]*m3.s[3]);
|
||||
}
|
||||
|
||||
/** @brief Matrix multiplication and add
|
||||
|
||||
Scheme:
|
||||
@code
|
||||
{A0 A1 A2 } |V0| |D0|
|
||||
{B0 B1 B2 } |V1| |D1|
|
||||
{C0 C1 C2 } x |V2| + |D2|
|
||||
====================
|
||||
{R0 R1 R2 R3}, where:
|
||||
R0 = A0V0 + A1V1 + A2V2 + D0,
|
||||
R1 = B0V0 + B1V1 + B2V2 + D1
|
||||
...
|
||||
@endcode
|
||||
*/
|
||||
inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& m3)
|
||||
{
|
||||
return v_float32x4(v.s[0]*m0.s[0] + v.s[1]*m1.s[0] + v.s[2]*m2.s[0] + m3.s[0],
|
||||
v.s[0]*m0.s[1] + v.s[1]*m1.s[1] + v.s[2]*m2.s[1] + m3.s[1],
|
||||
v.s[0]*m0.s[2] + v.s[1]*m1.s[2] + v.s[2]*m2.s[2] + m3.s[2],
|
||||
v.s[0]*m0.s[3] + v.s[1]*m1.s[3] + v.s[2]*m2.s[3] + m3.s[3]);
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
//! @name Check SIMD support
|
||||
//! @{
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -42,17 +42,42 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_INTRIN_NEON_HPP__
|
||||
#define __OPENCV_HAL_INTRIN_NEON_HPP__
|
||||
#ifndef OPENCV_HAL_INTRIN_NEON_HPP
|
||||
#define OPENCV_HAL_INTRIN_NEON_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
#define CV_SIMD128 1
|
||||
#if defined(__aarch64__)
|
||||
#define CV_SIMD128_64F 1
|
||||
#else
|
||||
#define CV_SIMD128_64F 0
|
||||
#endif
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \
|
||||
template <typename T> static inline \
|
||||
_Tpv vreinterpretq_##suffix##_f64(T a) { return (_Tpv) a; } \
|
||||
template <typename T> static inline \
|
||||
float64x2_t vreinterpretq_f64_##suffix(T a) { return (float64x2_t) a; }
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(uint8x16_t, u8)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(int8x16_t, s8)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(uint16x8_t, u16)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(int16x8_t, s16)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(uint32x4_t, u32)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(int32x4_t, s32)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(uint64x2_t, u64)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(int64x2_t, s64)
|
||||
OPENCV_HAL_IMPL_NEON_REINTERPRET(float32x4_t, f32)
|
||||
#endif
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
|
|
@ -201,7 +226,7 @@ struct v_uint64x2
|
|||
|
||||
v_uint64x2() {}
|
||||
explicit v_uint64x2(uint64x2_t v) : val(v) {}
|
||||
v_uint64x2(unsigned v0, unsigned v1)
|
||||
v_uint64x2(uint64 v0, uint64 v1)
|
||||
{
|
||||
uint64 v[] = {v0, v1};
|
||||
val = vld1q_u64(v);
|
||||
|
|
@ -220,7 +245,7 @@ struct v_int64x2
|
|||
|
||||
v_int64x2() {}
|
||||
explicit v_int64x2(int64x2_t v) : val(v) {}
|
||||
v_int64x2(int v0, int v1)
|
||||
v_int64x2(int64 v0, int64 v1)
|
||||
{
|
||||
int64 v[] = {v0, v1};
|
||||
val = vld1q_s64(v);
|
||||
|
|
@ -232,6 +257,70 @@ struct v_int64x2
|
|||
int64x2_t val;
|
||||
};
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
struct v_float64x2
|
||||
{
|
||||
typedef double lane_type;
|
||||
enum { nlanes = 2 };
|
||||
|
||||
v_float64x2() {}
|
||||
explicit v_float64x2(float64x2_t v) : val(v) {}
|
||||
v_float64x2(double v0, double v1)
|
||||
{
|
||||
double v[] = {v0, v1};
|
||||
val = vld1q_f64(v);
|
||||
}
|
||||
double get0() const
|
||||
{
|
||||
return vgetq_lane_f64(val, 0);
|
||||
}
|
||||
float64x2_t val;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if CV_FP16
|
||||
// Workaround for old compilers
|
||||
template <typename T> static inline int16x4_t vreinterpret_s16_f16(T a)
|
||||
{ return (int16x4_t)a; }
|
||||
template <typename T> static inline float16x4_t vreinterpret_f16_s16(T a)
|
||||
{ return (float16x4_t)a; }
|
||||
template <typename T> static inline float16x4_t cv_vld1_f16(const T* ptr)
|
||||
{
|
||||
#ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro
|
||||
return vreinterpret_f16_s16(vld1_s16((const short*)ptr));
|
||||
#else
|
||||
return vld1_f16((const __fp16*)ptr);
|
||||
#endif
|
||||
}
|
||||
template <typename T> static inline void cv_vst1_f16(T* ptr, float16x4_t a)
|
||||
{
|
||||
#ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro
|
||||
vst1_s16((short*)ptr, vreinterpret_s16_f16(a));
|
||||
#else
|
||||
vst1_f16((__fp16*)ptr, a);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct v_float16x4
|
||||
{
|
||||
typedef short lane_type;
|
||||
enum { nlanes = 4 };
|
||||
|
||||
v_float16x4() {}
|
||||
explicit v_float16x4(float16x4_t v) : val(v) {}
|
||||
v_float16x4(short v0, short v1, short v2, short v3)
|
||||
{
|
||||
short v[] = {v0, v1, v2, v3};
|
||||
val = cv_vld1_f16(v);
|
||||
}
|
||||
short get0() const
|
||||
{
|
||||
return vget_lane_s16(vreinterpret_s16_f16(val), 0);
|
||||
}
|
||||
float16x4_t val;
|
||||
};
|
||||
#endif
|
||||
|
||||
#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_setall_##suffix(_Tp v) { return v_##_Tpv(vdupq_n_##suffix(v)); } \
|
||||
|
|
@ -255,41 +344,56 @@ OPENCV_HAL_IMPL_NEON_INIT(int32x4, int, s32)
|
|||
OPENCV_HAL_IMPL_NEON_INIT(uint64x2, uint64, u64)
|
||||
OPENCV_HAL_IMPL_NEON_INIT(int64x2, int64, s64)
|
||||
OPENCV_HAL_IMPL_NEON_INIT(float32x4, float, f32)
|
||||
#if CV_SIMD128_64F
|
||||
#define OPENCV_HAL_IMPL_NEON_INIT_64(_Tpv, suffix) \
|
||||
inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(vreinterpretq_f64_##suffix(v.val)); }
|
||||
OPENCV_HAL_IMPL_NEON_INIT(float64x2, double, f64)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(uint8x16, u8)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(int8x16, s8)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(uint16x8, u16)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(int16x8, s16)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(uint32x4, u32)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(int32x4, s32)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(uint64x2, u64)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(int64x2, s64)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(float32x4, f32)
|
||||
OPENCV_HAL_IMPL_NEON_INIT_64(float64x2, f64)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_PACK(_Tpvec, _Tp, hreg, suffix, _Tpwvec, wsuffix, pack, op) \
|
||||
#define OPENCV_HAL_IMPL_NEON_PACK(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \
|
||||
inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
hreg a1 = vqmov##op##_##wsuffix(a.val), b1 = vqmov##op##_##wsuffix(b.val); \
|
||||
hreg a1 = mov(a.val), b1 = mov(b.val); \
|
||||
return _Tpvec(vcombine_##suffix(a1, b1)); \
|
||||
} \
|
||||
inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
hreg a1 = vqmov##op##_##wsuffix(a.val); \
|
||||
hreg a1 = mov(a.val); \
|
||||
vst1_##suffix(ptr, a1); \
|
||||
} \
|
||||
template<int n> inline \
|
||||
_Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
hreg a1 = vqrshr##op##_n_##wsuffix(a.val, n); \
|
||||
hreg b1 = vqrshr##op##_n_##wsuffix(b.val, n); \
|
||||
hreg a1 = rshr(a.val, n); \
|
||||
hreg b1 = rshr(b.val, n); \
|
||||
return _Tpvec(vcombine_##suffix(a1, b1)); \
|
||||
} \
|
||||
template<int n> inline \
|
||||
void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
hreg a1 = vqrshr##op##_n_##wsuffix(a.val, n); \
|
||||
hreg a1 = rshr(a.val, n); \
|
||||
vst1_##suffix(ptr, a1); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, u16, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, s16, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, u32, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, s32, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, u64, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, s64, pack, n)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, pack, vqmovn_u16, vqrshrn_n_u16)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, pack, vqmovn_s16, vqrshrn_n_s16)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, pack, vqmovn_u32, vqrshrn_n_u32)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, pack, vqmovn_s32, vqrshrn_n_s32)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, pack, vmovn_u64, vrshrn_n_u64)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, pack, vmovn_s64, vrshrn_n_s64)
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, s16, pack_u, un)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, s32, pack_u, un)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, pack_u, vqmovun_s16, vqrshrun_n_s16)
|
||||
OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, pack_u, vqmovun_s32, vqrshrun_n_s32)
|
||||
|
||||
inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
|
|
@ -303,6 +407,18 @@ inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
|||
return v_float32x4(res);
|
||||
}
|
||||
|
||||
inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& a)
|
||||
{
|
||||
float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val);
|
||||
float32x4_t res = vmulq_lane_f32(m0.val, vl, 0);
|
||||
res = vmlaq_lane_f32(res, m1.val, vl, 1);
|
||||
res = vmlaq_lane_f32(res, m2.val, vh, 0);
|
||||
res = vaddq_f32(res, a.val);
|
||||
return v_float32x4(res);
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_BIN_OP(bin_op, _Tpvec, intrin) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
|
|
@ -337,7 +453,13 @@ OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int64x2, vaddq_s64)
|
|||
OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int64x2, vsubq_s64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint64x2, vaddq_u64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint64x2, vsubq_u64)
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float32x4, vdivq_f32)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float64x2, vaddq_f64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float64x2, vsubq_f64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float64x2, vmulq_f64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float64x2, vdivq_f64)
|
||||
#else
|
||||
inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b)
|
||||
{
|
||||
float32x4_t reciprocal = vrecpeq_f32(b.val);
|
||||
|
|
@ -353,6 +475,7 @@ inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b)
|
|||
a.val = vmulq_f32(a.val, reciprocal);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b,
|
||||
v_int32x4& c, v_int32x4& d)
|
||||
|
|
@ -421,6 +544,18 @@ inline v_float32x4 operator ~ (const v_float32x4& a)
|
|||
return v_float32x4(vreinterpretq_f32_s32(vmvnq_s32(vreinterpretq_s32_f32(a.val))));
|
||||
}
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline v_float32x4 v_sqrt(const v_float32x4& x)
|
||||
{
|
||||
return v_float32x4(vsqrtq_f32(x.val));
|
||||
}
|
||||
|
||||
inline v_float32x4 v_invsqrt(const v_float32x4& x)
|
||||
{
|
||||
v_float32x4 one = v_setall_f32(1.0f);
|
||||
return one / v_sqrt(x);
|
||||
}
|
||||
#else
|
||||
inline v_float32x4 v_sqrt(const v_float32x4& x)
|
||||
{
|
||||
float32x4_t x1 = vmaxq_f32(x.val, vdupq_n_f32(FLT_MIN));
|
||||
|
|
@ -437,10 +572,54 @@ inline v_float32x4 v_invsqrt(const v_float32x4& x)
|
|||
e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e);
|
||||
return v_float32x4(e);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \
|
||||
inline _Tpuvec v_abs(const _Tpsvec& a) { return v_reinterpret_as_##usuffix(_Tpsvec(vabsq_##ssuffix(a.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_ABS(v_uint8x16, v_int8x16, u8, s8)
|
||||
OPENCV_HAL_IMPL_NEON_ABS(v_uint16x8, v_int16x8, u16, s16)
|
||||
OPENCV_HAL_IMPL_NEON_ABS(v_uint32x4, v_int32x4, u32, s32)
|
||||
|
||||
inline v_float32x4 v_abs(v_float32x4 x)
|
||||
{ return v_float32x4(vabsq_f32(x.val)); }
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
#define OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(bin_op, intrin) \
|
||||
inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \
|
||||
{ \
|
||||
return v_float64x2(vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val)))); \
|
||||
} \
|
||||
inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \
|
||||
{ \
|
||||
a.val = vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val))); \
|
||||
return a; \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(&, vandq_s64)
|
||||
OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(|, vorrq_s64)
|
||||
OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(^, veorq_s64)
|
||||
|
||||
inline v_float64x2 operator ~ (const v_float64x2& a)
|
||||
{
|
||||
return v_float64x2(vreinterpretq_f64_s32(vmvnq_s32(vreinterpretq_s32_f64(a.val))));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_sqrt(const v_float64x2& x)
|
||||
{
|
||||
return v_float64x2(vsqrtq_f64(x.val));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_invsqrt(const v_float64x2& x)
|
||||
{
|
||||
v_float64x2 one = v_setall_f64(1.0f);
|
||||
return one / v_sqrt(x);
|
||||
}
|
||||
|
||||
inline v_float64x2 v_abs(v_float64x2 x)
|
||||
{ return v_float64x2(vabsq_f64(x.val)); }
|
||||
#endif
|
||||
|
||||
// TODO: exp, log, sin, cos
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_BIN_FUNC(_Tpvec, func, intrin) \
|
||||
|
|
@ -463,8 +642,23 @@ OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_min, vminq_s32)
|
|||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_max, vmaxq_s32)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_min, vminq_f32)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_max, vmaxq_f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_min, vminq_f64)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_max, vmaxq_f64)
|
||||
#endif
|
||||
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline int64x2_t vmvnq_s64(int64x2_t a)
|
||||
{
|
||||
int64x2_t vx = vreinterpretq_s64_u32(vdupq_n_u32(0xFFFFFFFF));
|
||||
return veorq_s64(a, vx);
|
||||
}
|
||||
inline uint64x2_t vmvnq_u64(uint64x2_t a)
|
||||
{
|
||||
uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF));
|
||||
return veorq_u64(a, vx);
|
||||
}
|
||||
#endif
|
||||
#define OPENCV_HAL_IMPL_NEON_INT_CMP_OP(_Tpvec, cast, suffix, not_suffix) \
|
||||
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(cast(vceqq_##suffix(a.val, b.val))); } \
|
||||
|
|
@ -486,6 +680,11 @@ OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16)
|
|||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32)
|
||||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32)
|
||||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint64x2, OPENCV_HAL_NOP, u64, u64)
|
||||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int64x2, vreinterpretq_s64_u64, s64, u64)
|
||||
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float64x2, vreinterpretq_f64_u64, f64, u64)
|
||||
#endif
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_add_wrap, vaddq_u8)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_add_wrap, vaddq_s8)
|
||||
|
|
@ -501,6 +700,9 @@ OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_absdiff, vabdq_u8)
|
|||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_absdiff, vabdq_u16)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_absdiff, vabdq_u32)
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_absdiff, vabdq_f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_absdiff, vabdq_f64)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \
|
||||
inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \
|
||||
|
|
@ -528,6 +730,24 @@ inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_
|
|||
return v_float32x4(vmlaq_f32(c.val, a.val, b.val));
|
||||
}
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b)
|
||||
{
|
||||
v_float64x2 x(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val)));
|
||||
return v_sqrt(x);
|
||||
}
|
||||
|
||||
inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b)
|
||||
{
|
||||
return v_float64x2(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val)));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c)
|
||||
{
|
||||
return v_float64x2(vaddq_f64(c.val, vmulq_f64(a.val, b.val)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// trade efficiency for convenience
|
||||
#define OPENCV_HAL_IMPL_NEON_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \
|
||||
inline _Tpvec operator << (const _Tpvec& a, int n) \
|
||||
|
|
@ -539,7 +759,15 @@ template<int n> inline _Tpvec v_shl(const _Tpvec& a) \
|
|||
template<int n> inline _Tpvec v_shr(const _Tpvec& a) \
|
||||
{ return _Tpvec(vshrq_n_##suffix(a.val, n)); } \
|
||||
template<int n> inline _Tpvec v_rshr(const _Tpvec& a) \
|
||||
{ return _Tpvec(vrshrq_n_##suffix(a.val, n)); }
|
||||
{ return _Tpvec(vrshrq_n_##suffix(a.val, n)); } \
|
||||
template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a) \
|
||||
{ return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \
|
||||
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a) \
|
||||
{ return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \
|
||||
template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \
|
||||
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); }
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint8x16, u8, schar, s8)
|
||||
OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int8x16, s8, schar, s8)
|
||||
|
|
@ -555,6 +783,8 @@ inline _Tpvec v_load(const _Tp* ptr) \
|
|||
{ return _Tpvec(vld1q_##suffix(ptr)); } \
|
||||
inline _Tpvec v_load_aligned(const _Tp* ptr) \
|
||||
{ return _Tpvec(vld1q_##suffix(ptr)); } \
|
||||
inline _Tpvec v_load_low(const _Tp* ptr) \
|
||||
{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr), vdup_n_##suffix((_Tp)0))); } \
|
||||
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
|
||||
{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr0), vld1_##suffix(ptr1))); } \
|
||||
inline void v_store(_Tp* ptr, const _Tpvec& a) \
|
||||
|
|
@ -575,26 +805,80 @@ OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int32x4, int, s32)
|
|||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint64x2, uint64, u64)
|
||||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int64x2, int64, s64)
|
||||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, scalartype, func, scalar_func) \
|
||||
#if CV_FP16
|
||||
// Workaround for old comiplers
|
||||
inline v_float16x4 v_load_f16(const short* ptr)
|
||||
{ return v_float16x4(cv_vld1_f16(ptr)); }
|
||||
inline void v_store_f16(short* ptr, v_float16x4& a)
|
||||
{ cv_vst1_f16(ptr, a.val); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \
|
||||
inline scalartype v_reduce_##func(const _Tpvec& a) \
|
||||
{ \
|
||||
scalartype CV_DECL_ALIGNED(16) buf[4]; \
|
||||
v_store_aligned(buf, a); \
|
||||
scalartype s0 = scalar_func(buf[0], buf[1]); \
|
||||
scalartype s1 = scalar_func(buf[2], buf[3]); \
|
||||
return scalar_func(s0, s1); \
|
||||
_Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \
|
||||
a0 = vp##vectorfunc##_##suffix(a0, a0); \
|
||||
return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, unsigned, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int, max, std::max)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int, min, std::min)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float, max, std::max)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float, min, std::min)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, sum, add, u16)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, max, max, u16)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, unsigned short, min, min, u16)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, sum, add, s16)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, max, max, s16)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, min, min, s16)
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \
|
||||
inline scalartype v_reduce_##func(const _Tpvec& a) \
|
||||
{ \
|
||||
_Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \
|
||||
return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, vget_high_##suffix(a.val)),0); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, sum, add, u32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, max, max, u32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, min, min, u32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, sum, add, s32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, max, max, s32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, min, min, s32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, sum, add, f32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, max, max, f32)
|
||||
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, min, min, f32)
|
||||
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
{
|
||||
float32x4x2_t ab = vtrnq_f32(a.val, b.val);
|
||||
float32x4x2_t cd = vtrnq_f32(c.val, d.val);
|
||||
|
||||
float32x4_t u0 = vaddq_f32(ab.val[0], ab.val[1]); // a0+a1 b0+b1 a2+a3 b2+b3
|
||||
float32x4_t u1 = vaddq_f32(cd.val[0], cd.val[1]); // c0+c1 d0+d1 c2+c3 d2+d3
|
||||
|
||||
float32x4_t v0 = vcombine_f32(vget_low_f32(u0), vget_low_f32(u1));
|
||||
float32x4_t v1 = vcombine_f32(vget_high_f32(u0), vget_high_f32(u1));
|
||||
|
||||
return v_float32x4(vaddq_f32(v0, v1));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_POPCOUNT(_Tpvec, cast) \
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a) \
|
||||
{ \
|
||||
uint8x16_t t = vcntq_u8(cast(a.val)); \
|
||||
uint16x8_t t0 = vpaddlq_u8(t); /* 16 -> 8 */ \
|
||||
uint32x4_t t1 = vpaddlq_u16(t0); /* 8 -> 4 */ \
|
||||
return v_uint32x4(t1); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint8x16, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint16x8, vreinterpretq_u8_u16)
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint32x4, vreinterpretq_u8_u32)
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int8x16, vreinterpretq_u8_s8)
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int16x8, vreinterpretq_u8_s16)
|
||||
OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int32x4, vreinterpretq_u8_s32)
|
||||
|
||||
inline int v_signmask(const v_uint8x16& a)
|
||||
{
|
||||
|
|
@ -627,6 +911,16 @@ inline int v_signmask(const v_int32x4& a)
|
|||
{ return v_signmask(v_reinterpret_as_u32(a)); }
|
||||
inline int v_signmask(const v_float32x4& a)
|
||||
{ return v_signmask(v_reinterpret_as_u32(a)); }
|
||||
#if CV_SIMD128_64F
|
||||
inline int v_signmask(const v_uint64x2& a)
|
||||
{
|
||||
int64x1_t m0 = vdup_n_s64(0);
|
||||
uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), vcombine_s64(m0, m0));
|
||||
return (int)vgetq_lane_u64(v0, 0) + ((int)vgetq_lane_u64(v0, 1) << 1);
|
||||
}
|
||||
inline int v_signmask(const v_float64x2& a)
|
||||
{ return v_signmask(v_reinterpret_as_u64(a)); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \
|
||||
inline bool v_check_all(const v_##_Tpvec& a) \
|
||||
|
|
@ -645,6 +939,9 @@ inline bool v_check_any(const v_##_Tpvec& a) \
|
|||
OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint8x16, u8, 7)
|
||||
OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint16x8, u16, 15)
|
||||
OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint32x4, u32, 31)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint64x2, u64, 63)
|
||||
#endif
|
||||
|
||||
inline bool v_check_all(const v_int8x16& a)
|
||||
{ return v_check_all(v_reinterpret_as_u8(a)); }
|
||||
|
|
@ -664,6 +961,17 @@ inline bool v_check_any(const v_int32x4& a)
|
|||
inline bool v_check_any(const v_float32x4& a)
|
||||
{ return v_check_any(v_reinterpret_as_u32(a)); }
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline bool v_check_all(const v_int64x2& a)
|
||||
{ return v_check_all(v_reinterpret_as_u64(a)); }
|
||||
inline bool v_check_all(const v_float64x2& a)
|
||||
{ return v_check_all(v_reinterpret_as_u64(a)); }
|
||||
inline bool v_check_any(const v_int64x2& a)
|
||||
{ return v_check_any(v_reinterpret_as_u64(a)); }
|
||||
inline bool v_check_any(const v_float64x2& a)
|
||||
{ return v_check_any(v_reinterpret_as_u64(a)); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_SELECT(_Tpvec, suffix, usuffix) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
|
|
@ -677,6 +985,9 @@ OPENCV_HAL_IMPL_NEON_SELECT(v_int16x8, s16, u16)
|
|||
OPENCV_HAL_IMPL_NEON_SELECT(v_uint32x4, u32, u32)
|
||||
OPENCV_HAL_IMPL_NEON_SELECT(v_int32x4, s32, u32)
|
||||
OPENCV_HAL_IMPL_NEON_SELECT(v_float32x4, f32, u32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_SELECT(v_float64x2, f64, u64)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \
|
||||
inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \
|
||||
|
|
@ -710,6 +1021,27 @@ inline v_int32x4 v_load_expand_q(const schar* ptr)
|
|||
return v_int32x4(vmovl_s16(v1));
|
||||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \
|
||||
inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \
|
||||
{ \
|
||||
b0.val = vzip1q_##suffix(a0.val, a1.val); \
|
||||
b1.val = vzip2q_##suffix(a0.val, a1.val); \
|
||||
} \
|
||||
inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \
|
||||
{ \
|
||||
return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \
|
||||
} \
|
||||
inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \
|
||||
{ \
|
||||
return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \
|
||||
} \
|
||||
inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \
|
||||
{ \
|
||||
c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \
|
||||
d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \
|
||||
}
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \
|
||||
inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \
|
||||
{ \
|
||||
|
|
@ -730,6 +1062,7 @@ inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c,
|
|||
c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \
|
||||
d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
OPENCV_HAL_IMPL_NEON_UNPACKS(uint8x16, u8)
|
||||
OPENCV_HAL_IMPL_NEON_UNPACKS(int8x16, s8)
|
||||
|
|
@ -738,6 +1071,9 @@ OPENCV_HAL_IMPL_NEON_UNPACKS(int16x8, s16)
|
|||
OPENCV_HAL_IMPL_NEON_UNPACKS(uint32x4, u32)
|
||||
OPENCV_HAL_IMPL_NEON_UNPACKS(int32x4, s32)
|
||||
OPENCV_HAL_IMPL_NEON_UNPACKS(float32x4, f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_UNPACKS(float64x2, f64)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_EXTRACT(_Tpvec, suffix) \
|
||||
template <int s> \
|
||||
|
|
@ -755,6 +1091,9 @@ OPENCV_HAL_IMPL_NEON_EXTRACT(int32x4, s32)
|
|||
OPENCV_HAL_IMPL_NEON_EXTRACT(uint64x2, u64)
|
||||
OPENCV_HAL_IMPL_NEON_EXTRACT(int64x2, s64)
|
||||
OPENCV_HAL_IMPL_NEON_EXTRACT(float32x4, f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_EXTRACT(float64x2, f64)
|
||||
#endif
|
||||
|
||||
inline v_int32x4 v_round(const v_float32x4& a)
|
||||
{
|
||||
|
|
@ -782,6 +1121,38 @@ inline v_int32x4 v_ceil(const v_float32x4& a)
|
|||
inline v_int32x4 v_trunc(const v_float32x4& a)
|
||||
{ return v_int32x4(vcvtq_s32_f32(a.val)); }
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline v_int32x4 v_round(const v_float64x2& a)
|
||||
{
|
||||
static const int32x2_t zero = vdup_n_s32(0);
|
||||
return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_floor(const v_float64x2& a)
|
||||
{
|
||||
static const int32x2_t zero = vdup_n_s32(0);
|
||||
int64x2_t a1 = vcvtq_s64_f64(a.val);
|
||||
uint64x2_t mask = vcgtq_f64(vcvtq_f64_s64(a1), a.val);
|
||||
a1 = vaddq_s64(a1, vreinterpretq_s64_u64(mask));
|
||||
return v_int32x4(vcombine_s32(vmovn_s64(a1), zero));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_ceil(const v_float64x2& a)
|
||||
{
|
||||
static const int32x2_t zero = vdup_n_s32(0);
|
||||
int64x2_t a1 = vcvtq_s64_f64(a.val);
|
||||
uint64x2_t mask = vcgtq_f64(a.val, vcvtq_f64_s64(a1));
|
||||
a1 = vsubq_s64(a1, vreinterpretq_s64_u64(mask));
|
||||
return v_int32x4(vcombine_s32(vmovn_s64(a1), zero));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_trunc(const v_float64x2& a)
|
||||
{
|
||||
static const int32x2_t zero = vdup_n_s32(0);
|
||||
return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \
|
||||
inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \
|
||||
const v_##_Tpvec& a2, const v_##_Tpvec& a3, \
|
||||
|
|
@ -809,6 +1180,12 @@ OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s32)
|
|||
OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f32)
|
||||
|
||||
#define OPENCV_HAL_IMPL_NEON_INTERLEAVED(_Tpvec, _Tp, suffix) \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \
|
||||
{ \
|
||||
_Tpvec##x2_t v = vld2q_##suffix(ptr); \
|
||||
a.val = v.val[0]; \
|
||||
b.val = v.val[1]; \
|
||||
} \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \
|
||||
{ \
|
||||
_Tpvec##x3_t v = vld3q_##suffix(ptr); \
|
||||
|
|
@ -825,6 +1202,13 @@ inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \
|
|||
c.val = v.val[2]; \
|
||||
d.val = v.val[3]; \
|
||||
} \
|
||||
inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b) \
|
||||
{ \
|
||||
_Tpvec##x2_t v; \
|
||||
v.val[0] = a.val; \
|
||||
v.val[1] = b.val; \
|
||||
vst2q_##suffix(ptr, v); \
|
||||
} \
|
||||
inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, const v_##_Tpvec& c) \
|
||||
{ \
|
||||
_Tpvec##x3_t v; \
|
||||
|
|
@ -851,12 +1235,67 @@ OPENCV_HAL_IMPL_NEON_INTERLEAVED(int16x8, short, s16)
|
|||
OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint32x4, unsigned, u32)
|
||||
OPENCV_HAL_IMPL_NEON_INTERLEAVED(int32x4, int, s32)
|
||||
OPENCV_HAL_IMPL_NEON_INTERLEAVED(float32x4, float, f32)
|
||||
#if CV_SIMD128_64F
|
||||
OPENCV_HAL_IMPL_NEON_INTERLEAVED(float64x2, double, f64)
|
||||
#endif
|
||||
|
||||
inline v_float32x4 v_cvt_f32(const v_int32x4& a)
|
||||
{
|
||||
return v_float32x4(vcvtq_f32_s32(a.val));
|
||||
}
|
||||
|
||||
#if CV_SIMD128_64F
|
||||
inline v_float32x4 v_cvt_f32(const v_float64x2& a)
|
||||
{
|
||||
float32x2_t zero = vdup_n_f32(0.0f);
|
||||
return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), zero));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64(const v_int32x4& a)
|
||||
{
|
||||
return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_low_s32(a.val))));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_int32x4& a)
|
||||
{
|
||||
return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_high_s32(a.val))));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(vcvt_f64_f32(vget_low_f32(a.val)));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(vcvt_f64_f32(vget_high_f32(a.val)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CV_FP16
|
||||
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
|
||||
{
|
||||
return v_float32x4(vcvt_f32_f16(a.val));
|
||||
}
|
||||
|
||||
inline v_float16x4 v_cvt_f16(const v_float32x4& a)
|
||||
{
|
||||
return v_float16x4(vcvt_f16_f32(a.val));
|
||||
}
|
||||
#endif
|
||||
|
||||
//! @name Check SIMD support
|
||||
//! @{
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return (CV_CPU_HAS_SUPPORT_NEON) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
|
@ -42,10 +42,11 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_SSE_HPP__
|
||||
#define __OPENCV_HAL_SSE_HPP__
|
||||
#ifndef OPENCV_HAL_SSE_HPP
|
||||
#define OPENCV_HAL_SSE_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#define CV_SIMD128 1
|
||||
#define CV_SIMD128_64F 1
|
||||
|
|
@ -55,12 +56,14 @@ namespace cv
|
|||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
typedef uchar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
|
||||
v_uint8x16() {}
|
||||
v_uint8x16() : val(_mm_setzero_si128()) {}
|
||||
explicit v_uint8x16(__m128i v) : val(v) {}
|
||||
v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7,
|
||||
uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15)
|
||||
|
|
@ -83,7 +86,7 @@ struct v_int8x16
|
|||
typedef schar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
|
||||
v_int8x16() {}
|
||||
v_int8x16() : val(_mm_setzero_si128()) {}
|
||||
explicit v_int8x16(__m128i v) : val(v) {}
|
||||
v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7,
|
||||
schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15)
|
||||
|
|
@ -106,7 +109,7 @@ struct v_uint16x8
|
|||
typedef ushort lane_type;
|
||||
enum { nlanes = 8 };
|
||||
|
||||
v_uint16x8() {}
|
||||
v_uint16x8() : val(_mm_setzero_si128()) {}
|
||||
explicit v_uint16x8(__m128i v) : val(v) {}
|
||||
v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
|
||||
{
|
||||
|
|
@ -126,7 +129,7 @@ struct v_int16x8
|
|||
typedef short lane_type;
|
||||
enum { nlanes = 8 };
|
||||
|
||||
v_int16x8() {}
|
||||
v_int16x8() : val(_mm_setzero_si128()) {}
|
||||
explicit v_int16x8(__m128i v) : val(v) {}
|
||||
v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7)
|
||||
{
|
||||
|
|
@ -145,7 +148,7 @@ struct v_uint32x4
|
|||
typedef unsigned lane_type;
|
||||
enum { nlanes = 4 };
|
||||
|
||||
v_uint32x4() {}
|
||||
v_uint32x4() : val(_mm_setzero_si128()) {}
|
||||
explicit v_uint32x4(__m128i v) : val(v) {}
|
||||
v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3)
|
||||
{
|
||||
|
|
@ -163,7 +166,7 @@ struct v_int32x4
|
|||
typedef int lane_type;
|
||||
enum { nlanes = 4 };
|
||||
|
||||
v_int32x4() {}
|
||||
v_int32x4() : val(_mm_setzero_si128()) {}
|
||||
explicit v_int32x4(__m128i v) : val(v) {}
|
||||
v_int32x4(int v0, int v1, int v2, int v3)
|
||||
{
|
||||
|
|
@ -181,7 +184,7 @@ struct v_float32x4
|
|||
typedef float lane_type;
|
||||
enum { nlanes = 4 };
|
||||
|
||||
v_float32x4() {}
|
||||
v_float32x4() : val(_mm_setzero_ps()) {}
|
||||
explicit v_float32x4(__m128 v) : val(v) {}
|
||||
v_float32x4(float v0, float v1, float v2, float v3)
|
||||
{
|
||||
|
|
@ -199,7 +202,7 @@ struct v_uint64x2
|
|||
typedef uint64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
|
||||
v_uint64x2() {}
|
||||
v_uint64x2() : val(_mm_setzero_si128()) {}
|
||||
explicit v_uint64x2(__m128i v) : val(v) {}
|
||||
v_uint64x2(uint64 v0, uint64 v1)
|
||||
{
|
||||
|
|
@ -219,7 +222,7 @@ struct v_int64x2
|
|||
typedef int64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
|
||||
v_int64x2() {}
|
||||
v_int64x2() : val(_mm_setzero_si128()) {}
|
||||
explicit v_int64x2(__m128i v) : val(v) {}
|
||||
v_int64x2(int64 v0, int64 v1)
|
||||
{
|
||||
|
|
@ -239,7 +242,7 @@ struct v_float64x2
|
|||
typedef double lane_type;
|
||||
enum { nlanes = 2 };
|
||||
|
||||
v_float64x2() {}
|
||||
v_float64x2() : val(_mm_setzero_pd()) {}
|
||||
explicit v_float64x2(__m128d v) : val(v) {}
|
||||
v_float64x2(double v0, double v1)
|
||||
{
|
||||
|
|
@ -252,6 +255,26 @@ struct v_float64x2
|
|||
__m128d val;
|
||||
};
|
||||
|
||||
#if CV_FP16
|
||||
struct v_float16x4
|
||||
{
|
||||
typedef short lane_type;
|
||||
enum { nlanes = 4 };
|
||||
|
||||
v_float16x4() : val(_mm_setzero_si128()) {}
|
||||
explicit v_float16x4(__m128i v) : val(v) {}
|
||||
v_float16x4(short v0, short v1, short v2, short v3)
|
||||
{
|
||||
val = _mm_setr_epi16(v0, v1, v2, v3, 0, 0, 0, 0);
|
||||
}
|
||||
short get0() const
|
||||
{
|
||||
return (short)_mm_cvtsi128_si32(val);
|
||||
}
|
||||
__m128i val;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_INITVEC(_Tpvec, _Tp, suffix, zsuffix, ssuffix, _Tps, cast) \
|
||||
inline _Tpvec v_setzero_##suffix() { return _Tpvec(_mm_setzero_##zsuffix()); } \
|
||||
inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(_mm_set1_##ssuffix((_Tps)v)); } \
|
||||
|
|
@ -579,6 +602,16 @@ inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
|||
return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, v3)));
|
||||
}
|
||||
|
||||
inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& a)
|
||||
{
|
||||
__m128 v0 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(0, 0, 0, 0)), m0.val);
|
||||
__m128 v1 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(1, 1, 1, 1)), m1.val);
|
||||
__m128 v2 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(2, 2, 2, 2)), m2.val);
|
||||
|
||||
return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, a.val)));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_BIN_OP(bin_op, _Tpvec, intrin) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
|
|
@ -719,6 +752,18 @@ inline v_float64x2 v_invsqrt(const v_float64x2& x)
|
|||
return v_float64x2(_mm_div_pd(v_1, _mm_sqrt_pd(x.val)));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(_Tpuvec, _Tpsvec, func, suffix, subWidth) \
|
||||
inline _Tpuvec v_abs(const _Tpsvec& x) \
|
||||
{ return _Tpuvec(_mm_##func##_ep##suffix(x.val, _mm_sub_ep##subWidth(_mm_setzero_si128(), x.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint8x16, v_int8x16, min, u8, i8)
|
||||
OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint16x8, v_int16x8, max, i16, i16)
|
||||
inline v_uint32x4 v_abs(const v_int32x4& x)
|
||||
{
|
||||
__m128i s = _mm_srli_epi32(x.val, 31);
|
||||
__m128i f = _mm_srai_epi32(x.val, 31);
|
||||
return v_uint32x4(_mm_add_epi32(_mm_xor_si128(x.val, f), s));
|
||||
}
|
||||
inline v_float32x4 v_abs(const v_float32x4& x)
|
||||
{ return v_float32x4(_mm_and_ps(x.val, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)))); }
|
||||
inline v_float64x2 v_abs(const v_float64x2& x)
|
||||
|
|
@ -864,6 +909,15 @@ inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \
|
|||
OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float32x4, ps)
|
||||
OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float64x2, pd)
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec, cast) \
|
||||
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return cast(v_reinterpret_as_f64(a) == v_reinterpret_as_f64(b)); } \
|
||||
inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return cast(v_reinterpret_as_f64(a) != v_reinterpret_as_f64(b)); }
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_uint64x2, v_reinterpret_as_u64);
|
||||
OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_int64x2, v_reinterpret_as_s64);
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_add_wrap, _mm_add_epi8)
|
||||
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_add_wrap, _mm_add_epi8)
|
||||
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_add_wrap, _mm_add_epi16)
|
||||
|
|
@ -967,11 +1021,40 @@ OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint16x8, v_int16x8, epi16, _mm_srai_epi16)
|
|||
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint32x4, v_int32x4, epi32, _mm_srai_epi32)
|
||||
OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64)
|
||||
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_right(const _Tpvec &a)
|
||||
{
|
||||
enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
return _Tpvec(_mm_srli_si128(a.val, CV_SHIFT));
|
||||
}
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_left(const _Tpvec &a)
|
||||
{
|
||||
enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
return _Tpvec(_mm_slli_si128(a.val, CV_SHIFT));
|
||||
}
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b)
|
||||
{
|
||||
enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
return _Tpvec(_mm_or_si128(_mm_srli_si128(a.val, CV_SHIFT1), _mm_slli_si128(b.val, CV_SHIFT2)));
|
||||
}
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b)
|
||||
{
|
||||
enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) };
|
||||
return _Tpvec(_mm_or_si128(_mm_slli_si128(a.val, CV_SHIFT1), _mm_srli_si128(b.val, CV_SHIFT2)));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(_Tpvec, _Tp) \
|
||||
inline _Tpvec v_load(const _Tp* ptr) \
|
||||
{ return _Tpvec(_mm_loadu_si128((const __m128i*)ptr)); } \
|
||||
inline _Tpvec v_load_aligned(const _Tp* ptr) \
|
||||
{ return _Tpvec(_mm_load_si128((const __m128i*)ptr)); } \
|
||||
inline _Tpvec v_load_low(const _Tp* ptr) \
|
||||
{ return _Tpvec(_mm_loadl_epi64((const __m128i*)ptr)); } \
|
||||
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
|
||||
{ \
|
||||
return _Tpvec(_mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i*)ptr0), \
|
||||
|
|
@ -1000,6 +1083,8 @@ inline _Tpvec v_load(const _Tp* ptr) \
|
|||
{ return _Tpvec(_mm_loadu_##suffix(ptr)); } \
|
||||
inline _Tpvec v_load_aligned(const _Tp* ptr) \
|
||||
{ return _Tpvec(_mm_load_##suffix(ptr)); } \
|
||||
inline _Tpvec v_load_low(const _Tp* ptr) \
|
||||
{ return _Tpvec(_mm_castsi128_##suffix(_mm_loadl_epi64((const __m128i*)ptr))); } \
|
||||
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
|
||||
{ \
|
||||
return _Tpvec(_mm_castsi128_##suffix( \
|
||||
|
|
@ -1021,6 +1106,62 @@ 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_float64x2, double, pd)
|
||||
|
||||
#if CV_FP16
|
||||
inline v_float16x4 v_load_f16(const short* ptr)
|
||||
{ return v_float16x4(_mm_loadl_epi64((const __m128i*)ptr)); }
|
||||
inline void v_store_f16(short* ptr, v_float16x4& a)
|
||||
{ _mm_storel_epi64((__m128i*)ptr, a.val); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(_Tpvec, scalartype, func, suffix, sbit) \
|
||||
inline scalartype v_reduce_##func(const v_##_Tpvec& a) \
|
||||
{ \
|
||||
__m128i val = a.val; \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \
|
||||
return (scalartype)_mm_cvtsi128_si32(val); \
|
||||
} \
|
||||
inline unsigned scalartype v_reduce_##func(const v_u##_Tpvec& a) \
|
||||
{ \
|
||||
__m128i val = a.val; \
|
||||
__m128i smask = _mm_set1_epi16(sbit); \
|
||||
val = _mm_xor_si128(val, smask); \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \
|
||||
val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \
|
||||
return (unsigned scalartype)(_mm_cvtsi128_si32(val) ^ sbit); \
|
||||
}
|
||||
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8_SUM(_Tpvec, scalartype, suffix) \
|
||||
inline scalartype v_reduce_sum(const v_##_Tpvec& a) \
|
||||
{ \
|
||||
__m128i val = a.val; \
|
||||
val = _mm_adds_epi##suffix(val, _mm_srli_si128(val, 8)); \
|
||||
val = _mm_adds_epi##suffix(val, _mm_srli_si128(val, 4)); \
|
||||
val = _mm_adds_epi##suffix(val, _mm_srli_si128(val, 2)); \
|
||||
return (scalartype)_mm_cvtsi128_si32(val); \
|
||||
} \
|
||||
inline unsigned scalartype v_reduce_sum(const v_u##_Tpvec& a) \
|
||||
{ \
|
||||
__m128i val = a.val; \
|
||||
val = _mm_adds_epu##suffix(val, _mm_srli_si128(val, 8)); \
|
||||
val = _mm_adds_epu##suffix(val, _mm_srli_si128(val, 4)); \
|
||||
val = _mm_adds_epu##suffix(val, _mm_srli_si128(val, 2)); \
|
||||
return (unsigned scalartype)_mm_cvtsi128_si32(val); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, max, epi16, (short)-32768)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, min, epi16, (short)-32768)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_8_SUM(int16x8, short, 16)
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, cast_from, cast_to, extract) \
|
||||
inline scalartype v_reduce_sum(const _Tpvec& a) \
|
||||
{ \
|
||||
regtype val = a.val; \
|
||||
val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 8))); \
|
||||
val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 4))); \
|
||||
return (scalartype)_mm_cvt##extract(val); \
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(_Tpvec, scalartype, func, scalar_func) \
|
||||
inline scalartype v_reduce_##func(const _Tpvec& a) \
|
||||
{ \
|
||||
|
|
@ -1031,16 +1172,53 @@ inline scalartype v_reduce_##func(const _Tpvec& a) \
|
|||
return scalar_func(s0, s1); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_uint32x4, unsigned, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_int32x4, int, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_float32x4, float, __m128, ps, _mm_castps_si128, _mm_castsi128_ps, ss_f32)
|
||||
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
{
|
||||
#if CV_SSE3
|
||||
__m128 ab = _mm_hadd_ps(a.val, b.val);
|
||||
__m128 cd = _mm_hadd_ps(c.val, d.val);
|
||||
return v_float32x4(_mm_hadd_ps(ab, cd));
|
||||
#else
|
||||
__m128 ac = _mm_add_ps(_mm_unpacklo_ps(a.val, c.val), _mm_unpackhi_ps(a.val, c.val));
|
||||
__m128 bd = _mm_add_ps(_mm_unpacklo_ps(b.val, d.val), _mm_unpackhi_ps(b.val, d.val));
|
||||
return v_float32x4(_mm_add_ps(_mm_unpacklo_ps(ac, bd), _mm_unpackhi_ps(ac, bd)));
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, max, std::max)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, min, std::min)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, sum, OPENCV_HAL_ADD)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, max, std::max)
|
||||
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, min, std::min)
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_POPCOUNT(_Tpvec) \
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a) \
|
||||
{ \
|
||||
__m128i m1 = _mm_set1_epi32(0x55555555); \
|
||||
__m128i m2 = _mm_set1_epi32(0x33333333); \
|
||||
__m128i m4 = _mm_set1_epi32(0x0f0f0f0f); \
|
||||
__m128i p = a.val; \
|
||||
p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 1), m1), _mm_and_si128(p, m1)); \
|
||||
p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 2), m2), _mm_and_si128(p, m2)); \
|
||||
p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 4), m4), _mm_and_si128(p, m4)); \
|
||||
p = _mm_adds_epi8(p, _mm_srli_si128(p, 1)); \
|
||||
p = _mm_adds_epi8(p, _mm_srli_si128(p, 2)); \
|
||||
return v_uint32x4(_mm_and_si128(p, _mm_set1_epi32(0x000000ff))); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint8x16)
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int8x16)
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int16x8)
|
||||
OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int32x4)
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(_Tpvec, suffix, pack_op, and_op, signmask, allmask) \
|
||||
inline int v_signmask(const _Tpvec& a) \
|
||||
{ \
|
||||
|
|
@ -1256,6 +1434,24 @@ OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NO
|
|||
OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps)
|
||||
|
||||
// adopted from sse_utils.hpp
|
||||
inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b)
|
||||
{
|
||||
__m128i t00 = _mm_loadu_si128((const __m128i*)ptr);
|
||||
__m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16));
|
||||
|
||||
__m128i t10 = _mm_unpacklo_epi8(t00, t01);
|
||||
__m128i t11 = _mm_unpackhi_epi8(t00, t01);
|
||||
|
||||
__m128i t20 = _mm_unpacklo_epi8(t10, t11);
|
||||
__m128i t21 = _mm_unpackhi_epi8(t10, t11);
|
||||
|
||||
__m128i t30 = _mm_unpacklo_epi8(t20, t21);
|
||||
__m128i t31 = _mm_unpackhi_epi8(t20, t21);
|
||||
|
||||
a.val = _mm_unpacklo_epi8(t30, t31);
|
||||
b.val = _mm_unpackhi_epi8(t30, t31);
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c)
|
||||
{
|
||||
__m128i t00 = _mm_loadu_si128((const __m128i*)ptr);
|
||||
|
|
@ -1374,6 +1570,65 @@ inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4&
|
|||
v_transpose4x4(u0, u1, u2, u3, a, b, c, d);
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c)
|
||||
{
|
||||
__m128i t0 = _mm_loadu_si128((const __m128i*)ptr);
|
||||
__m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2));
|
||||
__m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4));
|
||||
|
||||
a = v_uint64x2(_mm_unpacklo_epi64(t0, _mm_unpackhi_epi64(t1, t1)));
|
||||
b = v_uint64x2(_mm_unpacklo_epi64(_mm_unpackhi_epi64(t0, t0), t2));
|
||||
c = v_uint64x2(_mm_unpacklo_epi64(t1, _mm_unpackhi_epi64(t2, t2)));
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const int64 *ptr, v_int64x2& a, v_int64x2& b, v_int64x2& c)
|
||||
{
|
||||
v_uint64x2 t0, t1, t2;
|
||||
v_load_deinterleave((const uint64*)ptr, t0, t1, t2);
|
||||
a = v_reinterpret_as_s64(t0);
|
||||
b = v_reinterpret_as_s64(t1);
|
||||
c = v_reinterpret_as_s64(t2);
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const double *ptr, v_float64x2& a, v_float64x2& b, v_float64x2& c)
|
||||
{
|
||||
v_uint64x2 t0, t1, t2;
|
||||
v_load_deinterleave((const uint64*)ptr, t0, t1, t2);
|
||||
a = v_reinterpret_as_f64(t0);
|
||||
b = v_reinterpret_as_f64(t1);
|
||||
c = v_reinterpret_as_f64(t2);
|
||||
}
|
||||
|
||||
// 2-channel, float only
|
||||
inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b)
|
||||
{
|
||||
const int mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1);
|
||||
|
||||
__m128 u0 = _mm_loadu_ps(ptr); // a0 b0 a1 b1
|
||||
__m128 u1 = _mm_loadu_ps((ptr + 4)); // a2 b2 a3 b3
|
||||
|
||||
a.val = _mm_shuffle_ps(u0, u1, mask_lo); // a0 a1 a2 a3
|
||||
b.val = _mm_shuffle_ps(u0, u1, mask_hi); // b0 b1 ab b3
|
||||
}
|
||||
|
||||
inline void v_store_interleave( short* ptr, const v_int16x8& a, const v_int16x8& b )
|
||||
{
|
||||
__m128i t0, t1;
|
||||
t0 = _mm_unpacklo_epi16(a.val, b.val);
|
||||
t1 = _mm_unpackhi_epi16(a.val, b.val);
|
||||
_mm_storeu_si128((__m128i*)(ptr), t0);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 8), t1);
|
||||
}
|
||||
|
||||
inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b)
|
||||
{
|
||||
__m128i v0 = _mm_unpacklo_epi8(a.val, b.val);
|
||||
__m128i v1 = _mm_unpackhi_epi8(a.val, b.val);
|
||||
|
||||
_mm_storeu_si128((__m128i*)(ptr), v0);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 16), v1);
|
||||
}
|
||||
|
||||
inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b,
|
||||
const v_uint8x16& c )
|
||||
{
|
||||
|
|
@ -1529,6 +1784,39 @@ inline void v_store_interleave(unsigned* ptr, const v_uint32x4& a, const v_uint3
|
|||
v_store(ptr + 12, t3);
|
||||
}
|
||||
|
||||
// 2-channel, float only
|
||||
inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b)
|
||||
{
|
||||
// a0 a1 a2 a3 ...
|
||||
// b0 b1 b2 b3 ...
|
||||
__m128 u0 = _mm_unpacklo_ps(a.val, b.val); // a0 b0 a1 b1
|
||||
__m128 u1 = _mm_unpackhi_ps(a.val, b.val); // a2 b2 a3 b3
|
||||
|
||||
_mm_storeu_ps(ptr, u0);
|
||||
_mm_storeu_ps((ptr + 4), u1);
|
||||
}
|
||||
|
||||
inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c)
|
||||
{
|
||||
__m128i t0 = _mm_unpacklo_epi64(a.val, b.val);
|
||||
__m128i t1 = _mm_unpacklo_epi64(c.val, _mm_unpackhi_epi64(a.val, a.val));
|
||||
__m128i t2 = _mm_unpackhi_epi64(b.val, c.val);
|
||||
|
||||
_mm_storeu_si128((__m128i*)ptr, t0);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 2), t1);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 4), t2);
|
||||
}
|
||||
|
||||
inline void v_store_interleave(int64 *ptr, const v_int64x2& a, const v_int64x2& b, const v_int64x2& c)
|
||||
{
|
||||
v_store_interleave((uint64*)ptr, v_reinterpret_as_u64(a), v_reinterpret_as_u64(b), v_reinterpret_as_u64(c));
|
||||
}
|
||||
|
||||
inline void v_store_interleave(double *ptr, const v_float64x2& a, const v_float64x2& b, const v_float64x2& c)
|
||||
{
|
||||
v_store_interleave((uint64*)ptr, v_reinterpret_as_u64(a), v_reinterpret_as_u64(b), v_reinterpret_as_u64(c));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(_Tpvec, _Tp, suffix, _Tpuvec, _Tpu, usuffix) \
|
||||
inline void v_load_deinterleave( const _Tp* ptr, _Tpvec& a0, \
|
||||
_Tpvec& b0, _Tpvec& c0 ) \
|
||||
|
|
@ -1587,11 +1875,45 @@ inline v_float64x2 v_cvt_f64(const v_int32x4& a)
|
|||
return v_float64x2(_mm_cvtepi32_pd(a.val));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_int32x4& a)
|
||||
{
|
||||
return v_float64x2(_mm_cvtepi32_pd(_mm_srli_si128(a.val,8)));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(_mm_cvtps_pd(a.val));
|
||||
}
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(_mm_cvtps_pd(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(a.val),8))));
|
||||
}
|
||||
|
||||
#if CV_FP16
|
||||
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
|
||||
{
|
||||
return v_float32x4(_mm_cvtph_ps(a.val));
|
||||
}
|
||||
|
||||
inline v_float16x4 v_cvt_f16(const v_float32x4& a)
|
||||
{
|
||||
return v_float16x4(_mm_cvtps_ph(a.val, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
//! @name Check SIMD support
|
||||
//! @{
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return (CV_CPU_HAS_SUPPORT_SSE2) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
962
lib/3rdParty/OpenCV3.4/include/opencv2/core/hal/intrin_vsx.hpp
vendored
Normal file
962
lib/3rdParty/OpenCV3.4/include/opencv2/core/hal/intrin_vsx.hpp
vendored
Normal file
|
|
@ -0,0 +1,962 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2015, Itseez Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_HAL_VSX_HPP
|
||||
#define OPENCV_HAL_VSX_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#define CV_SIMD128 1
|
||||
#define CV_SIMD128_64F 1
|
||||
|
||||
/**
|
||||
* todo: supporting half precision for power9
|
||||
* convert instractions xvcvhpsp, xvcvsphp
|
||||
**/
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
///////// Types ////////////
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
typedef uchar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
vec_uchar16 val;
|
||||
|
||||
explicit v_uint8x16(const vec_uchar16& v) : val(v)
|
||||
{}
|
||||
v_uint8x16() : val(vec_uchar16_z)
|
||||
{}
|
||||
v_uint8x16(vec_bchar16 v) : val(vec_uchar16_c(v))
|
||||
{}
|
||||
v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7,
|
||||
uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15)
|
||||
: val(vec_uchar16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15))
|
||||
{}
|
||||
uchar get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int8x16
|
||||
{
|
||||
typedef schar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
vec_char16 val;
|
||||
|
||||
explicit v_int8x16(const vec_char16& v) : val(v)
|
||||
{}
|
||||
v_int8x16() : val(vec_char16_z)
|
||||
{}
|
||||
v_int8x16(vec_bchar16 v) : val(vec_char16_c(v))
|
||||
{}
|
||||
v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7,
|
||||
schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15)
|
||||
: val(vec_char16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15))
|
||||
{}
|
||||
schar get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint16x8
|
||||
{
|
||||
typedef ushort lane_type;
|
||||
enum { nlanes = 8 };
|
||||
vec_ushort8 val;
|
||||
|
||||
explicit v_uint16x8(const vec_ushort8& v) : val(v)
|
||||
{}
|
||||
v_uint16x8() : val(vec_ushort8_z)
|
||||
{}
|
||||
v_uint16x8(vec_bshort8 v) : val(vec_ushort8_c(v))
|
||||
{}
|
||||
v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
|
||||
: val(vec_ushort8_set(v0, v1, v2, v3, v4, v5, v6, v7))
|
||||
{}
|
||||
ushort get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int16x8
|
||||
{
|
||||
typedef short lane_type;
|
||||
enum { nlanes = 8 };
|
||||
vec_short8 val;
|
||||
|
||||
explicit v_int16x8(const vec_short8& v) : val(v)
|
||||
{}
|
||||
v_int16x8() : val(vec_short8_z)
|
||||
{}
|
||||
v_int16x8(vec_bshort8 v) : val(vec_short8_c(v))
|
||||
{}
|
||||
v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7)
|
||||
: val(vec_short8_set(v0, v1, v2, v3, v4, v5, v6, v7))
|
||||
{}
|
||||
short get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint32x4
|
||||
{
|
||||
typedef unsigned lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_uint4 val;
|
||||
|
||||
explicit v_uint32x4(const vec_uint4& v) : val(v)
|
||||
{}
|
||||
v_uint32x4() : val(vec_uint4_z)
|
||||
{}
|
||||
v_uint32x4(vec_bint4 v) : val(vec_uint4_c(v))
|
||||
{}
|
||||
v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) : val(vec_uint4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
uint get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int32x4
|
||||
{
|
||||
typedef int lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_int4 val;
|
||||
|
||||
explicit v_int32x4(const vec_int4& v) : val(v)
|
||||
{}
|
||||
v_int32x4() : val(vec_int4_z)
|
||||
{}
|
||||
v_int32x4(vec_bint4 v) : val(vec_int4_c(v))
|
||||
{}
|
||||
v_int32x4(int v0, int v1, int v2, int v3) : val(vec_int4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
int get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_float32x4
|
||||
{
|
||||
typedef float lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_float4 val;
|
||||
|
||||
explicit v_float32x4(const vec_float4& v) : val(v)
|
||||
{}
|
||||
v_float32x4() : val(vec_float4_z)
|
||||
{}
|
||||
v_float32x4(vec_bint4 v) : val(vec_float4_c(v))
|
||||
{}
|
||||
v_float32x4(float v0, float v1, float v2, float v3) : val(vec_float4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
float get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint64x2
|
||||
{
|
||||
typedef uint64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_udword2 val;
|
||||
|
||||
explicit v_uint64x2(const vec_udword2& v) : val(v)
|
||||
{}
|
||||
v_uint64x2() : val(vec_udword2_z)
|
||||
{}
|
||||
v_uint64x2(vec_bdword2 v) : val(vec_udword2_c(v))
|
||||
{}
|
||||
v_uint64x2(uint64 v0, uint64 v1) : val(vec_udword2_set(v0, v1))
|
||||
{}
|
||||
uint64 get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int64x2
|
||||
{
|
||||
typedef int64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_dword2 val;
|
||||
|
||||
explicit v_int64x2(const vec_dword2& v) : val(v)
|
||||
{}
|
||||
v_int64x2() : val(vec_dword2_z)
|
||||
{}
|
||||
v_int64x2(vec_bdword2 v) : val(vec_dword2_c(v))
|
||||
{}
|
||||
v_int64x2(int64 v0, int64 v1) : val(vec_dword2_set(v0, v1))
|
||||
{}
|
||||
int64 get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_float64x2
|
||||
{
|
||||
typedef double lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_double2 val;
|
||||
|
||||
explicit v_float64x2(const vec_double2& v) : val(v)
|
||||
{}
|
||||
v_float64x2() : val(vec_double2_z)
|
||||
{}
|
||||
v_float64x2(vec_bdword2 v) : val(vec_double2_c(v))
|
||||
{}
|
||||
v_float64x2(double v0, double v1) : val(vec_double2_set(v0, v1))
|
||||
{}
|
||||
double get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
//////////////// Load and store operations ///////////////
|
||||
|
||||
/*
|
||||
* clang-5 aborted during parse "vec_xxx_c" only if it's
|
||||
* inside a function template which is defined by preprocessor macro.
|
||||
*
|
||||
* if vec_xxx_c defined as C++ cast, clang-5 will pass it
|
||||
*/
|
||||
#define OPENCV_HAL_IMPL_VSX_INITVEC(_Tpvec, _Tp, suffix, cast) \
|
||||
inline _Tpvec v_setzero_##suffix() { return _Tpvec(); } \
|
||||
inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));} \
|
||||
template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a) \
|
||||
{ return _Tpvec((cast)a.val); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint8x16, uchar, u8, vec_uchar16)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int8x16, schar, s8, vec_char16)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint16x8, ushort, u16, vec_ushort8)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int16x8, short, s16, vec_short8)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint32x4, uint, u32, vec_uint4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int32x4, int, s32, vec_int4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint64x2, uint64, u64, vec_udword2)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int64x2, int64, s64, vec_dword2)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_float32x4, float, f32, vec_float4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_float64x2, double, f64, vec_double2)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(_Tpvec, _Tp, ld_func, st_func) \
|
||||
inline _Tpvec v_load(const _Tp* ptr) \
|
||||
{ return _Tpvec(ld_func(0, ptr)); } \
|
||||
inline _Tpvec v_load_aligned(const _Tp* ptr) \
|
||||
{ return _Tpvec(ld_func(0, ptr)); } \
|
||||
inline _Tpvec v_load_low(const _Tp* ptr) \
|
||||
{ return _Tpvec(vec_ld_l8(ptr)); } \
|
||||
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
|
||||
{ return _Tpvec(vec_mergesqh(vec_ld_l8(ptr0), vec_ld_l8(ptr1))); } \
|
||||
inline void v_store(_Tp* ptr, const _Tpvec& a) \
|
||||
{ st_func(a.val, 0, ptr); } \
|
||||
inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \
|
||||
{ st_func(a.val, 0, ptr); } \
|
||||
inline void v_store_low(_Tp* ptr, const _Tpvec& a) \
|
||||
{ vec_st_l8(a.val, ptr); } \
|
||||
inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
|
||||
{ vec_st_h8(a.val, ptr); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint8x16, uchar, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int8x16, schar, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint16x8, ushort, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int16x8, short, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint32x4, uint, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int32x4, int, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_float32x4, float, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_float64x2, double, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint64x2, uint64, vsx_ld2, vsx_st2)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int64x2, int64, vsx_ld2, vsx_st2)
|
||||
|
||||
//////////////// Value reordering ///////////////
|
||||
|
||||
/* de&interleave */
|
||||
#define OPENCV_HAL_IMPL_VSX_INTERLEAVE(_Tp, _Tpvec) \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val);} \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, \
|
||||
_Tpvec& b, _Tpvec& c) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val); } \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b, \
|
||||
_Tpvec& c, _Tpvec& d) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val, d.val); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ vec_st_interleave(a.val, b.val, ptr); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, \
|
||||
const _Tpvec& b, const _Tpvec& c) \
|
||||
{ vec_st_interleave(a.val, b.val, c.val, ptr); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \
|
||||
const _Tpvec& c, const _Tpvec& d) \
|
||||
{ vec_st_interleave(a.val, b.val, c.val, d.val, ptr); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(uchar, v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(schar, v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(ushort, v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(short, v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint, v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(int, v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(float, v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(double, v_float64x2)
|
||||
|
||||
/* Expand */
|
||||
#define OPENCV_HAL_IMPL_VSX_EXPAND(_Tpvec, _Tpwvec, _Tp, fl, fh) \
|
||||
inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \
|
||||
{ \
|
||||
b0.val = fh(a.val); \
|
||||
b1.val = fl(a.val); \
|
||||
} \
|
||||
inline _Tpwvec v_load_expand(const _Tp* ptr) \
|
||||
{ return _Tpwvec(fh(vsx_ld(0, ptr))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint8x16, v_uint16x8, uchar, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int8x16, v_int16x8, schar, vec_unpackl, vec_unpackh)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint16x8, v_uint32x4, ushort, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int16x8, v_int32x4, short, vec_unpackl, vec_unpackh)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint32x4, v_uint64x2, uint, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int32x4, v_int64x2, int, vec_unpackl, vec_unpackh)
|
||||
|
||||
inline v_uint32x4 v_load_expand_q(const uchar* ptr)
|
||||
{ return v_uint32x4(vec_ld_buw(ptr)); }
|
||||
|
||||
inline v_int32x4 v_load_expand_q(const schar* ptr)
|
||||
{ return v_int32x4(vec_ld_bsw(ptr)); }
|
||||
|
||||
/* pack */
|
||||
#define OPENCV_HAL_IMPL_VSX_PACK(_Tpvec, _Tp, _Tpwvec, _Tpvn, _Tpdel, sfnc, pkfnc, addfnc, pack) \
|
||||
inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
return _Tpvec(pkfnc(a.val, b.val)); \
|
||||
} \
|
||||
inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
vec_st_l8(pkfnc(a.val, a.val), ptr); \
|
||||
} \
|
||||
template<int n> \
|
||||
inline _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
|
||||
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
|
||||
return _Tpvec(pkfnc(sfnc(addfnc(a.val, delta), vn), sfnc(addfnc(b.val, delta), vn))); \
|
||||
} \
|
||||
template<int n> \
|
||||
inline void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
|
||||
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
|
||||
vec_st_l8(pkfnc(sfnc(addfnc(a.val, delta), vn), delta), ptr); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_uint16x8, unsigned short, unsigned short,
|
||||
vec_sr, vec_packs, vec_adds, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int8x16, schar, v_int16x8, unsigned short, short,
|
||||
vec_sra, vec_packs, vec_adds, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_uint32x4, unsigned int, unsigned int,
|
||||
vec_sr, vec_packs, vec_add, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int16x8, short, v_int32x4, unsigned int, int,
|
||||
vec_sra, vec_packs, vec_add, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_uint64x2, unsigned long long, unsigned long long,
|
||||
vec_sr, vec_pack, vec_add, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int32x4, int, v_int64x2, unsigned long long, long long,
|
||||
vec_sra, vec_pack, vec_add, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_int16x8, unsigned short, short,
|
||||
vec_sra, vec_packsu, vec_adds, pack_u)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_int32x4, unsigned int, int,
|
||||
vec_sra, vec_packsu, vec_add, pack_u)
|
||||
// Following variant is not implemented on other platforms:
|
||||
//OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_int64x2, unsigned long long, long long,
|
||||
// vec_sra, vec_packsu, vec_add, pack_u)
|
||||
|
||||
/* Recombine */
|
||||
template <typename _Tpvec>
|
||||
inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1)
|
||||
{
|
||||
b0.val = vec_mergeh(a0.val, a1.val);
|
||||
b1.val = vec_mergel(a0.val, a1.val);
|
||||
}
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b)
|
||||
{ return _Tpvec(vec_mergesql(a.val, b.val)); }
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b)
|
||||
{ return _Tpvec(vec_mergesqh(a.val, b.val)); }
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d)
|
||||
{
|
||||
c.val = vec_mergesqh(a.val, b.val);
|
||||
d.val = vec_mergesql(a.val, b.val);
|
||||
}
|
||||
|
||||
/* Extract */
|
||||
template<int s, typename _Tpvec>
|
||||
inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b)
|
||||
{
|
||||
const int w = sizeof(typename _Tpvec::lane_type);
|
||||
const int n = _Tpvec::nlanes;
|
||||
const unsigned int sf = ((w * n) - (s * w));
|
||||
if (s == 0)
|
||||
return _Tpvec(a.val);
|
||||
else if (sf > 15)
|
||||
return _Tpvec();
|
||||
// bitwise it just to make xlc happy
|
||||
return _Tpvec(vec_sld(b.val, a.val, sf & 15));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_EXTRACT_2(_Tpvec) \
|
||||
template<int s> \
|
||||
inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
switch(s) { \
|
||||
case 0: return _Tpvec(a.val); \
|
||||
case 2: return _Tpvec(b.val); \
|
||||
case 1: return _Tpvec(vec_sldw(b.val, a.val, 2)); \
|
||||
default: return _Tpvec(); \
|
||||
} \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_EXTRACT_2(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_EXTRACT_2(v_int64x2)
|
||||
|
||||
|
||||
////////// Arithmetic, bitwise and comparison operations /////////
|
||||
|
||||
/* Element-wise binary and unary operations */
|
||||
/** Arithmetics **/
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_OP(bin_op, _Tpvec, intrin) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(intrin(a.val, b.val)); } \
|
||||
inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \
|
||||
{ a.val = intrin(a.val, b.val); return a; }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint8x16, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint8x16, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int8x16, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int8x16, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint16x8, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint16x8, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint16x8, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int16x8, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int16x8, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int16x8, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float32x4, vec_div)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float64x2, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float64x2, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float64x2, vec_div)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint64x2, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int64x2, vec_sub)
|
||||
|
||||
inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, v_int32x4& c, v_int32x4& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackh(a.val), vec_unpackh(b.val));
|
||||
d.val = vec_mul(vec_unpackl(a.val), vec_unpackl(b.val));
|
||||
}
|
||||
inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, v_uint32x4& c, v_uint32x4& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackhu(a.val), vec_unpackhu(b.val));
|
||||
d.val = vec_mul(vec_unpacklu(a.val), vec_unpacklu(b.val));
|
||||
}
|
||||
inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, v_uint64x2& c, v_uint64x2& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackhu(a.val), vec_unpackhu(b.val));
|
||||
d.val = vec_mul(vec_unpacklu(a.val), vec_unpacklu(b.val));
|
||||
}
|
||||
|
||||
/** Non-saturating arithmetics **/
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC(func, intrin) \
|
||||
template<typename _Tpvec> \
|
||||
inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(intrin(a.val, b.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_add_wrap, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_sub_wrap, vec_sub)
|
||||
|
||||
/** Bitwise shifts **/
|
||||
#define OPENCV_HAL_IMPL_VSX_SHIFT_OP(_Tpvec, shr, splfunc) \
|
||||
inline _Tpvec operator << (const _Tpvec& a, int imm) \
|
||||
{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \
|
||||
inline _Tpvec operator >> (const _Tpvec& a, int imm) \
|
||||
{ return _Tpvec(shr(a.val, splfunc(imm))); } \
|
||||
template<int imm> inline _Tpvec v_shl(const _Tpvec& a) \
|
||||
{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \
|
||||
template<int imm> inline _Tpvec v_shr(const _Tpvec& a) \
|
||||
{ return _Tpvec(shr(a.val, splfunc(imm))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint8x16, vec_sr, vec_uchar16_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint16x8, vec_sr, vec_ushort8_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint32x4, vec_sr, vec_uint4_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint64x2, vec_sr, vec_udword2_sp)
|
||||
// algebraic right shift
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int8x16, vec_sra, vec_uchar16_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int16x8, vec_sra, vec_ushort8_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int32x4, vec_sra, vec_uint4_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int64x2, vec_sra, vec_udword2_sp)
|
||||
|
||||
/** Bitwise logic **/
|
||||
#define OPENCV_HAL_IMPL_VSX_LOGIC_OP(_Tpvec) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(&, _Tpvec, vec_and) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(|, _Tpvec, vec_or) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(^, _Tpvec, vec_xor) \
|
||||
inline _Tpvec operator ~ (const _Tpvec& a) \
|
||||
{ return _Tpvec(vec_not(a.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int64x2)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float64x2)
|
||||
|
||||
/** Bitwise select **/
|
||||
#define OPENCV_HAL_IMPL_VSX_SELECT(_Tpvec, cast) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_sel(b.val, a.val, cast(mask.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint8x16, vec_bchar16_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int8x16, vec_bchar16_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint16x8, vec_bshort8_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int16x8, vec_bshort8_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_float32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
|
||||
|
||||
/** Comparison **/
|
||||
#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec) \
|
||||
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpeq(a.val, b.val)); } \
|
||||
inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpne(a.val, b.val)); } \
|
||||
inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmplt(a.val, b.val)); } \
|
||||
inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpgt(a.val, b.val)); } \
|
||||
inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmple(a.val, b.val)); } \
|
||||
inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpge(a.val, b.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float64x2)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int64x2)
|
||||
|
||||
/** min/max **/
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_max, vec_max)
|
||||
|
||||
/** Rotate **/
|
||||
#define OPENCV_IMPL_VSX_ROTATE(_Tpvec, suffix, shf, cast) \
|
||||
template<int imm> \
|
||||
inline _Tpvec v_rotate_##suffix(const _Tpvec& a) \
|
||||
{ \
|
||||
const int wd = imm * sizeof(typename _Tpvec::lane_type); \
|
||||
if (wd > 15) \
|
||||
return _Tpvec(); \
|
||||
return _Tpvec((cast)shf(vec_uchar16_c(a.val), vec_uchar16_sp(wd << 3))); \
|
||||
}
|
||||
|
||||
#define OPENCV_IMPL_VSX_ROTATE_LR(_Tpvec, cast) \
|
||||
OPENCV_IMPL_VSX_ROTATE(_Tpvec, left, vec_slo, cast) \
|
||||
OPENCV_IMPL_VSX_ROTATE(_Tpvec, right, vec_sro, cast)
|
||||
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_uint8x16, vec_uchar16)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_int8x16, vec_char16)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_uint16x8, vec_ushort8)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_int16x8, vec_short8)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_uint32x4, vec_uint4)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_int32x4, vec_int4)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_uint64x2, vec_udword2)
|
||||
OPENCV_IMPL_VSX_ROTATE_LR(v_int64x2, vec_dword2)
|
||||
|
||||
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b)
|
||||
{
|
||||
enum { CV_SHIFT = 16 - imm * (sizeof(typename _Tpvec::lane_type)) };
|
||||
if (CV_SHIFT == 16)
|
||||
return a;
|
||||
#ifdef __IBMCPP__
|
||||
return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT & 15));
|
||||
#else
|
||||
return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<int imm, typename _Tpvec>
|
||||
inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b)
|
||||
{
|
||||
enum { CV_SHIFT = imm * (sizeof(typename _Tpvec::lane_type)) };
|
||||
if (CV_SHIFT == 16)
|
||||
return b;
|
||||
return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT));
|
||||
}
|
||||
|
||||
#define OPENCV_IMPL_VSX_ROTATE_64(_Tpvec, suffix, rg1, rg2) \
|
||||
template<int imm> \
|
||||
inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
if (imm == 1) \
|
||||
return _Tpvec(vec_permi(rg1.val, rg2.val, 2)); \
|
||||
return imm ? b : a; \
|
||||
}
|
||||
|
||||
OPENCV_IMPL_VSX_ROTATE_64(v_int64x2, right, a, b)
|
||||
OPENCV_IMPL_VSX_ROTATE_64(v_uint64x2, right, a, b)
|
||||
|
||||
OPENCV_IMPL_VSX_ROTATE_64(v_int64x2, left, b, a)
|
||||
OPENCV_IMPL_VSX_ROTATE_64(v_uint64x2, left, b, a)
|
||||
|
||||
////////// Reduce and mask /////////
|
||||
|
||||
/** Reduce **/
|
||||
inline short v_reduce_sum(const v_int16x8& a)
|
||||
{
|
||||
const vec_int4 zero = vec_int4_z;
|
||||
return saturate_cast<short>(vec_extract(vec_sums(vec_sum4s(a.val, zero), zero), 3));
|
||||
}
|
||||
inline ushort v_reduce_sum(const v_uint16x8& a)
|
||||
{
|
||||
const vec_int4 v4 = vec_int4_c(vec_unpackhu(vec_adds(a.val, vec_sld(a.val, a.val, 8))));
|
||||
return saturate_cast<ushort>(vec_extract(vec_sums(v4, vec_int4_z), 3));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(_Tpvec, _Tpvec2, scalartype, suffix, func) \
|
||||
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
|
||||
{ \
|
||||
const _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
|
||||
return vec_extract(func(rs, vec_sld(rs, rs, 4)), 0); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, min, vec_min)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(_Tpvec, _Tpvec2, scalartype, suffix, func) \
|
||||
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
|
||||
{ \
|
||||
_Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
|
||||
rs = func(rs, vec_sld(rs, rs, 4)); \
|
||||
return vec_extract(func(rs, vec_sld(rs, rs, 2)), 0); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, min, vec_min)
|
||||
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
{
|
||||
vec_float4 ac = vec_add(vec_mergel(a.val, c.val), vec_mergeh(a.val, c.val));
|
||||
ac = vec_add(ac, vec_sld(ac, ac, 8));
|
||||
|
||||
vec_float4 bd = vec_add(vec_mergel(b.val, d.val), vec_mergeh(b.val, d.val));
|
||||
bd = vec_add(bd, vec_sld(bd, bd, 8));
|
||||
return v_float32x4(vec_mergeh(ac, bd));
|
||||
}
|
||||
|
||||
/** Popcount **/
|
||||
template<typename _Tpvec>
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a)
|
||||
{ return v_uint32x4(vec_popcntu(vec_uint4_c(a.val))); }
|
||||
|
||||
/** Mask **/
|
||||
inline int v_signmask(const v_uint8x16& a)
|
||||
{
|
||||
vec_uchar16 sv = vec_sr(a.val, vec_uchar16_sp(7));
|
||||
static const vec_uchar16 slm = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
|
||||
sv = vec_sl(sv, slm);
|
||||
vec_uint4 sv4 = vec_sum4s(sv, vec_uint4_z);
|
||||
static const vec_uint4 slm4 = {0, 0, 8, 8};
|
||||
sv4 = vec_sl(sv4, slm4);
|
||||
return vec_extract(vec_sums((vec_int4) sv4, vec_int4_z), 3);
|
||||
}
|
||||
inline int v_signmask(const v_int8x16& a)
|
||||
{ return v_signmask(v_reinterpret_as_u8(a)); }
|
||||
|
||||
inline int v_signmask(const v_int16x8& a)
|
||||
{
|
||||
static const vec_ushort8 slm = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
vec_short8 sv = vec_sr(a.val, vec_ushort8_sp(15));
|
||||
sv = vec_sl(sv, slm);
|
||||
vec_int4 svi = vec_int4_z;
|
||||
svi = vec_sums(vec_sum4s(sv, svi), svi);
|
||||
return vec_extract(svi, 3);
|
||||
}
|
||||
inline int v_signmask(const v_uint16x8& a)
|
||||
{ return v_signmask(v_reinterpret_as_s16(a)); }
|
||||
|
||||
inline int v_signmask(const v_int32x4& a)
|
||||
{
|
||||
static const vec_uint4 slm = {0, 1, 2, 3};
|
||||
vec_int4 sv = vec_sr(a.val, vec_uint4_sp(31));
|
||||
sv = vec_sl(sv, slm);
|
||||
sv = vec_sums(sv, vec_int4_z);
|
||||
return vec_extract(sv, 3);
|
||||
}
|
||||
inline int v_signmask(const v_uint32x4& a)
|
||||
{ return v_signmask(v_reinterpret_as_s32(a)); }
|
||||
inline int v_signmask(const v_float32x4& a)
|
||||
{ return v_signmask(v_reinterpret_as_s32(a)); }
|
||||
|
||||
inline int v_signmask(const v_int64x2& a)
|
||||
{
|
||||
VSX_UNUSED(const vec_dword2) sv = vec_sr(a.val, vec_udword2_sp(63));
|
||||
return (int)vec_extract(sv, 0) | (int)vec_extract(sv, 1) << 1;
|
||||
}
|
||||
inline int v_signmask(const v_uint64x2& a)
|
||||
{ return v_signmask(v_reinterpret_as_s64(a)); }
|
||||
inline int v_signmask(const v_float64x2& a)
|
||||
{ return v_signmask(v_reinterpret_as_s64(a)); }
|
||||
|
||||
|
||||
template<typename _Tpvec>
|
||||
inline bool v_check_all(const _Tpvec& a)
|
||||
{ return vec_all_lt(a.val, _Tpvec().val);}
|
||||
inline bool v_check_all(const v_uint8x16 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s8(a)); }
|
||||
inline bool v_check_all(const v_uint16x8 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s16(a)); }
|
||||
inline bool v_check_all(const v_uint32x4 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s32(a)); }
|
||||
|
||||
template<typename _Tpvec>
|
||||
inline bool v_check_any(const _Tpvec& a)
|
||||
{ return vec_any_lt(a.val, _Tpvec().val);}
|
||||
inline bool v_check_any(const v_uint8x16 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s8(a)); }
|
||||
inline bool v_check_any(const v_uint16x8 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s16(a)); }
|
||||
inline bool v_check_any(const v_uint32x4 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s32(a)); }
|
||||
|
||||
////////// Other math /////////
|
||||
|
||||
/** Some frequent operations **/
|
||||
inline v_float32x4 v_sqrt(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_sqrt(x.val)); }
|
||||
inline v_float64x2 v_sqrt(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_sqrt(x.val)); }
|
||||
|
||||
inline v_float32x4 v_invsqrt(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_rsqrt(x.val)); }
|
||||
inline v_float64x2 v_invsqrt(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_rsqrt(x.val)); }
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_MULADD(_Tpvec) \
|
||||
inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_sqrt(vec_madd(a.val, a.val, vec_mul(b.val, b.val)))); } \
|
||||
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_madd(a.val, a.val, vec_mul(b.val, b.val))); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(vec_madd(a.val, b.val, c.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_MULADD(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_MULADD(v_float64x2)
|
||||
|
||||
// TODO: exp, log, sin, cos
|
||||
|
||||
/** Absolute values **/
|
||||
inline v_uint8x16 v_abs(const v_int8x16& x)
|
||||
{ return v_uint8x16(vec_uchar16_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_uint16x8 v_abs(const v_int16x8& x)
|
||||
{ return v_uint16x8(vec_ushort8_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_uint32x4 v_abs(const v_int32x4& x)
|
||||
{ return v_uint32x4(vec_uint4_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_float32x4 v_abs(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_abs(x.val)); }
|
||||
|
||||
inline v_float64x2 v_abs(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_abs(x.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_absdiff, vec_absd)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \
|
||||
inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec2(cast(intrin(a.val, b.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int8x16, v_uint8x16, vec_uchar16_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int16x8, v_uint16x8, vec_ushort8_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int32x4, v_uint32x4, vec_uint4_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int64x2, v_uint64x2, vec_udword2_c, v_absdiff, vec_absd)
|
||||
|
||||
////////// Conversions /////////
|
||||
|
||||
/** Rounding **/
|
||||
inline v_int32x4 v_round(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_round(a.val))); }
|
||||
|
||||
inline v_int32x4 v_round(const v_float64x2& a)
|
||||
{ return v_int32x4(vec_mergesqo(vec_ctso(vec_round(a.val)), vec_int4_z)); }
|
||||
|
||||
inline v_int32x4 v_floor(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_floor(a.val))); }
|
||||
|
||||
inline v_int32x4 v_floor(const v_float64x2& a)
|
||||
{ return v_int32x4(vec_mergesqo(vec_ctso(vec_floor(a.val)), vec_int4_z)); }
|
||||
|
||||
inline v_int32x4 v_ceil(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_ceil(a.val))); }
|
||||
|
||||
inline v_int32x4 v_ceil(const v_float64x2& a)
|
||||
{ return v_int32x4(vec_mergesqo(vec_ctso(vec_ceil(a.val)), vec_int4_z)); }
|
||||
|
||||
inline v_int32x4 v_trunc(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(a.val)); }
|
||||
|
||||
inline v_int32x4 v_trunc(const v_float64x2& a)
|
||||
{ return v_int32x4(vec_mergesqo(vec_ctso(a.val), vec_int4_z)); }
|
||||
|
||||
/** To float **/
|
||||
inline v_float32x4 v_cvt_f32(const v_int32x4& a)
|
||||
{ return v_float32x4(vec_ctf(a.val)); }
|
||||
|
||||
inline v_float32x4 v_cvt_f32(const v_float64x2& a)
|
||||
{ return v_float32x4(vec_mergesqo(vec_cvfo(a.val), vec_float4_z)); }
|
||||
|
||||
inline v_float64x2 v_cvt_f64(const v_int32x4& a)
|
||||
{ return v_float64x2(vec_ctdo(vec_mergeh(a.val, a.val))); }
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_int32x4& a)
|
||||
{ return v_float64x2(vec_ctdo(vec_mergel(a.val, a.val))); }
|
||||
|
||||
inline v_float64x2 v_cvt_f64(const v_float32x4& a)
|
||||
{ return v_float64x2(vec_cvfo(vec_mergeh(a.val, a.val))); }
|
||||
|
||||
inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
{ return v_float64x2(vec_cvfo(vec_mergel(a.val, a.val))); }
|
||||
|
||||
/** Reinterpret **/
|
||||
/** its up there with load and store operations **/
|
||||
|
||||
////////// Matrix operations /////////
|
||||
|
||||
inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b)
|
||||
{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)); }
|
||||
|
||||
inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& m3)
|
||||
{
|
||||
const vec_float4 v0 = vec_splat(v.val, 0);
|
||||
const vec_float4 v1 = vec_splat(v.val, 1);
|
||||
const vec_float4 v2 = vec_splat(v.val, 2);
|
||||
VSX_UNUSED(const vec_float4) v3 = vec_splat(v.val, 3);
|
||||
return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, vec_mul(v3, m3.val)))));
|
||||
}
|
||||
|
||||
inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& a)
|
||||
{
|
||||
const vec_float4 v0 = vec_splat(v.val, 0);
|
||||
const vec_float4 v1 = vec_splat(v.val, 1);
|
||||
const vec_float4 v2 = vec_splat(v.val, 2);
|
||||
return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, a.val))));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(_Tpvec, _Tpvec2) \
|
||||
inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \
|
||||
const _Tpvec& a2, const _Tpvec& a3, \
|
||||
_Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \
|
||||
{ \
|
||||
_Tpvec2 a02 = vec_mergeh(a0.val, a2.val); \
|
||||
_Tpvec2 a13 = vec_mergeh(a1.val, a3.val); \
|
||||
b0.val = vec_mergeh(a02, a13); \
|
||||
b1.val = vec_mergel(a02, a13); \
|
||||
a02 = vec_mergel(a0.val, a2.val); \
|
||||
a13 = vec_mergel(a1.val, a3.val); \
|
||||
b2.val = vec_mergeh(a02, a13); \
|
||||
b3.val = vec_mergel(a02, a13); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_uint32x4, vec_uint4)
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_int32x4, vec_int4)
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_float32x4, vec_float4)
|
||||
|
||||
//! @name Check SIMD support
|
||||
//! @{
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return (CV_CPU_HAS_SUPPORT_VSX) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENCV_HAL_VSX_HPP
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_IPPASYNC_HPP__
|
||||
#define __OPENCV_CORE_IPPASYNC_HPP__
|
||||
#ifndef OPENCV_CORE_IPPASYNC_HPP
|
||||
#define OPENCV_CORE_IPPASYNC_HPP
|
||||
|
||||
#ifdef HAVE_IPP_A
|
||||
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_MAT_HPP__
|
||||
#define __OPENCV_CORE_MAT_HPP__
|
||||
#ifndef OPENCV_CORE_MAT_HPP
|
||||
#define OPENCV_CORE_MAT_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error mat.hpp header must be compiled as C++
|
||||
|
|
@ -53,6 +53,10 @@
|
|||
|
||||
#include "opencv2/core/bufferpool.hpp"
|
||||
|
||||
#ifdef CV_CXX11
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
|
@ -62,6 +66,8 @@ namespace cv
|
|||
enum { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
|
||||
ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 };
|
||||
|
||||
CV__DEBUG_NS_BEGIN
|
||||
|
||||
class CV_EXPORTS _OutputArray;
|
||||
|
||||
//////////////////////// Input/Output Array Arguments /////////////////////////////////
|
||||
|
|
@ -73,8 +79,8 @@ It is defined as:
|
|||
typedef const _InputArray& InputArray;
|
||||
@endcode
|
||||
where _InputArray is a class that can be constructed from `Mat`, `Mat_<T>`, `Matx<T, m, n>`,
|
||||
`std::vector<T>`, `std::vector<std::vector<T> >` or `std::vector<Mat>`. It can also be constructed
|
||||
from a matrix expression.
|
||||
`std::vector<T>`, `std::vector<std::vector<T> >`, `std::vector<Mat>`, `std::vector<Mat_<T> >`,
|
||||
`UMat`, `std::vector<UMat>` or `double`. It can also be constructed from a matrix expression.
|
||||
|
||||
Since this is mostly implementation-level class, and its interface may change in future versions, we
|
||||
do not describe it in details. There are a few key things, though, that should be kept in mind:
|
||||
|
|
@ -165,7 +171,9 @@ public:
|
|||
UMAT =10 << KIND_SHIFT,
|
||||
STD_VECTOR_UMAT =11 << KIND_SHIFT,
|
||||
STD_BOOL_VECTOR =12 << KIND_SHIFT,
|
||||
STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT
|
||||
STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT,
|
||||
STD_ARRAY =14 << KIND_SHIFT,
|
||||
STD_ARRAY_MAT =15 << KIND_SHIFT
|
||||
};
|
||||
|
||||
_InputArray();
|
||||
|
|
@ -177,6 +185,7 @@ public:
|
|||
template<typename _Tp> _InputArray(const std::vector<_Tp>& vec);
|
||||
_InputArray(const std::vector<bool>& vec);
|
||||
template<typename _Tp> _InputArray(const std::vector<std::vector<_Tp> >& vec);
|
||||
_InputArray(const std::vector<std::vector<bool> >&);
|
||||
template<typename _Tp> _InputArray(const std::vector<Mat_<_Tp> >& vec);
|
||||
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||
|
|
@ -189,6 +198,11 @@ public:
|
|||
_InputArray(const UMat& um);
|
||||
_InputArray(const std::vector<UMat>& umv);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _InputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
Mat getMat(int idx=-1) const;
|
||||
Mat getMat_(int idx=-1) const;
|
||||
UMat getUMat(int idx=-1) const;
|
||||
|
|
@ -293,6 +307,7 @@ public:
|
|||
template<typename _Tp> _OutputArray(std::vector<_Tp>& vec);
|
||||
_OutputArray(std::vector<bool>& vec);
|
||||
template<typename _Tp> _OutputArray(std::vector<std::vector<_Tp> >& vec);
|
||||
_OutputArray(std::vector<std::vector<bool> >&);
|
||||
template<typename _Tp> _OutputArray(std::vector<Mat_<_Tp> >& vec);
|
||||
template<typename _Tp> _OutputArray(Mat_<_Tp>& m);
|
||||
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
||||
|
|
@ -316,6 +331,13 @@ public:
|
|||
_OutputArray(const UMat& m);
|
||||
_OutputArray(const std::vector<UMat>& vec);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _OutputArray(std::array<_Tp, _Nm>& arr);
|
||||
template<typename _Tp, std::size_t _Nm> _OutputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _OutputArray(std::array<Mat, _Nm>& arr);
|
||||
template<std::size_t _Nm> _OutputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
bool fixedSize() const;
|
||||
bool fixedType() const;
|
||||
bool needed() const;
|
||||
|
|
@ -335,6 +357,9 @@ public:
|
|||
|
||||
void assign(const UMat& u) const;
|
||||
void assign(const Mat& m) const;
|
||||
|
||||
void assign(const std::vector<UMat>& v) const;
|
||||
void assign(const std::vector<Mat>& v) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -374,8 +399,18 @@ public:
|
|||
template<typename _Tp, int m, int n> _InputOutputArray(const Matx<_Tp, m, n>& matx);
|
||||
_InputOutputArray(const UMat& m);
|
||||
_InputOutputArray(const std::vector<UMat>& vec);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _InputOutputArray(std::array<_Tp, _Nm>& arr);
|
||||
template<typename _Tp, std::size_t _Nm> _InputOutputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputOutputArray(std::array<Mat, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputOutputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
CV__DEBUG_NS_END
|
||||
|
||||
typedef const _InputArray& InputArray;
|
||||
typedef InputArray InputArrayOfArrays;
|
||||
typedef const _OutputArray& OutputArray;
|
||||
|
|
@ -473,7 +508,9 @@ struct CV_EXPORTS UMatData
|
|||
{
|
||||
enum { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
|
||||
DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
|
||||
USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64};
|
||||
USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64,
|
||||
ASYNC_CLEANUP=128
|
||||
};
|
||||
UMatData(const MatAllocator* allocator);
|
||||
~UMatData();
|
||||
|
||||
|
|
@ -548,7 +585,7 @@ protected:
|
|||
An example demonstrating the serial out capabilities of cv::Mat
|
||||
*/
|
||||
|
||||
/** @brief n-dimensional dense array class
|
||||
/** @brief n-dimensional dense array class \anchor CVMat_Details
|
||||
|
||||
The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It
|
||||
can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel
|
||||
|
|
@ -660,7 +697,7 @@ sub-matrices.
|
|||
|
||||
- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example:
|
||||
@code
|
||||
// create a double-precision identity martix and add it to M.
|
||||
// create a double-precision identity matrix and add it to M.
|
||||
M += Mat::eye(M.rows, M.cols, CV_64F);
|
||||
@endcode
|
||||
|
||||
|
|
@ -693,7 +730,7 @@ If you need to process a whole row of a 2D array, the most efficient way is to g
|
|||
the row first, and then just use the plain C operator [] :
|
||||
@code
|
||||
// compute sum of positive matrix elements
|
||||
// (assuming that M isa double-precision matrix)
|
||||
// (assuming that M is a double-precision matrix)
|
||||
double sum=0;
|
||||
for(int i = 0; i < M.rows; i++)
|
||||
{
|
||||
|
|
@ -736,6 +773,8 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee
|
|||
@endcode
|
||||
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm,
|
||||
including std::sort().
|
||||
|
||||
@note Matrix Expressions and arithmetic see MatExpr
|
||||
*/
|
||||
class CV_EXPORTS Mat
|
||||
{
|
||||
|
|
@ -794,6 +833,13 @@ public:
|
|||
*/
|
||||
Mat(int ndims, const int* sizes, int type);
|
||||
|
||||
/** @overload
|
||||
@param sizes Array of integers specifying an n-dimensional array shape.
|
||||
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
|
||||
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
|
||||
*/
|
||||
Mat(const std::vector<int>& sizes, int type);
|
||||
|
||||
/** @overload
|
||||
@param ndims Array dimensionality.
|
||||
@param sizes Array of integers specifying an n-dimensional array shape.
|
||||
|
|
@ -805,6 +851,17 @@ public:
|
|||
*/
|
||||
Mat(int ndims, const int* sizes, int type, const Scalar& s);
|
||||
|
||||
/** @overload
|
||||
@param sizes Array of integers specifying an n-dimensional array shape.
|
||||
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
|
||||
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
|
||||
@param s An optional value to initialize each matrix element with. To set all the matrix elements to
|
||||
the particular value after the construction, use the assignment operator
|
||||
Mat::operator=(const Scalar& value) .
|
||||
*/
|
||||
Mat(const std::vector<int>& sizes, int type, const Scalar& s);
|
||||
|
||||
|
||||
/** @overload
|
||||
@param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied
|
||||
by these constructors. Instead, the header pointing to m data or its sub-array is constructed and
|
||||
|
|
@ -861,6 +918,20 @@ public:
|
|||
*/
|
||||
Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);
|
||||
|
||||
/** @overload
|
||||
@param sizes Array of integers specifying an n-dimensional array shape.
|
||||
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
|
||||
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
|
||||
@param data Pointer to the user data. Matrix constructors that take data and step parameters do not
|
||||
allocate matrix data. Instead, they just initialize the matrix header that points to the specified
|
||||
data, which means that no data is copied. This operation is very efficient and can be used to
|
||||
process external data using OpenCV functions. The external data is not automatically deallocated, so
|
||||
you should take care of it.
|
||||
@param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always
|
||||
set to the element size). If not specified, the matrix is assumed to be continuous.
|
||||
*/
|
||||
Mat(const std::vector<int>& sizes, int type, void* data, const size_t* steps=0);
|
||||
|
||||
/** @overload
|
||||
@param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied
|
||||
by these constructors. Instead, the header pointing to m data or its sub-array is constructed and
|
||||
|
|
@ -893,6 +964,16 @@ public:
|
|||
*/
|
||||
Mat(const Mat& m, const Range* ranges);
|
||||
|
||||
/** @overload
|
||||
@param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied
|
||||
by these constructors. Instead, the header pointing to m data or its sub-array is constructed and
|
||||
associated with it. The reference counter, if any, is incremented. So, when you modify the matrix
|
||||
formed using such a constructor, you also modify the corresponding elements of m . If you want to
|
||||
have an independent copy of the sub-array, use Mat::clone() .
|
||||
@param ranges Array of selected ranges of m along each dimensionality.
|
||||
*/
|
||||
Mat(const Mat& m, const std::vector<Range>& ranges);
|
||||
|
||||
/** @overload
|
||||
@param vec STL vector whose elements form the matrix. The matrix has a single column and the number
|
||||
of rows equal to the number of vector elements. Type of the matrix matches the type of vector
|
||||
|
|
@ -911,6 +992,19 @@ public:
|
|||
*/
|
||||
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||
|
||||
#ifdef CV_CXX11
|
||||
/** @overload
|
||||
*/
|
||||
template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
|
||||
explicit Mat(const std::initializer_list<_Tp> list);
|
||||
#endif
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
/** @overload
|
||||
*/
|
||||
template<typename _Tp, size_t _Nm> explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
||||
#endif
|
||||
|
||||
/** @overload
|
||||
*/
|
||||
template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
|
||||
|
|
@ -1037,18 +1131,40 @@ public:
|
|||
single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation.
|
||||
@param d index of the diagonal, with the following values:
|
||||
- `d=0` is the main diagonal.
|
||||
- `d>0` is a diagonal from the lower half. For example, d=1 means the diagonal is set
|
||||
- `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set
|
||||
immediately below the main one.
|
||||
- `d<0` is a diagonal from the upper half. For example, d=-1 means the diagonal is set
|
||||
- `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set
|
||||
immediately above the main one.
|
||||
For example:
|
||||
@code
|
||||
Mat m = (Mat_<int>(3,3) <<
|
||||
1,2,3,
|
||||
4,5,6,
|
||||
7,8,9);
|
||||
Mat d0 = m.diag(0);
|
||||
Mat d1 = m.diag(1);
|
||||
Mat d_1 = m.diag(-1);
|
||||
@endcode
|
||||
The resulting matrices are
|
||||
@code
|
||||
d0 =
|
||||
[1;
|
||||
5;
|
||||
9]
|
||||
d1 =
|
||||
[2;
|
||||
6]
|
||||
d_1 =
|
||||
[4;
|
||||
8]
|
||||
@endcode
|
||||
*/
|
||||
Mat diag(int d=0) const;
|
||||
|
||||
/** @brief creates a diagonal matrix
|
||||
|
||||
The method makes a new header for the specified matrix diagonal. The new matrix is represented as a
|
||||
single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation.
|
||||
@param d Single-column matrix that forms a diagonal matrix
|
||||
The method creates a square diagonal matrix from specified main diagonal.
|
||||
@param d One-dimensional matrix that represents the main diagonal.
|
||||
*/
|
||||
static Mat diag(const Mat& d);
|
||||
|
||||
|
|
@ -1079,8 +1195,8 @@ public:
|
|||
/** @overload
|
||||
@param m Destination matrix. If it does not have a proper size or type before the operation, it is
|
||||
reallocated.
|
||||
@param mask Operation mask. Its non-zero elements indicate which matrix elements need to be copied.
|
||||
The mask has to be of type CV_8U and can have 1 or multiple channels.
|
||||
@param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix
|
||||
elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
|
||||
*/
|
||||
void copyTo( OutputArray m, InputArray mask ) const;
|
||||
|
||||
|
|
@ -1116,7 +1232,8 @@ public:
|
|||
|
||||
This is an advanced variant of the Mat::operator=(const Scalar& s) operator.
|
||||
@param value Assigned scalar converted to the actual array type.
|
||||
@param mask Operation mask of the same size as \*this.
|
||||
@param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix
|
||||
elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels
|
||||
*/
|
||||
Mat& setTo(InputArray value, InputArray mask=noArray());
|
||||
|
||||
|
|
@ -1149,6 +1266,9 @@ public:
|
|||
/** @overload */
|
||||
Mat reshape(int cn, int newndims, const int* newsz) const;
|
||||
|
||||
/** @overload */
|
||||
Mat reshape(int cn, const std::vector<int>& newshape) const;
|
||||
|
||||
/** @brief Transposes a matrix.
|
||||
|
||||
The method performs matrix transposition by means of matrix expressions. It does not perform the
|
||||
|
|
@ -1329,6 +1449,12 @@ public:
|
|||
*/
|
||||
void create(int ndims, const int* sizes, int type);
|
||||
|
||||
/** @overload
|
||||
@param sizes Array of integers specifying a new array shape.
|
||||
@param type New matrix type.
|
||||
*/
|
||||
void create(const std::vector<int>& sizes, int type);
|
||||
|
||||
/** @brief Increments the reference counter.
|
||||
|
||||
The method increments the reference counter associated with the matrix data. If the matrix header
|
||||
|
|
@ -1355,7 +1481,7 @@ public:
|
|||
*/
|
||||
void release();
|
||||
|
||||
//! deallocates the matrix data
|
||||
//! internal use function, consider to use 'release' method instead; deallocates the matrix data
|
||||
void deallocate();
|
||||
//! internal use function; properly re-allocates _size, _step arrays
|
||||
void copySize(const Mat& m);
|
||||
|
|
@ -1369,6 +1495,14 @@ public:
|
|||
*/
|
||||
void reserve(size_t sz);
|
||||
|
||||
/** @brief Reserves space for the certain number of bytes.
|
||||
|
||||
The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes,
|
||||
nothing happens. If matrix has to be reallocated its previous content could be lost.
|
||||
@param sz Number of bytes.
|
||||
*/
|
||||
void reserveBuffer(size_t sz);
|
||||
|
||||
/** @brief Changes the number of matrix rows.
|
||||
|
||||
The methods change the number of matrix rows. If the matrix is reallocated, the first
|
||||
|
|
@ -1401,6 +1535,11 @@ public:
|
|||
*/
|
||||
template<typename _Tp> void push_back(const Mat_<_Tp>& elem);
|
||||
|
||||
/** @overload
|
||||
@param elem Added element(s).
|
||||
*/
|
||||
template<typename _Tp> void push_back(const std::vector<_Tp>& elem);
|
||||
|
||||
/** @overload
|
||||
@param m Added line(s).
|
||||
*/
|
||||
|
|
@ -1479,6 +1618,11 @@ public:
|
|||
*/
|
||||
Mat operator()( const Range* ranges ) const;
|
||||
|
||||
/** @overload
|
||||
@param ranges Array of selected ranges along each array dimension.
|
||||
*/
|
||||
Mat operator()(const std::vector<Range>& ranges) const;
|
||||
|
||||
// //! converts header to CvMat; no data is copied
|
||||
// operator CvMat() const;
|
||||
// //! converts header to CvMatND; no data is copied
|
||||
|
|
@ -1490,6 +1634,10 @@ public:
|
|||
template<typename _Tp, int n> operator Vec<_Tp, n>() const;
|
||||
template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
|
||||
#endif
|
||||
|
||||
/** @brief Reports whether the matrix is continuous or not.
|
||||
|
||||
The method returns true if the matrix elements are stored continuously without gaps at the end of
|
||||
|
|
@ -1522,7 +1670,7 @@ public:
|
|||
inv_scale = 1.f/alpha_scale;
|
||||
|
||||
CV_Assert( src1.type() == src2.type() &&
|
||||
src1.type() == CV_MAKETYPE(DataType<T>::depth, 4) &&
|
||||
src1.type() == CV_MAKETYPE(traits::Depth<T>::value, 4) &&
|
||||
src1.size() == src2.size());
|
||||
Size size = src1.size();
|
||||
dst.create(size, src1.type());
|
||||
|
|
@ -1632,6 +1780,12 @@ public:
|
|||
*/
|
||||
size_t total() const;
|
||||
|
||||
/** @brief Returns the total number of array elements.
|
||||
|
||||
The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim
|
||||
*/
|
||||
size_t total(int startDim, int endDim=INT_MAX) const;
|
||||
|
||||
//! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
|
||||
int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const;
|
||||
|
||||
|
|
@ -1645,10 +1799,16 @@ public:
|
|||
/** @overload */
|
||||
const uchar* ptr(int i0=0) const;
|
||||
|
||||
/** @overload */
|
||||
uchar* ptr(int i0, int i1);
|
||||
/** @overload */
|
||||
const uchar* ptr(int i0, int i1) const;
|
||||
/** @overload
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
uchar* ptr(int row, int col);
|
||||
/** @overload
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
const uchar* ptr(int row, int col) const;
|
||||
|
||||
/** @overload */
|
||||
uchar* ptr(int i0, int i1, int i2);
|
||||
|
|
@ -1668,10 +1828,16 @@ public:
|
|||
template<typename _Tp> _Tp* ptr(int i0=0);
|
||||
/** @overload */
|
||||
template<typename _Tp> const _Tp* ptr(int i0=0) const;
|
||||
/** @overload */
|
||||
template<typename _Tp> _Tp* ptr(int i0, int i1);
|
||||
/** @overload */
|
||||
template<typename _Tp> const _Tp* ptr(int i0, int i1) const;
|
||||
/** @overload
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
template<typename _Tp> _Tp* ptr(int row, int col);
|
||||
/** @overload
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
template<typename _Tp> const _Tp* ptr(int row, int col) const;
|
||||
/** @overload */
|
||||
template<typename _Tp> _Tp* ptr(int i0, int i1, int i2);
|
||||
/** @overload */
|
||||
|
|
@ -1702,6 +1868,17 @@ public:
|
|||
for(int j = 0; j < H.cols; j++)
|
||||
H.at<double>(i,j)=1./(i+j+1);
|
||||
@endcode
|
||||
|
||||
Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends
|
||||
on the image from which you are trying to retrieve the data. The table below gives a better insight in this:
|
||||
- If matrix is of type `CV_8U` then use `Mat.at<uchar>(y,x)`.
|
||||
- If matrix is of type `CV_8S` then use `Mat.at<schar>(y,x)`.
|
||||
- If matrix is of type `CV_16U` then use `Mat.at<ushort>(y,x)`.
|
||||
- If matrix is of type `CV_16S` then use `Mat.at<short>(y,x)`.
|
||||
- If matrix is of type `CV_32S` then use `Mat.at<int>(y,x)`.
|
||||
- If matrix is of type `CV_32F` then use `Mat.at<float>(y,x)`.
|
||||
- If matrix is of type `CV_64F` then use `Mat.at<double>(y,x)`.
|
||||
|
||||
@param i0 Index along the dimension 0
|
||||
*/
|
||||
template<typename _Tp> _Tp& at(int i0=0);
|
||||
|
|
@ -1710,15 +1887,15 @@ public:
|
|||
*/
|
||||
template<typename _Tp> const _Tp& at(int i0=0) const;
|
||||
/** @overload
|
||||
@param i0 Index along the dimension 0
|
||||
@param i1 Index along the dimension 1
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
template<typename _Tp> _Tp& at(int i0, int i1);
|
||||
template<typename _Tp> _Tp& at(int row, int col);
|
||||
/** @overload
|
||||
@param i0 Index along the dimension 0
|
||||
@param i1 Index along the dimension 1
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
template<typename _Tp> const _Tp& at(int i0, int i1) const;
|
||||
template<typename _Tp> const _Tp& at(int row, int col) const;
|
||||
|
||||
/** @overload
|
||||
@param i0 Index along the dimension 0
|
||||
|
|
@ -1773,7 +1950,7 @@ public:
|
|||
inv_scale = 1.f/alpha_scale;
|
||||
|
||||
CV_Assert( src1.type() == src2.type() &&
|
||||
src1.type() == DataType<VT>::type &&
|
||||
src1.type() == traits::Type<VT>::value &&
|
||||
src1.size() == src2.size());
|
||||
Size size = src1.size();
|
||||
dst.create(size, src1.type());
|
||||
|
|
@ -1805,19 +1982,18 @@ public:
|
|||
template<typename _Tp> MatIterator_<_Tp> end();
|
||||
template<typename _Tp> MatConstIterator_<_Tp> end() const;
|
||||
|
||||
/** @brief Invoke with arguments functor, and runs the functor over all matrix element.
|
||||
/** @brief Runs the given functor over all matrix elements in parallel.
|
||||
|
||||
The methods runs operation in parallel. Operation is passed by arguments. Operation have to be a
|
||||
function pointer, a function object or a lambda(C++11).
|
||||
The operation passed as argument has to be a function pointer, a function object or a lambda(C++11).
|
||||
|
||||
All of below operation is equal. Put 0xFF to first channel of all matrix elements:
|
||||
Example 1. All of the operations below put 0xFF the first channel of all matrix elements:
|
||||
@code
|
||||
Mat image(1920, 1080, CV_8UC3);
|
||||
typedef cv::Point3_<uint8_t> Pixel;
|
||||
|
||||
// first. raw pointer access.
|
||||
for (int r = 0; r < image.rows; ++r) {
|
||||
Pixel* ptr = image.ptr<Pixel>(0, r);
|
||||
Pixel* ptr = image.ptr<Pixel>(r, 0);
|
||||
const Pixel* ptr_end = ptr + image.cols;
|
||||
for (; ptr != ptr_end; ++ptr) {
|
||||
ptr->x = 255;
|
||||
|
|
@ -1842,18 +2018,18 @@ public:
|
|||
p.x = 255;
|
||||
});
|
||||
@endcode
|
||||
position parameter is index of current pixel:
|
||||
Example 2. Using the pixel's position:
|
||||
@code
|
||||
// Creating 3D matrix (255 x 255 x 255) typed uint8_t,
|
||||
// and initialize all elements by the value which equals elements position.
|
||||
// i.e. pixels (x,y,z) = (1,2,3) is (b,g,r) = (1,2,3).
|
||||
// Creating 3D matrix (255 x 255 x 255) typed uint8_t
|
||||
// and initialize all elements by the value which equals elements position.
|
||||
// i.e. pixels (x,y,z) = (1,2,3) is (b,g,r) = (1,2,3).
|
||||
|
||||
int sizes[] = { 255, 255, 255 };
|
||||
typedef cv::Point3_<uint8_t> Pixel;
|
||||
|
||||
Mat_<Pixel> image = Mat::zeros(3, sizes, CV_8UC3);
|
||||
|
||||
image.forEachWithPosition([&](Pixel& pixel, const int position[]) -> void{
|
||||
image.forEach<Pixel>([&](Pixel& pixel, const int position[]) -> void {
|
||||
pixel.x = position[0];
|
||||
pixel.y = position[1];
|
||||
pixel.z = position[2];
|
||||
|
|
@ -1913,7 +2089,7 @@ protected:
|
|||
|
||||
/** @brief Template matrix class derived from Mat
|
||||
|
||||
@code
|
||||
@code{.cpp}
|
||||
template<typename _Tp> class Mat_ : public Mat
|
||||
{
|
||||
public:
|
||||
|
|
@ -1925,7 +2101,7 @@ protected:
|
|||
The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any
|
||||
extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to
|
||||
these two classes can be freely but carefully converted one to another. For example:
|
||||
@code
|
||||
@code{.cpp}
|
||||
// create a 100x100 8-bit matrix
|
||||
Mat M(100,100,CV_8U);
|
||||
// this will be compiled fine. no any data conversion will be done.
|
||||
|
|
@ -1937,7 +2113,7 @@ While Mat is sufficient in most cases, Mat_ can be more convenient if you use a
|
|||
access operations and if you know matrix type at the compilation time. Note that
|
||||
`Mat::at(int y,int x)` and `Mat_::operator()(int y,int x)` do absolutely the same
|
||||
and run at the same speed, but the latter is certainly shorter:
|
||||
@code
|
||||
@code{.cpp}
|
||||
Mat_<double> M(20,20);
|
||||
for(int i = 0; i < M.rows; i++)
|
||||
for(int j = 0; j < M.cols; j++)
|
||||
|
|
@ -1947,7 +2123,7 @@ and run at the same speed, but the latter is certainly shorter:
|
|||
cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0);
|
||||
@endcode
|
||||
To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
|
||||
@code
|
||||
@code{.cpp}
|
||||
// allocate a 320x240 color image and fill it with green (in RGB space)
|
||||
Mat_<Vec3b> img(240, 320, Vec3b(0,255,0));
|
||||
// now draw a diagonal white line
|
||||
|
|
@ -1957,6 +2133,17 @@ To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
|
|||
for(int i = 0; i < img.rows; i++)
|
||||
for(int j = 0; j < img.cols; j++)
|
||||
img(i,j)[2] ^= (uchar)(i ^ j);
|
||||
@endcode
|
||||
Mat_ is fully compatible with C++11 range-based for loop. For example such loop
|
||||
can be used to safely apply look-up table:
|
||||
@code{.cpp}
|
||||
void applyTable(Mat_<uchar>& I, const uchar* const table)
|
||||
{
|
||||
for(auto& pixel : I)
|
||||
{
|
||||
pixel = table[pixel];
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
template<typename _Tp> class Mat_ : public Mat
|
||||
|
|
@ -1995,6 +2182,8 @@ public:
|
|||
Mat_(const Mat_& m, const Rect& roi);
|
||||
//! selects a submatrix, n-dim version
|
||||
Mat_(const Mat_& m, const Range* ranges);
|
||||
//! selects a submatrix, n-dim version
|
||||
Mat_(const Mat_& m, const std::vector<Range>& ranges);
|
||||
//! from a matrix expression
|
||||
explicit Mat_(const MatExpr& e);
|
||||
//! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column
|
||||
|
|
@ -2005,6 +2194,14 @@ public:
|
|||
explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
||||
explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer);
|
||||
|
||||
#ifdef CV_CXX11
|
||||
Mat_(std::initializer_list<_Tp> values);
|
||||
#endif
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template <std::size_t _Nm> explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
||||
#endif
|
||||
|
||||
Mat_& operator = (const Mat& m);
|
||||
Mat_& operator = (const Mat_& m);
|
||||
//! set all the elements to s.
|
||||
|
|
@ -2029,6 +2226,8 @@ public:
|
|||
void create(Size _size);
|
||||
//! equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
|
||||
void create(int _ndims, const int* _sizes);
|
||||
//! equivalent to Mat::release()
|
||||
void release();
|
||||
//! cross-product
|
||||
Mat_ cross(const Mat_& m) const;
|
||||
//! data type conversion
|
||||
|
|
@ -2064,6 +2263,7 @@ public:
|
|||
Mat_ operator()( const Range& rowRange, const Range& colRange ) const;
|
||||
Mat_ operator()( const Rect& roi ) const;
|
||||
Mat_ operator()( const Range* ranges ) const;
|
||||
Mat_ operator()(const std::vector<Range>& ranges) const;
|
||||
|
||||
//! more convenient forms of row and element access operators
|
||||
_Tp* operator [](int y);
|
||||
|
|
@ -2084,9 +2284,9 @@ public:
|
|||
//! returns read-only reference to the specified element (1D case)
|
||||
const _Tp& operator ()(int idx0) const;
|
||||
//! returns reference to the specified element (2D case)
|
||||
_Tp& operator ()(int idx0, int idx1);
|
||||
_Tp& operator ()(int row, int col);
|
||||
//! returns read-only reference to the specified element (2D case)
|
||||
const _Tp& operator ()(int idx0, int idx1) const;
|
||||
const _Tp& operator ()(int row, int col) const;
|
||||
//! returns reference to the specified element (3D case)
|
||||
_Tp& operator ()(int idx0, int idx1, int idx2);
|
||||
//! returns read-only reference to the specified element (3D case)
|
||||
|
|
@ -2097,6 +2297,12 @@ public:
|
|||
|
||||
//! conversion to vector.
|
||||
operator std::vector<_Tp>() const;
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
//! conversion to array.
|
||||
template<std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
|
||||
#endif
|
||||
|
||||
//! conversion to Vec
|
||||
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
|
||||
//! conversion to Matx
|
||||
|
|
@ -2168,8 +2374,10 @@ public:
|
|||
UMat(const UMat& m, const Range& rowRange, const Range& colRange=Range::all());
|
||||
UMat(const UMat& m, const Rect& roi);
|
||||
UMat(const UMat& m, const Range* ranges);
|
||||
UMat(const UMat& m, const std::vector<Range>& ranges);
|
||||
//! builds matrix from std::vector with or without copying the data
|
||||
template<typename _Tp> explicit UMat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||
|
||||
//! builds matrix from cv::Vec; the data is copied by default
|
||||
template<typename _Tp, int n> explicit UMat(const Vec<_Tp, n>& vec, bool copyData=true);
|
||||
//! builds matrix from cv::Matx; the data is copied by default
|
||||
|
|
@ -2199,9 +2407,9 @@ public:
|
|||
UMat colRange(int startcol, int endcol) const;
|
||||
UMat colRange(const Range& r) const;
|
||||
//! ... for the specified diagonal
|
||||
// (d=0 - the main diagonal,
|
||||
// >0 - a diagonal from the lower half,
|
||||
// <0 - a diagonal from the upper half)
|
||||
//! (d=0 - the main diagonal,
|
||||
//! >0 - a diagonal from the upper half,
|
||||
//! <0 - a diagonal from the lower half)
|
||||
UMat diag(int d=0) const;
|
||||
//! constructs a square diagonal matrix which main diagonal is vector "d"
|
||||
static UMat diag(const UMat& d);
|
||||
|
|
@ -2213,7 +2421,7 @@ public:
|
|||
void copyTo( OutputArray m ) const;
|
||||
//! copies those matrix elements to "m" that are marked with non-zero mask elements.
|
||||
void copyTo( OutputArray m, InputArray mask ) const;
|
||||
//! converts matrix to another datatype with optional scalng. See cvConvertScale.
|
||||
//! converts matrix to another datatype with optional scaling. See cvConvertScale.
|
||||
void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const;
|
||||
|
||||
void assignTo( UMat& m, int type=-1 ) const;
|
||||
|
|
@ -2252,6 +2460,7 @@ public:
|
|||
void create(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
|
||||
void create(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
|
||||
void create(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
|
||||
void create(const std::vector<int>& sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
|
||||
|
||||
//! increases the reference counter; use with care to avoid memleaks
|
||||
void addref();
|
||||
|
|
@ -2273,6 +2482,7 @@ public:
|
|||
UMat operator()( Range rowRange, Range colRange ) const;
|
||||
UMat operator()( const Rect& roi ) const;
|
||||
UMat operator()( const Range* ranges ) const;
|
||||
UMat operator()(const std::vector<Range>& ranges) const;
|
||||
|
||||
//! returns true iff the matrix data is continuous
|
||||
// (i.e. when there are no gaps between successive rows).
|
||||
|
|
@ -2308,6 +2518,10 @@ public:
|
|||
UMat& operator = (UMat&& m);
|
||||
#endif
|
||||
|
||||
/*! Returns the OpenCL buffer handle on which UMat operates on.
|
||||
The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
|
||||
returned to the OpenCV buffer pool.
|
||||
*/
|
||||
void* handle(int accessFlags) const;
|
||||
void ndoffset(size_t* ofs) const;
|
||||
|
||||
|
|
@ -2359,15 +2573,16 @@ Elements can be accessed using the following methods:
|
|||
SparseMat::find), for example:
|
||||
@code
|
||||
const int dims = 5;
|
||||
int size[] = {10, 10, 10, 10, 10};
|
||||
int size[5] = {10, 10, 10, 10, 10};
|
||||
SparseMat sparse_mat(dims, size, CV_32F);
|
||||
for(int i = 0; i < 1000; i++)
|
||||
{
|
||||
int idx[dims];
|
||||
for(int k = 0; k < dims; k++)
|
||||
idx[k] = rand()
|
||||
idx[k] = rand() % size[k];
|
||||
sparse_mat.ref<float>(idx) += 1.f;
|
||||
}
|
||||
cout << "nnz = " << sparse_mat.nzcount() << endl;
|
||||
@endcode
|
||||
- Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator.
|
||||
That is, the iteration loop is familiar to STL users:
|
||||
|
|
@ -2504,11 +2719,11 @@ public:
|
|||
/*!
|
||||
@param [out] m - output matrix; if it does not have a proper size or type before the operation,
|
||||
it is reallocated
|
||||
@param [in] rtype – desired output matrix type or, rather, the depth since the number of channels
|
||||
@param [in] rtype - desired output matrix type or, rather, the depth since the number of channels
|
||||
are the same as the input has; if rtype is negative, the output matrix will have the
|
||||
same type as the input.
|
||||
@param [in] alpha – optional scale factor
|
||||
@param [in] beta – optional delta added to the scaled values
|
||||
@param [in] alpha - optional scale factor
|
||||
@param [in] beta - optional delta added to the scaled values
|
||||
*/
|
||||
void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const;
|
||||
|
||||
|
|
@ -2782,9 +2997,7 @@ public:
|
|||
typedef const uchar** pointer;
|
||||
typedef uchar* reference;
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
#endif
|
||||
|
||||
//! default constructor
|
||||
MatConstIterator();
|
||||
|
|
@ -2849,9 +3062,7 @@ public:
|
|||
typedef const _Tp* pointer;
|
||||
typedef const _Tp& reference;
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
#endif
|
||||
|
||||
//! default constructor
|
||||
MatConstIterator_();
|
||||
|
|
@ -2869,9 +3080,9 @@ public:
|
|||
//! copy operator
|
||||
MatConstIterator_& operator = (const MatConstIterator_& it);
|
||||
//! returns the current matrix element
|
||||
_Tp operator *() const;
|
||||
const _Tp& operator *() const;
|
||||
//! returns the i-th matrix element, relative to the current
|
||||
_Tp operator [](ptrdiff_t i) const;
|
||||
const _Tp& operator [](ptrdiff_t i) const;
|
||||
|
||||
//! shifts the iterator forward by the specified number of elements
|
||||
MatConstIterator_& operator += (ptrdiff_t ofs);
|
||||
|
|
@ -2902,9 +3113,7 @@ public:
|
|||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
#endif
|
||||
|
||||
//! the default constructor
|
||||
MatIterator_();
|
||||
|
|
@ -3038,9 +3247,7 @@ template<typename _Tp> class SparseMatConstIterator_ : public SparseMatConstIter
|
|||
{
|
||||
public:
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
#endif
|
||||
|
||||
//! the default constructor
|
||||
SparseMatConstIterator_();
|
||||
|
|
@ -3074,9 +3281,7 @@ template<typename _Tp> class SparseMatIterator_ : public SparseMatConstIterator_
|
|||
{
|
||||
public:
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
#endif
|
||||
|
||||
//! the default constructor
|
||||
SparseMatIterator_();
|
||||
|
|
@ -3135,21 +3340,29 @@ The example below illustrates how you can compute a normalized and threshold 3D
|
|||
}
|
||||
|
||||
minProb *= image.rows*image.cols;
|
||||
Mat plane;
|
||||
NAryMatIterator it(&hist, &plane, 1);
|
||||
|
||||
// initialize iterator (the style is different from STL).
|
||||
// after initialization the iterator will contain
|
||||
// the number of slices or planes the iterator will go through.
|
||||
// it simultaneously increments iterators for several matrices
|
||||
// supplied as a null terminated list of pointers
|
||||
const Mat* arrays[] = {&hist, 0};
|
||||
Mat planes[1];
|
||||
NAryMatIterator itNAry(arrays, planes, 1);
|
||||
double s = 0;
|
||||
// iterate through the matrix. on each iteration
|
||||
// it.planes[*] (of type Mat) will be set to the current plane.
|
||||
for(int p = 0; p < it.nplanes; p++, ++it)
|
||||
// itNAry.planes[i] (of type Mat) will be set to the current plane
|
||||
// of the i-th n-dim matrix passed to the iterator constructor.
|
||||
for(int p = 0; p < itNAry.nplanes; p++, ++itNAry)
|
||||
{
|
||||
threshold(it.planes[0], it.planes[0], minProb, 0, THRESH_TOZERO);
|
||||
s += sum(it.planes[0])[0];
|
||||
threshold(itNAry.planes[0], itNAry.planes[0], minProb, 0, THRESH_TOZERO);
|
||||
s += sum(itNAry.planes[0])[0];
|
||||
}
|
||||
|
||||
s = 1./s;
|
||||
it = NAryMatIterator(&hist, &plane, 1);
|
||||
for(int p = 0; p < it.nplanes; p++, ++it)
|
||||
it.planes[0] *= s;
|
||||
itNAry = NAryMatIterator(arrays, planes, 1);
|
||||
for(int p = 0; p < itNAry.nplanes; p++, ++itNAry)
|
||||
itNAry.planes[0] *= s;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
|
|
@ -3428,4 +3641,4 @@ CV_EXPORTS MatExpr abs(const MatExpr& e);
|
|||
|
||||
#include "opencv2/core/mat.inl.hpp"
|
||||
|
||||
#endif // __OPENCV_CORE_MAT_HPP__
|
||||
#endif // OPENCV_CORE_MAT_HPP
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_MATX_HPP__
|
||||
#define __OPENCV_CORE_MATX_HPP__
|
||||
#ifndef OPENCV_CORE_MATX_HPP
|
||||
#define OPENCV_CORE_MATX_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error matx.hpp header must be compiled as C++
|
||||
|
|
@ -53,6 +53,10 @@
|
|||
#include "opencv2/core/traits.hpp"
|
||||
#include "opencv2/core/saturate.hpp"
|
||||
|
||||
#ifdef CV_CXX11
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
|
@ -77,21 +81,33 @@ If you need a more flexible type, use Mat . The elements of the matrix M are acc
|
|||
M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are
|
||||
available. To do an operation on Matx that is not implemented, you can easily convert the matrix to
|
||||
Mat and backwards:
|
||||
@code
|
||||
@code{.cpp}
|
||||
Matx33f m(1, 2, 3,
|
||||
4, 5, 6,
|
||||
7, 8, 9);
|
||||
cout << sum(Mat(m*m.t())) << endl;
|
||||
@endcode
|
||||
@endcode
|
||||
Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array:
|
||||
@code{.cpp}
|
||||
float values[] = { 1, 2, 3};
|
||||
Matx31f m(values);
|
||||
@endcode
|
||||
In case if C++11 features are avaliable, std::initializer_list can be also used to initizlize Matx:
|
||||
@code{.cpp}
|
||||
Matx31f m = { 1, 2, 3};
|
||||
@endcode
|
||||
*/
|
||||
template<typename _Tp, int m, int n> class Matx
|
||||
{
|
||||
public:
|
||||
enum { depth = DataType<_Tp>::depth,
|
||||
enum {
|
||||
rows = m,
|
||||
cols = n,
|
||||
channels = rows*cols,
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
depth = traits::Type<_Tp>::value,
|
||||
type = CV_MAKETYPE(depth, channels),
|
||||
#endif
|
||||
shortdim = (m < n ? m : n)
|
||||
};
|
||||
|
||||
|
|
@ -125,6 +141,10 @@ public:
|
|||
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
||||
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
||||
|
||||
#ifdef CV_CXX11
|
||||
Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
|
||||
#endif
|
||||
|
||||
static Matx all(_Tp alpha);
|
||||
static Matx zeros();
|
||||
static Matx ones();
|
||||
|
|
@ -242,13 +262,23 @@ public:
|
|||
typedef value_type vec_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = m * n,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp, int m, int n>
|
||||
struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp, int m, int n>
|
||||
struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
/** @brief Comma-separated Matrix Initializer
|
||||
*/
|
||||
template<typename _Tp, int m, int n> class MatxCommaInitializer
|
||||
|
|
@ -306,9 +336,13 @@ template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1>
|
|||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { depth = Matx<_Tp, cn, 1>::depth,
|
||||
enum {
|
||||
channels = cn,
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
depth = Matx<_Tp, cn, 1>::depth,
|
||||
type = CV_MAKETYPE(depth, channels),
|
||||
#endif
|
||||
_dummy_enum_finalizer = 0
|
||||
};
|
||||
|
||||
//! default constructor
|
||||
|
|
@ -327,6 +361,10 @@ public:
|
|||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
|
||||
explicit Vec(const _Tp* values);
|
||||
|
||||
#ifdef CV_CXX11
|
||||
Vec(std::initializer_list<_Tp>);
|
||||
#endif
|
||||
|
||||
Vec(const Vec<_Tp, cn>& v);
|
||||
|
||||
static Vec all(_Tp alpha);
|
||||
|
|
@ -401,13 +439,24 @@ public:
|
|||
typedef value_type vec_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = cn,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
depth = DataType<channel_type>::depth,
|
||||
type = CV_MAKETYPE(depth, channels),
|
||||
#endif
|
||||
_dummy_enum_finalizer = 0
|
||||
};
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp, int cn>
|
||||
struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp, int cn>
|
||||
struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
/** @brief Comma-separated Vec Initializer
|
||||
*/
|
||||
template<typename _Tp, int m> class VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1>
|
||||
|
|
@ -438,7 +487,7 @@ template<typename _Tp, int m> struct Matx_DetOp
|
|||
return p;
|
||||
for( int i = 0; i < m; i++ )
|
||||
p *= temp(i, i);
|
||||
return 1./p;
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -590,11 +639,12 @@ Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp
|
|||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13)
|
||||
{
|
||||
CV_StaticAssert(channels == 14, "Matx should have at least 14 elements.");
|
||||
CV_StaticAssert(channels >= 14, "Matx should have at least 14 elements.");
|
||||
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
|
||||
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
|
||||
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
|
||||
val[12] = v12; val[13] = v13;
|
||||
for (int i = 14; i < channels; i++) val[i] = _Tp(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -615,6 +665,19 @@ Matx<_Tp, m, n>::Matx(const _Tp* values)
|
|||
for( int i = 0; i < channels; i++ ) val[i] = values[i];
|
||||
}
|
||||
|
||||
#ifdef CV_CXX11
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
|
||||
{
|
||||
CV_DbgAssert(list.size() == channels);
|
||||
int i = 0;
|
||||
for(const auto& elem : list)
|
||||
{
|
||||
val[i++] = elem;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha)
|
||||
{
|
||||
|
|
@ -956,6 +1019,12 @@ template<typename _Tp, int cn> inline
|
|||
Vec<_Tp, cn>::Vec(const _Tp* values)
|
||||
: Matx<_Tp, cn, 1>(values) {}
|
||||
|
||||
#ifdef CV_CXX11
|
||||
template<typename _Tp, int cn> inline
|
||||
Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list)
|
||||
: Matx<_Tp, cn, 1>(list) {}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, int cn> inline
|
||||
Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
|
||||
: Matx<_Tp, cn, 1>(m.val) {}
|
||||
|
|
@ -1022,17 +1091,17 @@ Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const
|
|||
template<> inline
|
||||
Vec<float, 3> Vec<float, 3>::cross(const Vec<float, 3>& v) const
|
||||
{
|
||||
return Vec<float,3>(val[1]*v.val[2] - val[2]*v.val[1],
|
||||
val[2]*v.val[0] - val[0]*v.val[2],
|
||||
val[0]*v.val[1] - val[1]*v.val[0]);
|
||||
return Vec<float,3>(this->val[1]*v.val[2] - this->val[2]*v.val[1],
|
||||
this->val[2]*v.val[0] - this->val[0]*v.val[2],
|
||||
this->val[0]*v.val[1] - this->val[1]*v.val[0]);
|
||||
}
|
||||
|
||||
template<> inline
|
||||
Vec<double, 3> Vec<double, 3>::cross(const Vec<double, 3>& v) const
|
||||
{
|
||||
return Vec<double,3>(val[1]*v.val[2] - val[2]*v.val[1],
|
||||
val[2]*v.val[0] - val[0]*v.val[2],
|
||||
val[0]*v.val[1] - val[1]*v.val[0]);
|
||||
return Vec<double,3>(this->val[1]*v.val[2] - this->val[2]*v.val[1],
|
||||
this->val[2]*v.val[0] - this->val[0]*v.val[2],
|
||||
this->val[0]*v.val[1] - this->val[1]*v.val[0]);
|
||||
}
|
||||
|
||||
template<typename _Tp, int cn> template<typename T2> inline
|
||||
|
|
@ -1080,7 +1149,7 @@ Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v)
|
|||
|
||||
|
||||
|
||||
//////////////////////////////// matx comma initializer //////////////////////////////////
|
||||
//////////////////////////////// vec comma initializer //////////////////////////////////
|
||||
|
||||
|
||||
template<typename _Tp, typename _T2, int cn> static inline
|
||||
|
|
@ -1404,4 +1473,4 @@ template<typename _Tp> inline Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const V
|
|||
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_MATX_HPP__
|
||||
#endif // OPENCV_CORE_MATX_HPP
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_HAL_NEON_UTILS_HPP__
|
||||
#define __OPENCV_HAL_NEON_UTILS_HPP__
|
||||
#ifndef OPENCV_HAL_NEON_UTILS_HPP
|
||||
#define OPENCV_HAL_NEON_UTILS_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
|
|
@ -125,4 +125,4 @@ inline float32x2_t cv_vsqrt_f32(float32x2_t val)
|
|||
|
||||
//! @}
|
||||
|
||||
#endif // __OPENCV_HAL_NEON_UTILS_HPP__
|
||||
#endif // OPENCV_HAL_NEON_UTILS_HPP
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OPENCL_HPP__
|
||||
#define __OPENCV_OPENCL_HPP__
|
||||
#ifndef OPENCV_OPENCL_HPP
|
||||
#define OPENCV_OPENCL_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
|
|
@ -91,6 +91,7 @@ public:
|
|||
|
||||
String name() const;
|
||||
String extensions() const;
|
||||
bool isExtensionSupported(const String& extensionName) const;
|
||||
String version() const;
|
||||
String vendorName() const;
|
||||
String OpenCL_C_Version() const;
|
||||
|
|
@ -160,6 +161,9 @@ public:
|
|||
uint imagePitchAlignment() const;
|
||||
uint imageBaseAddressAlignment() const;
|
||||
|
||||
/// deprecated, use isExtensionSupported() method (probably with "cl_khr_subgroups" value)
|
||||
bool intelSubgroupsSupport() const;
|
||||
|
||||
size_t image2DMaxWidth() const;
|
||||
size_t image2DMaxHeight() const;
|
||||
|
||||
|
|
@ -246,6 +250,7 @@ public:
|
|||
const Device& device(size_t idx) const;
|
||||
Program getProg(const ProgramSource& prog,
|
||||
const String& buildopt, String& errmsg);
|
||||
void unloadProg(Program& prog);
|
||||
|
||||
static Context& getDefault(bool initialize = true);
|
||||
void* ptr() const;
|
||||
|
|
@ -256,6 +261,8 @@ public:
|
|||
void setUseSVM(bool enabled);
|
||||
|
||||
struct Impl;
|
||||
inline Impl* getImpl() const { return (Impl*)p; }
|
||||
//protected:
|
||||
Impl* p;
|
||||
};
|
||||
|
||||
|
|
@ -276,55 +283,38 @@ protected:
|
|||
Impl* p;
|
||||
};
|
||||
|
||||
/*
|
||||
//! @brief Attaches OpenCL context to OpenCV
|
||||
//
|
||||
//! @note Note:
|
||||
// OpenCV will check if available OpenCL platform has platformName name,
|
||||
// then assign context to OpenCV and call clRetainContext function.
|
||||
// The deviceID device will be used as target device and new command queue
|
||||
// will be created.
|
||||
//
|
||||
// Params:
|
||||
//! @param platformName - name of OpenCL platform to attach,
|
||||
//! this string is used to check if platform is available
|
||||
//! to OpenCV at runtime
|
||||
//! @param platfromID - ID of platform attached context was created for
|
||||
//! @param context - OpenCL context to be attached to OpenCV
|
||||
//! @param deviceID - ID of device, must be created from attached context
|
||||
/** @brief Attaches OpenCL context to OpenCV
|
||||
@note
|
||||
OpenCV will check if available OpenCL platform has platformName name, then assign context to
|
||||
OpenCV and call `clRetainContext` function. The deviceID device will be used as target device and
|
||||
new command queue will be created.
|
||||
@param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime
|
||||
@param platformID ID of platform attached context was created for
|
||||
@param context OpenCL context to be attached to OpenCV
|
||||
@param deviceID ID of device, must be created from attached context
|
||||
*/
|
||||
CV_EXPORTS void attachContext(const String& platformName, void* platformID, void* context, void* deviceID);
|
||||
|
||||
/*
|
||||
//! @brief Convert OpenCL buffer to UMat
|
||||
//
|
||||
//! @note Note:
|
||||
// OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV.
|
||||
// Memory content is not copied from clBuffer to UMat. Instead, buffer handle assigned
|
||||
// to UMat and clRetainMemObject is called.
|
||||
//
|
||||
// Params:
|
||||
//! @param cl_mem_buffer - source clBuffer handle
|
||||
//! @param step - num of bytes in single row
|
||||
//! @param rows - number of rows
|
||||
//! @param cols - number of cols
|
||||
//! @param type - OpenCV type of image
|
||||
//! @param dst - destination UMat
|
||||
/** @brief Convert OpenCL buffer to UMat
|
||||
@note
|
||||
OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV. Memory
|
||||
content is not copied from `clBuffer` to UMat. Instead, buffer handle assigned to UMat and
|
||||
`clRetainMemObject` is called.
|
||||
@param cl_mem_buffer source clBuffer handle
|
||||
@param step num of bytes in single row
|
||||
@param rows number of rows
|
||||
@param cols number of cols
|
||||
@param type OpenCV type of image
|
||||
@param dst destination UMat
|
||||
*/
|
||||
CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst);
|
||||
|
||||
/*
|
||||
//! @brief Convert OpenCL image2d_t to UMat
|
||||
//
|
||||
//! @note Note:
|
||||
// OpenCL image2d_t (cl_mem_image), should be compatible with OpenCV
|
||||
// UMat formats.
|
||||
// Memory content is copied from image to UMat with
|
||||
// clEnqueueCopyImageToBuffer function.
|
||||
//
|
||||
// Params:
|
||||
//! @param cl_mem_image - source image2d_t handle
|
||||
//! @param dst - destination UMat
|
||||
/** @brief Convert OpenCL image2d_t to UMat
|
||||
@note
|
||||
OpenCL `image2d_t` (cl_mem_image), should be compatible with OpenCV UMat formats. Memory content
|
||||
is copied from image to UMat with `clEnqueueCopyImageToBuffer` function.
|
||||
@param cl_mem_image source image2d_t handle
|
||||
@param dst destination UMat
|
||||
*/
|
||||
CV_EXPORTS void convertFromImage(void* cl_mem_image, UMat& dst);
|
||||
|
||||
|
|
@ -345,8 +335,12 @@ public:
|
|||
void* ptr() const;
|
||||
static Queue& getDefault();
|
||||
|
||||
/// @brief Returns OpenCL command queue with enable profiling mode support
|
||||
const Queue& getProfilingQueue() const;
|
||||
|
||||
struct Impl; friend struct Impl;
|
||||
inline Impl* getImpl() const { return p; }
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* p;
|
||||
};
|
||||
|
||||
|
|
@ -567,11 +561,26 @@ public:
|
|||
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
|
||||
i = set(i, a12); i = set(i, a13); i = set(i, a14); set(i, a15); return *this;
|
||||
}
|
||||
|
||||
/** @brief Run the OpenCL kernel.
|
||||
@param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3.
|
||||
@param globalsize work items for each dimension. It is not the final globalsize passed to
|
||||
OpenCL. Each dimension will be adjusted to the nearest integer divisible by the corresponding
|
||||
value in localsize. If localsize is NULL, it will still be adjusted depending on dims. The
|
||||
adjusted values are greater than or equal to the original values.
|
||||
@param localsize work-group size for each dimension.
|
||||
@param sync specify whether to wait for OpenCL computation to finish before return.
|
||||
@param q command queue
|
||||
*/
|
||||
bool run(int dims, size_t globalsize[],
|
||||
size_t localsize[], bool sync, const Queue& q=Queue());
|
||||
bool runTask(bool sync, const Queue& q=Queue());
|
||||
|
||||
/** @brief Similar to synchronized run() call with returning of kernel execution time
|
||||
* Separate OpenCL command queue may be used (with CL_QUEUE_PROFILING_ENABLE)
|
||||
* @return Execution time in nanoseconds or negative number on error
|
||||
*/
|
||||
int64 runProfiling(int dims, size_t globalsize[], size_t localsize[], const Queue& q=Queue());
|
||||
|
||||
size_t workGroupSize() const;
|
||||
size_t preferedWorkGroupSizeMultiple() const;
|
||||
bool compileWorkGroupSize(size_t wsz[]) const;
|
||||
|
|
@ -590,7 +599,6 @@ public:
|
|||
Program();
|
||||
Program(const ProgramSource& src,
|
||||
const String& buildflags, String& errmsg);
|
||||
explicit Program(const String& buf);
|
||||
Program(const Program& prog);
|
||||
|
||||
Program& operator = (const Program& prog);
|
||||
|
|
@ -598,38 +606,104 @@ public:
|
|||
|
||||
bool create(const ProgramSource& src,
|
||||
const String& buildflags, String& errmsg);
|
||||
bool read(const String& buf, const String& buildflags);
|
||||
bool write(String& buf) const;
|
||||
|
||||
const ProgramSource& source() const;
|
||||
void* ptr() const;
|
||||
|
||||
String getPrefix() const;
|
||||
static String getPrefix(const String& buildflags);
|
||||
/**
|
||||
* @brief Query device-specific program binary.
|
||||
*
|
||||
* Returns RAW OpenCL executable binary without additional attachments.
|
||||
*
|
||||
* @sa ProgramSource::fromBinary
|
||||
*
|
||||
* @param[out] binary output buffer
|
||||
*/
|
||||
void getBinary(std::vector<char>& binary) const;
|
||||
|
||||
struct Impl; friend struct Impl;
|
||||
inline Impl* getImpl() const { return (Impl*)p; }
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* p;
|
||||
public:
|
||||
#ifndef OPENCV_REMOVE_DEPRECATED_API
|
||||
// TODO Remove this
|
||||
CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead
|
||||
CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary)
|
||||
CV_DEPRECATED const ProgramSource& source() const; // implementation removed
|
||||
CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced
|
||||
CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class CV_EXPORTS ProgramSource
|
||||
{
|
||||
public:
|
||||
typedef uint64 hash_t;
|
||||
typedef uint64 hash_t; // deprecated
|
||||
|
||||
ProgramSource();
|
||||
explicit ProgramSource(const String& prog);
|
||||
explicit ProgramSource(const char* prog);
|
||||
explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash);
|
||||
explicit ProgramSource(const String& prog); // deprecated
|
||||
explicit ProgramSource(const char* prog); // deprecated
|
||||
~ProgramSource();
|
||||
ProgramSource(const ProgramSource& prog);
|
||||
ProgramSource& operator = (const ProgramSource& prog);
|
||||
|
||||
const String& source() const;
|
||||
hash_t hash() const;
|
||||
const String& source() const; // deprecated
|
||||
hash_t hash() const; // deprecated
|
||||
|
||||
|
||||
/** @brief Describe OpenCL program binary.
|
||||
* Do not call clCreateProgramWithBinary() and/or clBuildProgram().
|
||||
*
|
||||
* Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies).
|
||||
*
|
||||
* This kind of binary is not portable between platforms in general - it is specific to OpenCL vendor / device / driver version.
|
||||
*
|
||||
* @param module name of program owner module
|
||||
* @param name unique name of program (module+name is used as key for OpenCL program caching)
|
||||
* @param binary buffer address. See buffer lifetime requirement in description.
|
||||
* @param size buffer size
|
||||
* @param buildOptions additional program-related build options passed to clBuildProgram()
|
||||
* @return created ProgramSource object
|
||||
*/
|
||||
static ProgramSource fromBinary(const String& module, const String& name,
|
||||
const unsigned char* binary, const size_t size,
|
||||
const cv::String& buildOptions = cv::String());
|
||||
|
||||
/** @brief Describe OpenCL program in SPIR format.
|
||||
* Do not call clCreateProgramWithBinary() and/or clBuildProgram().
|
||||
*
|
||||
* Supports SPIR 1.2 by default (pass '-spir-std=X.Y' in buildOptions to override this behavior)
|
||||
*
|
||||
* Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies).
|
||||
*
|
||||
* Programs in this format are portable between OpenCL implementations with 'khr_spir' extension:
|
||||
* https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/cl_khr_spir.html
|
||||
* (but they are not portable between different platforms: 32-bit / 64-bit)
|
||||
*
|
||||
* Note: these programs can't support vendor specific extensions, like 'cl_intel_subgroups'.
|
||||
*
|
||||
* @param module name of program owner module
|
||||
* @param name unique name of program (module+name is used as key for OpenCL program caching)
|
||||
* @param binary buffer address. See buffer lifetime requirement in description.
|
||||
* @param size buffer size
|
||||
* @param buildOptions additional program-related build options passed to clBuildProgram()
|
||||
* (these options are added automatically: '-x spir' and '-spir-std=1.2')
|
||||
* @return created ProgramSource object.
|
||||
*/
|
||||
static ProgramSource fromSPIR(const String& module, const String& name,
|
||||
const unsigned char* binary, const size_t size,
|
||||
const cv::String& buildOptions = cv::String());
|
||||
|
||||
//OpenCL 2.1+ only
|
||||
//static Program fromSPIRV(const String& module, const String& name,
|
||||
// const unsigned char* binary, const size_t size,
|
||||
// const cv::String& buildOptions = cv::String());
|
||||
|
||||
struct Impl; friend struct Impl;
|
||||
inline Impl* getImpl() const { return (Impl*)p; }
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* p;
|
||||
};
|
||||
|
||||
|
|
@ -658,6 +732,7 @@ CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf)
|
|||
CV_EXPORTS const char* typeToStr(int t);
|
||||
CV_EXPORTS const char* memopTypeToStr(int t);
|
||||
CV_EXPORTS const char* vecopTypeToStr(int t);
|
||||
CV_EXPORTS const char* getOpenCLErrorString(int errorCode);
|
||||
CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL);
|
||||
CV_EXPORTS void getPlatfomsInfo(std::vector<PlatformInfo>& platform_info);
|
||||
|
||||
|
|
@ -697,22 +772,25 @@ class CV_EXPORTS Image2D
|
|||
public:
|
||||
Image2D();
|
||||
|
||||
// src: The UMat from which to get image properties and data
|
||||
// norm: Flag to enable the use of normalized channel data types
|
||||
// alias: Flag indicating that the image should alias the src UMat.
|
||||
// If true, changes to the image or src will be reflected in
|
||||
// both objects.
|
||||
/**
|
||||
@param src UMat object from which to get image properties and data
|
||||
@param norm flag to enable the use of normalized channel data types
|
||||
@param alias flag indicating that the image should alias the src UMat. If true, changes to the
|
||||
image or src will be reflected in both objects.
|
||||
*/
|
||||
explicit Image2D(const UMat &src, bool norm = false, bool alias = false);
|
||||
Image2D(const Image2D & i);
|
||||
~Image2D();
|
||||
|
||||
Image2D & operator = (const Image2D & i);
|
||||
|
||||
// Indicates if creating an aliased image should succeed. Depends on the
|
||||
// underlying platform and the dimensions of the UMat.
|
||||
/** Indicates if creating an aliased image should succeed.
|
||||
Depends on the underlying platform and the dimensions of the UMat.
|
||||
*/
|
||||
static bool canCreateAlias(const UMat &u);
|
||||
|
||||
// Indicates if the image format is supported.
|
||||
/** Indicates if the image format is supported.
|
||||
*/
|
||||
static bool isFormatSupported(int depth, int cn, bool norm);
|
||||
|
||||
void* ptr() const;
|
||||
|
|
@ -721,6 +799,24 @@ protected:
|
|||
Impl* p;
|
||||
};
|
||||
|
||||
class CV_EXPORTS Timer
|
||||
{
|
||||
public:
|
||||
Timer(const Queue& q);
|
||||
~Timer();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
uint64 durationNS() const; //< duration in nanoseconds
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* const p;
|
||||
|
||||
private:
|
||||
Timer(const Timer&); // disabled
|
||||
Timer& operator=(const Timer&); // disabled
|
||||
};
|
||||
|
||||
CV_EXPORTS MatAllocator* getOpenCLAllocator();
|
||||
|
||||
|
|
@ -728,6 +824,9 @@ CV_EXPORTS MatAllocator* getOpenCLAllocator();
|
|||
#ifdef __OPENCV_BUILD
|
||||
namespace internal {
|
||||
|
||||
CV_EXPORTS bool isOpenCLForced();
|
||||
#define OCL_FORCE_CHECK(condition) (cv::ocl::internal::isOpenCLForced() || (condition))
|
||||
|
||||
CV_EXPORTS bool isPerformanceCheckBypassed();
|
||||
#define OCL_PERFORMANCE_CHECK(condition) (cv::ocl::internal::isPerformanceCheckBypassed() || (condition))
|
||||
|
||||
|
|
@ -39,26 +39,31 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OPENCL_GENBASE_HPP__
|
||||
#define __OPENCV_OPENCL_GENBASE_HPP__
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
#ifndef OPENCV_OPENCL_GENBASE_HPP
|
||||
#define OPENCV_OPENCL_GENBASE_HPP
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
struct ProgramEntry
|
||||
namespace cv {
|
||||
namespace ocl {
|
||||
|
||||
class ProgramSource;
|
||||
|
||||
namespace internal {
|
||||
|
||||
struct CV_EXPORTS ProgramEntry
|
||||
{
|
||||
const char* module;
|
||||
const char* name;
|
||||
const char* programStr;
|
||||
const char* programCode;
|
||||
const char* programHash;
|
||||
ProgramSource* pProgramSource;
|
||||
|
||||
operator ProgramSource& () const;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_OPENGL_HPP__
|
||||
#define __OPENCV_CORE_OPENGL_HPP__
|
||||
#ifndef OPENCV_CORE_OPENGL_HPP
|
||||
#define OPENCV_CORE_OPENGL_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error opengl.hpp header must be compiled as C++
|
||||
|
|
@ -726,4 +726,4 @@ bool cv::ogl::Arrays::empty() const
|
|||
|
||||
//! @endcond
|
||||
|
||||
#endif /* __OPENCV_CORE_OPENGL_HPP__ */
|
||||
#endif /* OPENCV_CORE_OPENGL_HPP */
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_OPERATIONS_HPP__
|
||||
#define __OPENCV_CORE_OPERATIONS_HPP__
|
||||
#ifndef OPENCV_CORE_OPERATIONS_HPP
|
||||
#define OPENCV_CORE_OPERATIONS_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error operations.hpp header must be compiled as C++
|
||||
|
|
@ -82,7 +82,7 @@ template<typename _Tp> struct Matx_FastInvOp<_Tp, 2>
|
|||
{
|
||||
bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int) const
|
||||
{
|
||||
_Tp d = determinant(a);
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if( d == 0 )
|
||||
return false;
|
||||
d = 1/d;
|
||||
|
|
@ -137,7 +137,7 @@ template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 1>
|
|||
bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b,
|
||||
Matx<_Tp, 2, 1>& x, int) const
|
||||
{
|
||||
_Tp d = determinant(a);
|
||||
_Tp d = (_Tp)determinant(a);
|
||||
if( d == 0 )
|
||||
return false;
|
||||
d = 1/d;
|
||||
|
|
@ -349,6 +349,8 @@ inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next(
|
|||
inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
|
||||
inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
|
||||
|
||||
inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
|
||||
|
||||
inline unsigned RNG::next()
|
||||
{
|
||||
state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OPTIM_HPP__
|
||||
#define __OPENCV_OPTIM_HPP__
|
||||
#ifndef OPENCV_OPTIM_HPP
|
||||
#define OPENCV_OPTIM_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public:
|
|||
/** @brief Getter for the optimized function.
|
||||
|
||||
The optimized function is represented by Function interface, which requires derivatives to
|
||||
implement the sole method calc(double*) to evaluate the function.
|
||||
implement the calc(double*) and getDim() methods to evaluate the function.
|
||||
|
||||
@return Smart-pointer to an object that implements Function interface - it represents the
|
||||
function that is being optimized. It can be empty, if no function was given so far.
|
||||
28
lib/3rdParty/OpenCV3.4/include/opencv2/core/ovx.hpp
vendored
Normal file
28
lib/3rdParty/OpenCV3.4/include/opencv2/core/ovx.hpp
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// 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.
|
||||
|
||||
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
// OpenVX related definitions and declarations
|
||||
|
||||
#pragma once
|
||||
#ifndef OPENCV_OVX_HPP
|
||||
#define OPENCV_OVX_HPP
|
||||
|
||||
#include "cvdef.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
/// Check if use of OpenVX is possible
|
||||
CV_EXPORTS_W bool haveOpenVX();
|
||||
|
||||
/// Check if use of OpenVX is enabled
|
||||
CV_EXPORTS_W bool useOpenVX();
|
||||
|
||||
/// Enable/disable use of OpenVX
|
||||
CV_EXPORTS_W void setUseOpenVX(bool flag);
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_OVX_HPP
|
||||
|
|
@ -41,8 +41,13 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_PERSISTENCE_HPP__
|
||||
#define __OPENCV_CORE_PERSISTENCE_HPP__
|
||||
#ifndef OPENCV_CORE_PERSISTENCE_HPP
|
||||
#define OPENCV_CORE_PERSISTENCE_HPP
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
/// Define to support persistence legacy formats
|
||||
#define CV__LEGACY_PERSISTENCE
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error persistence.hpp header must be compiled as C++
|
||||
|
|
@ -57,8 +62,9 @@ Several functions that are described below take CvFileStorage\* as inputs and al
|
|||
save or to load hierarchical collections that consist of scalar values, standard CXCore objects
|
||||
(such as matrices, sequences, graphs), and user-defined objects.
|
||||
|
||||
OpenCV can read and write data in XML (<http://www.w3c.org/XML>) or YAML (<http://www.yaml.org>)
|
||||
formats. Below is an example of 3x3 floating-point identity matrix A, stored in XML and YAML files
|
||||
OpenCV can read and write data in XML (<http://www.w3c.org/XML>), YAML (<http://www.yaml.org>) or
|
||||
JSON (<http://www.json.org/>) formats. Below is an example of 3x3 floating-point identity matrix A,
|
||||
stored in XML and YAML files
|
||||
using CXCore functions:
|
||||
XML:
|
||||
@code{.xml}
|
||||
|
|
@ -85,10 +91,13 @@ As it can be seen from the examples, XML uses nested tags to represent hierarchy
|
|||
indentation for that purpose (similar to the Python programming language).
|
||||
|
||||
The same functions can read and write data in both formats; the particular format is determined by
|
||||
the extension of the opened file, ".xml" for XML files and ".yml" or ".yaml" for YAML.
|
||||
the extension of the opened file, ".xml" for XML files, ".yml" or ".yaml" for YAML and ".json" for
|
||||
JSON.
|
||||
*/
|
||||
typedef struct CvFileStorage CvFileStorage;
|
||||
typedef struct CvFileNode CvFileNode;
|
||||
typedef struct CvMat CvMat;
|
||||
typedef struct CvMatND CvMatND;
|
||||
|
||||
//! @} core_c
|
||||
|
||||
|
|
@ -99,20 +108,20 @@ namespace cv {
|
|||
|
||||
/** @addtogroup core_xml
|
||||
|
||||
XML/YAML file storages. {#xml_storage}
|
||||
XML/YAML/JSON file storages. {#xml_storage}
|
||||
=======================
|
||||
Writing to a file storage.
|
||||
--------------------------
|
||||
You can store and then restore various OpenCV data structures to/from XML (<http://www.w3c.org/XML>)
|
||||
or YAML (<http://www.yaml.org>) formats. Also, it is possible store and load arbitrarily complex
|
||||
data structures, which include OpenCV data structures, as well as primitive data types (integer and
|
||||
floating-point numbers and text strings) as their elements.
|
||||
You can store and then restore various OpenCV data structures to/from XML (<http://www.w3c.org/XML>),
|
||||
YAML (<http://www.yaml.org>) or JSON (<http://www.json.org/>) formats. Also, it is possible to store
|
||||
and load arbitrarily complex data structures, which include OpenCV data structures, as well as
|
||||
primitive data types (integer and floating-point numbers and text strings) as their elements.
|
||||
|
||||
Use the following procedure to write something to XML or YAML:
|
||||
Use the following procedure to write something to XML, YAML or JSON:
|
||||
-# Create new FileStorage and open it for writing. It can be done with a single call to
|
||||
FileStorage::FileStorage constructor that takes a filename, or you can use the default constructor
|
||||
and then call FileStorage::open. Format of the file (XML or YAML) is determined from the filename
|
||||
extension (".xml" and ".yml"/".yaml", respectively)
|
||||
and then call FileStorage::open. Format of the file (XML, YAML or JSON) is determined from the filename
|
||||
extension (".xml", ".yml"/".yaml" and ".json", respectively)
|
||||
-# Write all the data you want using the streaming operator `<<`, just like in the case of STL
|
||||
streams.
|
||||
-# Close the file using FileStorage::release. FileStorage destructor also closes the file.
|
||||
|
|
@ -151,7 +160,7 @@ Here is an example:
|
|||
return 0;
|
||||
}
|
||||
@endcode
|
||||
The sample above stores to XML and integer, text string (calibration date), 2 matrices, and a custom
|
||||
The sample above stores to YML an integer, a text string (calibration date), 2 matrices, and a custom
|
||||
structure "feature", which includes feature coordinates and LBP (local binary pattern) value. Here
|
||||
is output of the sample:
|
||||
@code{.yaml}
|
||||
|
|
@ -175,19 +184,19 @@ features:
|
|||
- { x:344, y:158, lbp:[ 1, 1, 0, 0, 0, 0, 1, 0 ] }
|
||||
@endcode
|
||||
|
||||
As an exercise, you can replace ".yml" with ".xml" in the sample above and see, how the
|
||||
As an exercise, you can replace ".yml" with ".xml" or ".json" in the sample above and see, how the
|
||||
corresponding XML file will look like.
|
||||
|
||||
Several things can be noted by looking at the sample code and the output:
|
||||
|
||||
- The produced YAML (and XML) consists of heterogeneous collections that can be nested. There are 2
|
||||
types of collections: named collections (mappings) and unnamed collections (sequences). In mappings
|
||||
- The produced YAML (and XML/JSON) consists of heterogeneous collections that can be nested. There are
|
||||
2 types of collections: named collections (mappings) and unnamed collections (sequences). In mappings
|
||||
each element has a name and is accessed by name. This is similar to structures and std::map in
|
||||
C/C++ and dictionaries in Python. In sequences elements do not have names, they are accessed by
|
||||
indices. This is similar to arrays and std::vector in C/C++ and lists, tuples in Python.
|
||||
"Heterogeneous" means that elements of each single collection can have different types.
|
||||
|
||||
Top-level collection in YAML/XML is a mapping. Each matrix is stored as a mapping, and the matrix
|
||||
Top-level collection in YAML/XML/JSON is a mapping. Each matrix is stored as a mapping, and the matrix
|
||||
elements are stored as a sequence. Then, there is a sequence of features, where each feature is
|
||||
represented a mapping, and lbp value in a nested sequence.
|
||||
|
||||
|
|
@ -203,7 +212,7 @@ Several things can be noted by looking at the sample code and the output:
|
|||
- To write a sequence, you first write the special string `[`, then write the elements, then
|
||||
write the closing `]`.
|
||||
|
||||
- In YAML (but not XML), mappings and sequences can be written in a compact Python-like inline
|
||||
- In YAML/JSON (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
|
||||
|
|
@ -211,7 +220,7 @@ Several things can be noted by looking at the sample code and the output:
|
|||
|
||||
Reading data from a file storage.
|
||||
---------------------------------
|
||||
To read the previously written XML or YAML file, do the following:
|
||||
To read the previously written XML, YAML or JSON file, do the following:
|
||||
-# Open the file storage using FileStorage::FileStorage constructor or FileStorage::open method.
|
||||
In the current implementation the whole file is parsed and the whole representation of file
|
||||
storage is built in memory as a hierarchy of file nodes (see FileNode)
|
||||
|
|
@ -292,8 +301,8 @@ A complete example using the FileStorage interface
|
|||
class CV_EXPORTS FileNode;
|
||||
class CV_EXPORTS FileNodeIterator;
|
||||
|
||||
/** @brief XML/YAML file storage class that encapsulates all the information necessary for writing or reading
|
||||
data to/from a file.
|
||||
/** @brief XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or
|
||||
reading data to/from a file.
|
||||
*/
|
||||
class CV_EXPORTS_W FileStorage
|
||||
{
|
||||
|
|
@ -309,7 +318,11 @@ public:
|
|||
FORMAT_MASK = (7<<3), //!< mask for format flags
|
||||
FORMAT_AUTO = 0, //!< flag, auto format
|
||||
FORMAT_XML = (1<<3), //!< flag, XML format
|
||||
FORMAT_YAML = (2<<3) //!< flag, YAML format
|
||||
FORMAT_YAML = (2<<3), //!< flag, YAML format
|
||||
FORMAT_JSON = (3<<3), //!< flag, JSON format
|
||||
|
||||
BASE64 = 64, //!< flag, write rawdata in Base64 by default. (consider using WRITE_BASE64)
|
||||
WRITE_BASE64 = BASE64 | WRITE, //!< flag, enable both WRITE and BASE64
|
||||
};
|
||||
enum
|
||||
{
|
||||
|
|
@ -327,16 +340,9 @@ public:
|
|||
CV_WRAP FileStorage();
|
||||
|
||||
/** @overload
|
||||
@param source Name of the file to open or the text string to read the data from. Extension of the
|
||||
file (.xml or .yml/.yaml) determines its format (XML or YAML respectively). Also you can append .gz
|
||||
to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and
|
||||
FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g.
|
||||
mydata.xml, .yml etc.).
|
||||
@param flags Mode of operation. See FileStorage::Mode
|
||||
@param encoding Encoding of the file. Note that UTF-16 XML encoding is not supported currently and
|
||||
you should use 8-bit encoding instead of it.
|
||||
@copydoc open()
|
||||
*/
|
||||
CV_WRAP FileStorage(const String& source, int flags, const String& encoding=String());
|
||||
CV_WRAP FileStorage(const String& filename, int flags, const String& encoding=String());
|
||||
|
||||
/** @overload */
|
||||
FileStorage(CvFileStorage* fs, bool owning=true);
|
||||
|
|
@ -349,10 +355,12 @@ public:
|
|||
See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release
|
||||
before opening the file.
|
||||
@param filename Name of the file to open or the text string to read the data from.
|
||||
Extension of the file (.xml or .yml/.yaml) determines its format (XML or YAML respectively).
|
||||
Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both
|
||||
Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON
|
||||
respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both
|
||||
FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify
|
||||
the output file format (e.g. mydata.xml, .yml etc.).
|
||||
the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters.
|
||||
You can use this format, "*?base64" (e.g. "file.json?base64" (case sensitive)), as an alternative to
|
||||
FileStorage::BASE64 flag.
|
||||
@param flags Mode of operation. One of FileStorage::Mode
|
||||
@param encoding Encoding of the file. Note that UTF-16 XML encoding is not supported currently and
|
||||
you should use 8-bit encoding instead of it.
|
||||
|
|
@ -398,7 +406,7 @@ public:
|
|||
FileNode operator[](const String& nodename) const;
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||
CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const;
|
||||
|
||||
/** @brief Returns the obsolete C FileStorage structure.
|
||||
@returns Pointer to the underlying C FileStorage structure
|
||||
|
|
@ -425,12 +433,38 @@ public:
|
|||
*/
|
||||
void writeObj( const String& name, const void* obj );
|
||||
|
||||
/**
|
||||
* @brief Simplified writing API to use with bindings.
|
||||
* @param name Name of the written object
|
||||
* @param val Value of the written object
|
||||
*/
|
||||
CV_WRAP void write(const String& name, double val);
|
||||
/// @overload
|
||||
CV_WRAP void write(const String& name, const String& val);
|
||||
/// @overload
|
||||
CV_WRAP void write(const String& name, InputArray val);
|
||||
|
||||
/** @brief Writes a comment.
|
||||
|
||||
The function writes a comment into file storage. The comments are skipped when the storage is read.
|
||||
@param comment The written comment, single-line or multi-line
|
||||
@param append If true, the function tries to put the comment at the end of current line.
|
||||
Else if the comment is multi-line, or if it does not fit at the end of the current
|
||||
line, the comment starts a new line.
|
||||
*/
|
||||
CV_WRAP void writeComment(const String& comment, bool append = false);
|
||||
|
||||
/** @brief Returns the normalized object name for the specified name of a file.
|
||||
@param filename Name of a file
|
||||
@returns The normalized object name.
|
||||
*/
|
||||
static String getDefaultObjectName(const String& filename);
|
||||
|
||||
/** @brief Returns the current format.
|
||||
* @returns The current format, see FileStorage::Mode
|
||||
*/
|
||||
CV_WRAP int getFormat() const;
|
||||
|
||||
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
|
||||
String elname; //!< the currently written element
|
||||
std::vector<char> structs; //!< the stack of written structures
|
||||
|
|
@ -443,7 +477,7 @@ template<> CV_EXPORTS void DefaultDeleter<CvFileStorage>::operator ()(CvFileStor
|
|||
|
||||
The node is used to store each and every element of the file storage opened for reading. When
|
||||
XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of
|
||||
nodes. Each node can be a “leaf” that is contain a single number or a string, or be a collection of
|
||||
nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of
|
||||
other nodes. There can be named collections (mappings) where each element has a name and it is
|
||||
accessed by a name, and ordered collections (sequences) where elements do not have names but rather
|
||||
accessed by index. Type of the file node can be determined using FileNode::type method.
|
||||
|
|
@ -499,12 +533,12 @@ public:
|
|||
/** @overload
|
||||
@param nodename Name of an element in the mapping node.
|
||||
*/
|
||||
CV_WRAP FileNode operator[](const char* nodename) const;
|
||||
CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const;
|
||||
|
||||
/** @overload
|
||||
@param i Index of an element in the sequence node.
|
||||
*/
|
||||
CV_WRAP FileNode operator[](int i) const;
|
||||
CV_WRAP_AS(at) FileNode operator[](int i) const;
|
||||
|
||||
/** @brief Returns type of the node.
|
||||
@returns Type of the node. See FileNode::Type
|
||||
|
|
@ -539,9 +573,7 @@ public:
|
|||
operator double() const;
|
||||
//! returns the node content as text string
|
||||
operator String() const;
|
||||
#ifndef OPENCV_NOSTL
|
||||
operator std::string() const;
|
||||
#endif
|
||||
|
||||
//! returns pointer to the underlying file node
|
||||
CvFileNode* operator *();
|
||||
|
|
@ -566,6 +598,13 @@ public:
|
|||
//! reads the registered object and returns pointer to it
|
||||
void* readObj() const;
|
||||
|
||||
//! Simplified reading API to use with bindings.
|
||||
CV_WRAP double real() const;
|
||||
//! Simplified reading API to use with bindings.
|
||||
CV_WRAP String string() const;
|
||||
//! Simplified reading API to use with bindings.
|
||||
CV_WRAP Mat mat() const;
|
||||
|
||||
// do not use wrapper pointer classes for better efficiency
|
||||
const CvFileStorage* fs;
|
||||
const CvFileNode* node;
|
||||
|
|
@ -659,8 +698,10 @@ CV_EXPORTS void write( FileStorage& fs, const String& name, double value );
|
|||
CV_EXPORTS void write( FileStorage& fs, const String& name, const String& value );
|
||||
CV_EXPORTS void write( FileStorage& fs, const String& name, const Mat& value );
|
||||
CV_EXPORTS void write( FileStorage& fs, const String& name, const SparseMat& value );
|
||||
#ifdef CV__LEGACY_PERSISTENCE
|
||||
CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector<KeyPoint>& value);
|
||||
CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector<DMatch>& value);
|
||||
#endif
|
||||
|
||||
CV_EXPORTS void writeScalar( FileStorage& fs, int value );
|
||||
CV_EXPORTS void writeScalar( FileStorage& fs, float value );
|
||||
|
|
@ -676,10 +717,15 @@ CV_EXPORTS void read(const FileNode& node, int& value, int default_value);
|
|||
CV_EXPORTS void read(const FileNode& node, float& value, float default_value);
|
||||
CV_EXPORTS void read(const FileNode& node, double& value, double default_value);
|
||||
CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value);
|
||||
CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value);
|
||||
CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() );
|
||||
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() );
|
||||
#ifdef CV__LEGACY_PERSISTENCE
|
||||
CV_EXPORTS void read(const FileNode& node, std::vector<KeyPoint>& keypoints);
|
||||
CV_EXPORTS void read(const FileNode& node, std::vector<DMatch>& matches);
|
||||
#endif
|
||||
CV_EXPORTS void read(const FileNode& node, KeyPoint& value, const KeyPoint& default_value);
|
||||
CV_EXPORTS void read(const FileNode& node, DMatch& value, const DMatch& default_value);
|
||||
|
||||
template<typename _Tp> static inline void read(const FileNode& node, Point_<_Tp>& value, const Point_<_Tp>& default_value)
|
||||
{
|
||||
|
|
@ -773,7 +819,7 @@ namespace internal
|
|||
VecWriterProxy( FileStorage* _fs ) : fs(_fs) {}
|
||||
void operator()(const std::vector<_Tp>& vec) const
|
||||
{
|
||||
int _fmt = DataType<_Tp>::fmt;
|
||||
int _fmt = traits::SafeFmt<_Tp>::fmt;
|
||||
char fmt[] = { (char)((_fmt >> 8) + '1'), (char)_fmt, '\0' };
|
||||
fs->writeRaw(fmt, !vec.empty() ? (uchar*)&vec[0] : 0, vec.size() * sizeof(_Tp));
|
||||
}
|
||||
|
|
@ -804,8 +850,10 @@ namespace internal
|
|||
{
|
||||
size_t remaining = it->remaining;
|
||||
size_t cn = DataType<_Tp>::channels;
|
||||
int _fmt = DataType<_Tp>::fmt;
|
||||
int _fmt = traits::SafeFmt<_Tp>::fmt;
|
||||
CV_Assert((_fmt >> 8) < 9);
|
||||
char fmt[] = { (char)((_fmt >> 8)+'1'), (char)_fmt, '\0' };
|
||||
CV_Assert((remaining % cn) == 0);
|
||||
size_t remaining1 = remaining / cn;
|
||||
count = count < remaining1 ? count : remaining1;
|
||||
vec.resize(count);
|
||||
|
|
@ -916,11 +964,10 @@ void write(FileStorage& fs, const Range& r )
|
|||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const std::vector<_Tp>& vec )
|
||||
{
|
||||
cv::internal::VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
|
||||
cv::internal::VecWriterProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> w(&fs);
|
||||
w(vec);
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Point_<_Tp>& pt )
|
||||
{
|
||||
|
|
@ -977,13 +1024,65 @@ void write(FileStorage& fs, const String& name, const Range& r )
|
|||
write(fs, r);
|
||||
}
|
||||
|
||||
static inline
|
||||
void write(FileStorage& fs, const String& name, const KeyPoint& kpt)
|
||||
{
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, kpt.pt.x);
|
||||
write(fs, kpt.pt.y);
|
||||
write(fs, kpt.size);
|
||||
write(fs, kpt.angle);
|
||||
write(fs, kpt.response);
|
||||
write(fs, kpt.octave);
|
||||
write(fs, kpt.class_id);
|
||||
}
|
||||
|
||||
static inline
|
||||
void write(FileStorage& fs, const String& name, const DMatch& m)
|
||||
{
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, m.queryIdx);
|
||||
write(fs, m.trainIdx);
|
||||
write(fs, m.imgIdx);
|
||||
write(fs, m.distance);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
|
||||
{
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+(DataType<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||
write(fs, vec);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const String& name, const std::vector< std::vector<_Tp> >& vec )
|
||||
{
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ);
|
||||
for(size_t i = 0; i < vec.size(); i++)
|
||||
{
|
||||
cv::internal::WriteStructContext ws_(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||
write(fs, vec[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CV__LEGACY_PERSISTENCE
|
||||
// This code is not needed anymore, but it is preserved here to keep source compatibility
|
||||
// Implementation is similar to templates instantiations
|
||||
static inline void write(FileStorage& fs, const KeyPoint& kpt) { write(fs, String(), kpt); }
|
||||
static inline void write(FileStorage& fs, const DMatch& m) { write(fs, String(), m); }
|
||||
static inline void write(FileStorage& fs, const std::vector<KeyPoint>& vec)
|
||||
{
|
||||
cv::internal::VecWriterProxy<KeyPoint, 0> w(&fs);
|
||||
w(vec);
|
||||
}
|
||||
static inline void write(FileStorage& fs, const std::vector<DMatch>& vec)
|
||||
{
|
||||
cv::internal::VecWriterProxy<DMatch, 0> w(&fs);
|
||||
w(vec);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//! @} FileStorage
|
||||
|
||||
//! @relates cv::FileNode
|
||||
|
|
@ -1032,7 +1131,7 @@ void read(const FileNode& node, short& value, short default_value)
|
|||
template<typename _Tp> static inline
|
||||
void read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount = (size_t)INT_MAX )
|
||||
{
|
||||
cv::internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it);
|
||||
r(vec, maxCount);
|
||||
}
|
||||
|
||||
|
|
@ -1048,6 +1147,24 @@ void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>&
|
|||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void read( const FileNode& node, std::vector<KeyPoint>& vec, const std::vector<KeyPoint>& default_value )
|
||||
{
|
||||
if(!node.node)
|
||||
vec = default_value;
|
||||
else
|
||||
read(node, vec);
|
||||
}
|
||||
|
||||
static inline
|
||||
void read( const FileNode& node, std::vector<DMatch>& vec, const std::vector<DMatch>& default_value )
|
||||
{
|
||||
if(!node.node)
|
||||
vec = default_value;
|
||||
else
|
||||
read(node, vec);
|
||||
}
|
||||
|
||||
//! @} FileNode
|
||||
|
||||
//! @relates cv::FileStorage
|
||||
|
|
@ -1103,7 +1220,7 @@ FileNodeIterator& operator >> (FileNodeIterator& it, _Tp& value)
|
|||
template<typename _Tp> static inline
|
||||
FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec)
|
||||
{
|
||||
cv::internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it);
|
||||
r(vec, (size_t)INT_MAX);
|
||||
return it;
|
||||
}
|
||||
|
|
@ -1130,6 +1247,39 @@ void operator >> (const FileNode& n, std::vector<_Tp>& vec)
|
|||
it >> vec;
|
||||
}
|
||||
|
||||
/** @brief Reads KeyPoint from a file storage.
|
||||
*/
|
||||
//It needs special handling because it contains two types of fields, int & float.
|
||||
static inline
|
||||
void operator >> (const FileNode& n, KeyPoint& kpt)
|
||||
{
|
||||
FileNodeIterator it = n.begin();
|
||||
it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id;
|
||||
}
|
||||
|
||||
#ifdef CV__LEGACY_PERSISTENCE
|
||||
static inline
|
||||
void operator >> (const FileNode& n, std::vector<KeyPoint>& vec)
|
||||
{
|
||||
read(n, vec);
|
||||
}
|
||||
static inline
|
||||
void operator >> (const FileNode& n, std::vector<DMatch>& vec)
|
||||
{
|
||||
read(n, vec);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @brief Reads DMatch from a file storage.
|
||||
*/
|
||||
//It needs special handling because it contains two types of fields, int & float.
|
||||
static inline
|
||||
void operator >> (const FileNode& n, DMatch& m)
|
||||
{
|
||||
FileNodeIterator it = n.begin();
|
||||
it >> m.queryIdx >> m.trainIdx >> m.imgIdx >> m.distance;
|
||||
}
|
||||
|
||||
//! @} FileNode
|
||||
|
||||
//! @relates cv::FileNodeIterator
|
||||
|
|
@ -1181,6 +1331,9 @@ inline FileNode::operator int() const { int value; read(*this, value, 0);
|
|||
inline FileNode::operator float() const { float value; read(*this, value, 0.f); return value; }
|
||||
inline FileNode::operator double() const { double value; read(*this, value, 0.); return value; }
|
||||
inline FileNode::operator String() const { String value; read(*this, value, value); return value; }
|
||||
inline double FileNode::real() const { return double(*this); }
|
||||
inline String FileNode::string() const { return String(*this); }
|
||||
inline Mat FileNode::mat() const { Mat value; read(*this, value, value); return value; }
|
||||
inline FileNodeIterator FileNode::begin() const { return FileNodeIterator(fs, node); }
|
||||
inline FileNodeIterator FileNode::end() const { return FileNodeIterator(fs, node, size()); }
|
||||
inline void FileNode::readRaw( const String& fmt, uchar* vec, size_t len ) const { begin().readRaw( fmt, vec, len ); }
|
||||
|
|
@ -1190,6 +1343,17 @@ inline String::String(const FileNode& fn): cstr_(0), len_(0) { read(fn, *this, *
|
|||
|
||||
//! @endcond
|
||||
|
||||
|
||||
CV_EXPORTS void cvStartWriteRawData_Base64(::CvFileStorage * fs, const char* name, int len, const char* dt);
|
||||
|
||||
CV_EXPORTS void cvWriteRawData_Base64(::CvFileStorage * fs, const void* _data, int len);
|
||||
|
||||
CV_EXPORTS void cvEndWriteRawData_Base64(::CvFileStorage * fs);
|
||||
|
||||
CV_EXPORTS void cvWriteMat_Base64(::CvFileStorage* fs, const char* name, const ::CvMat* mat);
|
||||
|
||||
CV_EXPORTS void cvWriteMatND_Base64(::CvFileStorage* fs, const char* name, const ::CvMatND* mat);
|
||||
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_PERSISTENCE_HPP__
|
||||
#endif // OPENCV_CORE_PERSISTENCE_HPP
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_PTR_INL_HPP__
|
||||
#define __OPENCV_CORE_PTR_INL_HPP__
|
||||
#ifndef OPENCV_CORE_PTR_INL_HPP
|
||||
#define OPENCV_CORE_PTR_INL_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -264,6 +264,9 @@ Ptr<T>::Ptr(Ptr&& o) : owner(o.owner), stored(o.stored)
|
|||
template<typename T>
|
||||
Ptr<T>& Ptr<T>::operator = (Ptr<T>&& o)
|
||||
{
|
||||
if (this == &o)
|
||||
return *this;
|
||||
|
||||
release();
|
||||
owner = o.owner;
|
||||
stored = o.stored;
|
||||
|
|
@ -358,8 +361,19 @@ Ptr<T> makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5&
|
|||
return Ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
}
|
||||
|
||||
template<typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
Ptr<T> makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10, const A11& a11)
|
||||
{
|
||||
return Ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11));
|
||||
}
|
||||
|
||||
template<typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
Ptr<T> makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10, const A11& a11, const A12& a12)
|
||||
{
|
||||
return Ptr<T>(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12));
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_PTR_INL_HPP__
|
||||
#endif // OPENCV_CORE_PTR_INL_HPP
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_SATURATE_HPP__
|
||||
#define __OPENCV_CORE_SATURATE_HPP__
|
||||
#ifndef OPENCV_CORE_SATURATE_HPP
|
||||
#define OPENCV_CORE_SATURATE_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/fast_math.hpp"
|
||||
|
|
@ -58,8 +58,8 @@ namespace cv
|
|||
|
||||
/** @brief Template function for accurate conversion from one primitive type to another.
|
||||
|
||||
The functions saturate_cast resemble the standard C++ cast operations, such as static_cast\<T\>()
|
||||
and others. They perform an efficient and accurate conversion from one primitive type to another
|
||||
The function saturate_cast resembles the standard C++ cast operations, such as static_cast\<T\>()
|
||||
and others. It perform an efficient and accurate conversion from one primitive type to another
|
||||
(see the introduction chapter). saturate in the name means that when the input value v is out of the
|
||||
range of the target type, the result is not formed just by taking low bits of the input, but instead
|
||||
the value is clipped. For example:
|
||||
|
|
@ -136,15 +136,30 @@ template<> inline short saturate_cast<short>(double v) { int iv = cvRound(
|
|||
template<> inline short saturate_cast<short>(int64 v) { return (short)((uint64)((int64)v - SHRT_MIN) <= (uint64)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); }
|
||||
template<> inline short saturate_cast<short>(uint64 v) { return (short)std::min(v, (uint64)SHRT_MAX); }
|
||||
|
||||
template<> inline int saturate_cast<int>(unsigned v) { return (int)std::min(v, (unsigned)INT_MAX); }
|
||||
template<> inline int saturate_cast<int>(int64 v) { return (int)((uint64)(v - INT_MIN) <= (uint64)UINT_MAX ? v : v > 0 ? INT_MAX : INT_MIN); }
|
||||
template<> inline int saturate_cast<int>(uint64 v) { return (int)std::min(v, (uint64)INT_MAX); }
|
||||
template<> inline int saturate_cast<int>(float v) { return cvRound(v); }
|
||||
template<> inline int saturate_cast<int>(double v) { return cvRound(v); }
|
||||
|
||||
template<> inline unsigned saturate_cast<unsigned>(schar v) { return (unsigned)std::max(v, (schar)0); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(short v) { return (unsigned)std::max(v, (short)0); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(int v) { return (unsigned)std::max(v, (int)0); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(int64 v) { return (unsigned)((uint64)v <= (uint64)UINT_MAX ? v : v > 0 ? UINT_MAX : 0); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(uint64 v) { return (unsigned)std::min(v, (uint64)UINT_MAX); }
|
||||
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v) { return cvRound(v); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v) { return static_cast<unsigned>(cvRound(v)); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return static_cast<unsigned>(cvRound(v)); }
|
||||
|
||||
template<> inline uint64 saturate_cast<uint64>(schar v) { return (uint64)std::max(v, (schar)0); }
|
||||
template<> inline uint64 saturate_cast<uint64>(short v) { return (uint64)std::max(v, (short)0); }
|
||||
template<> inline uint64 saturate_cast<uint64>(int v) { return (uint64)std::max(v, (int)0); }
|
||||
template<> inline uint64 saturate_cast<uint64>(int64 v) { return (uint64)std::max(v, (int64)0); }
|
||||
|
||||
template<> inline int64 saturate_cast<int64>(uint64 v) { return (int64)std::min(v, (uint64)LLONG_MAX); }
|
||||
|
||||
//! @}
|
||||
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_SATURATE_HPP__
|
||||
#endif // OPENCV_CORE_SATURATE_HPP
|
||||
526
lib/3rdParty/OpenCV3.4/include/opencv2/core/softfloat.hpp
vendored
Normal file
526
lib/3rdParty/OpenCV3.4/include/opencv2/core/softfloat.hpp
vendored
Normal file
|
|
@ -0,0 +1,526 @@
|
|||
// 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
|
||||
|
||||
// This file is based on files from package issued with the following license:
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#pragma once
|
||||
#ifndef softfloat_h
|
||||
#define softfloat_h 1
|
||||
|
||||
#include "cvdef.h"
|
||||
|
||||
// int32_t / uint32_t
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */
|
||||
namespace cv {
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
}
|
||||
#elif defined(_MSC_VER) || __cplusplus >= 201103L
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
/** @addtogroup core_utils_softfloat
|
||||
|
||||
[SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is a software implementation
|
||||
of floating-point calculations according to IEEE 754 standard.
|
||||
All calculations are done in integers, that's why they are machine-independent and bit-exact.
|
||||
This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc.
|
||||
OpenCV contains a subset of SoftFloat partially rewritten to C++.
|
||||
|
||||
### Types
|
||||
|
||||
There are two basic types: @ref softfloat and @ref softdouble.
|
||||
These types are binary compatible with float and double types respectively
|
||||
and support conversions to/from them.
|
||||
Other types from original SoftFloat library like fp16 or fp128 were thrown away
|
||||
as well as quiet/signaling NaN support, on-the-fly rounding mode switch
|
||||
and exception flags (though exceptions can be implemented in the future).
|
||||
|
||||
### Operations
|
||||
|
||||
Both types support the following:
|
||||
- Construction from signed and unsigned 32-bit and 64 integers,
|
||||
float/double or raw binary representation
|
||||
- Conversions betweeen each other, to float or double and to int
|
||||
using @ref cvRound, @ref cvTrunc, @ref cvFloor, @ref cvCeil or a bunch of
|
||||
saturate_cast functions
|
||||
- Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision
|
||||
- Comparison operations
|
||||
- Explicit sign, exponent and significand manipulation through get/set methods,
|
||||
number state indicators (isInf, isNan, isSubnormal)
|
||||
- Type-specific constants like eps, minimum/maximum value, best pi approximation, etc.
|
||||
- min(), max(), abs(), exp(), log() and pow() functions
|
||||
|
||||
*/
|
||||
//! @{
|
||||
|
||||
struct softfloat;
|
||||
struct softdouble;
|
||||
|
||||
struct CV_EXPORTS softfloat
|
||||
{
|
||||
public:
|
||||
/** @brief Default constructor */
|
||||
softfloat() { v = 0; }
|
||||
/** @brief Copy constructor */
|
||||
softfloat( const softfloat& c) { v = c.v; }
|
||||
/** @brief Assign constructor */
|
||||
softfloat& operator=( const softfloat& c )
|
||||
{
|
||||
if(&c != this) v = c.v;
|
||||
return *this;
|
||||
}
|
||||
/** @brief Construct from raw
|
||||
|
||||
Builds new value from raw binary representation
|
||||
*/
|
||||
static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; }
|
||||
|
||||
/** @brief Construct from integer */
|
||||
explicit softfloat( const uint32_t );
|
||||
explicit softfloat( const uint64_t );
|
||||
explicit softfloat( const int32_t );
|
||||
explicit softfloat( const int64_t );
|
||||
|
||||
#ifdef CV_INT32_T_IS_LONG_INT
|
||||
// for platforms with int32_t = long int
|
||||
explicit softfloat( const int a ) { *this = softfloat(static_cast<int32_t>(a)); }
|
||||
#endif
|
||||
|
||||
/** @brief Construct from float */
|
||||
explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
|
||||
|
||||
/** @brief Type casts */
|
||||
operator softdouble() const;
|
||||
operator float() const { Cv32suf s; s.u = v; return s.f; }
|
||||
|
||||
/** @brief Basic arithmetics */
|
||||
softfloat operator + (const softfloat&) const;
|
||||
softfloat operator - (const softfloat&) const;
|
||||
softfloat operator * (const softfloat&) const;
|
||||
softfloat operator / (const softfloat&) const;
|
||||
softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; }
|
||||
|
||||
/** @brief Remainder operator
|
||||
|
||||
A quote from original SoftFloat manual:
|
||||
|
||||
> The IEEE Standard remainder operation computes the value
|
||||
> a - n * b, where n is the integer closest to a / b.
|
||||
> If a / b is exactly halfway between two integers, n is the even integer
|
||||
> closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
|
||||
> Depending on the relative magnitudes of the operands, the remainder functions
|
||||
> can take considerably longer to execute than the other SoftFloat functions.
|
||||
> This is an inherent characteristic of the remainder operation itself and is not a flaw
|
||||
> in the SoftFloat implementation.
|
||||
*/
|
||||
softfloat operator % (const softfloat&) const;
|
||||
|
||||
softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; }
|
||||
softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; }
|
||||
softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; }
|
||||
softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; }
|
||||
softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; }
|
||||
|
||||
/** @brief Comparison operations
|
||||
|
||||
- Any operation with NaN produces false
|
||||
+ The only exception is when x is NaN: x != y for any y.
|
||||
- Positive and negative zeros are equal
|
||||
*/
|
||||
bool operator == ( const softfloat& ) const;
|
||||
bool operator != ( const softfloat& ) const;
|
||||
bool operator > ( const softfloat& ) const;
|
||||
bool operator >= ( const softfloat& ) const;
|
||||
bool operator < ( const softfloat& ) const;
|
||||
bool operator <= ( const softfloat& ) const;
|
||||
|
||||
/** @brief NaN state indicator */
|
||||
inline bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; }
|
||||
/** @brief Inf state indicator */
|
||||
inline bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; }
|
||||
/** @brief Subnormal number indicator */
|
||||
inline bool isSubnormal() const { return ((v >> 23) & 0xFF) == 0; }
|
||||
|
||||
/** @brief Get sign bit */
|
||||
inline bool getSign() const { return (v >> 31) != 0; }
|
||||
/** @brief Construct a copy with new sign bit */
|
||||
inline softfloat setSign(bool sign) const { softfloat x; x.v = (v & ((1U << 31) - 1)) | ((uint32_t)sign << 31); return x; }
|
||||
/** @brief Get 0-based exponent */
|
||||
inline int getExp() const { return ((v >> 23) & 0xFF) - 127; }
|
||||
/** @brief Construct a copy with new 0-based exponent */
|
||||
inline softfloat setExp(int e) const { softfloat x; x.v = (v & 0x807fffff) | (((e + 127) & 0xFF) << 23 ); return x; }
|
||||
|
||||
/** @brief Get a fraction part
|
||||
|
||||
Returns a number 1 <= x < 2 with the same significand
|
||||
*/
|
||||
inline softfloat getFrac() const
|
||||
{
|
||||
uint_fast32_t vv = (v & 0x007fffff) | (127 << 23);
|
||||
return softfloat::fromRaw(vv);
|
||||
}
|
||||
/** @brief Construct a copy with provided significand
|
||||
|
||||
Constructs a copy of a number with significand taken from parameter
|
||||
*/
|
||||
inline softfloat setFrac(const softfloat& s) const
|
||||
{
|
||||
softfloat x;
|
||||
x.v = (v & 0xff800000) | (s.v & 0x007fffff);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** @brief Zero constant */
|
||||
static softfloat zero() { return softfloat::fromRaw( 0 ); }
|
||||
/** @brief Positive infinity constant */
|
||||
static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); }
|
||||
/** @brief Default NaN constant */
|
||||
static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); }
|
||||
/** @brief One constant */
|
||||
static softfloat one() { return softfloat::fromRaw( 127 << 23 ); }
|
||||
/** @brief Smallest normalized value */
|
||||
static softfloat min() { return softfloat::fromRaw( 0x01 << 23 ); }
|
||||
/** @brief Difference between 1 and next representable value */
|
||||
static softfloat eps() { return softfloat::fromRaw( (127 - 23) << 23 ); }
|
||||
/** @brief Biggest finite value */
|
||||
static softfloat max() { return softfloat::fromRaw( (0xFF << 23) - 1 ); }
|
||||
/** @brief Correct pi approximation */
|
||||
static softfloat pi() { return softfloat::fromRaw( 0x40490fdb ); }
|
||||
|
||||
uint32_t v;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
struct CV_EXPORTS softdouble
|
||||
{
|
||||
public:
|
||||
/** @brief Default constructor */
|
||||
softdouble() : v(0) { }
|
||||
/** @brief Copy constructor */
|
||||
softdouble( const softdouble& c) { v = c.v; }
|
||||
/** @brief Assign constructor */
|
||||
softdouble& operator=( const softdouble& c )
|
||||
{
|
||||
if(&c != this) v = c.v;
|
||||
return *this;
|
||||
}
|
||||
/** @brief Construct from raw
|
||||
|
||||
Builds new value from raw binary representation
|
||||
*/
|
||||
static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; }
|
||||
|
||||
/** @brief Construct from integer */
|
||||
explicit softdouble( const uint32_t );
|
||||
explicit softdouble( const uint64_t );
|
||||
explicit softdouble( const int32_t );
|
||||
explicit softdouble( const int64_t );
|
||||
|
||||
#ifdef CV_INT32_T_IS_LONG_INT
|
||||
// for platforms with int32_t = long int
|
||||
explicit softdouble( const int a ) { *this = softdouble(static_cast<int32_t>(a)); }
|
||||
#endif
|
||||
|
||||
/** @brief Construct from double */
|
||||
explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
|
||||
|
||||
/** @brief Type casts */
|
||||
operator softfloat() const;
|
||||
operator double() const { Cv64suf s; s.u = v; return s.f; }
|
||||
|
||||
/** @brief Basic arithmetics */
|
||||
softdouble operator + (const softdouble&) const;
|
||||
softdouble operator - (const softdouble&) const;
|
||||
softdouble operator * (const softdouble&) const;
|
||||
softdouble operator / (const softdouble&) const;
|
||||
softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; }
|
||||
|
||||
/** @brief Remainder operator
|
||||
|
||||
A quote from original SoftFloat manual:
|
||||
|
||||
> The IEEE Standard remainder operation computes the value
|
||||
> a - n * b, where n is the integer closest to a / b.
|
||||
> If a / b is exactly halfway between two integers, n is the even integer
|
||||
> closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
|
||||
> Depending on the relative magnitudes of the operands, the remainder functions
|
||||
> can take considerably longer to execute than the other SoftFloat functions.
|
||||
> This is an inherent characteristic of the remainder operation itself and is not a flaw
|
||||
> in the SoftFloat implementation.
|
||||
*/
|
||||
softdouble operator % (const softdouble&) const;
|
||||
|
||||
softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; }
|
||||
softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; }
|
||||
softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; }
|
||||
softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; }
|
||||
softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; }
|
||||
|
||||
/** @brief Comparison operations
|
||||
|
||||
- Any operation with NaN produces false
|
||||
+ The only exception is when x is NaN: x != y for any y.
|
||||
- Positive and negative zeros are equal
|
||||
*/
|
||||
bool operator == ( const softdouble& ) const;
|
||||
bool operator != ( const softdouble& ) const;
|
||||
bool operator > ( const softdouble& ) const;
|
||||
bool operator >= ( const softdouble& ) const;
|
||||
bool operator < ( const softdouble& ) const;
|
||||
bool operator <= ( const softdouble& ) const;
|
||||
|
||||
/** @brief NaN state indicator */
|
||||
inline bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; }
|
||||
/** @brief Inf state indicator */
|
||||
inline bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; }
|
||||
/** @brief Subnormal number indicator */
|
||||
inline bool isSubnormal() const { return ((v >> 52) & 0x7FF) == 0; }
|
||||
|
||||
/** @brief Get sign bit */
|
||||
inline bool getSign() const { return (v >> 63) != 0; }
|
||||
/** @brief Construct a copy with new sign bit */
|
||||
softdouble setSign(bool sign) const { softdouble x; x.v = (v & ((1ULL << 63) - 1)) | ((uint_fast64_t)(sign) << 63); return x; }
|
||||
/** @brief Get 0-based exponent */
|
||||
inline int getExp() const { return ((v >> 52) & 0x7FF) - 1023; }
|
||||
/** @brief Construct a copy with new 0-based exponent */
|
||||
inline softdouble setExp(int e) const
|
||||
{
|
||||
softdouble x;
|
||||
x.v = (v & 0x800FFFFFFFFFFFFF) | ((uint_fast64_t)((e + 1023) & 0x7FF) << 52);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** @brief Get a fraction part
|
||||
|
||||
Returns a number 1 <= x < 2 with the same significand
|
||||
*/
|
||||
inline softdouble getFrac() const
|
||||
{
|
||||
uint_fast64_t vv = (v & 0x000FFFFFFFFFFFFF) | ((uint_fast64_t)(1023) << 52);
|
||||
return softdouble::fromRaw(vv);
|
||||
}
|
||||
/** @brief Construct a copy with provided significand
|
||||
|
||||
Constructs a copy of a number with significand taken from parameter
|
||||
*/
|
||||
inline softdouble setFrac(const softdouble& s) const
|
||||
{
|
||||
softdouble x;
|
||||
x.v = (v & 0xFFF0000000000000) | (s.v & 0x000FFFFFFFFFFFFF);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** @brief Zero constant */
|
||||
static softdouble zero() { return softdouble::fromRaw( 0 ); }
|
||||
/** @brief Positive infinity constant */
|
||||
static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); }
|
||||
/** @brief Default NaN constant */
|
||||
static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); }
|
||||
/** @brief One constant */
|
||||
static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); }
|
||||
/** @brief Smallest normalized value */
|
||||
static softdouble min() { return softdouble::fromRaw( (uint_fast64_t)( 0x01) << 52 ); }
|
||||
/** @brief Difference between 1 and next representable value */
|
||||
static softdouble eps() { return softdouble::fromRaw( (uint_fast64_t)( 1023 - 52 ) << 52 ); }
|
||||
/** @brief Biggest finite value */
|
||||
static softdouble max() { return softdouble::fromRaw( ((uint_fast64_t)(0x7FF) << 52) - 1 ); }
|
||||
/** @brief Correct pi approximation */
|
||||
static softdouble pi() { return softdouble::fromRaw( CV_BIG_INT(0x400921FB54442D18) ); }
|
||||
|
||||
uint64_t v;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** @brief Fused Multiplication and Addition
|
||||
|
||||
Computes (a*b)+c with single rounding
|
||||
*/
|
||||
CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c);
|
||||
CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c);
|
||||
|
||||
/** @brief Square root */
|
||||
CV_EXPORTS softfloat sqrt( const softfloat& a );
|
||||
CV_EXPORTS softdouble sqrt( const softdouble& a );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Ported from OpenCV and added for usability
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** @brief Truncates number to integer with minimum magnitude */
|
||||
CV_EXPORTS int cvTrunc(const cv::softfloat& a);
|
||||
CV_EXPORTS int cvTrunc(const cv::softdouble& a);
|
||||
|
||||
/** @brief Rounds a number to nearest even integer */
|
||||
CV_EXPORTS int cvRound(const cv::softfloat& a);
|
||||
CV_EXPORTS int cvRound(const cv::softdouble& a);
|
||||
|
||||
/** @brief Rounds a number to nearest even long long integer */
|
||||
CV_EXPORTS int64_t cvRound64(const cv::softdouble& a);
|
||||
|
||||
/** @brief Rounds a number down to integer */
|
||||
CV_EXPORTS int cvFloor(const cv::softfloat& a);
|
||||
CV_EXPORTS int cvFloor(const cv::softdouble& a);
|
||||
|
||||
/** @brief Rounds number up to integer */
|
||||
CV_EXPORTS int cvCeil(const cv::softfloat& a);
|
||||
CV_EXPORTS int cvCeil(const cv::softdouble& a);
|
||||
|
||||
namespace cv
|
||||
{
|
||||
/** @brief Saturate casts */
|
||||
template<typename _Tp> static inline _Tp saturate_cast(softfloat a) { return _Tp(a); }
|
||||
template<typename _Tp> static inline _Tp saturate_cast(softdouble a) { return _Tp(a); }
|
||||
|
||||
template<> inline uchar saturate_cast<uchar>(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
|
||||
template<> inline uchar saturate_cast<uchar>(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
|
||||
|
||||
template<> inline schar saturate_cast<schar>(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
|
||||
template<> inline schar saturate_cast<schar>(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
|
||||
|
||||
template<> inline ushort saturate_cast<ushort>(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
|
||||
template<> inline ushort saturate_cast<ushort>(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
|
||||
|
||||
template<> inline short saturate_cast<short>(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
|
||||
template<> inline short saturate_cast<short>(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
|
||||
|
||||
template<> inline int saturate_cast<int>(softfloat a) { return cvRound(a); }
|
||||
template<> inline int saturate_cast<int>(softdouble a) { return cvRound(a); }
|
||||
|
||||
template<> inline int64_t saturate_cast<int64_t>(softfloat a) { return cvRound(a); }
|
||||
template<> inline int64_t saturate_cast<int64_t>(softdouble a) { return cvRound64(a); }
|
||||
|
||||
/** @brief Saturate cast to unsigned integer and unsigned long long integer
|
||||
We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
|
||||
*/
|
||||
template<> inline unsigned saturate_cast<unsigned>(softfloat a) { return cvRound(a); }
|
||||
template<> inline unsigned saturate_cast<unsigned>(softdouble a) { return cvRound(a); }
|
||||
|
||||
template<> inline uint64_t saturate_cast<uint64_t>(softfloat a) { return cvRound(a); }
|
||||
template<> inline uint64_t saturate_cast<uint64_t>(softdouble a) { return cvRound64(a); }
|
||||
|
||||
/** @brief Min and Max functions */
|
||||
inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; }
|
||||
inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; }
|
||||
|
||||
inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; }
|
||||
inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; }
|
||||
|
||||
/** @brief Absolute value */
|
||||
inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; }
|
||||
inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; }
|
||||
|
||||
/** @brief Exponent
|
||||
|
||||
Special cases:
|
||||
- exp(NaN) is NaN
|
||||
- exp(-Inf) == 0
|
||||
- exp(+Inf) == +Inf
|
||||
*/
|
||||
CV_EXPORTS softfloat exp( const softfloat& a);
|
||||
CV_EXPORTS softdouble exp( const softdouble& a);
|
||||
|
||||
/** @brief Natural logarithm
|
||||
|
||||
Special cases:
|
||||
- log(NaN), log(x < 0) are NaN
|
||||
- log(0) == -Inf
|
||||
*/
|
||||
CV_EXPORTS softfloat log( const softfloat& a );
|
||||
CV_EXPORTS softdouble log( const softdouble& a );
|
||||
|
||||
/** @brief Raising to the power
|
||||
|
||||
Special cases:
|
||||
- x**NaN is NaN for any x
|
||||
- ( |x| == 1 )**Inf is NaN
|
||||
- ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf
|
||||
- ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0
|
||||
- x ** 0 == 1 for any x
|
||||
- x ** 1 == 1 for any x
|
||||
- NaN ** y is NaN for any other y
|
||||
- Inf**(y < 0) == 0
|
||||
- Inf ** y is +Inf for any other y
|
||||
- (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer
|
||||
- 0 ** 0 == 1
|
||||
- 0 ** (y < 0) is +Inf
|
||||
- 0 ** (y > 0) is 0
|
||||
*/
|
||||
CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b);
|
||||
CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b);
|
||||
|
||||
/** @brief Cube root
|
||||
|
||||
Special cases:
|
||||
- cbrt(NaN) is NaN
|
||||
- cbrt(+/-Inf) is +/-Inf
|
||||
*/
|
||||
CV_EXPORTS softfloat cbrt( const softfloat& a );
|
||||
|
||||
/** @brief Sine
|
||||
|
||||
Special cases:
|
||||
- sin(Inf) or sin(NaN) is NaN
|
||||
- sin(x) == x when sin(x) is close to zero
|
||||
*/
|
||||
CV_EXPORTS softdouble sin( const softdouble& a );
|
||||
|
||||
/** @brief Cosine
|
||||
*
|
||||
Special cases:
|
||||
- cos(Inf) or cos(NaN) is NaN
|
||||
- cos(x) == +/- 1 when cos(x) is close to +/- 1
|
||||
*/
|
||||
CV_EXPORTS softdouble cos( const softdouble& a );
|
||||
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
#endif
|
||||
|
|
@ -39,8 +39,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_SSE_UTILS_HPP__
|
||||
#define __OPENCV_CORE_SSE_UTILS_HPP__
|
||||
#ifndef OPENCV_CORE_SSE_UTILS_HPP
|
||||
#define OPENCV_CORE_SSE_UTILS_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error sse_utils.hpp header must be compiled as C++
|
||||
|
|
@ -649,4 +649,4 @@ inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m12
|
|||
|
||||
//! @}
|
||||
|
||||
#endif //__OPENCV_CORE_SSE_UTILS_HPP__
|
||||
#endif //OPENCV_CORE_SSE_UTILS_HPP
|
||||
|
|
@ -41,19 +41,23 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_TRAITS_HPP__
|
||||
#define __OPENCV_CORE_TRAITS_HPP__
|
||||
#ifndef OPENCV_CORE_TRAITS_HPP
|
||||
#define OPENCV_CORE_TRAITS_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//#define OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
|
||||
//! @addtogroup core_basic
|
||||
//! @{
|
||||
|
||||
/** @brief Template "trait" class for OpenCV primitive data types.
|
||||
|
||||
@note Deprecated. This is replaced by "single purpose" traits: traits::Type and traits::Depth
|
||||
|
||||
A primitive OpenCV data type is one of unsigned char, bool, signed char, unsigned short, signed
|
||||
short, int, float, double, or a tuple of values of one of these types, where all the values in the
|
||||
tuple have the same type. Any primitive type from the list can be defined by an identifier in the
|
||||
|
|
@ -102,10 +106,13 @@ So, such traits are used to tell OpenCV which data type you are working with, ev
|
|||
not native to OpenCV. For example, the matrix B initialization above is compiled because OpenCV
|
||||
defines the proper specialized template class DataType\<complex\<_Tp\> \> . This mechanism is also
|
||||
useful (and used in OpenCV this way) for generic algorithms implementations.
|
||||
|
||||
@note Default values were dropped to stop confusing developers about using of unsupported types (see #7599)
|
||||
*/
|
||||
template<typename _Tp> class DataType
|
||||
{
|
||||
public:
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
typedef _Tp value_type;
|
||||
typedef value_type work_type;
|
||||
typedef value_type channel_type;
|
||||
|
|
@ -116,6 +123,7 @@ public:
|
|||
fmt = 0,
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template<> class DataType<bool>
|
||||
|
|
@ -270,11 +278,14 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
|
||||
template<int _depth> class TypeDepth
|
||||
{
|
||||
#ifdef OPENCV_TRAITS_ENABLE_LEGACY_DEFAULTS
|
||||
enum { depth = CV_USRTYPE1 };
|
||||
typedef void value_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<> class TypeDepth<CV_8U>
|
||||
|
|
@ -319,8 +330,68 @@ template<> class TypeDepth<CV_64F>
|
|||
typedef double value_type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
namespace traits {
|
||||
|
||||
namespace internal {
|
||||
#define CV_CREATE_MEMBER_CHECK(X) \
|
||||
template<typename T> class CheckMember_##X { \
|
||||
struct Fallback { int X; }; \
|
||||
struct Derived : T, Fallback { }; \
|
||||
template<typename U, U> struct Check; \
|
||||
typedef char CV_NO[1]; \
|
||||
typedef char CV_YES[2]; \
|
||||
template<typename U> static CV_NO & func(Check<int Fallback::*, &U::X> *); \
|
||||
template<typename U> static CV_YES & func(...); \
|
||||
public: \
|
||||
typedef CheckMember_##X type; \
|
||||
enum { value = sizeof(func<Derived>(0)) == sizeof(CV_YES) }; \
|
||||
};
|
||||
|
||||
CV_CREATE_MEMBER_CHECK(fmt)
|
||||
CV_CREATE_MEMBER_CHECK(type)
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct Depth
|
||||
{ enum { value = DataType<T>::depth }; };
|
||||
|
||||
template<typename T>
|
||||
struct Type
|
||||
{ enum { value = DataType<T>::type }; };
|
||||
|
||||
/** Similar to traits::Type<T> but has value = -1 in case of unknown type (instead of compiler error) */
|
||||
template<typename T, bool available = internal::CheckMember_type< DataType<T> >::value >
|
||||
struct SafeType {};
|
||||
|
||||
template<typename T>
|
||||
struct SafeType<T, false>
|
||||
{ enum { value = -1 }; };
|
||||
|
||||
template<typename T>
|
||||
struct SafeType<T, true>
|
||||
{ enum { value = Type<T>::value }; };
|
||||
|
||||
|
||||
template<typename T, bool available = internal::CheckMember_fmt< DataType<T> >::value >
|
||||
struct SafeFmt {};
|
||||
|
||||
template<typename T>
|
||||
struct SafeFmt<T, false>
|
||||
{ enum { fmt = 0 }; };
|
||||
|
||||
template<typename T>
|
||||
struct SafeFmt<T, true>
|
||||
{ enum { fmt = DataType<T>::fmt }; };
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_TRAITS_HPP__
|
||||
#endif // OPENCV_CORE_TRAITS_HPP
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_TYPES_HPP__
|
||||
#define __OPENCV_CORE_TYPES_HPP__
|
||||
#ifndef OPENCV_CORE_TYPES_HPP
|
||||
#define OPENCV_CORE_TYPES_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error types.hpp header must be compiled as C++
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
#include <climits>
|
||||
#include <cfloat>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
|
|
@ -97,14 +98,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 2,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
//////////////////////////////// Point_ ////////////////////////////////
|
||||
|
|
@ -176,6 +186,7 @@ public:
|
|||
};
|
||||
|
||||
typedef Point_<int> Point2i;
|
||||
typedef Point_<int64> Point2l;
|
||||
typedef Point_<float> Point2f;
|
||||
typedef Point_<double> Point2d;
|
||||
typedef Point2i Point;
|
||||
|
|
@ -188,15 +199,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 2,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
//////////////////////////////// Point3_ ////////////////////////////////
|
||||
|
|
@ -231,7 +250,11 @@ public:
|
|||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Point3_<_Tp2>() const;
|
||||
//! conversion to cv::Vec<>
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
template<typename _Tp2> operator Vec<_Tp2, 3>() const;
|
||||
#else
|
||||
operator Vec<_Tp, 3>() const;
|
||||
#endif
|
||||
|
||||
//! dot product
|
||||
_Tp dot(const Point3_& pt) const;
|
||||
|
|
@ -255,16 +278,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 3,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; };
|
||||
} // namespace
|
||||
|
||||
//////////////////////////////// Size_ ////////////////////////////////
|
||||
|
||||
|
|
@ -295,6 +325,8 @@ public:
|
|||
Size_& operator = (const Size_& sz);
|
||||
//! the area (width*height)
|
||||
_Tp area() const;
|
||||
//! true if empty
|
||||
bool empty() const;
|
||||
|
||||
//! conversion of another data type.
|
||||
template<typename _Tp2> operator Size_<_Tp2>() const;
|
||||
|
|
@ -303,6 +335,7 @@ public:
|
|||
};
|
||||
|
||||
typedef Size_<int> Size2i;
|
||||
typedef Size_<int64> Size2l;
|
||||
typedef Size_<float> Size2f;
|
||||
typedef Size_<double> Size2d;
|
||||
typedef Size2i Size;
|
||||
|
|
@ -315,16 +348,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 2,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; };
|
||||
} // namespace
|
||||
|
||||
//////////////////////////////// Rect_ ////////////////////////////////
|
||||
|
||||
|
|
@ -393,6 +433,8 @@ public:
|
|||
Size_<_Tp> size() const;
|
||||
//! area (width*height) of the rectangle
|
||||
_Tp area() const;
|
||||
//! true if empty
|
||||
bool empty() const;
|
||||
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Rect_<_Tp2>() const;
|
||||
|
|
@ -416,16 +458,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 4,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; };
|
||||
} // namespace
|
||||
|
||||
///////////////////////////// RotatedRect /////////////////////////////
|
||||
|
||||
|
|
@ -473,11 +522,13 @@ public:
|
|||
RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3);
|
||||
|
||||
/** returns 4 vertices of the rectangle
|
||||
@param pts The points array for storing rectangle vertices.
|
||||
@param pts The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight.
|
||||
*/
|
||||
void points(Point2f pts[]) const;
|
||||
//! returns the minimal up-right rectangle containing the rotated rectangle
|
||||
//! returns the minimal up-right integer rectangle containing the rotated rectangle
|
||||
Rect boundingRect() const;
|
||||
//! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images
|
||||
Rect_<float> boundingRect2f() const;
|
||||
|
||||
Point2f center; //< the rectangle mass center
|
||||
Size2f size; //< width and height of the rectangle
|
||||
|
|
@ -492,15 +543,23 @@ public:
|
|||
typedef float channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = (int)sizeof(value_type)/sizeof(channel_type), // 5
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<>
|
||||
struct Depth< RotatedRect > { enum { value = Depth<float>::value }; };
|
||||
template<>
|
||||
struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth<float>::value, (int)sizeof(RotatedRect)/sizeof(float)) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
//////////////////////////////// Range /////////////////////////////////
|
||||
|
|
@ -548,22 +607,30 @@ public:
|
|||
typedef int channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 2,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<>
|
||||
struct Depth< Range > { enum { value = Depth<int>::value }; };
|
||||
template<>
|
||||
struct Type< Range > { enum { value = CV_MAKETYPE(Depth<int>::value, 2) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
//////////////////////////////// Scalar_ ///////////////////////////////
|
||||
|
||||
/** @brief Template class for a 4-element vector derived from Vec.
|
||||
|
||||
Being derived from Vec\<_Tp, 4\> , Scalar_ and Scalar can be used just as typical 4-element
|
||||
Being derived from Vec\<_Tp, 4\> , Scalar\_ and Scalar can be used just as typical 4-element
|
||||
vectors. In addition, they can be converted to/from CvScalar . The type Scalar is widely used in
|
||||
OpenCV to pass pixel values.
|
||||
*/
|
||||
|
|
@ -604,15 +671,23 @@ public:
|
|||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 4,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; };
|
||||
} // namespace
|
||||
|
||||
|
||||
/////////////////////////////// KeyPoint ////////////////////////////////
|
||||
|
|
@ -699,6 +774,7 @@ public:
|
|||
CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to)
|
||||
};
|
||||
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
template<> class DataType<KeyPoint>
|
||||
{
|
||||
public:
|
||||
|
|
@ -715,7 +791,7 @@ public:
|
|||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////// DMatch /////////////////////////////////
|
||||
|
|
@ -742,6 +818,7 @@ public:
|
|||
bool operator<(const DMatch &m) const;
|
||||
};
|
||||
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
template<> class DataType<DMatch>
|
||||
{
|
||||
public:
|
||||
|
|
@ -758,7 +835,7 @@ public:
|
|||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////// TermCriteria //////////////////////////////
|
||||
|
|
@ -872,15 +949,24 @@ public:
|
|||
typedef double channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<>
|
||||
struct Depth< Moments > { enum { value = Depth<double>::value }; };
|
||||
template<>
|
||||
struct Type< Moments > { enum { value = CV_MAKETYPE(Depth<double>::value, (int)(sizeof(Moments)/sizeof(double))) }; };
|
||||
} // namespace
|
||||
|
||||
//! @} imgproc_shape
|
||||
|
||||
//! @cond IGNORED
|
||||
|
|
@ -1031,7 +1117,8 @@ Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b)
|
|||
template<typename _Tp> static inline
|
||||
Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b)
|
||||
{
|
||||
return (a = a / b);
|
||||
a = a / b;
|
||||
return a;
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
|
|
@ -1326,11 +1413,19 @@ Point3_<_Tp>::operator Point3_<_Tp2>() const
|
|||
return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z));
|
||||
}
|
||||
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
template<typename _Tp> template<typename _Tp2> inline
|
||||
Point3_<_Tp>::operator Vec<_Tp2, 3>() const
|
||||
{
|
||||
return Vec<_Tp2, 3>(x, y, z);
|
||||
}
|
||||
#else
|
||||
template<typename _Tp> inline
|
||||
Point3_<_Tp>::operator Vec<_Tp, 3>() const
|
||||
{
|
||||
return Vec<_Tp, 3>(x, y, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp> inline
|
||||
Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt)
|
||||
|
|
@ -1575,9 +1670,19 @@ Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz)
|
|||
template<typename _Tp> inline
|
||||
_Tp Size_<_Tp>::area() const
|
||||
{
|
||||
return width * height;
|
||||
const _Tp result = width * height;
|
||||
CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer
|
||||
|| width == 0 || result / width == height); // make sure the result fits in the return value
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
bool Size_<_Tp>::empty() const
|
||||
{
|
||||
return width <= 0 || height <= 0;
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> static inline
|
||||
Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b)
|
||||
{
|
||||
|
|
@ -1714,7 +1819,16 @@ Size_<_Tp> Rect_<_Tp>::size() const
|
|||
template<typename _Tp> inline
|
||||
_Tp Rect_<_Tp>::area() const
|
||||
{
|
||||
return width * height;
|
||||
const _Tp result = width * height;
|
||||
CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer
|
||||
|| width == 0 || result / width == height); // make sure the result fits in the return value
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
bool Rect_<_Tp>::empty() const
|
||||
{
|
||||
return width <= 0 || height <= 0;
|
||||
}
|
||||
|
||||
template<typename _Tp> template<typename _Tp2> inline
|
||||
|
|
@ -1779,12 +1893,17 @@ Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
|
|||
template<typename _Tp> static inline
|
||||
Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
|
||||
{
|
||||
_Tp x1 = std::min(a.x, b.x);
|
||||
_Tp y1 = std::min(a.y, b.y);
|
||||
a.width = std::max(a.x + a.width, b.x + b.width) - x1;
|
||||
a.height = std::max(a.y + a.height, b.y + b.height) - y1;
|
||||
a.x = x1;
|
||||
a.y = y1;
|
||||
if (a.empty()) {
|
||||
a = b;
|
||||
}
|
||||
else if (!b.empty()) {
|
||||
_Tp x1 = std::min(a.x, b.x);
|
||||
_Tp y1 = std::min(a.y, b.y);
|
||||
a.width = std::max(a.x + a.width, b.x + b.width) - x1;
|
||||
a.height = std::max(a.y + a.height, b.y + b.height) - y1;
|
||||
a.x = x1;
|
||||
a.y = y1;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
@ -1832,7 +1951,26 @@ Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
|
|||
return c |= b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief measure dissimilarity between two sample sets
|
||||
*
|
||||
* computes the complement of the Jaccard Index as described in <https://en.wikipedia.org/wiki/Jaccard_index>.
|
||||
* For rectangles this reduces to computing the intersection over the union.
|
||||
*/
|
||||
template<typename _Tp> static inline
|
||||
double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) {
|
||||
_Tp Aa = a.area();
|
||||
_Tp Ab = b.area();
|
||||
|
||||
if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) {
|
||||
// jaccard_index = 1 -> distance = 0
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Aab = (a & b).area();
|
||||
// distance = 1 - jaccard_index
|
||||
return 1.0 - Aab / (Aa + Ab - Aab);
|
||||
}
|
||||
|
||||
////////////////////////////// RotatedRect //////////////////////////////
|
||||
|
||||
|
|
@ -2225,4 +2363,4 @@ TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon)
|
|||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_CORE_TYPES_HPP__
|
||||
#endif //OPENCV_CORE_TYPES_HPP
|
||||
|
|
@ -41,12 +41,12 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_TYPES_H__
|
||||
#define __OPENCV_CORE_TYPES_H__
|
||||
#ifndef OPENCV_CORE_TYPES_H
|
||||
#define OPENCV_CORE_TYPES_H
|
||||
|
||||
#ifdef HAVE_IPL
|
||||
# ifndef __IPL_H__
|
||||
# if defined WIN32 || defined _WIN32
|
||||
# if defined _WIN32
|
||||
# include <ipl.h>
|
||||
# else
|
||||
# include <ipl/ipl.h>
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
#include <float.h>
|
||||
#endif // SKIP_INCLUDES
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#if defined _WIN32
|
||||
# define CV_CDECL __cdecl
|
||||
# define CV_STDCALL __stdcall
|
||||
#else
|
||||
|
|
@ -130,24 +130,24 @@ enum {
|
|||
CV_BadImageSize= -10, /**< image size is invalid */
|
||||
CV_BadOffset= -11, /**< offset is invalid */
|
||||
CV_BadDataPtr= -12, /**/
|
||||
CV_BadStep= -13, /**/
|
||||
CV_BadStep= -13, /**< image step is wrong, this may happen for a non-continuous matrix */
|
||||
CV_BadModelOrChSeq= -14, /**/
|
||||
CV_BadNumChannels= -15, /**/
|
||||
CV_BadNumChannels= -15, /**< bad number of channels, for example, some functions accept only single channel matrices */
|
||||
CV_BadNumChannel1U= -16, /**/
|
||||
CV_BadDepth= -17, /**/
|
||||
CV_BadDepth= -17, /**< input image depth is not supported by the function */
|
||||
CV_BadAlphaChannel= -18, /**/
|
||||
CV_BadOrder= -19, /**/
|
||||
CV_BadOrigin= -20, /**/
|
||||
CV_BadAlign= -21, /**/
|
||||
CV_BadOrder= -19, /**< number of dimensions is out of range */
|
||||
CV_BadOrigin= -20, /**< incorrect input origin */
|
||||
CV_BadAlign= -21, /**< incorrect input align */
|
||||
CV_BadCallBack= -22, /**/
|
||||
CV_BadTileSize= -23, /**/
|
||||
CV_BadCOI= -24, /**/
|
||||
CV_BadROISize= -25, /**/
|
||||
CV_BadCOI= -24, /**< input COI is not supported */
|
||||
CV_BadROISize= -25, /**< incorrect input roi */
|
||||
CV_MaskIsTiled= -26, /**/
|
||||
CV_StsNullPtr= -27, /**< null pointer */
|
||||
CV_StsVecLengthErr= -28, /**< incorrect vector length */
|
||||
CV_StsFilterStructContentErr= -29, /**< incorr. filter structure content */
|
||||
CV_StsKernelStructContentErr= -30, /**< incorr. transform kernel content */
|
||||
CV_StsFilterStructContentErr= -29, /**< incorrect filter structure content */
|
||||
CV_StsKernelStructContentErr= -30, /**< incorrect transform kernel content */
|
||||
CV_StsFilterOffsetErr= -31, /**< incorrect filter offset value */
|
||||
CV_StsBadSize= -201, /**< the input/output structure size is incorrect */
|
||||
CV_StsDivByZero= -202, /**< division by zero */
|
||||
|
|
@ -163,14 +163,14 @@ enum {
|
|||
CV_StsParseError= -212, /**< invalid syntax/structure of the parsed file */
|
||||
CV_StsNotImplemented= -213, /**< the requested function/feature is not implemented */
|
||||
CV_StsBadMemBlock= -214, /**< an allocated block has been corrupted */
|
||||
CV_StsAssert= -215, /**< assertion failed */
|
||||
CV_GpuNotSupported= -216,
|
||||
CV_GpuApiCallError= -217,
|
||||
CV_OpenGlNotSupported= -218,
|
||||
CV_OpenGlApiCallError= -219,
|
||||
CV_OpenCLApiCallError= -220,
|
||||
CV_StsAssert= -215, /**< assertion failed */
|
||||
CV_GpuNotSupported= -216, /**< no CUDA support */
|
||||
CV_GpuApiCallError= -217, /**< GPU API call error */
|
||||
CV_OpenGlNotSupported= -218, /**< no OpenGL support */
|
||||
CV_OpenGlApiCallError= -219, /**< OpenGL API call error */
|
||||
CV_OpenCLApiCallError= -220, /**< OpenCL API call error */
|
||||
CV_OpenCLDoubleNotSupported= -221,
|
||||
CV_OpenCLInitError= -222,
|
||||
CV_OpenCLInitError= -222, /**< OpenCL initialization error */
|
||||
CV_OpenCLNoAMDBlasFft= -223
|
||||
};
|
||||
|
||||
|
|
@ -1669,6 +1669,9 @@ typedef struct CvFileStorage CvFileStorage;
|
|||
#define CV_STORAGE_FORMAT_AUTO 0
|
||||
#define CV_STORAGE_FORMAT_XML 8
|
||||
#define CV_STORAGE_FORMAT_YAML 16
|
||||
#define CV_STORAGE_FORMAT_JSON 24
|
||||
#define CV_STORAGE_BASE64 64
|
||||
#define CV_STORAGE_WRITE_BASE64 (CV_STORAGE_BASE64 | CV_STORAGE_WRITE)
|
||||
|
||||
/** @brief List of attributes. :
|
||||
|
||||
|
|
@ -1829,6 +1832,6 @@ CvModuleInfo;
|
|||
|
||||
/** @} */
|
||||
|
||||
#endif /*__OPENCV_CORE_TYPES_H__*/
|
||||
#endif /*OPENCV_CORE_TYPES_H*/
|
||||
|
||||
/* End of file. */
|
||||
|
|
@ -42,14 +42,23 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_UTILITY_H__
|
||||
#define __OPENCV_CORE_UTILITY_H__
|
||||
#ifndef OPENCV_CORE_UTILITY_H
|
||||
#define OPENCV_CORE_UTILITY_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error utility.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#if defined(check)
|
||||
# warning Detected Apple 'check' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include <ostream>
|
||||
|
||||
#ifdef CV_CXX11
|
||||
#include <functional>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
|
@ -57,8 +66,8 @@ namespace cv
|
|||
#ifdef CV_COLLECT_IMPL_DATA
|
||||
CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
|
||||
CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
|
||||
// Get stored implementation flags and fucntions names arrays
|
||||
// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which fucntion
|
||||
// Get stored implementation flags and functions names arrays
|
||||
// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function
|
||||
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
|
||||
|
||||
CV_EXPORTS bool useCollection(); // return implementation collection state
|
||||
|
|
@ -98,7 +107,7 @@ CV_EXPORTS void setUseCollection(bool flag); // set implementation collection st
|
|||
\code
|
||||
void my_func(const cv::Mat& m)
|
||||
{
|
||||
cv::AutoBuffer<float> buf; // create automatic buffer containing 1000 floats
|
||||
cv::AutoBuffer<float> buf(1000); // create automatic buffer containing 1000 floats
|
||||
|
||||
buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used,
|
||||
// otherwise the buffer of "m.rows" floats will be allocated
|
||||
|
|
@ -133,9 +142,9 @@ public:
|
|||
void resize(size_t _size);
|
||||
//! returns the current buffer size
|
||||
size_t size() const;
|
||||
//! returns pointer to the real buffer, stack-allocated or head-allocated
|
||||
//! returns pointer to the real buffer, stack-allocated or heap-allocated
|
||||
operator _Tp* ();
|
||||
//! returns read-only pointer to the real buffer, stack-allocated or head-allocated
|
||||
//! returns read-only pointer to the real buffer, stack-allocated or heap-allocated
|
||||
operator const _Tp* () const;
|
||||
|
||||
protected:
|
||||
|
|
@ -143,7 +152,7 @@ protected:
|
|||
_Tp* ptr;
|
||||
//! size of the real buffer
|
||||
size_t sz;
|
||||
//! pre-allocated buffer. At least 1 element to confirm C++ standard reqirements
|
||||
//! pre-allocated buffer. At least 1 element to confirm C++ standard requirements
|
||||
_Tp buf[(fixed_size > 0) ? fixed_size : 1];
|
||||
};
|
||||
|
||||
|
|
@ -189,15 +198,15 @@ If threads == 0, OpenCV will disable threading optimizations and run all it's fu
|
|||
sequentially. Passing threads \< 0 will reset threads number to system default. This function must
|
||||
be called outside of parallel region.
|
||||
|
||||
OpenCV will try to run it's functions with specified threads number, but some behaviour differs from
|
||||
OpenCV will try to run its functions with specified threads number, but some behaviour differs from
|
||||
framework:
|
||||
- `TBB` – User-defined parallel constructions will run with the same threads number, if
|
||||
another does not specified. If late on user creates own scheduler, OpenCV will be use it.
|
||||
- `OpenMP` – No special defined behaviour.
|
||||
- `Concurrency` – If threads == 1, OpenCV will disable threading optimizations and run it's
|
||||
- `TBB` - User-defined parallel constructions will run with the same threads number, if
|
||||
another is not specified. If later on user creates his own scheduler, OpenCV will use it.
|
||||
- `OpenMP` - No special defined behaviour.
|
||||
- `Concurrency` - If threads == 1, OpenCV will disable threading optimizations and run its
|
||||
functions sequentially.
|
||||
- `GCD` – Supports only values \<= 0.
|
||||
- `C=` – No special defined behaviour.
|
||||
- `GCD` - Supports only values \<= 0.
|
||||
- `C=` - No special defined behaviour.
|
||||
@param nthreads Number of threads used by OpenCV.
|
||||
@sa getNumThreads, getThreadNum
|
||||
*/
|
||||
|
|
@ -208,13 +217,13 @@ CV_EXPORTS_W void setNumThreads(int nthreads);
|
|||
Always returns 1 if OpenCV is built without threading support.
|
||||
|
||||
The exact meaning of return value depends on the threading framework used by OpenCV library:
|
||||
- `TBB` – The number of threads, that OpenCV will try to use for parallel regions. If there is
|
||||
- `TBB` - The number of threads, that OpenCV will try to use for parallel regions. If there is
|
||||
any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns
|
||||
default number of threads used by TBB library.
|
||||
- `OpenMP` – An upper bound on the number of threads that could be used to form a new team.
|
||||
- `Concurrency` – The number of threads, that OpenCV will try to use for parallel regions.
|
||||
- `GCD` – Unsupported; returns the GCD thread pool limit (512) for compatibility.
|
||||
- `C=` – The number of threads, that OpenCV will try to use for parallel regions, if before
|
||||
- `OpenMP` - An upper bound on the number of threads that could be used to form a new team.
|
||||
- `Concurrency` - The number of threads, that OpenCV will try to use for parallel regions.
|
||||
- `GCD` - Unsupported; returns the GCD thread pool limit (512) for compatibility.
|
||||
- `C=` - The number of threads, that OpenCV will try to use for parallel regions, if before
|
||||
called setNumThreads with threads \> 0, otherwise returns the number of logical CPUs,
|
||||
available for the process.
|
||||
@sa setNumThreads, getThreadNum
|
||||
|
|
@ -224,13 +233,13 @@ CV_EXPORTS_W int getNumThreads();
|
|||
/** @brief Returns the index of the currently executed thread within the current parallel region. Always
|
||||
returns 0 if called outside of parallel region.
|
||||
|
||||
The exact meaning of return value depends on the threading framework used by OpenCV library:
|
||||
- `TBB` – Unsupported with current 4.1 TBB release. May be will be supported in future.
|
||||
- `OpenMP` – The thread number, within the current team, of the calling thread.
|
||||
- `Concurrency` – An ID for the virtual processor that the current context is executing on (0
|
||||
The exact meaning of the return value depends on the threading framework used by OpenCV library:
|
||||
- `TBB` - Unsupported with current 4.1 TBB release. Maybe will be supported in future.
|
||||
- `OpenMP` - The thread number, within the current team, of the calling thread.
|
||||
- `Concurrency` - An ID for the virtual processor that the current context is executing on (0
|
||||
for master thread and unique number for others, but not necessary 1,2,3,...).
|
||||
- `GCD` – System calling thread's ID. Never returns 0 inside parallel region.
|
||||
- `C=` – The index of the current parallel task.
|
||||
- `GCD` - System calling thread's ID. Never returns 0 inside parallel region.
|
||||
- `C=` - The index of the current parallel task.
|
||||
@sa setNumThreads, getNumThreads
|
||||
*/
|
||||
CV_EXPORTS_W int getThreadNum();
|
||||
|
|
@ -247,7 +256,8 @@ CV_EXPORTS_W const String& getBuildInformation();
|
|||
|
||||
The function returns the number of ticks after the certain event (for example, when the machine was
|
||||
turned on). It can be used to initialize RNG or to measure a function execution time by reading the
|
||||
tick count before and after the function call. See also the tick frequency.
|
||||
tick count before and after the function call.
|
||||
@sa getTickFrequency, TickMeter
|
||||
*/
|
||||
CV_EXPORTS_W int64 getTickCount();
|
||||
|
||||
|
|
@ -260,9 +270,139 @@ execution time in seconds:
|
|||
// do something ...
|
||||
t = ((double)getTickCount() - t)/getTickFrequency();
|
||||
@endcode
|
||||
@sa getTickCount, TickMeter
|
||||
*/
|
||||
CV_EXPORTS_W double getTickFrequency();
|
||||
|
||||
/** @brief a Class to measure passing time.
|
||||
|
||||
The class computes passing time by counting the number of ticks per second. That is, the following code computes the
|
||||
execution time in seconds:
|
||||
@code
|
||||
TickMeter tm;
|
||||
tm.start();
|
||||
// do something ...
|
||||
tm.stop();
|
||||
std::cout << tm.getTimeSec();
|
||||
@endcode
|
||||
|
||||
It is also possible to compute the average time over multiple runs:
|
||||
@code
|
||||
TickMeter tm;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
tm.start();
|
||||
// do something ...
|
||||
tm.stop();
|
||||
}
|
||||
double average_time = tm.getTimeSec() / tm.getCounter();
|
||||
std::cout << "Average time in second per iteration is: " << average_time << std::endl;
|
||||
@endcode
|
||||
@sa getTickCount, getTickFrequency
|
||||
*/
|
||||
|
||||
class CV_EXPORTS_W TickMeter
|
||||
{
|
||||
public:
|
||||
//! the default constructor
|
||||
CV_WRAP TickMeter()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
starts counting ticks.
|
||||
*/
|
||||
CV_WRAP void start()
|
||||
{
|
||||
startTime = cv::getTickCount();
|
||||
}
|
||||
|
||||
/**
|
||||
stops counting ticks.
|
||||
*/
|
||||
CV_WRAP void stop()
|
||||
{
|
||||
int64 time = cv::getTickCount();
|
||||
if (startTime == 0)
|
||||
return;
|
||||
++counter;
|
||||
sumTime += (time - startTime);
|
||||
startTime = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
returns counted ticks.
|
||||
*/
|
||||
CV_WRAP int64 getTimeTicks() const
|
||||
{
|
||||
return sumTime;
|
||||
}
|
||||
|
||||
/**
|
||||
returns passed time in microseconds.
|
||||
*/
|
||||
CV_WRAP double getTimeMicro() const
|
||||
{
|
||||
return getTimeMilli()*1e3;
|
||||
}
|
||||
|
||||
/**
|
||||
returns passed time in milliseconds.
|
||||
*/
|
||||
CV_WRAP double getTimeMilli() const
|
||||
{
|
||||
return getTimeSec()*1e3;
|
||||
}
|
||||
|
||||
/**
|
||||
returns passed time in seconds.
|
||||
*/
|
||||
CV_WRAP double getTimeSec() const
|
||||
{
|
||||
return (double)getTimeTicks() / getTickFrequency();
|
||||
}
|
||||
|
||||
/**
|
||||
returns internal counter value.
|
||||
*/
|
||||
CV_WRAP int64 getCounter() const
|
||||
{
|
||||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
resets internal values.
|
||||
*/
|
||||
CV_WRAP void reset()
|
||||
{
|
||||
startTime = 0;
|
||||
sumTime = 0;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
int64 counter;
|
||||
int64 sumTime;
|
||||
int64 startTime;
|
||||
};
|
||||
|
||||
/** @brief output operator
|
||||
@code
|
||||
TickMeter tm;
|
||||
tm.start();
|
||||
// do something ...
|
||||
tm.stop();
|
||||
std::cout << tm;
|
||||
@endcode
|
||||
*/
|
||||
|
||||
static inline
|
||||
std::ostream& operator << (std::ostream& out, const TickMeter& tm)
|
||||
{
|
||||
return out << tm.getTimeSec() << "sec";
|
||||
}
|
||||
|
||||
/** @brief Returns the number of CPU ticks.
|
||||
|
||||
The function returns the current number of CPU ticks on some architectures (such as x86, x64,
|
||||
|
|
@ -301,12 +441,13 @@ The function returns the aligned pointer of the same type as the input pointer:
|
|||
*/
|
||||
template<typename _Tp> static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp))
|
||||
{
|
||||
CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2
|
||||
return (_Tp*)(((size_t)ptr + n-1) & -n);
|
||||
}
|
||||
|
||||
/** @brief Aligns a buffer size to the specified number of bytes.
|
||||
|
||||
The function returns the minimum number that is greater or equal to sz and is divisible by n :
|
||||
The function returns the minimum number that is greater than or equal to sz and is divisible by n :
|
||||
\f[\texttt{(sz + n-1) & -n}\f]
|
||||
@param sz Buffer size to align.
|
||||
@param n Alignment size that must be a power of two.
|
||||
|
|
@ -317,6 +458,23 @@ static inline size_t alignSize(size_t sz, int n)
|
|||
return (sz + n-1) & -n;
|
||||
}
|
||||
|
||||
/** @brief Integer division with result round up.
|
||||
|
||||
Use this function instead of `ceil((float)a / b)` expressions.
|
||||
|
||||
@sa alignSize
|
||||
*/
|
||||
static inline int divUp(int a, unsigned int b)
|
||||
{
|
||||
CV_DbgAssert(a >= 0);
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
/** @overload */
|
||||
static inline size_t divUp(size_t a, unsigned int b)
|
||||
{
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
/** @brief Enables or disables the optimized code.
|
||||
|
||||
The function can be used to dynamically turn on and off optimized code (code that uses SSE2, AVX,
|
||||
|
|
@ -338,7 +496,7 @@ The function returns true if the optimized code is enabled. Otherwise, it return
|
|||
*/
|
||||
CV_EXPORTS_W bool useOptimized();
|
||||
|
||||
static inline size_t getElemSize(int type) { return CV_ELEM_SIZE(type); }
|
||||
static inline size_t getElemSize(int type) { return (size_t)CV_ELEM_SIZE(type); }
|
||||
|
||||
/////////////////////////////// Parallel Primitives //////////////////////////////////
|
||||
|
||||
|
|
@ -355,15 +513,37 @@ public:
|
|||
*/
|
||||
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
|
||||
|
||||
#ifdef CV_CXX11
|
||||
class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody
|
||||
{
|
||||
private:
|
||||
std::function<void(const Range&)> m_functor;
|
||||
public:
|
||||
ParallelLoopBodyLambdaWrapper(std::function<void(const Range&)> functor) :
|
||||
m_functor(functor)
|
||||
{ }
|
||||
|
||||
virtual void operator() (const cv::Range& range) const
|
||||
{
|
||||
m_functor(range);
|
||||
}
|
||||
};
|
||||
|
||||
inline void parallel_for_(const Range& range, std::function<void(const Range&)> functor, double nstripes=-1.)
|
||||
{
|
||||
parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////////////////////////// forEach method of cv::Mat ////////////////////////////
|
||||
template<typename _Tp, typename Functor> inline
|
||||
void Mat::forEach_impl(const Functor& operation) {
|
||||
if (false) {
|
||||
operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(NULL));
|
||||
// If your compiler fail in this line.
|
||||
operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));
|
||||
// If your compiler fails in this line.
|
||||
// Please check that your functor signature is
|
||||
// (_Tp&, const int*) <- multidimential
|
||||
// or (_Tp&, void*) <- in case of you don't need current idx.
|
||||
// (_Tp&, const int*) <- multi-dimensional
|
||||
// or (_Tp&, void*) <- in case you don't need current idx.
|
||||
}
|
||||
|
||||
CV_Assert(this->total() / this->size[this->dims - 1] <= INT_MAX);
|
||||
|
|
@ -373,8 +553,8 @@ void Mat::forEach_impl(const Functor& operation) {
|
|||
{
|
||||
public:
|
||||
PixelOperationWrapper(Mat_<_Tp>* const frame, const Functor& _operation)
|
||||
: mat(frame), op(_operation) {};
|
||||
virtual ~PixelOperationWrapper(){};
|
||||
: mat(frame), op(_operation) {}
|
||||
virtual ~PixelOperationWrapper(){}
|
||||
// ! Overloaded virtual operator
|
||||
// convert range call to row call.
|
||||
virtual void operator()(const Range &range) const {
|
||||
|
|
@ -385,7 +565,7 @@ void Mat::forEach_impl(const Functor& operation) {
|
|||
this->rowCall2(row, COLS);
|
||||
}
|
||||
} else {
|
||||
std::vector<int> idx(COLS); /// idx is modified in this->rowCall
|
||||
std::vector<int> idx(DIMS); /// idx is modified in this->rowCall
|
||||
idx[DIMS - 2] = range.start - 1;
|
||||
|
||||
for (int line_num = range.start; line_num < range.end; ++line_num) {
|
||||
|
|
@ -403,7 +583,7 @@ void Mat::forEach_impl(const Functor& operation) {
|
|||
this->rowCall(&idx[0], COLS, DIMS);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
private:
|
||||
Mat_<_Tp>* const mat;
|
||||
const Functor op;
|
||||
|
|
@ -440,12 +620,12 @@ void Mat::forEach_impl(const Functor& operation) {
|
|||
op(*pixel++, static_cast<const int*>(idx));
|
||||
idx[1]++;
|
||||
}
|
||||
};
|
||||
}
|
||||
PixelOperationWrapper& operator=(const PixelOperationWrapper &) {
|
||||
CV_Assert(false);
|
||||
// We can not remove this implementation because Visual Studio warning C4822.
|
||||
return *this;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
parallel_for_(cv::Range(0, LINES), PixelOperationWrapper(reinterpret_cast<Mat_<_Tp>*>(this), operation));
|
||||
|
|
@ -505,6 +685,9 @@ public:
|
|||
virtual void deleteDataInstance(void* pData) const = 0;
|
||||
|
||||
int key_;
|
||||
|
||||
public:
|
||||
void cleanup(); //! Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid.
|
||||
};
|
||||
|
||||
// Main TLS data class
|
||||
|
|
@ -514,22 +697,25 @@ class TLSData : protected TLSDataContainer
|
|||
public:
|
||||
inline TLSData() {}
|
||||
inline ~TLSData() { release(); } // Release key and delete associated data
|
||||
inline T* get() const { return (T*)getData(); } // Get data assosiated with key
|
||||
inline T* get() const { return (T*)getData(); } // Get data associated with key
|
||||
inline T& getRef() const { T* ptr = (T*)getData(); CV_Assert(ptr); return *ptr; } // Get data associated with key
|
||||
|
||||
// Get data from all threads
|
||||
// Get data from all threads
|
||||
inline void gather(std::vector<T*> &data) const
|
||||
{
|
||||
std::vector<void*> &dataVoid = reinterpret_cast<std::vector<void*>&>(data);
|
||||
gatherData(dataVoid);
|
||||
}
|
||||
|
||||
inline void cleanup() { TLSDataContainer::cleanup(); }
|
||||
|
||||
private:
|
||||
virtual void* createDataInstance() const {return new T;} // Wrapper to allocate data by template
|
||||
virtual void deleteDataInstance(void* pData) const {delete (T*)pData;} // Wrapper to release data by template
|
||||
|
||||
// Disable TLS copy operations
|
||||
TLSData(TLSData &) {};
|
||||
TLSData& operator =(const TLSData &) {return *this;};
|
||||
TLSData(TLSData &) {}
|
||||
TLSData& operator =(const TLSData &) {return *this;}
|
||||
};
|
||||
|
||||
/** @brief Designed for command line parsing
|
||||
|
|
@ -565,7 +751,7 @@ The sample below demonstrates how to use CommandLineParser:
|
|||
|
||||
### Keys syntax
|
||||
|
||||
The keys parameter is a string containing several blocks, each one is enclosed in curley braces and
|
||||
The keys parameter is a string containing several blocks, each one is enclosed in curly braces and
|
||||
describes one argument. Each argument contains three parts separated by the `|` symbol:
|
||||
|
||||
-# argument names is a space-separated list of option synonyms (to mark argument as positional, prefix it with the `@` symbol)
|
||||
|
|
@ -636,7 +822,7 @@ public:
|
|||
|
||||
This method returns the path to the executable from the command line (`argv[0]`).
|
||||
|
||||
For example, if the application has been started with such command:
|
||||
For example, if the application has been started with such a command:
|
||||
@code{.sh}
|
||||
$ ./bin/my-executable
|
||||
@endcode
|
||||
|
|
@ -723,7 +909,7 @@ public:
|
|||
|
||||
/** @brief Check for parsing errors
|
||||
|
||||
Returns true if error occured while accessing the parameters (bad conversion, missing arguments,
|
||||
Returns true if error occurred while accessing the parameters (bad conversion, missing arguments,
|
||||
etc.). Call @ref printErrors to print error messages list.
|
||||
*/
|
||||
bool check() const;
|
||||
|
|
@ -742,7 +928,7 @@ public:
|
|||
*/
|
||||
void printMessage() const;
|
||||
|
||||
/** @brief Print list of errors occured
|
||||
/** @brief Print list of errors occurred
|
||||
|
||||
@sa check
|
||||
*/
|
||||
|
|
@ -813,10 +999,10 @@ AutoBuffer<_Tp, fixed_size>::allocate(size_t _size)
|
|||
return;
|
||||
}
|
||||
deallocate();
|
||||
sz = _size;
|
||||
if(_size > fixed_size)
|
||||
{
|
||||
ptr = new _Tp[_size];
|
||||
sz = _size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -867,7 +1053,6 @@ template<typename _Tp, size_t fixed_size> inline
|
|||
AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const
|
||||
{ return ptr; }
|
||||
|
||||
#ifndef OPENCV_NOSTL
|
||||
template<> inline std::string CommandLineParser::get<std::string>(int index, bool space_delete) const
|
||||
{
|
||||
return get<String>(index, space_delete);
|
||||
|
|
@ -876,14 +1061,179 @@ template<> inline std::string CommandLineParser::get<std::string>(const String&
|
|||
{
|
||||
return get<String>(name, space_delete);
|
||||
}
|
||||
#endif // OPENCV_NOSTL
|
||||
|
||||
//! @endcond
|
||||
|
||||
|
||||
// Basic Node class for tree building
|
||||
template<class OBJECT>
|
||||
class CV_EXPORTS Node
|
||||
{
|
||||
public:
|
||||
Node()
|
||||
{
|
||||
m_pParent = 0;
|
||||
}
|
||||
Node(OBJECT& payload) : m_payload(payload)
|
||||
{
|
||||
m_pParent = 0;
|
||||
}
|
||||
~Node()
|
||||
{
|
||||
removeChilds();
|
||||
if (m_pParent)
|
||||
{
|
||||
int idx = m_pParent->findChild(this);
|
||||
if (idx >= 0)
|
||||
m_pParent->m_childs.erase(m_pParent->m_childs.begin() + idx);
|
||||
}
|
||||
}
|
||||
|
||||
Node<OBJECT>* findChild(OBJECT& payload) const
|
||||
{
|
||||
for(size_t i = 0; i < this->m_childs.size(); i++)
|
||||
{
|
||||
if(this->m_childs[i]->m_payload == payload)
|
||||
return this->m_childs[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int findChild(Node<OBJECT> *pNode) const
|
||||
{
|
||||
for (size_t i = 0; i < this->m_childs.size(); i++)
|
||||
{
|
||||
if(this->m_childs[i] == pNode)
|
||||
return (int)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void addChild(Node<OBJECT> *pNode)
|
||||
{
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
CV_Assert(pNode->m_pParent == 0);
|
||||
pNode->m_pParent = this;
|
||||
this->m_childs.push_back(pNode);
|
||||
}
|
||||
|
||||
void removeChilds()
|
||||
{
|
||||
for(size_t i = 0; i < m_childs.size(); i++)
|
||||
{
|
||||
m_childs[i]->m_pParent = 0; // avoid excessive parent vector trimming
|
||||
delete m_childs[i];
|
||||
}
|
||||
m_childs.clear();
|
||||
}
|
||||
|
||||
int getDepth()
|
||||
{
|
||||
int count = 0;
|
||||
Node *pParent = m_pParent;
|
||||
while(pParent) count++, pParent = pParent->m_pParent;
|
||||
return count;
|
||||
}
|
||||
|
||||
public:
|
||||
OBJECT m_payload;
|
||||
Node<OBJECT>* m_pParent;
|
||||
std::vector<Node<OBJECT>*> m_childs;
|
||||
};
|
||||
|
||||
// Instrumentation external interface
|
||||
namespace instr
|
||||
{
|
||||
|
||||
#if !defined OPENCV_ABI_CHECK
|
||||
|
||||
enum TYPE
|
||||
{
|
||||
TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function
|
||||
TYPE_MARKER, // Information marker
|
||||
TYPE_WRAPPER, // Wrapper function for implementation
|
||||
TYPE_FUN, // Simple function call
|
||||
};
|
||||
|
||||
enum IMPL
|
||||
{
|
||||
IMPL_PLAIN = 0,
|
||||
IMPL_IPP,
|
||||
IMPL_OPENCL,
|
||||
};
|
||||
|
||||
struct NodeDataTls
|
||||
{
|
||||
NodeDataTls()
|
||||
{
|
||||
m_ticksTotal = 0;
|
||||
}
|
||||
uint64 m_ticksTotal;
|
||||
};
|
||||
|
||||
class CV_EXPORTS NodeData
|
||||
{
|
||||
public:
|
||||
NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, void* retAddress = NULL, bool alwaysExpand = false, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN);
|
||||
NodeData(NodeData &ref);
|
||||
~NodeData();
|
||||
NodeData& operator=(const NodeData&);
|
||||
|
||||
cv::String m_funName;
|
||||
cv::instr::TYPE m_instrType;
|
||||
cv::instr::IMPL m_implType;
|
||||
const char* m_fileName;
|
||||
int m_lineNum;
|
||||
void* m_retAddress;
|
||||
bool m_alwaysExpand;
|
||||
bool m_funError;
|
||||
|
||||
volatile int m_counter;
|
||||
volatile uint64 m_ticksTotal;
|
||||
TLSData<NodeDataTls> m_tls;
|
||||
int m_threads;
|
||||
|
||||
// No synchronization
|
||||
double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; }
|
||||
double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; }
|
||||
};
|
||||
bool operator==(const NodeData& lhs, const NodeData& rhs);
|
||||
|
||||
typedef Node<NodeData> InstrNode;
|
||||
|
||||
CV_EXPORTS InstrNode* getTrace();
|
||||
|
||||
#endif // !defined OPENCV_ABI_CHECK
|
||||
|
||||
|
||||
CV_EXPORTS bool useInstrumentation();
|
||||
CV_EXPORTS void setUseInstrumentation(bool flag);
|
||||
CV_EXPORTS void resetTrace();
|
||||
|
||||
enum FLAGS
|
||||
{
|
||||
FLAGS_NONE = 0,
|
||||
FLAGS_MAPPING = 0x01,
|
||||
FLAGS_EXPAND_SAME_NAMES = 0x02,
|
||||
};
|
||||
|
||||
CV_EXPORTS void setFlags(FLAGS modeFlags);
|
||||
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
|
||||
CV_EXPORTS FLAGS getFlags();
|
||||
}
|
||||
|
||||
namespace utils {
|
||||
|
||||
CV_EXPORTS int getThreadID();
|
||||
|
||||
} // namespace
|
||||
|
||||
} //namespace cv
|
||||
|
||||
#ifndef DISABLE_OPENCV_24_COMPATIBILITY
|
||||
#include "opencv2/core/core_c.h"
|
||||
#endif
|
||||
|
||||
#endif //__OPENCV_CORE_UTILITY_H__
|
||||
#endif //OPENCV_CORE_UTILITY_H
|
||||
71
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/filesystem.hpp
vendored
Normal file
71
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/filesystem.hpp
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// 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_UTILS_FILESYSTEM_HPP
|
||||
#define OPENCV_UTILS_FILESYSTEM_HPP
|
||||
|
||||
namespace cv { namespace utils { namespace fs {
|
||||
|
||||
|
||||
CV_EXPORTS bool exists(const cv::String& path);
|
||||
CV_EXPORTS bool isDirectory(const cv::String& path);
|
||||
|
||||
CV_EXPORTS void remove_all(const cv::String& path);
|
||||
|
||||
|
||||
CV_EXPORTS cv::String getcwd();
|
||||
|
||||
/** Join path components */
|
||||
CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path);
|
||||
|
||||
/**
|
||||
* Generate a list of all files that match the globbing pattern.
|
||||
*
|
||||
* Result entries are prefixed by base directory path.
|
||||
*
|
||||
* @param directory base directory
|
||||
* @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
|
||||
* @param[out] result result of globing.
|
||||
* @param recursive scan nested directories too
|
||||
* @param includeDirectories include directories into results list
|
||||
*/
|
||||
CV_EXPORTS void glob(const cv::String& directory, const cv::String& pattern,
|
||||
CV_OUT std::vector<cv::String>& result,
|
||||
bool recursive = false, bool includeDirectories = false);
|
||||
|
||||
/**
|
||||
* Generate a list of all files that match the globbing pattern.
|
||||
*
|
||||
* @param directory base directory
|
||||
* @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
|
||||
* @param[out] result globbing result with relative paths from base directory
|
||||
* @param recursive scan nested directories too
|
||||
* @param includeDirectories include directories into results list
|
||||
*/
|
||||
CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pattern,
|
||||
CV_OUT std::vector<cv::String>& result,
|
||||
bool recursive = false, bool includeDirectories = false);
|
||||
|
||||
|
||||
CV_EXPORTS bool createDirectory(const cv::String& path);
|
||||
CV_EXPORTS bool createDirectories(const cv::String& path);
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
// TODO
|
||||
//CV_EXPORTS cv::String getTempDirectory();
|
||||
|
||||
/**
|
||||
* @brief Returns directory to store OpenCV cache files
|
||||
* Create sub-directory in common OpenCV cache directory if it doesn't exist.
|
||||
* @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory.
|
||||
* @param configuration_name optional name of configuration parameter name which overrides default behavior.
|
||||
* @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user.
|
||||
*/
|
||||
CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
}}} // namespace
|
||||
|
||||
#endif // OPENCV_UTILS_FILESYSTEM_HPP
|
||||
22
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/logger.defines.hpp
vendored
Normal file
22
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/logger.defines.hpp
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// 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_LOGGER_DEFINES_HPP
|
||||
#define OPENCV_LOGGER_DEFINES_HPP
|
||||
|
||||
//! @addtogroup core_logging
|
||||
//! @{
|
||||
|
||||
// Supported logging levels and their semantic
|
||||
#define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogLevel() call
|
||||
#define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error)
|
||||
#define CV_LOG_LEVEL_ERROR 2 //!< Error message
|
||||
#define CV_LOG_LEVEL_WARN 3 //!< Warning message
|
||||
#define CV_LOG_LEVEL_INFO 4 //!< Info message
|
||||
#define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build.
|
||||
#define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // OPENCV_LOGGER_DEFINES_HPP
|
||||
87
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/logger.hpp
vendored
Normal file
87
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/logger.hpp
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// 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_LOGGER_HPP
|
||||
#define OPENCV_LOGGER_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <limits.h> // INT_MAX
|
||||
|
||||
#include "logger.defines.hpp"
|
||||
|
||||
//! @addtogroup core_logging
|
||||
// This section describes OpenCV logging utilities.
|
||||
//
|
||||
//! @{
|
||||
|
||||
namespace cv {
|
||||
namespace utils {
|
||||
namespace logging {
|
||||
|
||||
//! Supported logging levels and their semantic
|
||||
enum LogLevel {
|
||||
LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call
|
||||
LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error)
|
||||
LOG_LEVEL_ERROR = 2, //!< Error message
|
||||
LOG_LEVEL_WARNING = 3, //!< Warning message
|
||||
LOG_LEVEL_INFO = 4, //!< Info message
|
||||
LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build.
|
||||
LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
|
||||
#ifndef CV_DOXYGEN
|
||||
ENUM_LOG_LEVEL_FORCE_INT = INT_MAX
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Set global logging level
|
||||
@return previous logging level
|
||||
*/
|
||||
CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel);
|
||||
/** Get global logging level */
|
||||
CV_EXPORTS LogLevel getLogLevel();
|
||||
|
||||
namespace internal {
|
||||
/** Write log message */
|
||||
CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char* message);
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
* \def CV_LOG_STRIP_LEVEL
|
||||
*
|
||||
* Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|DISABLED] to compile out anything at that and before that logging level
|
||||
*/
|
||||
#ifndef CV_LOG_STRIP_LEVEL
|
||||
# if defined NDEBUG
|
||||
# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG
|
||||
# else
|
||||
# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define CV_LOG_FATAL(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_FATAL) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_FATAL, ss.str().c_str()); break; }
|
||||
#define CV_LOG_ERROR(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_ERROR) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_ERROR, ss.str().c_str()); break; }
|
||||
#define CV_LOG_WARNING(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_WARNING) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_WARNING, ss.str().c_str()); break; }
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
|
||||
#define CV_LOG_INFO(tag, ...)
|
||||
#else
|
||||
#define CV_LOG_INFO(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_INFO) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_INFO, ss.str().c_str()); break; }
|
||||
#endif
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
|
||||
#define CV_LOG_DEBUG(tag, ...)
|
||||
#else
|
||||
#define CV_LOG_DEBUG(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_DEBUG) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, ss.str().c_str()); break; }
|
||||
#endif
|
||||
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
|
||||
#define CV_LOG_VERBOSE(tag, v, ...)
|
||||
#else
|
||||
#define CV_LOG_VERBOSE(tag, v, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_VERBOSE) break; std::stringstream ss; ss << "[VERB" << v << ":" << cv::utils::getThreadID() << "] " << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_VERBOSE, ss.str().c_str()); break; }
|
||||
#endif
|
||||
|
||||
|
||||
}}} // namespace
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // OPENCV_LOGGER_HPP
|
||||
250
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/trace.hpp
vendored
Normal file
250
lib/3rdParty/OpenCV3.4/include/opencv2/core/utils/trace.hpp
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
// 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_TRACE_HPP
|
||||
#define OPENCV_TRACE_HPP
|
||||
|
||||
#include <opencv2/core/cvdef.h>
|
||||
|
||||
//! @addtogroup core_logging
|
||||
// This section describes OpenCV tracing utilities.
|
||||
//
|
||||
//! @{
|
||||
|
||||
namespace cv {
|
||||
namespace utils {
|
||||
namespace trace {
|
||||
|
||||
//! Macro to trace function
|
||||
#define CV_TRACE_FUNCTION()
|
||||
|
||||
#define CV_TRACE_FUNCTION_SKIP_NESTED()
|
||||
|
||||
//! Trace code scope.
|
||||
//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "initialize".
|
||||
#define CV_TRACE_REGION(name_as_static_string_literal)
|
||||
//! mark completed of the current opened region and create new one
|
||||
//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "step1".
|
||||
#define CV_TRACE_REGION_NEXT(name_as_static_string_literal)
|
||||
|
||||
//! Macro to trace argument value
|
||||
#define CV_TRACE_ARG(arg_id)
|
||||
|
||||
//! Macro to trace argument value (expanded version)
|
||||
#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value)
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CV_TRACE_NS cv::utils::trace
|
||||
|
||||
namespace details {
|
||||
|
||||
#ifndef __OPENCV_TRACE
|
||||
# if defined __OPENCV_BUILD && !defined __OPENCV_TESTS && !defined __OPENCV_APPS
|
||||
# define __OPENCV_TRACE 1
|
||||
# else
|
||||
# define __OPENCV_TRACE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_TRACE_FILENAME
|
||||
# define CV_TRACE_FILENAME __FILE__
|
||||
#endif
|
||||
|
||||
#ifndef CV__TRACE_FUNCTION
|
||||
# if defined _MSC_VER
|
||||
# define CV__TRACE_FUNCTION __FUNCSIG__
|
||||
# elif defined __GNUC__
|
||||
# define CV__TRACE_FUNCTION __PRETTY_FUNCTION__
|
||||
# else
|
||||
# define CV__TRACE_FUNCTION "<unknown>"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! Thread-local instance (usually allocated on stack)
|
||||
class CV_EXPORTS Region
|
||||
{
|
||||
public:
|
||||
struct LocationExtraData;
|
||||
struct LocationStaticStorage
|
||||
{
|
||||
LocationExtraData** ppExtra; //< implementation specific data
|
||||
const char* name; //< region name (function name or other custom name)
|
||||
const char* filename; //< source code filename
|
||||
int line; //< source code line
|
||||
int flags; //< flags (implementation code path: Plain, IPP, OpenCL)
|
||||
};
|
||||
|
||||
Region(const LocationStaticStorage& location);
|
||||
inline ~Region()
|
||||
{
|
||||
if (implFlags != 0)
|
||||
destroy();
|
||||
CV_DbgAssert(implFlags == 0);
|
||||
CV_DbgAssert(pImpl == NULL);
|
||||
}
|
||||
|
||||
class Impl;
|
||||
Impl* pImpl; // NULL if current region is not active
|
||||
int implFlags; // see RegionFlag, 0 if region is ignored
|
||||
|
||||
bool isActive() const { return pImpl != NULL; }
|
||||
|
||||
void destroy();
|
||||
private:
|
||||
Region(const Region&); // disabled
|
||||
Region& operator= (const Region&); // disabled
|
||||
};
|
||||
|
||||
//! Specify region flags
|
||||
enum RegionLocationFlag {
|
||||
REGION_FLAG_FUNCTION = (1 << 0), //< region is function (=1) / nested named region (=0)
|
||||
REGION_FLAG_APP_CODE = (1 << 1), //< region is Application code (=1) / OpenCV library code (=0)
|
||||
REGION_FLAG_SKIP_NESTED = (1 << 2), //< avoid processing of nested regions
|
||||
|
||||
REGION_FLAG_IMPL_IPP = (1 << 16), //< region is part of IPP code path
|
||||
REGION_FLAG_IMPL_OPENCL = (2 << 16), //< region is part of OpenCL code path
|
||||
REGION_FLAG_IMPL_OPENVX = (3 << 16), //< region is part of OpenVX code path
|
||||
|
||||
REGION_FLAG_IMPL_MASK = (15 << 16),
|
||||
|
||||
REGION_FLAG_REGION_FORCE = (1 << 30),
|
||||
REGION_FLAG_REGION_NEXT = (1 << 31), //< close previous region (see #CV_TRACE_REGION_NEXT macro)
|
||||
|
||||
ENUM_REGION_FLAG_FORCE_INT = INT_MAX
|
||||
};
|
||||
|
||||
struct CV_EXPORTS TraceArg {
|
||||
public:
|
||||
struct ExtraData;
|
||||
ExtraData** ppExtra;
|
||||
const char* name;
|
||||
int flags;
|
||||
};
|
||||
/** @brief Add meta information to current region (function)
|
||||
* See CV_TRACE_ARG macro
|
||||
* @param arg argument information structure (global static cache)
|
||||
* @param value argument value (can by dynamic string literal in case of string, static allocation is not required)
|
||||
*/
|
||||
CV_EXPORTS void traceArg(const TraceArg& arg, const char* value);
|
||||
//! @overload
|
||||
CV_EXPORTS void traceArg(const TraceArg& arg, int value);
|
||||
//! @overload
|
||||
CV_EXPORTS void traceArg(const TraceArg& arg, int64 value);
|
||||
//! @overload
|
||||
CV_EXPORTS void traceArg(const TraceArg& arg, double value);
|
||||
|
||||
#define CV__TRACE_LOCATION_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_, loc_id), __LINE__)
|
||||
#define CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_extra_, loc_id) , __LINE__)
|
||||
|
||||
#define CV__TRACE_DEFINE_LOCATION_(loc_id, name, flags) \
|
||||
static CV_TRACE_NS::details::Region::LocationExtraData* CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) = 0; \
|
||||
static const CV_TRACE_NS::details::Region::LocationStaticStorage \
|
||||
CV__TRACE_LOCATION_VARNAME(loc_id) = { &(CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id)), name, CV_TRACE_FILENAME, __LINE__, flags};
|
||||
|
||||
#define CV__TRACE_DEFINE_LOCATION_FN(name, flags) CV__TRACE_DEFINE_LOCATION_(fn, name, (flags | CV_TRACE_NS::details::REGION_FLAG_FUNCTION))
|
||||
|
||||
|
||||
#define CV__TRACE_OPENCV_FUNCTION() \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, 0); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
#define CV__TRACE_OPENCV_FUNCTION_NAME(name) \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(name, 0); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
#define CV__TRACE_APP_FUNCTION() \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
#define CV__TRACE_APP_FUNCTION_NAME(name) \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
|
||||
#define CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED() \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
#define CV__TRACE_OPENCV_FUNCTION_NAME_SKIP_NESTED(name) \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
#define CV__TRACE_APP_FUNCTION_SKIP_NESTED() \
|
||||
CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED | CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
|
||||
const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
|
||||
|
||||
|
||||
#define CV__TRACE_REGION_(name_as_static_string_literal, flags) \
|
||||
CV__TRACE_DEFINE_LOCATION_(region, name_as_static_string_literal, flags); \
|
||||
CV_TRACE_NS::details::Region CVAUX_CONCAT(__region_, __LINE__)(CV__TRACE_LOCATION_VARNAME(region));
|
||||
|
||||
#define CV__TRACE_REGION(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, 0)
|
||||
#define CV__TRACE_REGION_NEXT(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, CV_TRACE_NS::details::REGION_FLAG_REGION_NEXT)
|
||||
|
||||
#define CV__TRACE_ARG_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_ ## arg_id, __LINE__)
|
||||
#define CV__TRACE_ARG_EXTRA_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_extra_ ## arg_id, __LINE__)
|
||||
|
||||
#define CV__TRACE_DEFINE_ARG_(arg_id, name, flags) \
|
||||
static CV_TRACE_NS::details::TraceArg::ExtraData* CV__TRACE_ARG_EXTRA_VARNAME(arg_id) = 0; \
|
||||
static const CV_TRACE_NS::details::TraceArg \
|
||||
CV__TRACE_ARG_VARNAME(arg_id) = { &(CV__TRACE_ARG_EXTRA_VARNAME(arg_id)), name, flags };
|
||||
|
||||
#define CV__TRACE_ARG_VALUE(arg_id, arg_name, value) \
|
||||
CV__TRACE_DEFINE_ARG_(arg_id, arg_name, 0); \
|
||||
CV_TRACE_NS::details::traceArg((CV__TRACE_ARG_VARNAME(arg_id)), value);
|
||||
|
||||
#define CV__TRACE_ARG(arg_id) CV_TRACE_ARG_VALUE(arg_id, #arg_id, (arg_id))
|
||||
|
||||
} // namespace
|
||||
|
||||
#ifndef OPENCV_DISABLE_TRACE
|
||||
#undef CV_TRACE_FUNCTION
|
||||
#undef CV_TRACE_FUNCTION_SKIP_NESTED
|
||||
#if __OPENCV_TRACE
|
||||
#define CV_TRACE_FUNCTION CV__TRACE_OPENCV_FUNCTION
|
||||
#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED
|
||||
#else
|
||||
#define CV_TRACE_FUNCTION CV__TRACE_APP_FUNCTION
|
||||
#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_APP_FUNCTION_SKIP_NESTED
|
||||
#endif
|
||||
|
||||
#undef CV_TRACE_REGION
|
||||
#define CV_TRACE_REGION CV__TRACE_REGION
|
||||
|
||||
#undef CV_TRACE_REGION_NEXT
|
||||
#define CV_TRACE_REGION_NEXT CV__TRACE_REGION_NEXT
|
||||
|
||||
#undef CV_TRACE_ARG_VALUE
|
||||
#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) \
|
||||
if (__region_fn.isActive()) \
|
||||
{ \
|
||||
CV__TRACE_ARG_VALUE(arg_id, arg_name, value); \
|
||||
}
|
||||
|
||||
#undef CV_TRACE_ARG
|
||||
#define CV_TRACE_ARG CV__TRACE_ARG
|
||||
|
||||
#endif // OPENCV_DISABLE_TRACE
|
||||
|
||||
#ifdef OPENCV_TRACE_VERBOSE
|
||||
#define CV_TRACE_FUNCTION_VERBOSE CV_TRACE_FUNCTION
|
||||
#define CV_TRACE_REGION_VERBOSE CV_TRACE_REGION
|
||||
#define CV_TRACE_REGION_NEXT_VERBOSE CV_TRACE_REGION_NEXT
|
||||
#define CV_TRACE_ARG_VALUE_VERBOSE CV_TRACE_ARG_VALUE
|
||||
#define CV_TRACE_ARG_VERBOSE CV_TRACE_ARG
|
||||
#else
|
||||
#define CV_TRACE_FUNCTION_VERBOSE(...)
|
||||
#define CV_TRACE_REGION_VERBOSE(...)
|
||||
#define CV_TRACE_REGION_NEXT_VERBOSE(...)
|
||||
#define CV_TRACE_ARG_VALUE_VERBOSE(...)
|
||||
#define CV_TRACE_ARG_VERBOSE(...)
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
}}} // namespace
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // OPENCV_TRACE_HPP
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
// Copyright (C) 2015, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#ifndef __OPENCV_CORE_VA_INTEL_HPP__
|
||||
#define __OPENCV_CORE_VA_INTEL_HPP__
|
||||
#ifndef OPENCV_CORE_VA_INTEL_HPP
|
||||
#define OPENCV_CORE_VA_INTEL_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error va_intel.hpp header must be compiled as C++
|
||||
|
|
@ -74,4 +74,4 @@ CV_EXPORTS void convertFromVASurface(VADisplay display, VASurfaceID surface, Siz
|
|||
|
||||
}} // namespace cv::va_intel
|
||||
|
||||
#endif /* __OPENCV_CORE_VA_INTEL_HPP__ */
|
||||
#endif /* OPENCV_CORE_VA_INTEL_HPP */
|
||||
|
|
@ -47,18 +47,18 @@
|
|||
Usefull to test in user programs
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_VERSION_HPP__
|
||||
#define __OPENCV_VERSION_HPP__
|
||||
#ifndef OPENCV_VERSION_HPP
|
||||
#define OPENCV_VERSION_HPP
|
||||
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 1
|
||||
#define CV_VERSION_MINOR 4
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_STATUS ""
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
#define CVAUX_STRW_EXP(__A) L#__A
|
||||
#define CVAUX_STRW_EXP(__A) L ## #__A
|
||||
#define CVAUX_STRW(__A) CVAUX_STRW_EXP(__A)
|
||||
|
||||
#define CV_VERSION CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS
|
||||
1070
lib/3rdParty/OpenCV3.4/include/opencv2/core/vsx_utils.hpp
vendored
Normal file
1070
lib/3rdParty/OpenCV3.4/include/opencv2/core/vsx_utils.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -39,8 +39,8 @@
|
|||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_WIMAGE_HPP__
|
||||
#define __OPENCV_CORE_WIMAGE_HPP__
|
||||
#ifndef OPENCV_CORE_WIMAGE_HPP
|
||||
#define OPENCV_CORE_WIMAGE_HPP
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
|
|
@ -1,6 +1,15 @@
|
|||
#ifndef OPENCV_CVCONFIG_H_INCLUDED
|
||||
#define OPENCV_CVCONFIG_H_INCLUDED
|
||||
|
||||
/* OpenCV compiled as static or dynamic libs */
|
||||
#define BUILD_SHARED_LIBS
|
||||
|
||||
/* OpenCV intrinsics optimized code */
|
||||
#define CV_ENABLE_INTRINSICS
|
||||
|
||||
/* OpenCV additional optimized code */
|
||||
/* #undef CV_DISABLE_OPTIMIZATION */
|
||||
|
||||
/* Compile for 'real' NVIDIA GPU architectures */
|
||||
#define CUDA_ARCH_BIN ""
|
||||
|
||||
|
|
@ -26,10 +35,10 @@
|
|||
/* #undef HAVE_CARBON */
|
||||
|
||||
/* AMD's Basic Linear Algebra Subprograms Library*/
|
||||
#define HAVE_CLAMDBLAS
|
||||
/* #undef HAVE_CLAMDBLAS */
|
||||
|
||||
/* AMD's OpenCL Fast Fourier Transform Library*/
|
||||
#define HAVE_CLAMDFFT
|
||||
/* #undef HAVE_CLAMDFFT */
|
||||
|
||||
/* Clp support */
|
||||
/* #undef HAVE_CLP */
|
||||
|
|
@ -71,12 +80,6 @@
|
|||
/* FFMpeg video library */
|
||||
#define HAVE_FFMPEG
|
||||
|
||||
/* ffmpeg's libswscale */
|
||||
#define HAVE_FFMPEG_SWSCALE
|
||||
|
||||
/* ffmpeg in Gentoo */
|
||||
#define HAVE_GENTOO_FFMPEG
|
||||
|
||||
/* Geospatial Data Abstraction Library */
|
||||
/* #undef HAVE_GDAL */
|
||||
|
||||
|
|
@ -89,15 +92,19 @@
|
|||
/* GTK+ 2.x toolkit */
|
||||
/* #undef HAVE_GTK */
|
||||
|
||||
/* Halide support */
|
||||
/* #undef HAVE_HALIDE */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Intel Perceptual Computing SDK library */
|
||||
/* #undef HAVE_INTELPERC */
|
||||
|
||||
/* Intel Integrated Performance Primitives */
|
||||
#define HAVE_IPP
|
||||
#define HAVE_IPP_ICV_ONLY
|
||||
#define HAVE_IPP_ICV
|
||||
#define HAVE_IPP_IW
|
||||
|
||||
/* Intel IPP Async */
|
||||
/* #undef HAVE_IPP_A */
|
||||
|
|
@ -111,6 +118,9 @@
|
|||
/* libpng/png.h needs to be included */
|
||||
/* #undef HAVE_LIBPNG_PNG_H */
|
||||
|
||||
/* GDCM DICOM codec */
|
||||
/* #undef HAVE_GDCM */
|
||||
|
||||
/* V4L/V4L2 capturing support via libv4l */
|
||||
/* #undef HAVE_LIBV4L */
|
||||
|
||||
|
|
@ -120,6 +130,9 @@
|
|||
/* NVidia Video Decoding API*/
|
||||
/* #undef HAVE_NVCUVID */
|
||||
|
||||
/* NVidia Video Encoding API*/
|
||||
/* #undef HAVE_NVCUVENC */
|
||||
|
||||
/* OpenCL Support */
|
||||
#define HAVE_OPENCL
|
||||
/* #undef HAVE_OPENCL_STATIC */
|
||||
|
|
@ -141,7 +154,7 @@
|
|||
#define HAVE_PNG
|
||||
|
||||
/* Posix threads (pthreads) */
|
||||
/* #undef HAVE_PTHREADS */
|
||||
/* #undef HAVE_PTHREAD */
|
||||
|
||||
/* parallel_for with pthreads */
|
||||
/* #undef HAVE_PTHREADS_PF */
|
||||
|
|
@ -194,3 +207,42 @@
|
|||
|
||||
/* Intel VA-API/OpenCL */
|
||||
/* #undef HAVE_VA_INTEL */
|
||||
|
||||
/* Intel Media SDK */
|
||||
/* #undef HAVE_MFX */
|
||||
|
||||
/* Lapack */
|
||||
/* #undef HAVE_LAPACK */
|
||||
|
||||
/* Library was compiled with functions instrumentation */
|
||||
/* #undef ENABLE_INSTRUMENTATION */
|
||||
|
||||
/* OpenVX */
|
||||
/* #undef HAVE_OPENVX */
|
||||
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
/*defined(HAVE_OPENNI) || too specialized */ \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
#define HAVE_VIDEO_INPUT
|
||||
#endif
|
||||
|
||||
#if /*defined(HAVE_XINE) || */\
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
#define HAVE_VIDEO_OUTPUT
|
||||
#endif
|
||||
|
||||
/* OpenCV trace utilities */
|
||||
#define OPENCV_TRACE
|
||||
|
||||
|
||||
#endif // OPENCV_CVCONFIG_H_INCLUDED
|
||||
|
|
@ -10,8 +10,7 @@
|
|||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
@ -40,19 +39,26 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_ALL_HPP__
|
||||
#define __OPENCV_ALL_HPP__
|
||||
#ifndef OPENCV_DNN_HPP
|
||||
#define OPENCV_DNN_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/photo.hpp"
|
||||
#include "opencv2/video.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
#include "opencv2/objdetect.hpp"
|
||||
#include "opencv2/calib3d.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/videoio.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/ml.hpp"
|
||||
// This is an umbrealla header to include into you project.
|
||||
// We are free to change headers layout in dnn subfolder, so please include
|
||||
// this header for future compatibility
|
||||
|
||||
#endif
|
||||
|
||||
/** @defgroup dnn Deep Neural Network module
|
||||
@{
|
||||
This module contains:
|
||||
- API for new layers creation, layers are building bricks of neural networks;
|
||||
- set of built-in most-useful Layers;
|
||||
- API to constuct and modify comprehensive neural networks from layers;
|
||||
- functionality for loading serialized networks models from differnet frameworks.
|
||||
|
||||
Functionality of this module is designed only for forward pass computations (i. e. network testing).
|
||||
A network training is in principle not supported.
|
||||
@}
|
||||
*/
|
||||
#include <opencv2/dnn/dnn.hpp>
|
||||
|
||||
#endif /* OPENCV_DNN_HPP */
|
||||
583
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/all_layers.hpp
vendored
Normal file
583
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/all_layers.hpp
vendored
Normal file
|
|
@ -0,0 +1,583 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DNN_DNN_ALL_LAYERS_HPP
|
||||
#define OPENCV_DNN_DNN_ALL_LAYERS_HPP
|
||||
#include <opencv2/dnn.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
//! @addtogroup dnn
|
||||
//! @{
|
||||
|
||||
/** @defgroup dnnLayerList Partial List of Implemented Layers
|
||||
@{
|
||||
This subsection of dnn module contains information about bult-in layers and their descriptions.
|
||||
|
||||
Classes listed here, in fact, provides C++ API for creating intances of bult-in layers.
|
||||
In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones.
|
||||
You can use both API, but factory API is less convinient for native C++ programming and basically designed for use inside importers (see @ref readNetFromCaffe(), @ref readNetFromTorch(), @ref readNetFromTensorflow()).
|
||||
|
||||
Bult-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers.
|
||||
In partuclar, the following layers and Caffe importer were tested to reproduce <a href="http://caffe.berkeleyvision.org/tutorial/layers.html">Caffe</a> functionality:
|
||||
- Convolution
|
||||
- Deconvolution
|
||||
- Pooling
|
||||
- InnerProduct
|
||||
- TanH, ReLU, Sigmoid, BNLL, Power, AbsVal
|
||||
- Softmax
|
||||
- Reshape, Flatten, Slice, Split
|
||||
- LRN
|
||||
- MVN
|
||||
- Dropout (since it does nothing on forward pass -))
|
||||
*/
|
||||
|
||||
class CV_EXPORTS BlankLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<Layer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
//! LSTM recurrent layer
|
||||
class CV_EXPORTS LSTMLayer : public Layer
|
||||
{
|
||||
public:
|
||||
/** Creates instance of LSTM layer */
|
||||
static Ptr<LSTMLayer> create(const LayerParams& params);
|
||||
|
||||
/** @deprecated Use LayerParams::blobs instead.
|
||||
@brief Set trained weights for LSTM layer.
|
||||
|
||||
LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights.
|
||||
|
||||
Let @f$x_t@f$ be current input, @f$h_t@f$ be current output, @f$c_t@f$ be current state.
|
||||
Than current output and current cell state is computed as follows:
|
||||
@f{eqnarray*}{
|
||||
h_t &= o_t \odot tanh(c_t), \\
|
||||
c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\
|
||||
@f}
|
||||
where @f$\odot@f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t@f$ is internal gates that are computed using learned wights.
|
||||
|
||||
Gates are computed as follows:
|
||||
@f{eqnarray*}{
|
||||
i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\
|
||||
f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\
|
||||
o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\
|
||||
g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\
|
||||
@f}
|
||||
where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices:
|
||||
@f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$.
|
||||
|
||||
For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$
|
||||
(i.e. @f$W_x@f$ is vertical contacentaion of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$.
|
||||
The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$
|
||||
and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$.
|
||||
|
||||
@param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_h @f$)
|
||||
@param Wx is matrix defining how current input is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_x @f$)
|
||||
@param b is bias vector (i.e. according to abovemtioned notation is @f$ b @f$)
|
||||
*/
|
||||
CV_DEPRECATED virtual void setWeights(const Mat &Wh, const Mat &Wx, const Mat &b) = 0;
|
||||
|
||||
/** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape.
|
||||
* @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used,
|
||||
* where `Wh` is parameter from setWeights().
|
||||
*/
|
||||
virtual void setOutShape(const MatShape &outTailShape = MatShape()) = 0;
|
||||
|
||||
/** @deprecated Use flag `produce_cell_output` in LayerParams.
|
||||
* @brief Specifies either interpet first dimension of input blob as timestamp dimenion either as sample.
|
||||
*
|
||||
* If flag is set to true then shape of input blob will be interpeted as [`T`, `N`, `[data dims]`] where `T` specifies number of timpestamps, `N` is number of independent streams.
|
||||
* In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times.
|
||||
*
|
||||
* If flag is set to false then shape of input blob will be interpeted as [`N`, `[data dims]`].
|
||||
* In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`].
|
||||
*/
|
||||
CV_DEPRECATED virtual void setUseTimstampsDim(bool use = true) = 0;
|
||||
|
||||
/** @deprecated Use flag `use_timestamp_dim` in LayerParams.
|
||||
* @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output.
|
||||
* @details Shape of the second output is the same as first output.
|
||||
*/
|
||||
CV_DEPRECATED virtual void setProduceCellOutput(bool produce = false) = 0;
|
||||
|
||||
/* In common case it use single input with @f$x_t@f$ values to compute output(s) @f$h_t@f$ (and @f$c_t@f$).
|
||||
* @param input should contain packed values @f$x_t@f$
|
||||
* @param output contains computed outputs: @f$h_t@f$ (and @f$c_t@f$ if setProduceCellOutput() flag was set to true).
|
||||
*
|
||||
* If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`],
|
||||
* where `T` specifies number of timpestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]).
|
||||
*
|
||||
* If setUseTimstampsDim() is set to fase then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension.
|
||||
* (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]).
|
||||
*/
|
||||
|
||||
int inputNameToIndex(String inputName);
|
||||
int outputNameToIndex(String outputName);
|
||||
};
|
||||
|
||||
/** @brief Classical recurrent layer
|
||||
|
||||
Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$.
|
||||
|
||||
- input: should contain packed input @f$x_t@f$.
|
||||
- output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true).
|
||||
|
||||
input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively.
|
||||
|
||||
output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix.
|
||||
|
||||
If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix.
|
||||
*/
|
||||
class CV_EXPORTS RNNLayer : public Layer
|
||||
{
|
||||
public:
|
||||
/** Creates instance of RNNLayer */
|
||||
static Ptr<RNNLayer> create(const LayerParams& params);
|
||||
|
||||
/** Setups learned weights.
|
||||
|
||||
Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows:
|
||||
@f{eqnarray*}{
|
||||
h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\
|
||||
o_t &= tanh&(W_{ho} h_t + b_o),
|
||||
@f}
|
||||
|
||||
@param Wxh is @f$ W_{xh} @f$ matrix
|
||||
@param bh is @f$ b_{h} @f$ vector
|
||||
@param Whh is @f$ W_{hh} @f$ matrix
|
||||
@param Who is @f$ W_{xo} @f$ matrix
|
||||
@param bo is @f$ b_{o} @f$ vector
|
||||
*/
|
||||
virtual void setWeights(const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo) = 0;
|
||||
|
||||
/** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output.
|
||||
* @details Shape of the second output is the same as first output.
|
||||
*/
|
||||
virtual void setProduceHiddenOutput(bool produce = false) = 0;
|
||||
|
||||
};
|
||||
|
||||
class CV_EXPORTS BaseConvolutionLayer : public Layer
|
||||
{
|
||||
public:
|
||||
Size kernel, stride, pad, dilation, adjustPad;
|
||||
String padMode;
|
||||
int numOutput;
|
||||
};
|
||||
|
||||
class CV_EXPORTS ConvolutionLayer : public BaseConvolutionLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<BaseConvolutionLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS DeconvolutionLayer : public BaseConvolutionLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<BaseConvolutionLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS LRNLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int type;
|
||||
|
||||
int size;
|
||||
float alpha, beta, bias;
|
||||
bool normBySize;
|
||||
|
||||
static Ptr<LRNLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS PoolingLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int type;
|
||||
Size kernel, stride, pad;
|
||||
bool globalPooling;
|
||||
bool computeMaxIdx;
|
||||
String padMode;
|
||||
bool ceilMode;
|
||||
// ROIPooling parameters.
|
||||
Size pooledSize;
|
||||
float spatialScale;
|
||||
// PSROIPooling parameters.
|
||||
int psRoiOutChannels;
|
||||
|
||||
static Ptr<PoolingLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS SoftmaxLayer : public Layer
|
||||
{
|
||||
public:
|
||||
bool logSoftMax;
|
||||
|
||||
static Ptr<SoftmaxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS InnerProductLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int axis;
|
||||
static Ptr<InnerProductLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS MVNLayer : public Layer
|
||||
{
|
||||
public:
|
||||
float eps;
|
||||
bool normVariance, acrossChannels;
|
||||
|
||||
static Ptr<MVNLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/* Reshaping */
|
||||
|
||||
class CV_EXPORTS ReshapeLayer : public Layer
|
||||
{
|
||||
public:
|
||||
MatShape newShapeDesc;
|
||||
Range newShapeRange;
|
||||
|
||||
static Ptr<ReshapeLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS FlattenLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<FlattenLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ConcatLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int axis;
|
||||
/**
|
||||
* @brief Add zero padding in case of concatenation of blobs with different
|
||||
* spatial sizes.
|
||||
*
|
||||
* Details: https://github.com/torch/nn/blob/master/doc/containers.md#depthconcat
|
||||
*/
|
||||
bool padding;
|
||||
|
||||
static Ptr<ConcatLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS SplitLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int outputsCount; //!< Number of copies that will be produced (is ignored when negative).
|
||||
|
||||
static Ptr<SplitLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
/**
|
||||
* Slice layer has several modes:
|
||||
* 1. Caffe mode
|
||||
* @param[in] axis Axis of split operation
|
||||
* @param[in] slice_point Array of split points
|
||||
*
|
||||
* Number of output blobs equals to number of split points plus one. The
|
||||
* first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis,
|
||||
* the second output blob is a slice of input from @p slice_point[0] to
|
||||
* @p slice_point[1] - 1 by @p axis and the last output blob is a slice of
|
||||
* input from @p slice_point[-1] up to the end of @p axis size.
|
||||
*
|
||||
* 2. TensorFlow mode
|
||||
* @param begin Vector of start indices
|
||||
* @param size Vector of sizes
|
||||
*
|
||||
* More convinient numpy-like slice. One and only output blob
|
||||
* is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]`
|
||||
*
|
||||
* 3. Torch mode
|
||||
* @param axis Axis of split operation
|
||||
*
|
||||
* Split input blob on the equal parts by @p axis.
|
||||
*/
|
||||
class CV_EXPORTS SliceLayer : public Layer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Vector of slice ranges.
|
||||
*
|
||||
* The first dimension equals number of output blobs.
|
||||
* Inner vector has slice ranges for the first number of input dimensions.
|
||||
*/
|
||||
std::vector<std::vector<Range> > sliceRanges;
|
||||
int axis;
|
||||
|
||||
static Ptr<SliceLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS PermuteLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<PermuteLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Adds extra values for specific axes.
|
||||
* @param paddings Vector of paddings in format
|
||||
* @code
|
||||
* [ pad_before, pad_after, // [0]th dimension
|
||||
* pad_before, pad_after, // [1]st dimension
|
||||
* ...
|
||||
* pad_before, pad_after ] // [n]th dimension
|
||||
* @endcode
|
||||
* that represents number of padded values at every dimension
|
||||
* starting from the first one. The rest of dimensions won't
|
||||
* be padded.
|
||||
* @param value Value to be padded. Defaults to zero.
|
||||
* @param type Padding type: 'constant', 'reflect'
|
||||
* @param input_dims Torch's parameter. If @p input_dims is not equal to the
|
||||
* actual input dimensionality then the `[0]th` dimension
|
||||
* is considered as a batch dimension and @p paddings are shifted
|
||||
* to a one dimension. Defaults to `-1` that means padding
|
||||
* corresponding to @p paddings.
|
||||
*/
|
||||
class CV_EXPORTS PaddingLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<PaddingLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/* Activations */
|
||||
class CV_EXPORTS ActivationLayer : public Layer
|
||||
{
|
||||
public:
|
||||
virtual void forwardSlice(const float* src, float* dst, int len,
|
||||
size_t outPlaneSize, int cn0, int cn1) const = 0;
|
||||
};
|
||||
|
||||
class CV_EXPORTS ReLULayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
float negativeSlope;
|
||||
|
||||
static Ptr<ReLULayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ReLU6Layer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<ReLU6Layer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<Layer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ELULayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<ELULayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS TanHLayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<TanHLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS SigmoidLayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<SigmoidLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS BNLLLayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<BNLLLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS AbsLayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<AbsLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS PowerLayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
float power, scale, shift;
|
||||
|
||||
static Ptr<PowerLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
/* Layers used in semantic segmentation */
|
||||
|
||||
class CV_EXPORTS CropLayer : public Layer
|
||||
{
|
||||
public:
|
||||
int startAxis;
|
||||
std::vector<int> offset;
|
||||
|
||||
static Ptr<CropLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS EltwiseLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<EltwiseLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS BatchNormLayer : public Layer
|
||||
{
|
||||
public:
|
||||
bool hasWeights, hasBias;
|
||||
float epsilon;
|
||||
|
||||
virtual void getScaleShift(Mat& scale, Mat& shift) const = 0;
|
||||
static Ptr<BatchNormLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS MaxUnpoolLayer : public Layer
|
||||
{
|
||||
public:
|
||||
Size poolKernel;
|
||||
Size poolPad;
|
||||
Size poolStride;
|
||||
|
||||
static Ptr<MaxUnpoolLayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ScaleLayer : public Layer
|
||||
{
|
||||
public:
|
||||
bool hasBias;
|
||||
|
||||
static Ptr<ScaleLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ShiftLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<ShiftLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS PriorBoxLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<PriorBoxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ReorgLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<ReorgLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS RegionLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<RegionLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS DetectionOutputLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<DetectionOutputLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief \f$ L_p \f$ - normalization layer.
|
||||
* @param p Normalization factor. The most common `p = 1` for \f$ L_1 \f$ -
|
||||
* normalization or `p = 2` for \f$ L_2 \f$ - normalization or a custom one.
|
||||
* @param eps Parameter \f$ \epsilon \f$ to prevent a division by zero.
|
||||
* @param across_spatial If true, normalize an input across all non-batch dimensions.
|
||||
* Otherwise normalize an every channel separately.
|
||||
*
|
||||
* Across spatial:
|
||||
* @f[
|
||||
* norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\
|
||||
* dst(x, y, c) = \frac{ src(x, y, c) }{norm}
|
||||
* @f]
|
||||
*
|
||||
* Channel wise normalization:
|
||||
* @f[
|
||||
* norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\
|
||||
* dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)}
|
||||
* @f]
|
||||
*
|
||||
* Where `x, y` - spatial cooridnates, `c` - channel.
|
||||
*
|
||||
* An every sample in the batch is normalized separately. Optionally,
|
||||
* output is scaled by the trained parameters.
|
||||
*/
|
||||
class NormalizeBBoxLayer : public Layer
|
||||
{
|
||||
public:
|
||||
float pnorm, epsilon;
|
||||
bool acrossSpatial;
|
||||
|
||||
static Ptr<NormalizeBBoxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Resize input 4-dimensional blob by nearest neghbor strategy.
|
||||
*
|
||||
* Layer is used to support TensorFlow's resize_nearest_neighbor op.
|
||||
*/
|
||||
class CV_EXPORTS ResizeNearestNeighborLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<ResizeNearestNeighborLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ProposalLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<ProposalLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
//! @}
|
||||
//! @}
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
#endif
|
||||
152
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dict.hpp
vendored
Normal file
152
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dict.hpp
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
|
||||
#include <opencv2/dnn/dnn.hpp>
|
||||
|
||||
#ifndef OPENCV_DNN_DNN_DICT_HPP
|
||||
#define OPENCV_DNN_DNN_DICT_HPP
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
//! @addtogroup dnn
|
||||
//! @{
|
||||
|
||||
/** @brief This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64.
|
||||
* @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers.
|
||||
*/
|
||||
struct CV_EXPORTS_W DictValue
|
||||
{
|
||||
DictValue(const DictValue &r);
|
||||
DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
|
||||
CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
|
||||
DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
|
||||
CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
|
||||
CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
|
||||
DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
|
||||
|
||||
template<typename TypeIter>
|
||||
static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array
|
||||
template<typename TypeIter>
|
||||
static DictValue arrayReal(TypeIter begin, int size); //!< Constructs floating point array
|
||||
template<typename TypeIter>
|
||||
static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings
|
||||
|
||||
template<typename T>
|
||||
T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its.
|
||||
|
||||
int size() const;
|
||||
|
||||
CV_WRAP bool isInt() const;
|
||||
CV_WRAP bool isString() const;
|
||||
CV_WRAP bool isReal() const;
|
||||
|
||||
CV_WRAP int getIntValue(int idx = -1) const;
|
||||
CV_WRAP double getRealValue(int idx = -1) const;
|
||||
CV_WRAP String getStringValue(int idx = -1) const;
|
||||
|
||||
DictValue &operator=(const DictValue &r);
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv);
|
||||
|
||||
~DictValue();
|
||||
|
||||
private:
|
||||
|
||||
int type;
|
||||
|
||||
union
|
||||
{
|
||||
AutoBuffer<int64, 1> *pi;
|
||||
AutoBuffer<double, 1> *pd;
|
||||
AutoBuffer<String, 1> *ps;
|
||||
void *pv;
|
||||
};
|
||||
|
||||
DictValue(int _type, void *_p) : type(_type), pv(_p) {}
|
||||
void release();
|
||||
};
|
||||
|
||||
/** @brief This class implements name-value dictionary, values are instances of DictValue. */
|
||||
class CV_EXPORTS Dict
|
||||
{
|
||||
typedef std::map<String, DictValue> _Dict;
|
||||
_Dict dict;
|
||||
|
||||
public:
|
||||
|
||||
//! Checks a presence of the @p key in the dictionary.
|
||||
bool has(const String &key) const;
|
||||
|
||||
//! If the @p key in the dictionary then returns pointer to its value, else returns NULL.
|
||||
DictValue *ptr(const String &key);
|
||||
|
||||
/** @overload */
|
||||
const DictValue *ptr(const String &key) const;
|
||||
|
||||
//! If the @p key in the dictionary then returns its value, else an error will be generated.
|
||||
const DictValue &get(const String &key) const;
|
||||
|
||||
/** @overload */
|
||||
template <typename T>
|
||||
T get(const String &key) const;
|
||||
|
||||
//! If the @p key in the dictionary then returns its value, else returns @p defaultValue.
|
||||
template <typename T>
|
||||
T get(const String &key, const T &defaultValue) const;
|
||||
|
||||
//! Sets new @p value for the @p key, or adds new key-value pair into the dictionary.
|
||||
template<typename T>
|
||||
const T &set(const String &key, const T &value);
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &stream, const Dict &dict);
|
||||
};
|
||||
|
||||
//! @}
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
757
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dnn.hpp
vendored
Normal file
757
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dnn.hpp
vendored
Normal file
|
|
@ -0,0 +1,757 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DNN_DNN_HPP
|
||||
#define OPENCV_DNN_DNN_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_EXPERIMENTAL_NS
|
||||
#define CV__DNN_EXPERIMENTAL_NS_BEGIN namespace experimental_dnn_v3 {
|
||||
#define CV__DNN_EXPERIMENTAL_NS_END }
|
||||
namespace cv { namespace dnn { namespace experimental_dnn_v3 { } using namespace experimental_dnn_v3; }}
|
||||
#else
|
||||
#define CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
#define CV__DNN_EXPERIMENTAL_NS_END
|
||||
#endif
|
||||
|
||||
#include <opencv2/dnn/dict.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
//! @addtogroup dnn
|
||||
//! @{
|
||||
|
||||
typedef std::vector<int> MatShape;
|
||||
|
||||
/**
|
||||
* @brief Enum of computation backends supported by layers.
|
||||
*/
|
||||
enum Backend
|
||||
{
|
||||
DNN_BACKEND_DEFAULT,
|
||||
DNN_BACKEND_HALIDE
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enum of target devices for computations.
|
||||
*/
|
||||
enum Target
|
||||
{
|
||||
DNN_TARGET_CPU,
|
||||
DNN_TARGET_OPENCL
|
||||
};
|
||||
|
||||
/** @brief This class provides all data needed to initialize layer.
|
||||
*
|
||||
* It includes dictionary with scalar params (which can be readed by using Dict interface),
|
||||
* blob params #blobs and optional meta information: #name and #type of layer instance.
|
||||
*/
|
||||
class CV_EXPORTS LayerParams : public Dict
|
||||
{
|
||||
public:
|
||||
//TODO: Add ability to name blob params
|
||||
std::vector<Mat> blobs; //!< List of learned parameters stored as blobs.
|
||||
|
||||
String name; //!< Name of the layer instance (optional, can be used internal purposes).
|
||||
String type; //!< Type name which was used for creating layer by layer factory (optional).
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Derivatives of this class encapsulates functions of certain backends.
|
||||
*/
|
||||
class BackendNode
|
||||
{
|
||||
public:
|
||||
BackendNode(int backendId);
|
||||
|
||||
virtual ~BackendNode(); //!< Virtual destructor to make polymorphism.
|
||||
|
||||
int backendId; //!< Backend identifier.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Derivatives of this class wraps cv::Mat for different backends and targets.
|
||||
*/
|
||||
class BackendWrapper
|
||||
{
|
||||
public:
|
||||
BackendWrapper(int backendId, int targetId);
|
||||
|
||||
/**
|
||||
* @brief Wrap cv::Mat for specific backend and target.
|
||||
* @param[in] targetId Target identifier.
|
||||
* @param[in] m cv::Mat for wrapping.
|
||||
*
|
||||
* Make CPU->GPU data transfer if it's require for the target.
|
||||
*/
|
||||
BackendWrapper(int targetId, const cv::Mat& m);
|
||||
|
||||
/**
|
||||
* @brief Make wrapper for reused cv::Mat.
|
||||
* @param[in] base Wrapper of cv::Mat that will be reused.
|
||||
* @param[in] shape Specific shape.
|
||||
*
|
||||
* Initialize wrapper from another one. It'll wrap the same host CPU
|
||||
* memory and mustn't allocate memory on device(i.e. GPU). It might
|
||||
* has different shape. Use in case of CPU memory reusing for reuse
|
||||
* associented memory on device too.
|
||||
*/
|
||||
BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape& shape);
|
||||
|
||||
virtual ~BackendWrapper(); //!< Virtual destructor to make polymorphism.
|
||||
|
||||
/**
|
||||
* @brief Transfer data to CPU host memory.
|
||||
*/
|
||||
virtual void copyToHost() = 0;
|
||||
|
||||
/**
|
||||
* @brief Indicate that an actual data is on CPU.
|
||||
*/
|
||||
virtual void setHostDirty() = 0;
|
||||
|
||||
int backendId; //!< Backend identifier.
|
||||
int targetId; //!< Target identifier.
|
||||
};
|
||||
|
||||
class CV_EXPORTS ActivationLayer;
|
||||
class CV_EXPORTS BatchNormLayer;
|
||||
class CV_EXPORTS ScaleLayer;
|
||||
|
||||
/** @brief This interface class allows to build new Layers - are building blocks of networks.
|
||||
*
|
||||
* Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs.
|
||||
* Also before using the new layer into networks you must register your layer by using one of @ref dnnLayerFactory "LayerFactory" macros.
|
||||
*/
|
||||
class CV_EXPORTS_W Layer : public Algorithm
|
||||
{
|
||||
public:
|
||||
|
||||
//! List of learned parameters must be stored here to allow read them by using Net::getParam().
|
||||
CV_PROP_RW std::vector<Mat> blobs;
|
||||
|
||||
/** @brief Computes and sets internal parameters according to inputs, outputs and blobs.
|
||||
* @param[in] input vector of already allocated input blobs
|
||||
* @param[out] output vector of already allocated output blobs
|
||||
*
|
||||
* If this method is called after network has allocated all memory for input and output blobs
|
||||
* and before inferencing.
|
||||
*/
|
||||
virtual void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output);
|
||||
|
||||
/** @brief Given the @p input blobs, computes the output @p blobs.
|
||||
* @param[in] input the input blobs.
|
||||
* @param[out] output allocated output blobs, which will store results of the computation.
|
||||
* @param[out] internals allocated internal blobs
|
||||
*/
|
||||
virtual void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals) = 0;
|
||||
|
||||
/** @brief Given the @p input blobs, computes the output @p blobs.
|
||||
* @param[in] inputs the input blobs.
|
||||
* @param[out] outputs allocated output blobs, which will store results of the computation.
|
||||
* @param[out] internals allocated internal blobs
|
||||
*/
|
||||
virtual void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals) = 0;
|
||||
|
||||
/** @brief Given the @p input blobs, computes the output @p blobs.
|
||||
* @param[in] inputs the input blobs.
|
||||
* @param[out] outputs allocated output blobs, which will store results of the computation.
|
||||
* @param[out] internals allocated internal blobs
|
||||
*/
|
||||
void forward_fallback(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals);
|
||||
|
||||
/** @brief @overload */
|
||||
CV_WRAP void finalize(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs);
|
||||
|
||||
/** @brief @overload */
|
||||
CV_WRAP std::vector<Mat> finalize(const std::vector<Mat> &inputs);
|
||||
|
||||
/** @brief Allocates layer and computes output. */
|
||||
CV_WRAP void run(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs,
|
||||
CV_IN_OUT std::vector<Mat> &internals);
|
||||
|
||||
/** @brief Returns index of input blob into the input array.
|
||||
* @param inputName label of input blob
|
||||
*
|
||||
* Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation.
|
||||
* This method maps label of input blob to its index into input vector.
|
||||
*/
|
||||
virtual int inputNameToIndex(String inputName);
|
||||
/** @brief Returns index of output blob in output array.
|
||||
* @see inputNameToIndex()
|
||||
*/
|
||||
virtual int outputNameToIndex(String outputName);
|
||||
|
||||
/**
|
||||
* @brief Ask layer if it support specific backend for doing computations.
|
||||
* @param[in] backendId computation backend identifier.
|
||||
* @see Backend
|
||||
*/
|
||||
virtual bool supportBackend(int backendId);
|
||||
|
||||
/**
|
||||
* @brief Returns Halide backend node.
|
||||
* @param[in] inputs Input Halide buffers.
|
||||
* @see BackendNode, BackendWrapper
|
||||
*
|
||||
* Input buffers should be exactly the same that will be used in forward invocations.
|
||||
* Despite we can use Halide::ImageParam based on input shape only,
|
||||
* it helps prevent some memory management issues (if something wrong,
|
||||
* Halide tests will be failed).
|
||||
*/
|
||||
virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs);
|
||||
|
||||
/**
|
||||
* @brief Automatic Halide scheduling based on layer hyper-parameters.
|
||||
* @param[in] node Backend node with Halide functions.
|
||||
* @param[in] inputs Blobs that will be used in forward invocations.
|
||||
* @param[in] outputs Blobs that will be used in forward invocations.
|
||||
* @param[in] targetId Target identifier
|
||||
* @see BackendNode, Target
|
||||
*
|
||||
* Layer don't use own Halide::Func members because we can have applied
|
||||
* layers fusing. In this way the fused function should be scheduled.
|
||||
*/
|
||||
virtual void applyHalideScheduler(Ptr<BackendNode>& node,
|
||||
const std::vector<Mat*> &inputs,
|
||||
const std::vector<Mat> &outputs,
|
||||
int targetId) const;
|
||||
|
||||
/**
|
||||
* @brief Implement layers fusing.
|
||||
* @param[in] node Backend node of bottom layer.
|
||||
* @see BackendNode
|
||||
*
|
||||
* Actual for graph-based backends. If layer attached successfully,
|
||||
* returns non-empty cv::Ptr to node of the same backend.
|
||||
* Fuse only over the last function.
|
||||
*/
|
||||
virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node);
|
||||
|
||||
/**
|
||||
* @brief Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case.
|
||||
* @param[in] layer The subsequent activation layer.
|
||||
*
|
||||
* Returns true if the activation layer has been attached successfully.
|
||||
*/
|
||||
virtual bool setActivation(const Ptr<ActivationLayer>& layer);
|
||||
|
||||
/**
|
||||
* @brief Tries to attach to the layer the subsequent batch normalization layer, i.e. do the layer fusion in a partial case.
|
||||
* @param[in] layer The subsequent batch normalization layer.
|
||||
*
|
||||
* Returns true if the batch normalization layer has been attached successfully.
|
||||
*/
|
||||
virtual bool setBatchNorm(const Ptr<BatchNormLayer>& layer);
|
||||
|
||||
/**
|
||||
* @brief Tries to attach to the layer the subsequent scaling layer, i.e. do the layer fusion in a partial case.
|
||||
* @param[in] layer The subsequent scaling layer.
|
||||
*
|
||||
* Returns true if the scaling layer has been attached successfully.
|
||||
*/
|
||||
virtual bool setScale(const Ptr<ScaleLayer>& layer);
|
||||
|
||||
/**
|
||||
* @brief "Deattaches" all the layers, attached to particular layer.
|
||||
*/
|
||||
virtual void unsetAttached();
|
||||
|
||||
virtual bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
const int requiredOutputs,
|
||||
std::vector<MatShape> &outputs,
|
||||
std::vector<MatShape> &internals) const;
|
||||
virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
|
||||
const std::vector<MatShape> &outputs) const {(void)inputs; (void)outputs; return 0;}
|
||||
|
||||
CV_PROP String name; //!< Name of the layer instance, can be used for logging or other internal purposes.
|
||||
CV_PROP String type; //!< Type name which was used for creating layer by layer factory.
|
||||
CV_PROP int preferableTarget; //!< prefer target for layer forwarding
|
||||
|
||||
Layer();
|
||||
explicit Layer(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
|
||||
void setParamsFrom(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
|
||||
virtual ~Layer();
|
||||
};
|
||||
|
||||
/** @brief This class allows to create and manipulate comprehensive artificial neural networks.
|
||||
*
|
||||
* Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances,
|
||||
* and edges specify relationships between layers inputs and outputs.
|
||||
*
|
||||
* Each network layer has unique integer id and unique string name inside its network.
|
||||
* LayerId can store either layer name or layer id.
|
||||
*
|
||||
* This class supports reference counting of its instances, i. e. copies point to the same instance.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE Net
|
||||
{
|
||||
public:
|
||||
|
||||
CV_WRAP Net(); //!< Default constructor.
|
||||
CV_WRAP ~Net(); //!< Destructor frees the net only if there aren't references to the net anymore.
|
||||
|
||||
/** Returns true if there are no layers in the network. */
|
||||
CV_WRAP bool empty() const;
|
||||
|
||||
/** @brief Adds new layer to the net.
|
||||
* @param name unique name of the adding layer.
|
||||
* @param type typename of the adding layer (type must be registered in LayerRegister).
|
||||
* @param params parameters which will be used to initialize the creating layer.
|
||||
* @returns unique identifier of created layer, or -1 if a failure will happen.
|
||||
*/
|
||||
int addLayer(const String &name, const String &type, LayerParams ¶ms);
|
||||
/** @brief Adds new layer and connects its first input to the first output of previously added layer.
|
||||
* @see addLayer()
|
||||
*/
|
||||
int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms);
|
||||
|
||||
/** @brief Converts string name of the layer to the integer identifier.
|
||||
* @returns id of the layer, or -1 if the layer wasn't found.
|
||||
*/
|
||||
CV_WRAP int getLayerId(const String &layer);
|
||||
|
||||
CV_WRAP std::vector<String> getLayerNames() const;
|
||||
|
||||
/** @brief Container for strings and integers. */
|
||||
typedef DictValue LayerId;
|
||||
|
||||
/** @brief Returns pointer to layer with specified id or name which the network use. */
|
||||
CV_WRAP Ptr<Layer> getLayer(LayerId layerId);
|
||||
|
||||
/** @brief Returns pointers to input layers of specific layer. */
|
||||
std::vector<Ptr<Layer> > getLayerInputs(LayerId layerId); // FIXIT: CV_WRAP
|
||||
|
||||
/** @brief Delete layer for the network (not implemented yet) */
|
||||
CV_WRAP void deleteLayer(LayerId layer);
|
||||
|
||||
/** @brief Connects output of the first layer to input of the second layer.
|
||||
* @param outPin descriptor of the first layer output.
|
||||
* @param inpPin descriptor of the second layer input.
|
||||
*
|
||||
* Descriptors have the following template <DFN><layer_name>[.input_number]</DFN>:
|
||||
* - the first part of the template <DFN>layer_name</DFN> is sting name of the added layer.
|
||||
* If this part is empty then the network input pseudo layer will be used;
|
||||
* - the second optional part of the template <DFN>input_number</DFN>
|
||||
* is either number of the layer input, either label one.
|
||||
* If this part is omitted then the first layer input will be used.
|
||||
*
|
||||
* @see setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex()
|
||||
*/
|
||||
CV_WRAP void connect(String outPin, String inpPin);
|
||||
|
||||
/** @brief Connects #@p outNum output of the first layer to #@p inNum input of the second layer.
|
||||
* @param outLayerId identifier of the first layer
|
||||
* @param inpLayerId identifier of the second layer
|
||||
* @param outNum number of the first layer output
|
||||
* @param inpNum number of the second layer input
|
||||
*/
|
||||
void connect(int outLayerId, int outNum, int inpLayerId, int inpNum);
|
||||
|
||||
/** @brief Sets outputs names of the network input pseudo layer.
|
||||
*
|
||||
* Each net always has special own the network input pseudo layer with id=0.
|
||||
* This layer stores the user blobs only and don't make any computations.
|
||||
* In fact, this layer provides the only way to pass user data into the network.
|
||||
* As any other layer, this layer can label its outputs and this function provides an easy way to do this.
|
||||
*/
|
||||
CV_WRAP void setInputsNames(const std::vector<String> &inputBlobNames);
|
||||
|
||||
/** @brief Runs forward pass to compute output of layer with name @p outputName.
|
||||
* @param outputName name for layer which output is needed to get
|
||||
* @return blob for first output of specified layer.
|
||||
* @details By default runs forward pass for the whole network.
|
||||
*/
|
||||
CV_WRAP Mat forward(const String& outputName = String());
|
||||
|
||||
/** @brief Runs forward pass to compute output of layer with name @p outputName.
|
||||
* @param outputBlobs contains all output blobs for specified layer.
|
||||
* @param outputName name for layer which output is needed to get
|
||||
* @details If @p outputName is empty, runs forward pass for the whole network.
|
||||
*/
|
||||
CV_WRAP void forward(OutputArrayOfArrays outputBlobs, const String& outputName = String());
|
||||
|
||||
/** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames.
|
||||
* @param outputBlobs contains blobs for first outputs of specified layers.
|
||||
* @param outBlobNames names for layers which outputs are needed to get
|
||||
*/
|
||||
CV_WRAP void forward(OutputArrayOfArrays outputBlobs,
|
||||
const std::vector<String>& outBlobNames);
|
||||
|
||||
/** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames.
|
||||
* @param outputBlobs contains all output blobs for each layer specified in @p outBlobNames.
|
||||
* @param outBlobNames names for layers which outputs are needed to get
|
||||
*/
|
||||
CV_WRAP_AS(forwardAndRetrieve) void forward(CV_OUT std::vector<std::vector<Mat> >& outputBlobs,
|
||||
const std::vector<String>& outBlobNames);
|
||||
|
||||
/**
|
||||
* @brief Compile Halide layers.
|
||||
* @param[in] scheduler Path to YAML file with scheduling directives.
|
||||
* @see setPreferableBackend
|
||||
*
|
||||
* Schedule layers that support Halide backend. Then compile them for
|
||||
* specific target. For layers that not represented in scheduling file
|
||||
* or if no manual scheduling used at all, automatic scheduling will be applied.
|
||||
*/
|
||||
CV_WRAP void setHalideScheduler(const String& scheduler);
|
||||
|
||||
/**
|
||||
* @brief Ask network to use specific computation backend where it supported.
|
||||
* @param[in] backendId backend identifier.
|
||||
* @see Backend
|
||||
*/
|
||||
CV_WRAP void setPreferableBackend(int backendId);
|
||||
|
||||
/**
|
||||
* @brief Ask network to make computations on specific target device.
|
||||
* @param[in] targetId target identifier.
|
||||
* @see Target
|
||||
*/
|
||||
CV_WRAP void setPreferableTarget(int targetId);
|
||||
|
||||
/** @brief Sets the new value for the layer output blob
|
||||
* @param name descriptor of the updating layer output blob.
|
||||
* @param blob new blob.
|
||||
* @see connect(String, String) to know format of the descriptor.
|
||||
* @note If updating blob is not empty then @p blob must have the same shape,
|
||||
* because network reshaping is not implemented yet.
|
||||
*/
|
||||
CV_WRAP void setInput(InputArray blob, const String& name = "");
|
||||
|
||||
/** @brief Sets the new value for the learned param of the layer.
|
||||
* @param layer name or id of the layer.
|
||||
* @param numParam index of the layer parameter in the Layer::blobs array.
|
||||
* @param blob the new value.
|
||||
* @see Layer::blobs
|
||||
* @note If shape of the new blob differs from the previous shape,
|
||||
* then the following forward pass may fail.
|
||||
*/
|
||||
CV_WRAP void setParam(LayerId layer, int numParam, const Mat &blob);
|
||||
|
||||
/** @brief Returns parameter blob of the layer.
|
||||
* @param layer name or id of the layer.
|
||||
* @param numParam index of the layer parameter in the Layer::blobs array.
|
||||
* @see Layer::blobs
|
||||
*/
|
||||
CV_WRAP Mat getParam(LayerId layer, int numParam = 0);
|
||||
|
||||
/** @brief Returns indexes of layers with unconnected outputs.
|
||||
*/
|
||||
CV_WRAP std::vector<int> getUnconnectedOutLayers() const;
|
||||
/** @brief Returns input and output shapes for all layers in loaded model;
|
||||
* preliminary inferencing isn't necessary.
|
||||
* @param netInputShapes shapes for all input blobs in net input layer.
|
||||
* @param layersIds output parameter for layer IDs.
|
||||
* @param inLayersShapes output parameter for input layers shapes;
|
||||
* order is the same as in layersIds
|
||||
* @param outLayersShapes output parameter for output layers shapes;
|
||||
* order is the same as in layersIds
|
||||
*/
|
||||
CV_WRAP void getLayersShapes(const std::vector<MatShape>& netInputShapes,
|
||||
CV_OUT std::vector<int>& layersIds,
|
||||
CV_OUT std::vector<std::vector<MatShape> >& inLayersShapes,
|
||||
CV_OUT std::vector<std::vector<MatShape> >& outLayersShapes) const;
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP void getLayersShapes(const MatShape& netInputShape,
|
||||
CV_OUT std::vector<int>& layersIds,
|
||||
CV_OUT std::vector<std::vector<MatShape> >& inLayersShapes,
|
||||
CV_OUT std::vector<std::vector<MatShape> >& outLayersShapes) const;
|
||||
|
||||
/** @brief Returns input and output shapes for layer with specified
|
||||
* id in loaded model; preliminary inferencing isn't necessary.
|
||||
* @param netInputShape shape input blob in net input layer.
|
||||
* @param layerId id for layer.
|
||||
* @param inLayerShapes output parameter for input layers shapes;
|
||||
* order is the same as in layersIds
|
||||
* @param outLayerShapes output parameter for output layers shapes;
|
||||
* order is the same as in layersIds
|
||||
*/
|
||||
void getLayerShapes(const MatShape& netInputShape,
|
||||
const int layerId,
|
||||
CV_OUT std::vector<MatShape>& inLayerShapes,
|
||||
CV_OUT std::vector<MatShape>& outLayerShapes) const; // FIXIT: CV_WRAP
|
||||
|
||||
/** @overload */
|
||||
void getLayerShapes(const std::vector<MatShape>& netInputShapes,
|
||||
const int layerId,
|
||||
CV_OUT std::vector<MatShape>& inLayerShapes,
|
||||
CV_OUT std::vector<MatShape>& outLayerShapes) const; // FIXIT: CV_WRAP
|
||||
|
||||
/** @brief Computes FLOP for whole loaded model with specified input shapes.
|
||||
* @param netInputShapes vector of shapes for all net inputs.
|
||||
* @returns computed FLOP.
|
||||
*/
|
||||
CV_WRAP int64 getFLOPS(const std::vector<MatShape>& netInputShapes) const;
|
||||
/** @overload */
|
||||
CV_WRAP int64 getFLOPS(const MatShape& netInputShape) const;
|
||||
/** @overload */
|
||||
CV_WRAP int64 getFLOPS(const int layerId,
|
||||
const std::vector<MatShape>& netInputShapes) const;
|
||||
/** @overload */
|
||||
CV_WRAP int64 getFLOPS(const int layerId,
|
||||
const MatShape& netInputShape) const;
|
||||
|
||||
/** @brief Returns list of types for layer used in model.
|
||||
* @param layersTypes output parameter for returning types.
|
||||
*/
|
||||
CV_WRAP void getLayerTypes(CV_OUT std::vector<String>& layersTypes) const;
|
||||
|
||||
/** @brief Returns count of layers of specified type.
|
||||
* @param layerType type.
|
||||
* @returns count of layers
|
||||
*/
|
||||
CV_WRAP int getLayersCount(const String& layerType) const;
|
||||
|
||||
/** @brief Computes bytes number which are requered to store
|
||||
* all weights and intermediate blobs for model.
|
||||
* @param netInputShapes vector of shapes for all net inputs.
|
||||
* @param weights output parameter to store resulting bytes for weights.
|
||||
* @param blobs output parameter to store resulting bytes for intermediate blobs.
|
||||
*/
|
||||
void getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
|
||||
CV_OUT size_t& weights, CV_OUT size_t& blobs) const; // FIXIT: CV_WRAP
|
||||
/** @overload */
|
||||
CV_WRAP void getMemoryConsumption(const MatShape& netInputShape,
|
||||
CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
|
||||
/** @overload */
|
||||
CV_WRAP void getMemoryConsumption(const int layerId,
|
||||
const std::vector<MatShape>& netInputShapes,
|
||||
CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
|
||||
/** @overload */
|
||||
CV_WRAP void getMemoryConsumption(const int layerId,
|
||||
const MatShape& netInputShape,
|
||||
CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
|
||||
|
||||
/** @brief Computes bytes number which are requered to store
|
||||
* all weights and intermediate blobs for each layer.
|
||||
* @param netInputShapes vector of shapes for all net inputs.
|
||||
* @param layerIds output vector to save layer IDs.
|
||||
* @param weights output parameter to store resulting bytes for weights.
|
||||
* @param blobs output parameter to store resulting bytes for intermediate blobs.
|
||||
*/
|
||||
void getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
|
||||
CV_OUT std::vector<int>& layerIds,
|
||||
CV_OUT std::vector<size_t>& weights,
|
||||
CV_OUT std::vector<size_t>& blobs) const; // FIXIT: CV_WRAP
|
||||
/** @overload */
|
||||
void getMemoryConsumption(const MatShape& netInputShape,
|
||||
CV_OUT std::vector<int>& layerIds,
|
||||
CV_OUT std::vector<size_t>& weights,
|
||||
CV_OUT std::vector<size_t>& blobs) const; // FIXIT: CV_WRAP
|
||||
|
||||
/** @brief Enables or disables layer fusion in the network.
|
||||
* @param fusion true to enable the fusion, false to disable. The fusion is enabled by default.
|
||||
*/
|
||||
CV_WRAP void enableFusion(bool fusion);
|
||||
|
||||
/** @brief Returns overall time for inference and timings (in ticks) for layers.
|
||||
* Indexes in returned vector correspond to layers ids. Some layers can be fused with others,
|
||||
* in this case zero ticks count will be return for that skipped layers.
|
||||
* @param timings vector for tick timings for all layers.
|
||||
* @return overall ticks for model inference.
|
||||
*/
|
||||
CV_WRAP int64 getPerfProfile(CV_OUT std::vector<double>& timings);
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
Ptr<Impl> impl;
|
||||
};
|
||||
|
||||
/** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
||||
* @param cfgFile path to the .cfg file with text description of the network architecture.
|
||||
* @param darknetModel path to the .weights file with learned network.
|
||||
* @returns Network object that ready to do forward, throw an exception in failure cases.
|
||||
* @returns Net object.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());
|
||||
|
||||
/** @brief Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.
|
||||
* @param prototxt path to the .prototxt file with text description of the network architecture.
|
||||
* @param caffeModel path to the .caffemodel file with learned network.
|
||||
* @returns Net object.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String());
|
||||
|
||||
/** @brief Reads a network model stored in Caffe model in memory.
|
||||
* @details This is an overloaded member function, provided for convenience.
|
||||
* It differs from the above function only in what argument(s) it accepts.
|
||||
* @param bufferProto buffer containing the content of the .prototxt file
|
||||
* @param lenProto length of bufferProto
|
||||
* @param bufferModel buffer containing the content of the .caffemodel file
|
||||
* @param lenModel length of bufferModel
|
||||
* @returns Net object.
|
||||
*/
|
||||
CV_EXPORTS Net readNetFromCaffe(const char *bufferProto, size_t lenProto,
|
||||
const char *bufferModel = NULL, size_t lenModel = 0);
|
||||
|
||||
/** @brief Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
||||
* @param model path to the .pb file with binary protobuf description of the network architecture
|
||||
* @param config path to the .pbtxt file that contains text graph definition in protobuf format.
|
||||
* Resulting Net object is built by text graph using weights from a binary one that
|
||||
* let us make it more flexible.
|
||||
* @returns Net object.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromTensorflow(const String &model, const String &config = String());
|
||||
|
||||
/** @brief Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
||||
* @details This is an overloaded member function, provided for convenience.
|
||||
* It differs from the above function only in what argument(s) it accepts.
|
||||
* @param bufferModel buffer containing the content of the pb file
|
||||
* @param lenModel length of bufferModel
|
||||
* @param bufferConfig buffer containing the content of the pbtxt file
|
||||
* @param lenConfig length of bufferConfig
|
||||
*/
|
||||
CV_EXPORTS Net readNetFromTensorflow(const char *bufferModel, size_t lenModel,
|
||||
const char *bufferConfig = NULL, size_t lenConfig = 0);
|
||||
|
||||
/**
|
||||
* @brief Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
|
||||
* @param model path to the file, dumped from Torch by using torch.save() function.
|
||||
* @param isBinary specifies whether the network was serialized in ascii mode or binary.
|
||||
* @returns Net object.
|
||||
*
|
||||
* @note Ascii mode of Torch serializer is more preferable, because binary mode extensively use `long` type of C language,
|
||||
* which has various bit-length on different systems.
|
||||
*
|
||||
* The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
|
||||
* with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
|
||||
*
|
||||
* List of supported layers (i.e. object instances derived from Torch nn.Module class):
|
||||
* - nn.Sequential
|
||||
* - nn.Parallel
|
||||
* - nn.Concat
|
||||
* - nn.Linear
|
||||
* - nn.SpatialConvolution
|
||||
* - nn.SpatialMaxPooling, nn.SpatialAveragePooling
|
||||
* - nn.ReLU, nn.TanH, nn.Sigmoid
|
||||
* - nn.Reshape
|
||||
* - nn.SoftMax, nn.LogSoftMax
|
||||
*
|
||||
* Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromTorch(const String &model, bool isBinary = true);
|
||||
|
||||
/** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework.
|
||||
* @warning This function has the same limitations as readNetFromTorch().
|
||||
*/
|
||||
CV_EXPORTS_W Mat readTorchBlob(const String &filename, bool isBinary = true);
|
||||
/** @brief Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center,
|
||||
* subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels.
|
||||
* @param image input image (with 1-, 3- or 4-channels).
|
||||
* @param size spatial size for output image
|
||||
* @param mean scalar with mean values which are subtracted from channels. Values are intended
|
||||
* to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
|
||||
* @param scalefactor multiplier for @p image values.
|
||||
* @param swapRB flag which indicates that swap first and last channels
|
||||
* in 3-channel image is necessary.
|
||||
* @param crop flag which indicates whether image will be cropped after resize or not
|
||||
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
|
||||
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
|
||||
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
|
||||
* @returns 4-dimansional Mat with NCHW dimensions order.
|
||||
*/
|
||||
CV_EXPORTS_W Mat blobFromImage(InputArray image, double scalefactor=1.0, const Size& size = Size(),
|
||||
const Scalar& mean = Scalar(), bool swapRB=true, bool crop=true);
|
||||
/** @brief Creates 4-dimensional blob from series of images. Optionally resizes and
|
||||
* crops @p images from center, subtract @p mean values, scales values by @p scalefactor,
|
||||
* swap Blue and Red channels.
|
||||
* @param images input images (all with 1-, 3- or 4-channels).
|
||||
* @param size spatial size for output image
|
||||
* @param mean scalar with mean values which are subtracted from channels. Values are intended
|
||||
* to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
|
||||
* @param scalefactor multiplier for @p images values.
|
||||
* @param swapRB flag which indicates that swap first and last channels
|
||||
* in 3-channel image is necessary.
|
||||
* @param crop flag which indicates whether image will be cropped after resize or not
|
||||
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
|
||||
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
|
||||
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
|
||||
* @returns 4-dimansional Mat with NCHW dimensions order.
|
||||
*/
|
||||
CV_EXPORTS_W Mat blobFromImages(const std::vector<Mat>& images, double scalefactor=1.0,
|
||||
Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true, bool crop=true);
|
||||
|
||||
/** @brief Convert all weights of Caffe network to half precision floating point.
|
||||
* @param src Path to origin model from Caffe framework contains single
|
||||
* precision floating point weights (usually has `.caffemodel` extension).
|
||||
* @param dst Path to destination model with updated weights.
|
||||
* @param layersTypes Set of layers types which parameters will be converted.
|
||||
* By default, converts only Convolutional and Fully-Connected layers'
|
||||
* weights.
|
||||
*
|
||||
* @note Shrinked model has no origin float32 weights so it can't be used
|
||||
* in origin Caffe framework anymore. However the structure of data
|
||||
* is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe.
|
||||
* So the resulting model may be used there.
|
||||
*/
|
||||
CV_EXPORTS_W void shrinkCaffeModel(const String& src, const String& dst,
|
||||
const std::vector<String>& layersTypes = std::vector<String>());
|
||||
|
||||
/** @brief Performs non maximum suppression given boxes and corresponding scores.
|
||||
|
||||
* @param bboxes a set of bounding boxes to apply NMS.
|
||||
* @param scores a set of corresponding confidences.
|
||||
* @param score_threshold a threshold used to filter boxes by score.
|
||||
* @param nms_threshold a threshold used in non maximum suppression.
|
||||
* @param indices the kept indices of bboxes after NMS.
|
||||
* @param eta a coefficient in adaptive threshold formula: \f$nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\f$.
|
||||
* @param top_k if `>0`, keep at most @p top_k picked indices.
|
||||
*/
|
||||
CV_EXPORTS_W void NMSBoxes(const std::vector<Rect>& bboxes, const std::vector<float>& scores,
|
||||
const float score_threshold, const float nms_threshold,
|
||||
CV_OUT std::vector<int>& indices,
|
||||
const float eta = 1.f, const int top_k = 0);
|
||||
|
||||
|
||||
//! @}
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
|
||||
#include <opencv2/dnn/layer.hpp>
|
||||
#include <opencv2/dnn/dnn.inl.hpp>
|
||||
|
||||
#endif /* OPENCV_DNN_DNN_HPP */
|
||||
373
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dnn.inl.hpp
vendored
Normal file
373
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/dnn.inl.hpp
vendored
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DNN_DNN_INL_HPP
|
||||
#define OPENCV_DNN_DNN_INL_HPP
|
||||
|
||||
#include <opencv2/dnn.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
|
||||
template<typename TypeIter>
|
||||
DictValue DictValue::arrayInt(TypeIter begin, int size)
|
||||
{
|
||||
DictValue res(Param::INT, new AutoBuffer<int64, 1>(size));
|
||||
for (int j = 0; j < size; begin++, j++)
|
||||
(*res.pi)[j] = *begin;
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename TypeIter>
|
||||
DictValue DictValue::arrayReal(TypeIter begin, int size)
|
||||
{
|
||||
DictValue res(Param::REAL, new AutoBuffer<double, 1>(size));
|
||||
for (int j = 0; j < size; begin++, j++)
|
||||
(*res.pd)[j] = *begin;
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename TypeIter>
|
||||
DictValue DictValue::arrayString(TypeIter begin, int size)
|
||||
{
|
||||
DictValue res(Param::STRING, new AutoBuffer<String, 1>(size));
|
||||
for (int j = 0; j < size; begin++, j++)
|
||||
(*res.ps)[j] = *begin;
|
||||
return res;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline DictValue DictValue::get<DictValue>(int idx) const
|
||||
{
|
||||
CV_Assert(idx == -1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int64 DictValue::get<int64>(int idx) const
|
||||
{
|
||||
CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
|
||||
idx = (idx == -1) ? 0 : idx;
|
||||
|
||||
if (type == Param::INT)
|
||||
{
|
||||
return (*pi)[idx];
|
||||
}
|
||||
else if (type == Param::REAL)
|
||||
{
|
||||
double doubleValue = (*pd)[idx];
|
||||
|
||||
double fracpart, intpart;
|
||||
fracpart = std::modf(doubleValue, &intpart);
|
||||
CV_Assert(fracpart == 0.0);
|
||||
|
||||
return (int64)doubleValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(isInt() || isReal());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int DictValue::get<int>(int idx) const
|
||||
{
|
||||
return (int)get<int64>(idx);
|
||||
}
|
||||
|
||||
inline int DictValue::getIntValue(int idx) const
|
||||
{
|
||||
return (int)get<int64>(idx);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned DictValue::get<unsigned>(int idx) const
|
||||
{
|
||||
return (unsigned)get<int64>(idx);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool DictValue::get<bool>(int idx) const
|
||||
{
|
||||
return (get<int64>(idx) != 0);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline double DictValue::get<double>(int idx) const
|
||||
{
|
||||
CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
|
||||
idx = (idx == -1) ? 0 : idx;
|
||||
|
||||
if (type == Param::REAL)
|
||||
{
|
||||
return (*pd)[idx];
|
||||
}
|
||||
else if (type == Param::INT)
|
||||
{
|
||||
return (double)(*pi)[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(isReal() || isInt());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline double DictValue::getRealValue(int idx) const
|
||||
{
|
||||
return get<double>(idx);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline float DictValue::get<float>(int idx) const
|
||||
{
|
||||
return (float)get<double>(idx);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline String DictValue::get<String>(int idx) const
|
||||
{
|
||||
CV_Assert(isString());
|
||||
CV_Assert((idx == -1 && ps->size() == 1) || (idx >= 0 && idx < (int)ps->size()));
|
||||
return (*ps)[(idx == -1) ? 0 : idx];
|
||||
}
|
||||
|
||||
|
||||
inline String DictValue::getStringValue(int idx) const
|
||||
{
|
||||
return get<String>(idx);
|
||||
}
|
||||
|
||||
inline void DictValue::release()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Param::INT:
|
||||
delete pi;
|
||||
break;
|
||||
case Param::STRING:
|
||||
delete ps;
|
||||
break;
|
||||
case Param::REAL:
|
||||
delete pd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline DictValue::~DictValue()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
inline DictValue & DictValue::operator=(const DictValue &r)
|
||||
{
|
||||
if (&r == this)
|
||||
return *this;
|
||||
|
||||
if (r.type == Param::INT)
|
||||
{
|
||||
AutoBuffer<int64, 1> *tmp = new AutoBuffer<int64, 1>(*r.pi);
|
||||
release();
|
||||
pi = tmp;
|
||||
}
|
||||
else if (r.type == Param::STRING)
|
||||
{
|
||||
AutoBuffer<String, 1> *tmp = new AutoBuffer<String, 1>(*r.ps);
|
||||
release();
|
||||
ps = tmp;
|
||||
}
|
||||
else if (r.type == Param::REAL)
|
||||
{
|
||||
AutoBuffer<double, 1> *tmp = new AutoBuffer<double, 1>(*r.pd);
|
||||
release();
|
||||
pd = tmp;
|
||||
}
|
||||
|
||||
type = r.type;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline DictValue::DictValue(const DictValue &r)
|
||||
{
|
||||
type = r.type;
|
||||
|
||||
if (r.type == Param::INT)
|
||||
pi = new AutoBuffer<int64, 1>(*r.pi);
|
||||
else if (r.type == Param::STRING)
|
||||
ps = new AutoBuffer<String, 1>(*r.ps);
|
||||
else if (r.type == Param::REAL)
|
||||
pd = new AutoBuffer<double, 1>(*r.pd);
|
||||
}
|
||||
|
||||
inline bool DictValue::isString() const
|
||||
{
|
||||
return (type == Param::STRING);
|
||||
}
|
||||
|
||||
inline bool DictValue::isInt() const
|
||||
{
|
||||
return (type == Param::INT);
|
||||
}
|
||||
|
||||
inline bool DictValue::isReal() const
|
||||
{
|
||||
return (type == Param::REAL || type == Param::INT);
|
||||
}
|
||||
|
||||
inline int DictValue::size() const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Param::INT:
|
||||
return (int)pi->size();
|
||||
break;
|
||||
case Param::STRING:
|
||||
return (int)ps->size();
|
||||
break;
|
||||
case Param::REAL:
|
||||
return (int)pd->size();
|
||||
break;
|
||||
default:
|
||||
CV_Error(Error::StsInternal, "");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (dictv.isInt())
|
||||
{
|
||||
for (i = 0; i < dictv.size() - 1; i++)
|
||||
stream << dictv.get<int64>(i) << ", ";
|
||||
stream << dictv.get<int64>(i);
|
||||
}
|
||||
else if (dictv.isReal())
|
||||
{
|
||||
for (i = 0; i < dictv.size() - 1; i++)
|
||||
stream << dictv.get<double>(i) << ", ";
|
||||
stream << dictv.get<double>(i);
|
||||
}
|
||||
else if (dictv.isString())
|
||||
{
|
||||
for (i = 0; i < dictv.size() - 1; i++)
|
||||
stream << "\"" << dictv.get<String>(i) << "\", ";
|
||||
stream << dictv.get<String>(i);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool Dict::has(const String &key) const
|
||||
{
|
||||
return dict.count(key) != 0;
|
||||
}
|
||||
|
||||
inline DictValue *Dict::ptr(const String &key)
|
||||
{
|
||||
_Dict::iterator i = dict.find(key);
|
||||
return (i == dict.end()) ? NULL : &i->second;
|
||||
}
|
||||
|
||||
inline const DictValue *Dict::ptr(const String &key) const
|
||||
{
|
||||
_Dict::const_iterator i = dict.find(key);
|
||||
return (i == dict.end()) ? NULL : &i->second;
|
||||
}
|
||||
|
||||
inline const DictValue &Dict::get(const String &key) const
|
||||
{
|
||||
_Dict::const_iterator i = dict.find(key);
|
||||
if (i == dict.end())
|
||||
CV_Error(Error::StsObjectNotFound, "Required argument \"" + key + "\" not found into dictionary");
|
||||
return i->second;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T Dict::get(const String &key) const
|
||||
{
|
||||
return this->get(key).get<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T Dict::get(const String &key, const T &defaultValue) const
|
||||
{
|
||||
_Dict::const_iterator i = dict.find(key);
|
||||
|
||||
if (i != dict.end())
|
||||
return i->second.get<T>();
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline const T &Dict::set(const String &key, const T &value)
|
||||
{
|
||||
_Dict::iterator i = dict.find(key);
|
||||
|
||||
if (i != dict.end())
|
||||
i->second = DictValue(value);
|
||||
else
|
||||
dict.insert(std::make_pair(key, DictValue(value)));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &stream, const Dict &dict)
|
||||
{
|
||||
Dict::_Dict::const_iterator it;
|
||||
for (it = dict.dict.begin(); it != dict.dict.end(); it++)
|
||||
stream << it->first << " : " << it->second << "\n";
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
78
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/layer.details.hpp
vendored
Normal file
78
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/layer.details.hpp
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// 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_DNN_LAYER_DETAILS_HPP
|
||||
#define OPENCV_DNN_LAYER_DETAILS_HPP
|
||||
|
||||
#include <opencv2/dnn/layer.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
|
||||
/** @brief Registers layer constructor in runtime.
|
||||
* @param type string, containing type name of the layer.
|
||||
* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
|
||||
* @details This macros must be placed inside the function code.
|
||||
*/
|
||||
#define CV_DNN_REGISTER_LAYER_FUNC(type, constuctorFunc) \
|
||||
cv::dnn::LayerFactory::registerLayer(#type, constuctorFunc);
|
||||
|
||||
/** @brief Registers layer class in runtime.
|
||||
* @param type string, containing type name of the layer.
|
||||
* @param class C++ class, derived from Layer.
|
||||
* @details This macros must be placed inside the function code.
|
||||
*/
|
||||
#define CV_DNN_REGISTER_LAYER_CLASS(type, class) \
|
||||
cv::dnn::LayerFactory::registerLayer(#type, cv::dnn::details::_layerDynamicRegisterer<class>);
|
||||
|
||||
/** @brief Registers layer constructor on module load time.
|
||||
* @param type string, containing type name of the layer.
|
||||
* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
|
||||
* @details This macros must be placed outside the function code.
|
||||
*/
|
||||
#define CV_DNN_REGISTER_LAYER_FUNC_STATIC(type, constuctorFunc) \
|
||||
static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constuctorFunc);
|
||||
|
||||
/** @brief Registers layer class on module load time.
|
||||
* @param type string, containing type name of the layer.
|
||||
* @param class C++ class, derived from Layer.
|
||||
* @details This macros must be placed outside the function code.
|
||||
*/
|
||||
#define CV_DNN_REGISTER_LAYER_CLASS_STATIC(type, class) \
|
||||
Ptr<Layer> __LayerStaticRegisterer_func_##type(LayerParams ¶ms) \
|
||||
{ return Ptr<Layer>(new class(params)); } \
|
||||
static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type);
|
||||
|
||||
namespace details {
|
||||
|
||||
template<typename LayerClass>
|
||||
Ptr<Layer> _layerDynamicRegisterer(LayerParams ¶ms)
|
||||
{
|
||||
return Ptr<Layer>(LayerClass::create(params));
|
||||
}
|
||||
|
||||
//allows automatically register created layer on module load time
|
||||
class _LayerStaticRegisterer
|
||||
{
|
||||
String type;
|
||||
public:
|
||||
|
||||
_LayerStaticRegisterer(const String &layerType, LayerFactory::Constuctor layerConstuctor)
|
||||
{
|
||||
this->type = layerType;
|
||||
LayerFactory::registerLayer(layerType, layerConstuctor);
|
||||
}
|
||||
|
||||
~_LayerStaticRegisterer()
|
||||
{
|
||||
LayerFactory::unregisterLayer(type);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}} // namespace
|
||||
|
||||
#endif
|
||||
85
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/layer.hpp
vendored
Normal file
85
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/layer.hpp
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DNN_LAYER_HPP
|
||||
#define OPENCV_DNN_LAYER_HPP
|
||||
#include <opencv2/dnn.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
//! @addtogroup dnn
|
||||
//! @{
|
||||
//!
|
||||
//! @defgroup dnnLayerFactory Utilities for New Layers Registration
|
||||
//! @{
|
||||
|
||||
/** @brief %Layer factory allows to create instances of registered layers. */
|
||||
class CV_EXPORTS LayerFactory
|
||||
{
|
||||
public:
|
||||
|
||||
//! Each Layer class must provide this function to the factory
|
||||
typedef Ptr<Layer>(*Constuctor)(LayerParams ¶ms);
|
||||
|
||||
//! Registers the layer class with typename @p type and specified @p constructor. Thread-safe.
|
||||
static void registerLayer(const String &type, Constuctor constructor);
|
||||
|
||||
//! Unregisters registered layer with specified type name. Thread-safe.
|
||||
static void unregisterLayer(const String &type);
|
||||
|
||||
/** @brief Creates instance of registered layer.
|
||||
* @param type type name of creating layer.
|
||||
* @param params parameters which will be used for layer initialization.
|
||||
* @note Thread-safe.
|
||||
*/
|
||||
static Ptr<Layer> createLayerInstance(const String &type, LayerParams& params);
|
||||
|
||||
private:
|
||||
LayerFactory();
|
||||
};
|
||||
|
||||
//! @}
|
||||
//! @}
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
#endif
|
||||
206
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/shape_utils.hpp
vendored
Normal file
206
lib/3rdParty/OpenCV3.4/include/opencv2/dnn/shape_utils.hpp
vendored
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DNN_DNN_SHAPE_UTILS_HPP
|
||||
#define OPENCV_DNN_DNN_SHAPE_UTILS_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/core/types_c.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
|
||||
//Useful shortcut
|
||||
inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
|
||||
{
|
||||
return s << "[" << r.start << ", " << r.end << ")";
|
||||
}
|
||||
|
||||
//Slicing
|
||||
|
||||
struct _Range : public cv::Range
|
||||
{
|
||||
_Range(const Range &r) : cv::Range(r) {}
|
||||
_Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {}
|
||||
};
|
||||
|
||||
static inline Mat slice(const Mat &m, const _Range &r0)
|
||||
{
|
||||
Range ranges[CV_MAX_DIM];
|
||||
for (int i = 1; i < m.dims; i++)
|
||||
ranges[i] = Range::all();
|
||||
ranges[0] = r0;
|
||||
return m(&ranges[0]);
|
||||
}
|
||||
|
||||
static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1)
|
||||
{
|
||||
CV_Assert(m.dims >= 2);
|
||||
Range ranges[CV_MAX_DIM];
|
||||
for (int i = 2; i < m.dims; i++)
|
||||
ranges[i] = Range::all();
|
||||
ranges[0] = r0;
|
||||
ranges[1] = r1;
|
||||
return m(&ranges[0]);
|
||||
}
|
||||
|
||||
static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2)
|
||||
{
|
||||
CV_Assert(m.dims >= 3);
|
||||
Range ranges[CV_MAX_DIM];
|
||||
for (int i = 3; i < m.dims; i++)
|
||||
ranges[i] = Range::all();
|
||||
ranges[0] = r0;
|
||||
ranges[1] = r1;
|
||||
ranges[2] = r2;
|
||||
return m(&ranges[0]);
|
||||
}
|
||||
|
||||
static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3)
|
||||
{
|
||||
CV_Assert(m.dims >= 4);
|
||||
Range ranges[CV_MAX_DIM];
|
||||
for (int i = 4; i < m.dims; i++)
|
||||
ranges[i] = Range::all();
|
||||
ranges[0] = r0;
|
||||
ranges[1] = r1;
|
||||
ranges[2] = r2;
|
||||
ranges[3] = r3;
|
||||
return m(&ranges[0]);
|
||||
}
|
||||
|
||||
static inline Mat getPlane(const Mat &m, int n, int cn)
|
||||
{
|
||||
CV_Assert(m.dims > 2);
|
||||
int sz[CV_MAX_DIM];
|
||||
for(int i = 2; i < m.dims; i++)
|
||||
{
|
||||
sz[i-2] = m.size.p[i];
|
||||
}
|
||||
return Mat(m.dims - 2, sz, m.type(), (void*)m.ptr<float>(n, cn));
|
||||
}
|
||||
|
||||
static inline MatShape shape(const int* dims, const int n = 4)
|
||||
{
|
||||
MatShape shape;
|
||||
shape.assign(dims, dims + n);
|
||||
return shape;
|
||||
}
|
||||
|
||||
static inline MatShape shape(const Mat& mat)
|
||||
{
|
||||
return shape(mat.size.p, mat.dims);
|
||||
}
|
||||
|
||||
static inline MatShape shape(const UMat& mat)
|
||||
{
|
||||
return shape(mat.size.p, mat.dims);
|
||||
}
|
||||
|
||||
namespace {inline bool is_neg(int i) { return i < 0; }}
|
||||
|
||||
static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1)
|
||||
{
|
||||
int dims[] = {a0, a1, a2, a3};
|
||||
MatShape s = shape(dims);
|
||||
s.erase(std::remove_if(s.begin(), s.end(), is_neg), s.end());
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline int total(const MatShape& shape, int start = -1, int end = -1)
|
||||
{
|
||||
if (start == -1) start = 0;
|
||||
if (end == -1) end = (int)shape.size();
|
||||
|
||||
if (shape.empty())
|
||||
return 0;
|
||||
|
||||
int elems = 1;
|
||||
CV_Assert(start <= (int)shape.size() && end <= (int)shape.size() &&
|
||||
start <= end);
|
||||
for(int i = start; i < end; i++)
|
||||
{
|
||||
elems *= shape[i];
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
static inline MatShape concat(const MatShape& a, const MatShape& b)
|
||||
{
|
||||
MatShape c = a;
|
||||
c.insert(c.end(), b.begin(), b.end());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
inline void print(const MatShape& shape, const String& name = "")
|
||||
{
|
||||
printf("%s: [", name.c_str());
|
||||
size_t i, n = shape.size();
|
||||
for( i = 0; i < n; i++ )
|
||||
printf(" %d", shape[i]);
|
||||
printf(" ]\n");
|
||||
}
|
||||
|
||||
inline int clamp(int ax, int dims)
|
||||
{
|
||||
return ax < 0 ? ax + dims : ax;
|
||||
}
|
||||
|
||||
inline int clamp(int ax, const MatShape& shape)
|
||||
{
|
||||
return clamp(ax, (int)shape.size());
|
||||
}
|
||||
|
||||
inline Range clamp(const Range& r, int axisSize)
|
||||
{
|
||||
Range clamped(std::max(r.start, 0),
|
||||
r.end > 0 ? std::min(r.end, axisSize) : axisSize + r.end + 1);
|
||||
CV_Assert(clamped.start < clamped.end, clamped.end <= axisSize);
|
||||
return clamped;
|
||||
}
|
||||
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -40,11 +40,15 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FEATURES_2D_HPP__
|
||||
#define __OPENCV_FEATURES_2D_HPP__
|
||||
#ifndef OPENCV_FEATURES_2D_HPP
|
||||
#define OPENCV_FEATURES_2D_HPP
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
#include "opencv2/flann/miniflann.hpp"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup features2d 2D Features Framework
|
||||
|
|
@ -117,6 +121,10 @@ public:
|
|||
* Remove duplicated keypoints.
|
||||
*/
|
||||
static void removeDuplicated( std::vector<KeyPoint>& keypoints );
|
||||
/*
|
||||
* Remove duplicated keypoints and sort the remaining keypoints
|
||||
*/
|
||||
static void removeDuplicatedSorted( std::vector<KeyPoint>& keypoints );
|
||||
|
||||
/*
|
||||
* Retain the specified number of the best keypoints (according to the response)
|
||||
|
|
@ -153,8 +161,8 @@ public:
|
|||
@param masks Masks for each input image specifying where to look for keypoints (optional).
|
||||
masks[i] is a mask for images[i].
|
||||
*/
|
||||
virtual void detect( InputArrayOfArrays images,
|
||||
std::vector<std::vector<KeyPoint> >& keypoints,
|
||||
CV_WRAP virtual void detect( InputArrayOfArrays images,
|
||||
CV_OUT std::vector<std::vector<KeyPoint> >& keypoints,
|
||||
InputArrayOfArrays masks=noArray() );
|
||||
|
||||
/** @brief Computes the descriptors for a set of keypoints detected in an image (first variant) or image set
|
||||
|
|
@ -182,8 +190,8 @@ public:
|
|||
descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the
|
||||
descriptor for keypoint j-th keypoint.
|
||||
*/
|
||||
virtual void compute( InputArrayOfArrays images,
|
||||
std::vector<std::vector<KeyPoint> >& keypoints,
|
||||
CV_WRAP virtual void compute( InputArrayOfArrays images,
|
||||
CV_OUT CV_IN_OUT std::vector<std::vector<KeyPoint> >& keypoints,
|
||||
OutputArrayOfArrays descriptors );
|
||||
|
||||
/** Detects keypoints and computes the descriptors */
|
||||
|
|
@ -196,8 +204,21 @@ public:
|
|||
CV_WRAP virtual int descriptorType() const;
|
||||
CV_WRAP virtual int defaultNorm() const;
|
||||
|
||||
CV_WRAP void write( const String& fileName ) const;
|
||||
|
||||
CV_WRAP void read( const String& fileName );
|
||||
|
||||
virtual void write( FileStorage&) const;
|
||||
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP virtual void read( const FileNode&);
|
||||
|
||||
//! Return true if detector object is empty
|
||||
CV_WRAP virtual bool empty() const;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
|
||||
};
|
||||
|
||||
/** Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch
|
||||
|
|
@ -242,6 +263,24 @@ public:
|
|||
@param indexChange index remapping of the bits. */
|
||||
CV_WRAP static Ptr<BRISK> create(const std::vector<float> &radiusList, const std::vector<int> &numberList,
|
||||
float dMax=5.85f, float dMin=8.2f, const std::vector<int>& indexChange=std::vector<int>());
|
||||
|
||||
/** @brief The BRISK constructor for a custom pattern, detection threshold and octaves
|
||||
|
||||
@param thresh AGAST detection threshold score.
|
||||
@param octaves detection octaves. Use 0 to do single scale.
|
||||
@param radiusList defines the radii (in pixels) where the samples around a keypoint are taken (for
|
||||
keypoint scale 1).
|
||||
@param numberList defines the number of sampling points on the sampling circle. Must be the same
|
||||
size as radiusList..
|
||||
@param dMax threshold for the short pairings used for descriptor formation (in pixels for keypoint
|
||||
scale 1).
|
||||
@param dMin threshold for the long pairings used for orientation determination (in pixels for
|
||||
keypoint scale 1).
|
||||
@param indexChange index remapping of the bits. */
|
||||
CV_WRAP static Ptr<BRISK> create(int thresh, int octaves, const std::vector<float> &radiusList,
|
||||
const std::vector<int> &numberList, float dMax=5.85f, float dMin=8.2f,
|
||||
const std::vector<int>& indexChange=std::vector<int>());
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @brief Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor
|
||||
|
|
@ -315,6 +354,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setFastThreshold(int fastThreshold) = 0;
|
||||
CV_WRAP virtual int getFastThreshold() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @brief Maximally stable extremal region extractor
|
||||
|
|
@ -355,13 +395,13 @@ public:
|
|||
|
||||
/** @brief Detect %MSER regions
|
||||
|
||||
@param image input image (8UC1, 8UC3 or 8UC4)
|
||||
@param image input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3)
|
||||
@param msers resulting list of point sets
|
||||
@param bboxes resulting bounding boxes
|
||||
*/
|
||||
CV_WRAP virtual void detectRegions( InputArray image,
|
||||
CV_OUT std::vector<std::vector<Point> >& msers,
|
||||
std::vector<Rect>& bboxes ) = 0;
|
||||
CV_OUT std::vector<Rect>& bboxes ) = 0;
|
||||
|
||||
CV_WRAP virtual void setDelta(int delta) = 0;
|
||||
CV_WRAP virtual int getDelta() const = 0;
|
||||
|
|
@ -374,6 +414,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setPass2Only(bool f) = 0;
|
||||
CV_WRAP virtual bool getPass2Only() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @overload */
|
||||
|
|
@ -429,6 +470,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setType(int type) = 0;
|
||||
CV_WRAP virtual int getType() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @overload */
|
||||
|
|
@ -483,6 +525,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setType(int type) = 0;
|
||||
CV_WRAP virtual int getType() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. :
|
||||
|
|
@ -492,6 +535,8 @@ class CV_EXPORTS_W GFTTDetector : public Feature2D
|
|||
public:
|
||||
CV_WRAP static Ptr<GFTTDetector> create( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1,
|
||||
int blockSize=3, bool useHarrisDetector=false, double k=0.04 );
|
||||
CV_WRAP static Ptr<GFTTDetector> create( int maxCorners, double qualityLevel, double minDistance,
|
||||
int blockSize, int gradiantSize, bool useHarrisDetector=false, double k=0.04 );
|
||||
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
|
||||
CV_WRAP virtual int getMaxFeatures() const = 0;
|
||||
|
||||
|
|
@ -509,6 +554,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setK(double k) = 0;
|
||||
CV_WRAP virtual double getK() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @brief Class for extracting blobs from an image. :
|
||||
|
|
@ -575,6 +621,7 @@ public:
|
|||
|
||||
CV_WRAP static Ptr<SimpleBlobDetector>
|
||||
create(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params());
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
//! @} features2d_main
|
||||
|
|
@ -631,15 +678,25 @@ public:
|
|||
|
||||
CV_WRAP virtual void setDiffusivity(int diff) = 0;
|
||||
CV_WRAP virtual int getDiffusivity() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13 . :
|
||||
/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13.
|
||||
|
||||
@note AKAZE descriptors can only be used with KAZE or AKAZE keypoints. Try to avoid using *extract*
|
||||
and *detect* instead of *operator()* due to performance reasons. .. [ANB13] Fast Explicit Diffusion
|
||||
for Accelerated Features in Nonlinear Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien
|
||||
Bartoli. In British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
|
||||
*/
|
||||
@details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe.
|
||||
|
||||
@note When you need descriptors use Feature2D::detectAndCompute, which
|
||||
provides better performance. When using Feature2D::detect followed by
|
||||
Feature2D::compute scale space pyramid is computed twice.
|
||||
|
||||
@note AKAZE implements T-API. When image is passed as UMat some parts of the algorithm
|
||||
will use OpenCL.
|
||||
|
||||
@note [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear
|
||||
Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In
|
||||
British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
|
||||
|
||||
*/
|
||||
class CV_EXPORTS_W AKAZE : public Feature2D
|
||||
{
|
||||
public:
|
||||
|
|
@ -689,6 +746,7 @@ public:
|
|||
|
||||
CV_WRAP virtual void setDiffusivity(int diff) = 0;
|
||||
CV_WRAP virtual int getDiffusivity() const = 0;
|
||||
CV_WRAP virtual String getDefaultName() const;
|
||||
};
|
||||
|
||||
//! @} features2d_main
|
||||
|
|
@ -728,7 +786,7 @@ struct CV_EXPORTS SL2
|
|||
* Euclidean distance functor
|
||||
*/
|
||||
template<class T>
|
||||
struct CV_EXPORTS L2
|
||||
struct L2
|
||||
{
|
||||
enum { normType = NORM_L2 };
|
||||
typedef T ValueType;
|
||||
|
|
@ -744,7 +802,7 @@ struct CV_EXPORTS L2
|
|||
* Manhattan distance (city block distance) functor
|
||||
*/
|
||||
template<class T>
|
||||
struct CV_EXPORTS L1
|
||||
struct L1
|
||||
{
|
||||
enum { normType = NORM_L1 };
|
||||
typedef T ValueType;
|
||||
|
|
@ -771,6 +829,15 @@ an image set.
|
|||
class CV_EXPORTS_W DescriptorMatcher : public Algorithm
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
FLANNBASED = 1,
|
||||
BRUTEFORCE = 2,
|
||||
BRUTEFORCE_L1 = 3,
|
||||
BRUTEFORCE_HAMMING = 4,
|
||||
BRUTEFORCE_HAMMINGLUT = 5,
|
||||
BRUTEFORCE_SL2 = 6
|
||||
};
|
||||
virtual ~DescriptorMatcher();
|
||||
|
||||
/** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor
|
||||
|
|
@ -868,8 +935,8 @@ public:
|
|||
query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are
|
||||
returned in the distance increasing order.
|
||||
*/
|
||||
void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors,
|
||||
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
CV_WRAP void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors,
|
||||
CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
InputArray mask=noArray(), bool compactResult=false ) const;
|
||||
|
||||
/** @overload
|
||||
|
|
@ -906,11 +973,24 @@ public:
|
|||
false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
|
||||
the matches vector does not contain matches for fully masked-out query descriptors.
|
||||
*/
|
||||
void radiusMatch( InputArray queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
CV_WRAP void radiusMatch( InputArray queryDescriptors, CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
InputArrayOfArrays masks=noArray(), bool compactResult=false );
|
||||
|
||||
|
||||
CV_WRAP void write( const String& fileName ) const
|
||||
{
|
||||
FileStorage fs(fileName, FileStorage::WRITE);
|
||||
write(fs);
|
||||
}
|
||||
|
||||
CV_WRAP void read( const String& fileName )
|
||||
{
|
||||
FileStorage fs(fileName, FileStorage::READ);
|
||||
read(fs.root());
|
||||
}
|
||||
// Reads matcher object from a file node
|
||||
virtual void read( const FileNode& );
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP virtual void read( const FileNode& );
|
||||
// Writes matcher object to a file storage
|
||||
virtual void write( FileStorage& ) const;
|
||||
|
||||
|
|
@ -920,7 +1000,7 @@ public:
|
|||
that is, copies both parameters and train data. If emptyTrainData is true, the method creates an
|
||||
object copy with the current parameters but with empty train data.
|
||||
*/
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||
CV_WRAP virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||
|
||||
/** @brief Creates a descriptor matcher of a given type with the default parameters (using default
|
||||
constructor).
|
||||
|
|
@ -934,6 +1014,13 @@ public:
|
|||
- `FlannBased`
|
||||
*/
|
||||
CV_WRAP static Ptr<DescriptorMatcher> create( const String& descriptorMatcherType );
|
||||
|
||||
CV_WRAP static Ptr<DescriptorMatcher> create( int matcherType );
|
||||
|
||||
|
||||
// see corresponding cv::Algorithm method
|
||||
CV_WRAP inline void write(const Ptr<FileStorage>& fs, const String& name = String()) const { Algorithm::write(fs, name); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Class to work with descriptors from several images as with one merged matrix.
|
||||
|
|
@ -990,8 +1077,17 @@ sets.
|
|||
class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
/** @brief Brute-force matcher constructor.
|
||||
/** @brief Brute-force matcher constructor (obsolete). Please use BFMatcher.create()
|
||||
*
|
||||
*
|
||||
*/
|
||||
CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
|
||||
|
||||
virtual ~BFMatcher() {}
|
||||
|
||||
virtual bool isMaskSupported() const { return true; }
|
||||
|
||||
/** @brief Brute-force matcher create method.
|
||||
@param normType One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are
|
||||
preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and
|
||||
BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor
|
||||
|
|
@ -1003,10 +1099,7 @@ public:
|
|||
pairs. Such technique usually produces best results with minimal number of outliers when there are
|
||||
enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
|
||||
*/
|
||||
CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
|
||||
virtual ~BFMatcher() {}
|
||||
|
||||
virtual bool isMaskSupported() const { return true; }
|
||||
CV_WRAP static Ptr<BFMatcher> create( int normType=NORM_L2, bool crossCheck=false ) ;
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
protected:
|
||||
|
|
@ -1019,10 +1112,11 @@ protected:
|
|||
bool crossCheck;
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN)
|
||||
|
||||
/** @brief Flann-based descriptor matcher.
|
||||
|
||||
This matcher trains flann::Index_ on a train descriptor collection and calls its nearest search
|
||||
This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search
|
||||
methods to find the best matches. So, this matcher may be faster when matching a large train
|
||||
collection than the brute force matcher. FlannBasedMatcher does not support masking permissible
|
||||
matches of descriptor sets because flann::Index does not support this. :
|
||||
|
|
@ -1044,6 +1138,8 @@ public:
|
|||
virtual void train();
|
||||
virtual bool isMaskSupported() const;
|
||||
|
||||
CV_WRAP static Ptr<FlannBasedMatcher> create();
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
protected:
|
||||
static void convertToDMatches( const DescriptorCollection& descriptors,
|
||||
|
|
@ -1063,6 +1159,8 @@ protected:
|
|||
int addedDescCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//! @} features2d_match
|
||||
|
||||
/****************************************************************************************\
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
//
|
||||
//M*/
|
||||
|
||||
#ifndef _OPENCV_FLANN_HPP_
|
||||
#define _OPENCV_FLANN_HPP_
|
||||
#ifndef OPENCV_FLANN_HPP
|
||||
#define OPENCV_FLANN_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/flann/miniflann.hpp"
|
||||
|
|
@ -59,7 +59,7 @@ can be found in @cite Muja2009 .
|
|||
namespace cvflann
|
||||
{
|
||||
CV_EXPORTS flann_distance_t flann_distance_type();
|
||||
FLANN_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order);
|
||||
CV_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ public:
|
|||
|
||||
::cvflann::IndexParams getParameters() { return nnIndex->getParameters(); }
|
||||
|
||||
FLANN_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); }
|
||||
CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); }
|
||||
|
||||
private:
|
||||
::cvflann::Index<Distance>* nnIndex;
|
||||
|
|
@ -338,164 +338,134 @@ int GenericIndex<Distance>::radiusSearch(const Mat& query, Mat& indices, Mat& di
|
|||
* @deprecated Use GenericIndex class instead
|
||||
*/
|
||||
template <typename T>
|
||||
class
|
||||
#ifndef _MSC_VER
|
||||
FLANN_DEPRECATED
|
||||
#endif
|
||||
Index_ {
|
||||
class Index_
|
||||
{
|
||||
public:
|
||||
typedef typename L2<T>::ElementType ElementType;
|
||||
typedef typename L2<T>::ResultType DistanceType;
|
||||
typedef typename L2<T>::ElementType ElementType;
|
||||
typedef typename L2<T>::ResultType DistanceType;
|
||||
|
||||
Index_(const Mat& features, const ::cvflann::IndexParams& params);
|
||||
|
||||
~Index_();
|
||||
|
||||
void knnSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& params);
|
||||
void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params);
|
||||
|
||||
int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& params);
|
||||
int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params);
|
||||
|
||||
void save(String filename)
|
||||
{
|
||||
if (nnIndex_L1) nnIndex_L1->save(filename);
|
||||
if (nnIndex_L2) nnIndex_L2->save(filename);
|
||||
}
|
||||
|
||||
int veclen() const
|
||||
CV_DEPRECATED Index_(const Mat& dataset, const ::cvflann::IndexParams& params)
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->veclen();
|
||||
if (nnIndex_L2) return nnIndex_L2->veclen();
|
||||
}
|
||||
printf("[WARNING] The cv::flann::Index_<T> class is deperecated, use cv::flann::GenericIndex<Distance> instead\n");
|
||||
|
||||
int size() const
|
||||
CV_Assert(dataset.type() == CvType<ElementType>::type());
|
||||
CV_Assert(dataset.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_dataset((ElementType*)dataset.ptr<ElementType>(0), dataset.rows, dataset.cols);
|
||||
|
||||
if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) {
|
||||
nnIndex_L1 = NULL;
|
||||
nnIndex_L2 = new ::cvflann::Index< L2<ElementType> >(m_dataset, params);
|
||||
}
|
||||
else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) {
|
||||
nnIndex_L1 = new ::cvflann::Index< L1<ElementType> >(m_dataset, params);
|
||||
nnIndex_L2 = NULL;
|
||||
}
|
||||
else {
|
||||
printf("[ERROR] cv::flann::Index_<T> only provides backwards compatibility for the L1 and L2 distances. "
|
||||
"For other distance types you must use cv::flann::GenericIndex<Distance>\n");
|
||||
CV_Assert(0);
|
||||
}
|
||||
if (nnIndex_L1) nnIndex_L1->buildIndex();
|
||||
if (nnIndex_L2) nnIndex_L2->buildIndex();
|
||||
}
|
||||
CV_DEPRECATED ~Index_()
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->size();
|
||||
if (nnIndex_L2) return nnIndex_L2->size();
|
||||
}
|
||||
if (nnIndex_L1) delete nnIndex_L1;
|
||||
if (nnIndex_L2) delete nnIndex_L2;
|
||||
}
|
||||
|
||||
::cvflann::IndexParams getParameters()
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->getParameters();
|
||||
if (nnIndex_L2) return nnIndex_L2->getParameters();
|
||||
CV_DEPRECATED void knnSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
|
||||
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
|
||||
::cvflann::Matrix<DistanceType> m_dists(&dists[0], 1, dists.size());
|
||||
|
||||
}
|
||||
if (nnIndex_L1) nnIndex_L1->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
|
||||
if (nnIndex_L2) nnIndex_L2->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
|
||||
}
|
||||
CV_DEPRECATED void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
CV_Assert(queries.type() == CvType<ElementType>::type());
|
||||
CV_Assert(queries.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_queries((ElementType*)queries.ptr<ElementType>(0), queries.rows, queries.cols);
|
||||
|
||||
FLANN_DEPRECATED const ::cvflann::IndexParams* getIndexParameters()
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->getIndexParameters();
|
||||
if (nnIndex_L2) return nnIndex_L2->getIndexParameters();
|
||||
}
|
||||
CV_Assert(indices.type() == CV_32S);
|
||||
CV_Assert(indices.isContinuous());
|
||||
::cvflann::Matrix<int> m_indices((int*)indices.ptr<int>(0), indices.rows, indices.cols);
|
||||
|
||||
CV_Assert(dists.type() == CvType<DistanceType>::type());
|
||||
CV_Assert(dists.isContinuous());
|
||||
::cvflann::Matrix<DistanceType> m_dists((DistanceType*)dists.ptr<DistanceType>(0), dists.rows, dists.cols);
|
||||
|
||||
if (nnIndex_L1) nnIndex_L1->knnSearch(m_queries,m_indices,m_dists,knn, searchParams);
|
||||
if (nnIndex_L2) nnIndex_L2->knnSearch(m_queries,m_indices,m_dists,knn, searchParams);
|
||||
}
|
||||
|
||||
CV_DEPRECATED int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
|
||||
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
|
||||
::cvflann::Matrix<DistanceType> m_dists(&dists[0], 1, dists.size());
|
||||
|
||||
if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
}
|
||||
|
||||
CV_DEPRECATED int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
CV_Assert(query.type() == CvType<ElementType>::type());
|
||||
CV_Assert(query.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)query.ptr<ElementType>(0), query.rows, query.cols);
|
||||
|
||||
CV_Assert(indices.type() == CV_32S);
|
||||
CV_Assert(indices.isContinuous());
|
||||
::cvflann::Matrix<int> m_indices((int*)indices.ptr<int>(0), indices.rows, indices.cols);
|
||||
|
||||
CV_Assert(dists.type() == CvType<DistanceType>::type());
|
||||
CV_Assert(dists.isContinuous());
|
||||
::cvflann::Matrix<DistanceType> m_dists((DistanceType*)dists.ptr<DistanceType>(0), dists.rows, dists.cols);
|
||||
|
||||
if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
}
|
||||
|
||||
CV_DEPRECATED void save(String filename)
|
||||
{
|
||||
if (nnIndex_L1) nnIndex_L1->save(filename);
|
||||
if (nnIndex_L2) nnIndex_L2->save(filename);
|
||||
}
|
||||
|
||||
CV_DEPRECATED int veclen() const
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->veclen();
|
||||
if (nnIndex_L2) return nnIndex_L2->veclen();
|
||||
}
|
||||
|
||||
CV_DEPRECATED int size() const
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->size();
|
||||
if (nnIndex_L2) return nnIndex_L2->size();
|
||||
}
|
||||
|
||||
CV_DEPRECATED ::cvflann::IndexParams getParameters()
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->getParameters();
|
||||
if (nnIndex_L2) return nnIndex_L2->getParameters();
|
||||
|
||||
}
|
||||
|
||||
CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters()
|
||||
{
|
||||
if (nnIndex_L1) return nnIndex_L1->getIndexParameters();
|
||||
if (nnIndex_L2) return nnIndex_L2->getIndexParameters();
|
||||
}
|
||||
|
||||
private:
|
||||
// providing backwards compatibility for L2 and L1 distances (most common)
|
||||
::cvflann::Index< L2<ElementType> >* nnIndex_L2;
|
||||
::cvflann::Index< L1<ElementType> >* nnIndex_L1;
|
||||
// providing backwards compatibility for L2 and L1 distances (most common)
|
||||
::cvflann::Index< L2<ElementType> >* nnIndex_L2;
|
||||
::cvflann::Index< L1<ElementType> >* nnIndex_L1;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
template <typename T>
|
||||
class FLANN_DEPRECATED Index_;
|
||||
#endif
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
template <typename T>
|
||||
Index_<T>::Index_(const Mat& dataset, const ::cvflann::IndexParams& params)
|
||||
{
|
||||
printf("[WARNING] The cv::flann::Index_<T> class is deperecated, use cv::flann::GenericIndex<Distance> instead\n");
|
||||
|
||||
CV_Assert(dataset.type() == CvType<ElementType>::type());
|
||||
CV_Assert(dataset.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_dataset((ElementType*)dataset.ptr<ElementType>(0), dataset.rows, dataset.cols);
|
||||
|
||||
if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) {
|
||||
nnIndex_L1 = NULL;
|
||||
nnIndex_L2 = new ::cvflann::Index< L2<ElementType> >(m_dataset, params);
|
||||
}
|
||||
else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) {
|
||||
nnIndex_L1 = new ::cvflann::Index< L1<ElementType> >(m_dataset, params);
|
||||
nnIndex_L2 = NULL;
|
||||
}
|
||||
else {
|
||||
printf("[ERROR] cv::flann::Index_<T> only provides backwards compatibility for the L1 and L2 distances. "
|
||||
"For other distance types you must use cv::flann::GenericIndex<Distance>\n");
|
||||
CV_Assert(0);
|
||||
}
|
||||
if (nnIndex_L1) nnIndex_L1->buildIndex();
|
||||
if (nnIndex_L2) nnIndex_L2->buildIndex();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Index_<T>::~Index_()
|
||||
{
|
||||
if (nnIndex_L1) delete nnIndex_L1;
|
||||
if (nnIndex_L2) delete nnIndex_L2;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Index_<T>::knnSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
|
||||
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
|
||||
::cvflann::Matrix<DistanceType> m_dists(&dists[0], 1, dists.size());
|
||||
|
||||
if (nnIndex_L1) nnIndex_L1->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
|
||||
if (nnIndex_L2) nnIndex_L2->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void Index_<T>::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
CV_Assert(queries.type() == CvType<ElementType>::type());
|
||||
CV_Assert(queries.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_queries((ElementType*)queries.ptr<ElementType>(0), queries.rows, queries.cols);
|
||||
|
||||
CV_Assert(indices.type() == CV_32S);
|
||||
CV_Assert(indices.isContinuous());
|
||||
::cvflann::Matrix<int> m_indices((int*)indices.ptr<int>(0), indices.rows, indices.cols);
|
||||
|
||||
CV_Assert(dists.type() == CvType<DistanceType>::type());
|
||||
CV_Assert(dists.isContinuous());
|
||||
::cvflann::Matrix<DistanceType> m_dists((DistanceType*)dists.ptr<DistanceType>(0), dists.rows, dists.cols);
|
||||
|
||||
if (nnIndex_L1) nnIndex_L1->knnSearch(m_queries,m_indices,m_dists,knn, searchParams);
|
||||
if (nnIndex_L2) nnIndex_L2->knnSearch(m_queries,m_indices,m_dists,knn, searchParams);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int Index_<T>::radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
|
||||
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
|
||||
::cvflann::Matrix<DistanceType> m_dists(&dists[0], 1, dists.size());
|
||||
|
||||
if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int Index_<T>::radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
|
||||
{
|
||||
CV_Assert(query.type() == CvType<ElementType>::type());
|
||||
CV_Assert(query.isContinuous());
|
||||
::cvflann::Matrix<ElementType> m_query((ElementType*)query.ptr<ElementType>(0), query.rows, query.cols);
|
||||
|
||||
CV_Assert(indices.type() == CV_32S);
|
||||
CV_Assert(indices.isContinuous());
|
||||
::cvflann::Matrix<int> m_indices((int*)indices.ptr<int>(0), indices.rows, indices.cols);
|
||||
|
||||
CV_Assert(dists.type() == CvType<DistanceType>::type());
|
||||
CV_Assert(dists.isContinuous());
|
||||
::cvflann::Matrix<DistanceType> m_dists((DistanceType*)dists.ptr<DistanceType>(0), dists.rows, dists.cols);
|
||||
|
||||
if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
/** @brief Clusters features using hierarchical k-means algorithm.
|
||||
|
||||
|
|
@ -535,7 +505,7 @@ int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::K
|
|||
/** @deprecated
|
||||
*/
|
||||
template <typename ELEM_TYPE, typename DIST_TYPE>
|
||||
FLANN_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params)
|
||||
CV_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params)
|
||||
{
|
||||
printf("[WARNING] cv::flann::hierarchicalClustering<ELEM_TYPE,DIST_TYPE> is deprecated, use "
|
||||
"cv::flann::hierarchicalClustering<Distance> instead\n");
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue