Merge branch 'master' of git://github.com/Opencv/opencv into UserColormap
This commit is contained in:
Vendored
+1
-1
@@ -31,7 +31,7 @@ function(_icv_downloader)
|
||||
return() # Not supported
|
||||
endif()
|
||||
|
||||
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_CURRENT_LIST_DIR}/unpack")
|
||||
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_BINARY_DIR}/3rdparty/ippicv")
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")
|
||||
|
||||
if(DEFINED OPENCV_ICV_PACKAGE_DOWNLOADED
|
||||
|
||||
Vendored
+5
-16
@@ -1,18 +1,7 @@
|
||||
add_library(openvx_hal STATIC src/openvx_hal.cpp include/openvx_hal.hpp include/ivx.hpp include/ivx_lib_debug.hpp)
|
||||
target_include_directories(openvx_hal PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/modules/core/include
|
||||
${CMAKE_SOURCE_DIR}/modules/imgproc/include
|
||||
${OPENVX_INCLUDE_DIR})
|
||||
target_link_libraries(openvx_hal LINK_PUBLIC ${OPENVX_LIBRARIES})
|
||||
set_target_properties(openvx_hal PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
set_target_properties(openvx_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(openvx_hal EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
if(NOT HAVE_OPENVX)
|
||||
message(STATUS "OpenVX is not available, disabling openvx-related HAL and stuff")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPENVX_HAL_FOUND TRUE PARENT_SCOPE)
|
||||
set(OPENVX_HAL_VERSION 0.0.1 PARENT_SCOPE)
|
||||
set(OPENVX_HAL_LIBRARIES "openvx_hal" PARENT_SCOPE)
|
||||
set(OPENVX_HAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/openvx_hal.hpp" PARENT_SCOPE)
|
||||
set(OPENVX_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" "${OPENVX_INCLUDE_DIR}" PARENT_SCOPE)
|
||||
set(OPENCV_3P_OPENVX_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(hal)
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
add_library(openvx_hal STATIC openvx_hal.cpp openvx_hal.hpp ${OPENCV_3P_OPENVX_DIR}/include/ivx.hpp ${OPENCV_3P_OPENVX_DIR}/include/ivx_lib_debug.hpp)
|
||||
target_include_directories(openvx_hal PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${OPENCV_3P_OPENVX_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/modules/core/include
|
||||
${CMAKE_SOURCE_DIR}/modules/imgproc/include
|
||||
${OPENVX_INCLUDE_DIR})
|
||||
target_link_libraries(openvx_hal LINK_PUBLIC ${OPENVX_LIBRARIES})
|
||||
set_target_properties(openvx_hal PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
set_target_properties(openvx_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(openvx_hal EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
endif()
|
||||
|
||||
set(OPENVX_HAL_FOUND TRUE CACHE INTERNAL "")
|
||||
set(OPENVX_HAL_VERSION 0.0.1 CACHE INTERNAL "")
|
||||
set(OPENVX_HAL_LIBRARIES "openvx_hal" CACHE INTERNAL "")
|
||||
set(OPENVX_HAL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/openvx_hal.hpp" CACHE INTERNAL "")
|
||||
set(OPENVX_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" "${OPENCV_3P_OPENVX_DIR}/include" "${OPENVX_INCLUDE_DIR}" CACHE INTERNAL "")
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
#OpenVX-based HAL implementation.
|
||||
It's built when OpenVX is available (`HAVE_OPENVX`).
|
||||
To build OpenCV with OpenVX support add the following **cmake** options:
|
||||
`-DOPENVX_ROOT=/path/to/prebuilt/openvx -DWITH_OPENVX=YES`
|
||||
Vendored
+1088
File diff suppressed because it is too large
Load Diff
Vendored
+143
@@ -0,0 +1,143 @@
|
||||
#ifndef OPENCV_OPENVX_HAL_HPP_INCLUDED
|
||||
#define OPENCV_OPENVX_HAL_HPP_INCLUDED
|
||||
|
||||
#include "opencv2/core/hal/interface.h"
|
||||
#include "opencv2/imgproc/hal/interface.h"
|
||||
|
||||
#include "VX/vx.h"
|
||||
|
||||
template <typename T>
|
||||
int ovx_hal_add(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
template <typename T>
|
||||
int ovx_hal_sub(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
|
||||
template <typename T>
|
||||
int ovx_hal_absdiff(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
|
||||
template <typename T>
|
||||
int ovx_hal_and(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
template <typename T>
|
||||
int ovx_hal_or(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
template <typename T>
|
||||
int ovx_hal_xor(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h);
|
||||
int ovx_hal_not(const uchar *a, size_t astep, uchar *c, size_t cstep, int w, int h);
|
||||
|
||||
template <typename T>
|
||||
int ovx_hal_mul(const T *a, size_t astep, const T *b, size_t bstep, T *c, size_t cstep, int w, int h, double scale);
|
||||
|
||||
int ovx_hal_merge8u(const uchar **src_data, uchar *dst_data, int len, int cn);
|
||||
int ovx_hal_resize(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, double inv_scale_x, double inv_scale_y, int interpolation);
|
||||
int ovx_hal_warpAffine(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, const double M[6], int interpolation, int borderType, const double borderValue[4]);
|
||||
int ovx_hal_warpPerspectve(int atype, const uchar *a, size_t astep, int aw, int ah, uchar *b, size_t bstep, int bw, int bh, const double M[9], int interpolation, int borderType, const double borderValue[4]);
|
||||
|
||||
struct cvhalFilter2D;
|
||||
int ovx_hal_filterInit(cvhalFilter2D **filter_context, uchar *kernel_data, size_t kernel_step, int kernel_type, int kernel_width, int kernel_height,
|
||||
int, int, int src_type, int dst_type, int borderType, double delta, int anchor_x, int anchor_y, bool allowSubmatrix, bool allowInplace);
|
||||
int ovx_hal_filterFree(cvhalFilter2D *filter_context);
|
||||
int ovx_hal_filter(cvhalFilter2D *filter_context, uchar *a, size_t astep, uchar *b, size_t bstep, int w, int h, int, int, int, int);
|
||||
int ovx_hal_sepFilterInit(cvhalFilter2D **filter_context, int src_type, int dst_type,
|
||||
int kernel_type, uchar *kernelx_data, int kernelx_length, uchar *kernely_data, int kernely_length,
|
||||
int anchor_x, int anchor_y, double delta, int borderType);
|
||||
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
int ovx_hal_morphInit(cvhalFilter2D **filter_context, int operation, int src_type, int dst_type, int , int ,
|
||||
int kernel_type, uchar *kernel_data, size_t kernel_step, int kernel_width, int kernel_height, int anchor_x, int anchor_y,
|
||||
int borderType, const double borderValue[4], int iterations, bool allowSubmatrix, bool allowInplace);
|
||||
int ovx_hal_morphFree(cvhalFilter2D *filter_context);
|
||||
int ovx_hal_morph(cvhalFilter2D *filter_context, uchar *a, size_t astep, uchar *b, size_t bstep, int w, int h, int , int , int , int , int , int , int , int );
|
||||
#endif // 1.0 guard
|
||||
|
||||
int ovx_hal_cvtBGRtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int depth, int acn, int bcn, bool swapBlue);
|
||||
int ovx_hal_cvtGraytoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int depth, int bcn);
|
||||
int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtThreePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtBGRtoThreePlaneYUV(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int acn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx, int ycn);
|
||||
int ovx_hal_integral(int depth, int sdepth, int, const uchar * a, size_t astep, uchar * b, size_t bstep, uchar * c, size_t, uchar * d, size_t, int w, int h, int cn);
|
||||
|
||||
//==================================================================================================
|
||||
// functions redefinition
|
||||
// ...
|
||||
|
||||
#undef cv_hal_add8u
|
||||
#define cv_hal_add8u ovx_hal_add<uchar>
|
||||
#undef cv_hal_add16s
|
||||
#define cv_hal_add16s ovx_hal_add<short>
|
||||
#undef cv_hal_sub8u
|
||||
#define cv_hal_sub8u ovx_hal_sub<uchar>
|
||||
#undef cv_hal_sub16s
|
||||
#define cv_hal_sub16s ovx_hal_sub<short>
|
||||
|
||||
#undef cv_hal_absdiff8u
|
||||
#define cv_hal_absdiff8u ovx_hal_absdiff<uchar>
|
||||
#undef cv_hal_absdiff16s
|
||||
#define cv_hal_absdiff16s ovx_hal_absdiff<short>
|
||||
|
||||
#undef cv_hal_and8u
|
||||
#define cv_hal_and8u ovx_hal_and<uchar>
|
||||
#undef cv_hal_or8u
|
||||
#define cv_hal_or8u ovx_hal_or<uchar>
|
||||
#undef cv_hal_xor8u
|
||||
#define cv_hal_xor8u ovx_hal_xor<uchar>
|
||||
#undef cv_hal_not8u
|
||||
#define cv_hal_not8u ovx_hal_not
|
||||
|
||||
#undef cv_hal_mul8u
|
||||
#define cv_hal_mul8u ovx_hal_mul<uchar>
|
||||
#undef cv_hal_mul16s
|
||||
#define cv_hal_mul16s ovx_hal_mul<short>
|
||||
|
||||
#undef cv_hal_merge8u
|
||||
#define cv_hal_merge8u ovx_hal_merge8u
|
||||
|
||||
//#undef cv_hal_resize
|
||||
//#define cv_hal_resize ovx_hal_resize
|
||||
|
||||
//OpenVX warps use round to zero policy at least in sample implementation
|
||||
//while OpenCV require round to nearest
|
||||
//#undef cv_hal_warpAffine
|
||||
//#define cv_hal_warpAffine ovx_hal_warpAffine
|
||||
//#undef cv_hal_warpPerspective
|
||||
//#define cv_hal_warpPerspective ovx_hal_warpPerspectve
|
||||
|
||||
#undef cv_hal_filterInit
|
||||
#define cv_hal_filterInit ovx_hal_filterInit
|
||||
#undef cv_hal_filter
|
||||
#define cv_hal_filter ovx_hal_filter
|
||||
#undef cv_hal_filterFree
|
||||
#define cv_hal_filterFree ovx_hal_filterFree
|
||||
|
||||
#undef cv_hal_sepFilterInit
|
||||
#define cv_hal_sepFilterInit ovx_hal_sepFilterInit
|
||||
#undef cv_hal_sepFilter
|
||||
#define cv_hal_sepFilter ovx_hal_filter
|
||||
#undef cv_hal_sepFilterFree
|
||||
#define cv_hal_sepFilterFree ovx_hal_filterFree
|
||||
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
|
||||
#undef cv_hal_morphInit
|
||||
#define cv_hal_morphInit ovx_hal_morphInit
|
||||
#undef cv_hal_morph
|
||||
#define cv_hal_morph ovx_hal_morph
|
||||
#undef cv_hal_morphFree
|
||||
#define cv_hal_morphFree ovx_hal_morphFree
|
||||
|
||||
#endif // 1.0 guard
|
||||
|
||||
#undef cv_hal_cvtBGRtoBGR
|
||||
#define cv_hal_cvtBGRtoBGR ovx_hal_cvtBGRtoBGR
|
||||
#undef cv_hal_cvtGraytoBGR
|
||||
#define cv_hal_cvtGraytoBGR ovx_hal_cvtGraytoBGR
|
||||
#undef cv_hal_cvtTwoPlaneYUVtoBGR
|
||||
#define cv_hal_cvtTwoPlaneYUVtoBGR ovx_hal_cvtTwoPlaneYUVtoBGR
|
||||
#undef cv_hal_cvtThreePlaneYUVtoBGR
|
||||
#define cv_hal_cvtThreePlaneYUVtoBGR ovx_hal_cvtThreePlaneYUVtoBGR
|
||||
#undef cv_hal_cvtBGRtoThreePlaneYUV
|
||||
#define cv_hal_cvtBGRtoThreePlaneYUV ovx_hal_cvtBGRtoThreePlaneYUV
|
||||
#undef cv_hal_cvtOnePlaneYUVtoBGR
|
||||
#define cv_hal_cvtOnePlaneYUVtoBGR ovx_hal_cvtOnePlaneYUVtoBGR
|
||||
#undef cv_hal_integral
|
||||
#define cv_hal_integral ovx_hal_integral
|
||||
|
||||
#endif
|
||||
Vendored
+333
-6
@@ -22,6 +22,18 @@ Details: TBD
|
||||
#include <VX/vx.h>
|
||||
#include <VX/vxu.h>
|
||||
|
||||
#ifndef VX_VERSION_1_1
|
||||
// 1.1 to 1.0 backward compatibility defines
|
||||
|
||||
static const vx_enum VX_INTERPOLATION_BILINEAR = VX_INTERPOLATION_TYPE_BILINEAR;
|
||||
static const vx_enum VX_INTERPOLATION_AREA = VX_INTERPOLATION_TYPE_AREA;
|
||||
static const vx_enum VX_INTERPOLATION_NEAREST_NEIGHBOR = VX_INTERPOLATION_TYPE_NEAREST_NEIGHBOR;
|
||||
|
||||
static const vx_enum VX_BORDER_CONSTANT = VX_BORDER_MODE_CONSTANT;
|
||||
static const vx_enum VX_BORDER_REPLICATE = VX_BORDER_MODE_REPLICATE;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef IVX_USE_CXX98
|
||||
// checking compiler
|
||||
#if __cplusplus < 201103L && (!defined(_MSC_VER) || _MSC_VER < 1800)
|
||||
@@ -56,6 +68,7 @@ Details: TBD
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifndef IVX_USE_CXX98
|
||||
#include <type_traits>
|
||||
@@ -190,14 +203,14 @@ inline vx_size enumToTypeSize(vx_enum type)
|
||||
template<typename T> struct TypeToEnum {};
|
||||
template<> struct TypeToEnum<vx_char> { static const vx_enum value = VX_TYPE_CHAR; };
|
||||
template<> struct TypeToEnum<vx_int8> { static const vx_enum value = VX_TYPE_INT8; };
|
||||
template<> struct TypeToEnum<vx_uint8> { static const vx_enum value = VX_TYPE_UINT8; };
|
||||
template<> struct TypeToEnum<vx_int16> { static const vx_enum value = VX_TYPE_INT16; };
|
||||
template<> struct TypeToEnum<vx_uint16> { static const vx_enum value = VX_TYPE_UINT16; };
|
||||
template<> struct TypeToEnum<vx_int32> { static const vx_enum value = VX_TYPE_INT32; };
|
||||
template<> struct TypeToEnum<vx_uint32> { static const vx_enum value = VX_TYPE_UINT32; };
|
||||
template<> struct TypeToEnum<vx_uint8> { static const vx_enum value = VX_TYPE_UINT8, imgType = VX_DF_IMAGE_U8; };
|
||||
template<> struct TypeToEnum<vx_int16> { static const vx_enum value = VX_TYPE_INT16, imgType = VX_DF_IMAGE_S16; };
|
||||
template<> struct TypeToEnum<vx_uint16> { static const vx_enum value = VX_TYPE_UINT16, imgType = VX_DF_IMAGE_U16; };
|
||||
template<> struct TypeToEnum<vx_int32> { static const vx_enum value = VX_TYPE_INT32, imgType = VX_DF_IMAGE_S32; };
|
||||
template<> struct TypeToEnum<vx_uint32> { static const vx_enum value = VX_TYPE_UINT32, imgType = VX_DF_IMAGE_U32; };
|
||||
template<> struct TypeToEnum<vx_int64> { static const vx_enum value = VX_TYPE_INT64; };
|
||||
template<> struct TypeToEnum<vx_uint64> { static const vx_enum value = VX_TYPE_UINT64; };
|
||||
template<> struct TypeToEnum<vx_float32> { static const vx_enum value = VX_TYPE_FLOAT32; };
|
||||
template<> struct TypeToEnum<vx_float32> { static const vx_enum value = VX_TYPE_FLOAT32, imgType = VX_DF_IMAGE('F', '0', '3', '2'); };
|
||||
template<> struct TypeToEnum<vx_float64> { static const vx_enum value = VX_TYPE_FLOAT64; };
|
||||
template<> struct TypeToEnum<vx_bool> { static const vx_enum value = VX_TYPE_BOOL; };
|
||||
template<> struct TypeToEnum<vx_keypoint_t> {static const vx_enum value = VX_TYPE_KEYPOINT; };
|
||||
@@ -343,6 +356,15 @@ template <> struct RefTypeTraits <vx_lut>
|
||||
static vx_status release(vxType& ref) { return vxReleaseLUT(&ref); }
|
||||
};
|
||||
|
||||
class Pyramid;
|
||||
template <> struct RefTypeTraits <vx_pyramid>
|
||||
{
|
||||
typedef vx_pyramid vxType;
|
||||
typedef Pyramid wrapperType;
|
||||
static const vx_enum vxTypeEnum = VX_TYPE_PYRAMID;
|
||||
static vx_status release(vxType& ref) { return vxReleasePyramid(&ref); }
|
||||
};
|
||||
|
||||
class Distribution;
|
||||
template <> struct RefTypeTraits <vx_distribution>
|
||||
{
|
||||
@@ -352,6 +374,15 @@ template <> struct RefTypeTraits <vx_distribution>
|
||||
static vx_status release(vxType& ref) { return vxReleaseDistribution(&ref); }
|
||||
};
|
||||
|
||||
class Remap;
|
||||
template <> struct RefTypeTraits <vx_remap>
|
||||
{
|
||||
typedef vx_remap vxType;
|
||||
typedef Remap wrapperType;
|
||||
static const vx_enum vxTypeEnum = VX_TYPE_REMAP;
|
||||
static vx_status release(vxType& ref) { return vxReleaseRemap(&ref); }
|
||||
};
|
||||
|
||||
#ifdef IVX_USE_CXX98
|
||||
|
||||
/// Casting to vx_reference with compile-time check
|
||||
@@ -909,6 +940,34 @@ public:
|
||||
void setImmediateBorder(vx_enum mode, const vx_pixel_value_t& val)
|
||||
{ border_t bm = {mode, val}; setImmediateBorder(bm); }
|
||||
|
||||
/// vxSetContextAttribute(BORDER) wrapper
|
||||
template <typename T>
|
||||
void setImmediateBorder(vx_enum mode, const T& _val)
|
||||
{
|
||||
vx_pixel_value_t val;
|
||||
switch (TypeToEnum<T>::value)
|
||||
{
|
||||
case VX_TYPE_UINT8:
|
||||
val.U8 = _val;
|
||||
break;
|
||||
case VX_TYPE_INT16:
|
||||
val.S16 = _val;
|
||||
break;
|
||||
case VX_TYPE_UINT16:
|
||||
val.U16 = _val;
|
||||
break;
|
||||
case VX_TYPE_INT32:
|
||||
val.S32 = _val;
|
||||
break;
|
||||
case VX_TYPE_UINT32:
|
||||
val.U32 = _val;
|
||||
break;
|
||||
default:
|
||||
throw WrapperError("Unsupported constant border value type");
|
||||
}
|
||||
setImmediateBorder(mode, val);
|
||||
}
|
||||
|
||||
/// vxSetContextAttribute(BORDER) wrapper
|
||||
void setImmediateBorder(vx_enum mode)
|
||||
{ vx_pixel_value_t val = {}; setImmediateBorder(mode, val); }
|
||||
@@ -1264,6 +1323,34 @@ static const vx_enum
|
||||
void setBorder(vx_enum mode, const vx_pixel_value_t& val)
|
||||
{ vx_border_t bm = {mode, val}; setBorder(bm); }
|
||||
|
||||
/// vxSetNodeAttribute(BORDER) wrapper
|
||||
template <typename T>
|
||||
void setBorder(vx_enum mode, const T& _val)
|
||||
{
|
||||
vx_pixel_value_t val;
|
||||
switch (TypeToEnum<T>::value)
|
||||
{
|
||||
case VX_TYPE_UINT8:
|
||||
val.U8 = _val;
|
||||
break;
|
||||
case VX_TYPE_INT16:
|
||||
val.S16 = _val;
|
||||
break;
|
||||
case VX_TYPE_UINT16:
|
||||
val.U16 = _val;
|
||||
break;
|
||||
case VX_TYPE_INT32:
|
||||
val.S32 = _val;
|
||||
break;
|
||||
case VX_TYPE_UINT32:
|
||||
val.U32 = _val;
|
||||
break;
|
||||
default:
|
||||
throw WrapperError("Unsupported constant border value type");
|
||||
}
|
||||
setBorder(mode, val);
|
||||
}
|
||||
|
||||
/// vxSetNodeAttribute(BORDER) wrapper
|
||||
void setBorder(vx_enum mode)
|
||||
{ vx_pixel_value_t val = {}; setBorder(mode, val); }
|
||||
@@ -1302,6 +1389,25 @@ public:
|
||||
static Image createUniform(vx_context context, vx_uint32 width, vx_uint32 height, vx_df_image format, const void* value)
|
||||
{ return Image(vxCreateUniformImage(context, width, height, format, value)); }
|
||||
#endif
|
||||
template <typename T>
|
||||
static Image createUniform(vx_context context, vx_uint32 width, vx_uint32 height, vx_df_image format, const T value)
|
||||
{
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
vx_pixel_value_t pixel;
|
||||
switch (format)
|
||||
{
|
||||
case VX_DF_IMAGE_U8:pixel.U8 = (vx_uint8)value; break;
|
||||
case VX_DF_IMAGE_S16:pixel.S16 = (vx_int16)value; break;
|
||||
case VX_DF_IMAGE_U16:pixel.U16 = (vx_uint16)value; break;
|
||||
case VX_DF_IMAGE_S32:pixel.S32 = (vx_int32)value; break;
|
||||
case VX_DF_IMAGE_U32:pixel.U32 = (vx_uint32)value; break;
|
||||
default:throw ivx::WrapperError("uniform image type unsupported by this call");
|
||||
}
|
||||
return Image(vxCreateUniformImage(context, width, height, format, &pixel));
|
||||
#else
|
||||
return Image(vxCreateUniformImage(context, width, height, format, &value));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Planes number for the specified image format (fourcc)
|
||||
/// \return 0 for unknown formats
|
||||
@@ -1514,6 +1620,15 @@ static const vx_enum
|
||||
}
|
||||
#endif // VX_VERSION_1_1
|
||||
|
||||
/// vxSetImageAttribute() wrapper
|
||||
template<typename T>
|
||||
void setAttribute(vx_enum att, T& value) const
|
||||
{ IVX_CHECK_STATUS(vxSetImageAttribute(ref, att, &value, sizeof(value))); }
|
||||
|
||||
/// vxSetImageAttribute(SPACE) wrapper
|
||||
void setColorSpace(const vx_enum& sp)
|
||||
{ setAttribute(VX_IMAGE_SPACE, sp); }
|
||||
|
||||
/// vxGetValidRegionImage() wrapper
|
||||
vx_rectangle_t getValidRegion() const
|
||||
{
|
||||
@@ -1804,7 +1919,9 @@ public:
|
||||
swap(_planeIdx, p._planeIdx);
|
||||
#endif
|
||||
swap(_img, p._img);
|
||||
#ifdef IVX_USE_OPENCV
|
||||
swap(_m, p._m);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2755,6 +2872,74 @@ public:
|
||||
#endif //IVX_USE_OPENCV
|
||||
};
|
||||
|
||||
/*
|
||||
* Pyramid
|
||||
*/
|
||||
class Pyramid : public RefWrapper<vx_pyramid>
|
||||
{
|
||||
public:
|
||||
IVX_REF_STD_CTORS_AND_ASSIGNMENT(Pyramid)
|
||||
|
||||
static Pyramid create(vx_context context, vx_size levels, vx_float32 scale,
|
||||
vx_uint32 width, vx_uint32 height, vx_df_image format)
|
||||
{return Pyramid(vxCreatePyramid(context, levels, scale, width, height, format));}
|
||||
|
||||
static Pyramid createVirtual(vx_graph graph, vx_size levels, vx_float32 scale,
|
||||
vx_uint32 width, vx_uint32 height, vx_df_image format)
|
||||
{return Pyramid(vxCreateVirtualPyramid(graph, levels, scale, width, height, format));}
|
||||
|
||||
#ifndef VX_VERSION_1_1
|
||||
static const vx_enum
|
||||
VX_PYRAMID_LEVELS = VX_PYRAMID_ATTRIBUTE_LEVELS,
|
||||
VX_PYRAMID_SCALE = VX_PYRAMID_ATTRIBUTE_SCALE,
|
||||
VX_PYRAMID_WIDTH = VX_PYRAMID_ATTRIBUTE_WIDTH,
|
||||
VX_PYRAMID_HEIGHT = VX_PYRAMID_ATTRIBUTE_HEIGHT,
|
||||
VX_PYRAMID_FORMAT = VX_PYRAMID_ATTRIBUTE_FORMAT;
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
void query(vx_enum att, T& value) const
|
||||
{ IVX_CHECK_STATUS( vxQueryPyramid(ref, att, &value, sizeof(value)) ); }
|
||||
|
||||
vx_size levels() const
|
||||
{
|
||||
vx_size l;
|
||||
query(VX_PYRAMID_LEVELS, l);
|
||||
return l;
|
||||
}
|
||||
|
||||
vx_float32 scale() const
|
||||
{
|
||||
vx_float32 s;
|
||||
query(VX_PYRAMID_SCALE, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
vx_uint32 width() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_PYRAMID_WIDTH, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_uint32 height() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_PYRAMID_HEIGHT, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_df_image format() const
|
||||
{
|
||||
vx_df_image f;
|
||||
query(VX_PYRAMID_FORMAT, f);
|
||||
return f;
|
||||
}
|
||||
|
||||
Image getLevel(vx_uint32 index)
|
||||
{ return Image(vxGetPyramidLevel(ref, index)); }
|
||||
};
|
||||
|
||||
/*
|
||||
* Distribution
|
||||
*/
|
||||
@@ -2922,6 +3107,148 @@ public:
|
||||
#endif //IVX_USE_OPENCV
|
||||
};
|
||||
|
||||
/*
|
||||
* Remap
|
||||
*/
|
||||
class Remap : public RefWrapper<vx_remap>
|
||||
{
|
||||
public:
|
||||
IVX_REF_STD_CTORS_AND_ASSIGNMENT(Remap);
|
||||
|
||||
static Remap create(vx_context context, vx_uint32 src_width, vx_uint32 src_height, vx_uint32 dst_width, vx_uint32 dst_height)
|
||||
{
|
||||
return Remap(vxCreateRemap(context, src_width, src_height, dst_width, dst_height));
|
||||
}
|
||||
|
||||
#ifndef VX_VERSION_1_1
|
||||
static const vx_enum
|
||||
VX_REMAP_SOURCE_WIDTH = VX_REMAP_ATTRIBUTE_SOURCE_WIDTH,
|
||||
VX_REMAP_SOURCE_HEIGHT = VX_REMAP_ATTRIBUTE_SOURCE_HEIGHT,
|
||||
VX_REMAP_DESTINATION_WIDTH = VX_REMAP_ATTRIBUTE_DESTINATION_WIDTH,
|
||||
VX_REMAP_DESTINATION_HEIGHT = VX_REMAP_ATTRIBUTE_DESTINATION_HEIGHT;
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
void query(vx_enum att, T& value) const
|
||||
{ IVX_CHECK_STATUS(vxQueryRemap(ref, att, &value, sizeof(value))); }
|
||||
|
||||
vx_uint32 srcWidth() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_REMAP_SOURCE_WIDTH, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_uint32 srcHeight() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_REMAP_SOURCE_HEIGHT, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_uint32 dstWidth() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_REMAP_DESTINATION_WIDTH, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_uint32 dstHeight() const
|
||||
{
|
||||
vx_uint32 v;
|
||||
query(VX_REMAP_DESTINATION_HEIGHT, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
vx_uint32 srcCoordType() const
|
||||
{ return VX_TYPE_FLOAT32; }
|
||||
|
||||
vx_uint32 dstCoordType() const
|
||||
{ return VX_TYPE_UINT32; }
|
||||
|
||||
void setMapping(vx_uint32 dst_x, vx_uint32 dst_y, vx_float32 src_x, vx_float32 src_y)
|
||||
{ IVX_CHECK_STATUS(vxSetRemapPoint(ref, dst_x, dst_y, src_x, src_y)); }
|
||||
|
||||
void getMapping(vx_uint32 dst_x, vx_uint32 dst_y, vx_float32 &src_x, vx_float32 &src_y) const
|
||||
{ IVX_CHECK_STATUS(vxGetRemapPoint(ref, dst_x, dst_y, &src_x, &src_y)); }
|
||||
|
||||
#ifdef IVX_USE_OPENCV
|
||||
void setMappings(const cv::Mat& map_x, const cv::Mat& map_y)
|
||||
{
|
||||
if (map_x.type() != enumToCVType(srcCoordType()) || map_y.type() != enumToCVType(srcCoordType()))
|
||||
throw WrapperError(std::string(__func__) + "(): mapping type is wrong");
|
||||
if ((vx_uint32)(map_x.rows) != dstHeight() || (vx_uint32)(map_x.cols) != dstWidth())
|
||||
throw WrapperError(std::string(__func__) + "(): x mapping size is wrong");
|
||||
if ((vx_uint32)(map_y.rows) != dstHeight() || (vx_uint32)(map_y.cols) != dstWidth())
|
||||
throw WrapperError(std::string(__func__) + "(): y mapping size is wrong");
|
||||
|
||||
for (vx_uint32 y = 0; y < dstHeight(); y++)
|
||||
{
|
||||
const vx_float32* map_x_line = map_x.ptr<vx_float32>(y);
|
||||
const vx_float32* map_y_line = map_y.ptr<vx_float32>(y);
|
||||
for (vx_uint32 x = 0; x < dstWidth(); x++)
|
||||
setMapping(x, y, map_x_line[x], map_y_line[x]);
|
||||
}
|
||||
}
|
||||
|
||||
void setMappings(const cv::Mat& map)
|
||||
{
|
||||
if (map.depth() != CV_MAT_DEPTH(enumToCVType(srcCoordType())) || map.channels() != 2)
|
||||
throw WrapperError(std::string(__func__) + "(): mapping type is wrong");
|
||||
if ((vx_uint32)(map.rows) != dstHeight() || (vx_uint32)(map.cols) != dstWidth())
|
||||
throw WrapperError(std::string(__func__) + "(): x mapping size is wrong");
|
||||
|
||||
for (vx_uint32 y = 0; y < dstHeight(); y++)
|
||||
{
|
||||
const vx_float32* map_line = map.ptr<vx_float32>(y);
|
||||
for (vx_uint32 x = 0; x < 2*dstWidth(); x+=2)
|
||||
setMapping(x, y, map_line[x], map_line[x+1]);
|
||||
}
|
||||
}
|
||||
|
||||
void getMappings(cv::Mat& map_x, cv::Mat& map_y) const
|
||||
{
|
||||
if (map_x.type() != enumToCVType(srcCoordType()) || map_y.type() != enumToCVType(srcCoordType()))
|
||||
throw WrapperError(std::string(__func__) + "(): mapping type is wrong");
|
||||
if (((vx_uint32)(map_x.rows) != dstHeight() || (vx_uint32)(map_x.cols) != dstWidth()) && !map_x.empty())
|
||||
throw WrapperError(std::string(__func__) + "(): x mapping size is wrong");
|
||||
if (((vx_uint32)(map_y.rows) != dstHeight() || (vx_uint32)(map_y.cols) != dstWidth()) && !map_y.empty())
|
||||
throw WrapperError(std::string(__func__) + "(): y mapping size is wrong");
|
||||
|
||||
if (map_x.empty())
|
||||
map_x = cv::Mat((int)dstHeight(), (int)dstWidth(), enumToCVType(srcCoordType()));
|
||||
if (map_y.empty())
|
||||
map_y = cv::Mat((int)dstHeight(), (int)dstWidth(), enumToCVType(srcCoordType()));
|
||||
|
||||
for (vx_uint32 y = 0; y < dstHeight(); y++)
|
||||
{
|
||||
vx_float32* map_x_line = map_x.ptr<vx_float32>(y);
|
||||
vx_float32* map_y_line = map_y.ptr<vx_float32>(y);
|
||||
for (vx_uint32 x = 0; x < dstWidth(); x++)
|
||||
getMapping(x, y, map_x_line[x], map_y_line[x]);
|
||||
}
|
||||
}
|
||||
|
||||
void getMappings(cv::Mat& map) const
|
||||
{
|
||||
if (map.depth() != CV_MAT_DEPTH(enumToCVType(srcCoordType())) || map.channels() != 2)
|
||||
throw WrapperError(std::string(__func__) + "(): mapping type is wrong");
|
||||
if (((vx_uint32)(map.rows) != dstHeight() || (vx_uint32)(map.cols) != dstWidth()) && !map.empty())
|
||||
throw WrapperError(std::string(__func__) + "(): x mapping size is wrong");
|
||||
|
||||
if (map.empty())
|
||||
map = cv::Mat((int)dstHeight(), (int)dstWidth(), CV_MAKETYPE(CV_MAT_DEPTH(enumToCVType(srcCoordType())),2));
|
||||
|
||||
for (vx_uint32 y = 0; y < dstHeight(); y++)
|
||||
{
|
||||
vx_float32* map_line = map.ptr<vx_float32>(y);
|
||||
for (vx_uint32 x = 0; x < 2*dstWidth(); x+=2)
|
||||
getMapping(x, y, map_line[x], map_line[x+1]);
|
||||
}
|
||||
}
|
||||
#endif //IVX_USE_OPENCV
|
||||
};
|
||||
|
||||
/// Standard nodes
|
||||
namespace nodes {
|
||||
|
||||
|
||||
-1273
File diff suppressed because it is too large
Load Diff
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
#include "openvx_hal.hpp"
|
||||
|
||||
vxContext * vxContext::getContext()
|
||||
{
|
||||
// not thread safe
|
||||
static vxContext instance;
|
||||
return &instance;
|
||||
}
|
||||
+3
-2
@@ -227,7 +227,7 @@ OCV_OPTION(WITH_VA "Include VA support" OFF
|
||||
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
@@ -556,6 +556,7 @@ include(cmake/OpenCVFindLibsGrfmt.cmake)
|
||||
include(cmake/OpenCVFindLibsGUI.cmake)
|
||||
include(cmake/OpenCVFindLibsVideo.cmake)
|
||||
include(cmake/OpenCVFindLibsPerf.cmake)
|
||||
include(cmake/OpenCVFindLAPACK.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect other 3rd-party libraries/tools
|
||||
@@ -1222,7 +1223,7 @@ status(" Use Intel VA-API/OpenCL:" HAVE_VA_INTEL THEN "YES (MSDK: ${VA
|
||||
endif(DEFINED WITH_VA_INTEL)
|
||||
|
||||
if(DEFINED WITH_LAPACK)
|
||||
status(" Use Lapack:" HAVE_LAPACK THEN "YES" ELSE NO)
|
||||
status(" Use Lapack:" HAVE_LAPACK THEN "YES (${LAPACK_LIBRARIES})" ELSE NO)
|
||||
endif(DEFINED WITH_LAPACK)
|
||||
|
||||
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
|
||||
|
||||
@@ -1270,7 +1270,7 @@ void cvCreateTrainingSamples( const char* filename,
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Sample", &sample );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
@@ -1402,7 +1402,7 @@ void cvCreateTestSamples( const char* infoname,
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Image", &cvbgreader->src );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilena
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Sample", sample );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
@@ -1672,7 +1672,7 @@ void cvShowVecSamples( const char* filename, int winwidth, int winheight,
|
||||
icvGetTraininDataFromVec( sample, &file );
|
||||
if( scale != 1.0 ) cvResize( sample, scaled_sample, CV_INTER_LINEAR);
|
||||
cvShowImage( "Sample", scaled_sample );
|
||||
if( cvWaitKey( 0 ) == 27 ) break;
|
||||
if( (cvWaitKey( 0 ) & 0xFF) == 27 ) break;
|
||||
}
|
||||
if( scaled_sample && scaled_sample != sample ) cvReleaseMat( &scaled_sample );
|
||||
cvReleaseMat( &sample );
|
||||
@@ -1680,4 +1680,4 @@ void cvShowVecSamples( const char* filename, int winwidth, int winheight,
|
||||
}
|
||||
fclose( file.input );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
||||
for (std::vector<cv::Ptr<FrameProcessor> >::iterator it = processors.begin(); it != processors.end(); ++it)
|
||||
processedFrame = (*it)->processFrame(processedFrame);
|
||||
cv::imshow(mainWindowName, processedFrame);
|
||||
int key = cv::waitKey(CAP_DELAY);
|
||||
char key = (char)cv::waitKey(CAP_DELAY);
|
||||
|
||||
if(key == 27) // esc
|
||||
return Finished;
|
||||
|
||||
@@ -412,6 +412,7 @@ bool CvCascadeClassifier::readStages( const FileNode &node)
|
||||
}
|
||||
|
||||
// For old Haar Classifier file saving
|
||||
#define ICV_HAAR_TYPE_ID "opencv-haar-classifier"
|
||||
#define ICV_HAAR_SIZE_NAME "size"
|
||||
#define ICV_HAAR_STAGES_NAME "stages"
|
||||
#define ICV_HAAR_TREES_NAME "trees"
|
||||
@@ -434,11 +435,12 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
|
||||
if ( !fs.isOpened() )
|
||||
return;
|
||||
|
||||
fs << FileStorage::getDefaultObjectName(filename) << "{";
|
||||
fs << FileStorage::getDefaultObjectName(filename);
|
||||
if ( !baseFormat )
|
||||
{
|
||||
Mat featureMap;
|
||||
getUsedFeaturesIdxMap( featureMap );
|
||||
fs << "{";
|
||||
writeParams( fs );
|
||||
fs << CC_STAGE_NUM << (int)stageClassifiers.size();
|
||||
writeStages( fs, featureMap );
|
||||
@@ -450,6 +452,7 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
|
||||
CvSeq* weak;
|
||||
if ( cascadeParams.featureType != CvFeatureParams::HAAR )
|
||||
CV_Error( CV_StsBadFunc, "old file format is used for Haar-like features only");
|
||||
fs << "{:" ICV_HAAR_TYPE_ID;
|
||||
fs << ICV_HAAR_SIZE_NAME << "[:" << cascadeParams.winSize.width <<
|
||||
cascadeParams.winSize.height << "]";
|
||||
fs << ICV_HAAR_STAGES_NAME << "[";
|
||||
|
||||
@@ -101,6 +101,10 @@ if(MINGW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CV_ICC AND NOT ENABLE_FAST_MATH)
|
||||
add_extra_compiler_option("-fp-model precise")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# High level of warnings.
|
||||
add_extra_compiler_option(-W)
|
||||
@@ -414,8 +418,13 @@ if(MSVC)
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
|
||||
if(NOT ENABLE_NOISY_WARNINGS AND MSVC_VERSION EQUAL 1400)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267)
|
||||
if(NOT ENABLE_NOISY_WARNINGS)
|
||||
if(MSVC_VERSION EQUAL 1400)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267)
|
||||
endif()
|
||||
if(MSVC_VERSION LESS 1900) # MSVS2015
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127) # warning C4127: conditional expression is constant
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# allow extern "C" functions throw exceptions
|
||||
@@ -432,6 +441,13 @@ if(MSVC)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4275) # non dll-interface class 'std::exception' used as base for dll-interface class 'cv::Exception'
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm'
|
||||
endif()
|
||||
|
||||
if(CV_ICC AND NOT ENABLE_NOISY_WARNINGS)
|
||||
foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
|
||||
string(REGEX REPLACE "( |^)/W[0-9]+( |$)" "\\1\\2" ${flags} "${${flags}}")
|
||||
endforeach()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qwd673") # PCH warning
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib")
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#COPYRIGHT
|
||||
#
|
||||
#All contributions by the University of California:
|
||||
#Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
|
||||
#All rights reserved.
|
||||
#
|
||||
#All other contributions:
|
||||
#Copyright (c) 2014, 2015, the respective contributors
|
||||
#All rights reserved.
|
||||
#
|
||||
#Caffe uses a shared copyright model: each contributor holds copyright over
|
||||
#their contributions to Caffe. The project versioning records all such
|
||||
#contribution and copyright details. If a contributor wants to further mark
|
||||
#their specific copyright on a particular contribution, they should indicate
|
||||
#their copyright solely in the commit message of the change when it is
|
||||
#committed.
|
||||
#
|
||||
#LICENSE
|
||||
#
|
||||
#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.
|
||||
#
|
||||
#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 COPYRIGHT OWNER 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.
|
||||
#
|
||||
#CONTRIBUTION AGREEMENT
|
||||
#
|
||||
#By contributing to the BVLC/caffe repository through pull-request, comment,
|
||||
#or otherwise, the contributor releases their content to the
|
||||
#license and copyright terms herein.
|
||||
|
||||
|
||||
# Find the Atlas (and Lapack) libraries
|
||||
#
|
||||
# The following variables are optionally searched for defaults
|
||||
# Atlas_ROOT_DIR: Base directory where all Atlas components are found
|
||||
#
|
||||
# The following are set after configuration is done:
|
||||
# Atlas_FOUND
|
||||
# Atlas_INCLUDE_DIRS
|
||||
# Atlas_LIBRARIES
|
||||
# Atlas_LIBRARYRARY_DIRS
|
||||
|
||||
set(Atlas_INCLUDE_SEARCH_PATHS
|
||||
/usr/include/atlas
|
||||
/usr/include/atlas-base
|
||||
$ENV{Atlas_ROOT_DIR}
|
||||
$ENV{Atlas_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
set(Atlas_LIB_SEARCH_PATHS
|
||||
/usr/lib/atlas
|
||||
/usr/lib/atlas-base
|
||||
$ENV{Atlas_ROOT_DIR}
|
||||
$ENV{Atlas_ROOT_DIR}/lib
|
||||
)
|
||||
|
||||
find_path(Atlas_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
|
||||
find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES lapacke.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
|
||||
|
||||
find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS})
|
||||
find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
|
||||
find_library(Atlas_LAPACK_LIBRARY NAMES lapack alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS})
|
||||
|
||||
set(LOOKED_FOR
|
||||
Atlas_CBLAS_INCLUDE_DIR
|
||||
Atlas_CLAPACK_INCLUDE_DIR
|
||||
|
||||
Atlas_CBLAS_LIBRARY
|
||||
Atlas_BLAS_LIBRARY
|
||||
Atlas_LAPACK_LIBRARY
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR})
|
||||
|
||||
if(ATLAS_FOUND)
|
||||
set(Atlas_INCLUDE_DIR ${Atlas_CBLAS_INCLUDE_DIR} ${Atlas_CLAPACK_INCLUDE_DIR})
|
||||
set(Atlas_LIBRARIES ${Atlas_LAPACK_LIBRARY} ${Atlas_CBLAS_LIBRARY} ${Atlas_BLAS_LIBRARY})
|
||||
mark_as_advanced(${LOOKED_FOR})
|
||||
|
||||
message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})")
|
||||
endif(ATLAS_FOUND)
|
||||
@@ -0,0 +1,78 @@
|
||||
macro(_find_file_in_dirs VAR NAME DIRS)
|
||||
find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH)
|
||||
set(${VAR} ${${VAR}}/${NAME})
|
||||
unset(${VAR} CACHE)
|
||||
endmacro()
|
||||
|
||||
if(WITH_LAPACK)
|
||||
ocv_update(LAPACK_IMPL "Unknown")
|
||||
if(NOT LAPACK_LIBRARIES)
|
||||
include(cmake/OpenCVFindMKL.cmake)
|
||||
if(HAVE_MKL)
|
||||
set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS})
|
||||
set(LAPACK_LIBRARIES ${MKL_LIBRARIES} )
|
||||
set(LAPACK_CBLAS_H "mkl_cblas.h" )
|
||||
set(LAPACK_LAPACKE_H "mkl_lapack.h" )
|
||||
set(LAPACK_IMPL "MKL")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT LAPACK_LIBRARIES)
|
||||
include(cmake/OpenCVFindOpenBLAS.cmake)
|
||||
if(OpenBLAS_FOUND)
|
||||
set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR} )
|
||||
set(LAPACK_LIBRARIES ${OpenBLAS_LIB} )
|
||||
set(LAPACK_CBLAS_H "cblas.h" )
|
||||
set(LAPACK_LAPACKE_H "lapacke.h" )
|
||||
set(LAPACK_IMPL "OpenBLAS")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT LAPACK_LIBRARIES AND UNIX)
|
||||
include(cmake/OpenCVFindAtlas.cmake)
|
||||
if(ATLAS_FOUND)
|
||||
set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR})
|
||||
set(LAPACK_LIBRARIES ${Atlas_LIBRARIES} )
|
||||
set(LAPACK_CBLAS_H "cblas.h" )
|
||||
set(LAPACK_LAPACKE_H "lapacke.h" )
|
||||
set(LAPACK_IMPL "Atlas")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT LAPACK_LIBRARIES AND APPLE)
|
||||
set(LAPACK_INCLUDE_DIR "Accelerate")
|
||||
set(LAPACK_LIBRARIES "-framework Accelerate")
|
||||
set(LAPACK_CBLAS_H "cblas.h" )
|
||||
set(LAPACK_LAPACKE_H "lapacke.h" )
|
||||
set(LAPACK_IMPL "Apple")
|
||||
endif()
|
||||
|
||||
set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE)
|
||||
set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE)
|
||||
set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE)
|
||||
set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE)
|
||||
set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE)
|
||||
|
||||
if(LAPACK_LIBRARIES) #adding proxy cblas.h header
|
||||
message(STATUS "LAPACK_IMPL: ${LAPACK_IMPL}, LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
|
||||
if("${LAPACK_IMPL}" STREQUAL "Apple")
|
||||
set(CBLAS_H_PATH "Accelerate/Accelerate.h")
|
||||
set(LAPACKE_H_PATH "Accelerate/Accelerate.h")
|
||||
else()
|
||||
_find_file_in_dirs(CBLAS_H_PATH "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}")
|
||||
_find_file_in_dirs(LAPACKE_H_PATH "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}")
|
||||
endif()
|
||||
if(NOT CBLAS_H_PATH OR NOT LAPACKE_H_PATH)
|
||||
message(WARNING "CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'")
|
||||
endif()
|
||||
ocv_include_directories(${LAPACK_INCLUDE_DIR})
|
||||
list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
|
||||
set(HAVE_LAPACK 1)
|
||||
|
||||
set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h)
|
||||
set(_include_str "\#include \"${CBLAS_H_PATH}\"")
|
||||
if("${CBLAS_H_PATH}" STREQUAL "${LAPACKE_H_PATH}")
|
||||
else()
|
||||
set(_include_str "${_include_str}\n\#include \"${LAPACKE_H_PATH}\"")
|
||||
endif()
|
||||
file(WRITE ${CBLAS_H_PROXY_PATH} ${_include_str})
|
||||
endif()
|
||||
endif()
|
||||
@@ -3,33 +3,29 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# --- Lapack ---
|
||||
if(WITH_LAPACK)
|
||||
if(WIN32)
|
||||
set(BLA_STATIC 1)
|
||||
endif()
|
||||
find_package(LAPACK)
|
||||
if(LAPACK_FOUND)
|
||||
find_path(LAPACKE_INCLUDE_DIR "lapacke.h")
|
||||
find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h")
|
||||
if(LAPACKE_INCLUDE_DIR OR MKL_LAPACKE_INCLUDE_DIR)
|
||||
find_path(CBLAS_INCLUDE_DIR "cblas.h")
|
||||
find_path(MKL_CBLAS_INCLUDE_DIR "mkl_cblas.h")
|
||||
|
||||
if(CBLAS_INCLUDE_DIR OR MKL_CBLAS_INCLUDE_DIR)
|
||||
set(HAVE_LAPACK 1)
|
||||
|
||||
if(CBLAS_INCLUDE_DIR)
|
||||
ocv_include_directories(${LAPACKE_INCLUDE_DIR} ${CBLAS_INCLUDE_DIR})
|
||||
set(HAVE_LAPACK_GENERIC 1)
|
||||
elseif(MKL_CBLAS_INCLUDE_DIR)
|
||||
ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR} ${MKL_CBLAS_INCLUDE_DIR})
|
||||
set(HAVE_LAPACK_MKL 1)
|
||||
endif()
|
||||
list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# if(WITH_LAPACK)
|
||||
# if(WIN32)
|
||||
# set(BLA_STATIC 1)
|
||||
# endif()
|
||||
# find_package(LAPACK)
|
||||
# if(LAPACK_FOUND)
|
||||
# find_path(LAPACKE_INCLUDE_DIR "lapacke.h")
|
||||
# find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h")
|
||||
# if(LAPACKE_INCLUDE_DIR)
|
||||
# ocv_include_directories(${LAPACKE_INCLUDE_DIR})
|
||||
# set(HAVE_LAPACK 1)
|
||||
# set(HAVE_LAPACK_GENERIC 1)
|
||||
# elseif(MKL_LAPACKE_INCLUDE_DIR)
|
||||
# ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR})
|
||||
# set(HAVE_LAPACK 1)
|
||||
# set(HAVE_LAPACK_MKL 1)
|
||||
# elseif(APPLE)
|
||||
# set(HAVE_LAPACK 1)
|
||||
# set(HAVE_LAPACK_APPLE 1)
|
||||
# endif()
|
||||
# list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
# --- TBB ---
|
||||
if(WITH_TBB)
|
||||
|
||||
@@ -236,6 +236,7 @@ if(WITH_FFMPEG)
|
||||
if(NOT __VALID_FFMPEG)
|
||||
#message(FATAL_ERROR "FFMPEG: test check build log:\n${TRY_OUT}")
|
||||
message(STATUS "WARNING: Can't build ffmpeg test code")
|
||||
set(HAVE_FFMPEG FALSE)
|
||||
else()
|
||||
ocv_append_build_options(VIDEOIO FFMPEG)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
#
|
||||
# The script to detect Intel(R) Math Kernel Library (MKL)
|
||||
# installation/package
|
||||
#
|
||||
# Parameters:
|
||||
# MKL_WITH_TBB
|
||||
#
|
||||
# On return this will define:
|
||||
#
|
||||
# HAVE_MKL - True if Intel IPP found
|
||||
# MKL_ROOT_DIR - root of IPP installation
|
||||
# MKL_INCLUDE_DIRS - IPP include folder
|
||||
# MKL_LIBRARIES - IPP libraries that are used by OpenCV
|
||||
#
|
||||
|
||||
macro (mkl_find_lib VAR NAME DIRS)
|
||||
find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH)
|
||||
set(${VAR} ${${VAR}}/${NAME})
|
||||
unset(${VAR} CACHE)
|
||||
endmacro()
|
||||
|
||||
macro(mkl_fail)
|
||||
set(HAVE_MKL OFF CACHE BOOL "True if MKL found")
|
||||
set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory")
|
||||
unset(MKL_INCLUDE_DIRS CACHE)
|
||||
unset(MKL_LIBRARIES CACHE)
|
||||
return()
|
||||
endmacro()
|
||||
|
||||
macro(get_mkl_version VERSION_FILE)
|
||||
# read MKL version info from file
|
||||
file(STRINGS ${VERSION_FILE} STR1 REGEX "__INTEL_MKL__")
|
||||
file(STRINGS ${VERSION_FILE} STR2 REGEX "__INTEL_MKL_MINOR__")
|
||||
file(STRINGS ${VERSION_FILE} STR3 REGEX "__INTEL_MKL_UPDATE__")
|
||||
#file(STRINGS ${VERSION_FILE} STR4 REGEX "INTEL_MKL_VERSION")
|
||||
|
||||
# extract info and assign to variables
|
||||
string(REGEX MATCHALL "[0-9]+" MKL_VERSION_MAJOR ${STR1})
|
||||
string(REGEX MATCHALL "[0-9]+" MKL_VERSION_MINOR ${STR2})
|
||||
string(REGEX MATCHALL "[0-9]+" MKL_VERSION_UPDATE ${STR3})
|
||||
set(MKL_VERSION_STR "${MKL_VERSION_MAJOR}.${MKL_VERSION_MINOR}.${MKL_VERSION_UPDATE}" CACHE STRING "MKL version" FORCE)
|
||||
endmacro()
|
||||
|
||||
|
||||
if(NOT DEFINED MKL_USE_MULTITHREAD)
|
||||
OCV_OPTION(MKL_WITH_TBB "Use MKL with TBB multithreading" OFF)#ON IF WITH_TBB)
|
||||
OCV_OPTION(MKL_WITH_OPENMP "Use MKL with OpenMP multithreading" OFF)#ON IF WITH_OPENMP)
|
||||
endif()
|
||||
|
||||
#check current MKL_ROOT_DIR
|
||||
if(NOT MKL_ROOT_DIR OR NOT EXISTS ${MKL_ROOT_DIR}/include/mkl.h)
|
||||
set(mkl_root_paths ${MKL_ROOT_DIR})
|
||||
if(DEFINED $ENV{MKLROOT})
|
||||
list(APPEND mkl_root_paths $ENV{MKLROOT})
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(ProgramFilesx86 "ProgramFiles(x86)")
|
||||
list(APPEND mkl_root_paths $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows/mkl)
|
||||
endif()
|
||||
if(UNIX)
|
||||
list(APPEND mkl_root_paths "/opt/intel/mkl")
|
||||
endif()
|
||||
|
||||
find_path(MKL_ROOT_DIR include/mkl.h PATHS ${mkl_root_paths})
|
||||
endif()
|
||||
|
||||
if(NOT MKL_ROOT_DIR)
|
||||
mkl_fail()
|
||||
endif()
|
||||
|
||||
set(MKL_INCLUDE_DIRS ${MKL_ROOT_DIR}/include)
|
||||
get_mkl_version(${MKL_INCLUDE_DIRS}/mkl_version.h)
|
||||
|
||||
#determine arch
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
|
||||
set(MKL_X64 1)
|
||||
set(MKL_ARCH "intel64")
|
||||
|
||||
include(CheckTypeSize)
|
||||
CHECK_TYPE_SIZE(int _sizeof_int)
|
||||
if (_sizeof_int EQUAL 4)
|
||||
set(MKL_LP64 "lp64")
|
||||
else()
|
||||
set(MKL_LP64 "ilp64")
|
||||
endif()
|
||||
else()
|
||||
set(MKL_ARCH "ia32")
|
||||
endif()
|
||||
|
||||
if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQUAL "11.3.0")
|
||||
set(mkl_lib_find_paths
|
||||
${MKL_ROOT_DIR}/lib
|
||||
${MKL_ROOT_DIR}/lib/${MKL_ARCH} ${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH})
|
||||
|
||||
set(mkl_lib_list
|
||||
mkl_core
|
||||
mkl_intel_${MKL_LP64})
|
||||
|
||||
if(MKL_WITH_TBB)
|
||||
list(APPEND mkl_lib_list mkl_tbb_thread tbb)
|
||||
elseif(MKL_WITH_OPENMP)
|
||||
if(MSVC)
|
||||
list(APPEND mkl_lib_list mkl_intel_thread libiomp5md)
|
||||
else()
|
||||
list(APPEND mkl_lib_list libmkl_gnu_thread)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND mkl_lib_list mkl_sequential)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "MKL version ${MKL_VERSION_STR} is not supported")
|
||||
mkl_fail()
|
||||
endif()
|
||||
|
||||
|
||||
set(MKL_LIBRARIES "")
|
||||
foreach(lib ${mkl_lib_list})
|
||||
find_library(${lib} ${lib} ${mkl_lib_find_paths})
|
||||
mark_as_advanced(${lib})
|
||||
if(NOT ${lib})
|
||||
mkl_fail()
|
||||
endif()
|
||||
list(APPEND MKL_LIBRARIES ${${lib}})
|
||||
endforeach()
|
||||
|
||||
message(STATUS "Found MKL ${MKL_VERSION_STR} at: ${MKL_ROOT_DIR}")
|
||||
set(HAVE_MKL ON CACHE BOOL "True if MKL found")
|
||||
set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory")
|
||||
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIRS} CACHE PATH "Path to MKL include directory")
|
||||
if(NOT UNIX)
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE FILEPATH "MKL libarries")
|
||||
else()
|
||||
#it's ugly but helps to avoid cyclic lib problem
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARIES} ${MKL_LIBRARIES} ${MKL_LIBRARIES} "-lpthread" "-lm" "-ldl")
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE STRING "MKL libarries")
|
||||
endif()
|
||||
@@ -0,0 +1,106 @@
|
||||
#COPYRIGHT
|
||||
#
|
||||
#All contributions by the University of California:
|
||||
#Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
|
||||
#All rights reserved.
|
||||
#
|
||||
#All other contributions:
|
||||
#Copyright (c) 2014, 2015, the respective contributors
|
||||
#All rights reserved.
|
||||
#
|
||||
#Caffe uses a shared copyright model: each contributor holds copyright over
|
||||
#their contributions to Caffe. The project versioning records all such
|
||||
#contribution and copyright details. If a contributor wants to further mark
|
||||
#their specific copyright on a particular contribution, they should indicate
|
||||
#their copyright solely in the commit message of the change when it is
|
||||
#committed.
|
||||
#
|
||||
#LICENSE
|
||||
#
|
||||
#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.
|
||||
#
|
||||
#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 COPYRIGHT OWNER 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.
|
||||
#
|
||||
#CONTRIBUTION AGREEMENT
|
||||
#
|
||||
#By contributing to the BVLC/caffe repository through pull-request, comment,
|
||||
#or otherwise, the contributor releases their content to the
|
||||
#license and copyright terms herein.
|
||||
|
||||
SET(Open_BLAS_INCLUDE_SEARCH_PATHS
|
||||
/usr/include
|
||||
/usr/include/openblas
|
||||
/usr/include/openblas-base
|
||||
/usr/local/include
|
||||
/usr/local/include/openblas
|
||||
/usr/local/include/openblas-base
|
||||
/opt/OpenBLAS/include
|
||||
$ENV{OpenBLAS_HOME}
|
||||
$ENV{OpenBLAS_HOME}/include
|
||||
)
|
||||
|
||||
SET(Open_BLAS_LIB_SEARCH_PATHS
|
||||
/lib/
|
||||
/lib/openblas-base
|
||||
/lib64/
|
||||
/usr/lib
|
||||
/usr/lib/openblas-base
|
||||
/usr/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/opt/OpenBLAS/lib
|
||||
$ENV{OpenBLAS}cd
|
||||
$ENV{OpenBLAS}/lib
|
||||
$ENV{OpenBLAS_HOME}
|
||||
$ENV{OpenBLAS_HOME}/lib
|
||||
)
|
||||
|
||||
FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS})
|
||||
FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
|
||||
|
||||
SET(OpenBLAS_FOUND ON)
|
||||
|
||||
# Check include files
|
||||
IF(NOT OpenBLAS_INCLUDE_DIR)
|
||||
SET(OpenBLAS_FOUND OFF)
|
||||
MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off")
|
||||
ENDIF()
|
||||
|
||||
# Check libraries
|
||||
IF(NOT OpenBLAS_LIB)
|
||||
SET(OpenBLAS_FOUND OFF)
|
||||
MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off")
|
||||
ENDIF()
|
||||
|
||||
IF (OpenBLAS_FOUND)
|
||||
IF (NOT OpenBLAS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}")
|
||||
MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}")
|
||||
ENDIF (NOT OpenBLAS_FIND_QUIETLY)
|
||||
ELSE (OpenBLAS_FOUND)
|
||||
IF (OpenBLAS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find OpenBLAS")
|
||||
ENDIF (OpenBLAS_FIND_REQUIRED)
|
||||
ENDIF (OpenBLAS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
OpenBLAS_INCLUDE_DIR
|
||||
OpenBLAS_LIB
|
||||
OpenBLAS
|
||||
)
|
||||
+28
-6
@@ -302,6 +302,7 @@ macro(ocv_warnings_disable)
|
||||
set(_flag_vars "")
|
||||
set(_msvc_warnings "")
|
||||
set(_gxx_warnings "")
|
||||
set(_icc_warnings "")
|
||||
foreach(arg ${ARGN})
|
||||
if(arg MATCHES "^CMAKE_")
|
||||
list(APPEND _flag_vars ${arg})
|
||||
@@ -309,6 +310,8 @@ macro(ocv_warnings_disable)
|
||||
list(APPEND _msvc_warnings ${arg})
|
||||
elseif(arg MATCHES "^-W")
|
||||
list(APPEND _gxx_warnings ${arg})
|
||||
elseif(arg MATCHES "^-wd" OR arg MATCHES "^-Qwd" OR arg MATCHES "^/Qwd")
|
||||
list(APPEND _icc_warnings ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
if(MSVC AND _msvc_warnings AND _flag_vars)
|
||||
@@ -331,9 +334,25 @@ macro(ocv_warnings_disable)
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
if(CV_ICC AND _icc_warnings AND _flag_vars)
|
||||
foreach(var ${_flag_vars})
|
||||
foreach(warning ${_icc_warnings})
|
||||
if(UNIX)
|
||||
string(REPLACE "-Qwd" "-wd" warning "${warning}")
|
||||
else()
|
||||
string(REPLACE "-wd" "-Qwd" warning "${warning}")
|
||||
endif()
|
||||
ocv_check_flag_support(${var} "${warning}" _varname)
|
||||
if(${_varname})
|
||||
set(${var} "${${var}} ${warning}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
unset(_flag_vars)
|
||||
unset(_msvc_warnings)
|
||||
unset(_gxx_warnings)
|
||||
unset(_icc_warnings)
|
||||
endif(NOT ENABLE_NOISY_WARNINGS)
|
||||
endmacro()
|
||||
|
||||
@@ -672,8 +691,11 @@ function(ocv_install_target)
|
||||
set(${__package}_TARGETS "${${__package}_TARGETS}" CACHE INTERNAL "List of ${__package} targets")
|
||||
endif()
|
||||
|
||||
if(INSTALL_CREATE_DISTRIB)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
if(MSVS)
|
||||
if(NOT INSTALL_IGNORE_PDB AND
|
||||
(INSTALL_PDB OR
|
||||
(INSTALL_CREATE_DISTRIB AND NOT BUILD_SHARED_LIBS)
|
||||
))
|
||||
set(__target "${ARGV0}")
|
||||
|
||||
set(isArchive 0)
|
||||
@@ -701,13 +723,13 @@ function(ocv_install_target)
|
||||
get_target_property(fname ${__target} LOCATION_DEBUG)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Debug)
|
||||
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Debug OPTIONAL)
|
||||
endif()
|
||||
|
||||
get_target_property(fname ${__target} LOCATION_RELEASE)
|
||||
if(fname MATCHES "\\.lib$")
|
||||
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
|
||||
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Release)
|
||||
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Release OPTIONAL)
|
||||
endif()
|
||||
else()
|
||||
# CMake 2.8.12 broke PDB support for STATIC libraries from MSVS, fix was introduced in CMake 3.1.0.
|
||||
@@ -1076,16 +1098,16 @@ endfunction()
|
||||
|
||||
macro(ocv_add_testdata basedir dest_subdir)
|
||||
if(BUILD_TESTS)
|
||||
cmake_parse_arguments(__TESTDATA "" "COMPONENT" "" ${ARGN})
|
||||
if(NOT CMAKE_CROSSCOMPILING AND NOT INSTALL_TESTS)
|
||||
file(COPY ${basedir}/
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/${OPENCV_TEST_DATA_INSTALL_PATH}/${dest_subdir}
|
||||
${__TESTDATA_UNPARSED_ARGUMENTS}
|
||||
${ARGN}
|
||||
)
|
||||
endif()
|
||||
if(INSTALL_TESTS)
|
||||
install(DIRECTORY ${basedir}/
|
||||
DESTINATION ${OPENCV_TEST_DATA_INSTALL_PATH}/contrib/text
|
||||
COMPONENT "tests"
|
||||
${ARGN}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#
|
||||
# find_package(OpenCV REQUIRED core videoio)
|
||||
#
|
||||
# You can also mark OpenCV components as optional:
|
||||
|
||||
# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz)
|
||||
#
|
||||
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
|
||||
#
|
||||
# This file will define the following variables:
|
||||
@@ -48,6 +52,21 @@ SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
|
||||
SET(OpenCV_VERSION_TWEAK 0)
|
||||
SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8
|
||||
AND OpenCV_FIND_COMPONENTS # prevent excessive output
|
||||
)
|
||||
# HANDLE_COMPONENTS was introduced in CMake 2.8.8
|
||||
list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS)
|
||||
# The missing components will be handled by the FindPackageHandleStandardArgs
|
||||
# module.
|
||||
set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE)
|
||||
else()
|
||||
# The missing components will be handled by this config.
|
||||
set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE)
|
||||
endif()
|
||||
|
||||
# Extract directory name from full path of the file currently being processed.
|
||||
# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it
|
||||
# for older versions of CMake to support these as well.
|
||||
@@ -120,24 +139,33 @@ endif()
|
||||
set(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@)
|
||||
|
||||
# expand short module names and see if requested components exist
|
||||
set(OpenCV_FIND_COMPONENTS_ "")
|
||||
foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
|
||||
# Store the name of the original component so we can set the
|
||||
# OpenCV_<component>_FOUND variable which can be checked by the user.
|
||||
set (__original_cvcomponent ${__cvcomponent})
|
||||
if(NOT __cvcomponent MATCHES "^opencv_")
|
||||
set(__cvcomponent opencv_${__cvcomponent})
|
||||
endif()
|
||||
list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx)
|
||||
if(__cvcomponentIdx LESS 0)
|
||||
#requested component is not found...
|
||||
if(OpenCV_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "${__cvcomponent} is required but was not found")
|
||||
elseif(NOT OpenCV_FIND_QUIETLY)
|
||||
message(WARNING "${__cvcomponent} is required but was not found")
|
||||
endif()
|
||||
if(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
|
||||
# Either the component is required or the user did not set any components at
|
||||
# all. In the latter case, the OpenCV_FIND_REQUIRED_<component> variable
|
||||
# will not be defined since it is not set by this config. So let's assume
|
||||
# the implicitly set components are always required.
|
||||
if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR
|
||||
OpenCV_FIND_REQUIRED_${__original_cvcomponent})
|
||||
message(FATAL_ERROR "${__cvcomponent} is required but was not found")
|
||||
elseif(NOT OpenCV_FIND_QUIETLY)
|
||||
# The component was marked as optional using OPTIONAL_COMPONENTS
|
||||
message(WARNING "Optional component ${__cvcomponent} was not found")
|
||||
endif()
|
||||
endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
|
||||
#indicate that module is NOT found
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
|
||||
set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND")
|
||||
set(OpenCV_${__original_cvcomponent}_FOUND FALSE)
|
||||
else()
|
||||
list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent})
|
||||
# Not using list(APPEND) here, because OpenCV_LIBS may not exist yet.
|
||||
# Also not clearing OpenCV_LIBS anywhere, so that multiple calls
|
||||
# to find_package(OpenCV) with different component lists add up.
|
||||
@@ -145,6 +173,7 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
|
||||
#indicate that module is found
|
||||
string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
|
||||
set(${__cvcomponentUP}_FOUND 1)
|
||||
set(OpenCV_${__original_cvcomponent}_FOUND TRUE)
|
||||
endif()
|
||||
if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent})
|
||||
get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG)
|
||||
@@ -170,7 +199,6 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
|
||||
|
||||
# ==============================================================
|
||||
# Compatibility stuff
|
||||
@@ -226,3 +254,8 @@ macro(ocv_list_filterout lst regex)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# We do not actually need REQUIRED_VARS to be checked for. Just use the
|
||||
# installation directory for the status.
|
||||
find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH
|
||||
VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS})
|
||||
|
||||
@@ -198,12 +198,6 @@
|
||||
/* Lapack */
|
||||
#cmakedefine HAVE_LAPACK
|
||||
|
||||
/* Lapack Generic */
|
||||
#cmakedefine HAVE_LAPACK_GENERIC
|
||||
|
||||
/* Lapack MKL */
|
||||
#cmakedefine HAVE_LAPACK_MKL
|
||||
|
||||
/* FP16 */
|
||||
#cmakedefine HAVE_FP16
|
||||
|
||||
|
||||
+9
-2
@@ -31,10 +31,17 @@ MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
ALIASES += add_toggle{1}="@htmlonly[block] <div class='newInnerHTML'>\1</div><div> <script type="text/javascript"> addToggle(); </script>@endhtmlonly"
|
||||
ALIASES += add_toggle_cpp="@htmlonly[block] <div class='newInnerHTML' title='cpp' style='display: none;'>C++</div><div class='toggleable_div label_cpp' style='display: none;'>@endhtmlonly"
|
||||
ALIASES += add_toggle_java="@htmlonly[block] <div class='newInnerHTML' title='java' style='display: none;'>Java</div><div class='toggleable_div label_java' style='display: none;'>@endhtmlonly"
|
||||
ALIASES += add_toggle_python="@htmlonly[block] <div class='newInnerHTML' title='python' style='display: none;'>Python</div><div class='toggleable_div label_python' style='display: none;'>@endhtmlonly"
|
||||
ALIASES += end_toggle="@htmlonly[block] </div> @endhtmlonly"
|
||||
ALIASES += prev_tutorial{1}="**Prev Tutorial:** \ref \1 \n"
|
||||
ALIASES += next_tutorial{1}="**Next Tutorial:** \ref \1 \n"
|
||||
ALIASES += youtube{1}="@htmlonly[block]<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/\1?rel=0' frameborder='0' align='middle' allowfullscreen></iframe></div>@endhtmlonly"
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = YES
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING =
|
||||
|
||||
@@ -17,5 +17,74 @@ $generatedby  <a href="http://www.doxygen.org/index.html">
|
||||
</a> $doxygenversion
|
||||
</small></address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function addButton(label, buttonName) {
|
||||
var b = document.createElement("BUTTON");
|
||||
b.innerHTML = buttonName;
|
||||
b.setAttribute('class', 'toggleable_button label_' + label);
|
||||
b.onclick = function() {
|
||||
$('.toggleable_button').css({
|
||||
border: '2px outset',
|
||||
'border-radius': '4px'
|
||||
});
|
||||
$('.toggleable_button.label_' + label).css({
|
||||
border: '2px inset',
|
||||
'border-radius': '4px'
|
||||
});
|
||||
$('.toggleable_div').css('display', 'none');
|
||||
$('.toggleable_div.label_' + label).css('display', 'block');
|
||||
};
|
||||
b.style.border = '2px outset';
|
||||
b.style.borderRadius = '4px';
|
||||
b.style.margin = '2px';
|
||||
return b;
|
||||
}
|
||||
function buttonsToAdd($elements, $heading, $type) {
|
||||
if ($elements.length === 0) {
|
||||
$elements = $("" + $type + ":contains(" + $heading.html() + ")").parent().prev("div.newInnerHTML");
|
||||
}
|
||||
var arr = jQuery.makeArray($elements);
|
||||
var seen = {};
|
||||
arr.forEach(function(e) {
|
||||
var txt = e.innerHTML;
|
||||
if (!seen[txt]) {
|
||||
$button = addButton(e.title, txt);
|
||||
if (Object.keys(seen).length == 0) {
|
||||
var linebreak1 = document.createElement("br");
|
||||
var linebreak2 = document.createElement("br");
|
||||
($heading).append(linebreak1);
|
||||
($heading).append(linebreak2);
|
||||
}
|
||||
($heading).append($button);
|
||||
seen[txt] = true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
$("h2").each(function() {
|
||||
$heading = $(this);
|
||||
$smallerHeadings = $(this).nextUntil("h2").filter("h3").add($(this).nextUntil("h2").find("h3"));
|
||||
if ($smallerHeadings.length) {
|
||||
$smallerHeadings.each(function() {
|
||||
var $elements = $(this).nextUntil("h3").filter("div.newInnerHTML");
|
||||
buttonsToAdd($elements, $(this), "h3");
|
||||
});
|
||||
} else {
|
||||
var $elements = $(this).nextUntil("h2").filter("div.newInnerHTML");
|
||||
buttonsToAdd($elements, $heading, "h2");
|
||||
}
|
||||
});
|
||||
$(".toggleable_button").first().click();
|
||||
var $clickDefault = $('.toggleable_button.label_python').first();
|
||||
if ($clickDefault.length) {
|
||||
$clickDefault.click();
|
||||
}
|
||||
$clickDefault = $('.toggleable_button.label_cpp').first();
|
||||
if ($clickDefault.length) {
|
||||
$clickDefault.click();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -54,4 +54,34 @@ $extrastylesheet
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function getLabelName(innerHTML) {
|
||||
var str = innerHTML.toLowerCase();
|
||||
// Replace all '+' with 'p'
|
||||
str = str.split('+').join('p');
|
||||
// Replace all ' ' with '_'
|
||||
str = str.split(' ').join('_');
|
||||
// Replace all '#' with 'sharp'
|
||||
str = str.split('#').join('sharp');
|
||||
// Replace other special characters with 'ascii' + code
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var charCode = str.charCodeAt(i);
|
||||
if (!(charCode == 95 || (charCode > 96 && charCode < 123) || (charCode > 47 && charCode < 58)))
|
||||
str = str.substr(0, i) + 'ascii' + charCode + str.substr(i + 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function addToggle() {
|
||||
var $getDiv = $('div.newInnerHTML').last();
|
||||
var buttonName = $getDiv.html();
|
||||
var label = getLabelName(buttonName.trim());
|
||||
$getDiv.attr("title", label);
|
||||
$getDiv.hide();
|
||||
$getDiv = $getDiv.next();
|
||||
$getDiv.attr("class", "toggleable_div label_" + label);
|
||||
$getDiv.hide();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<!-- end header part -->
|
||||
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
|
||||
//<![CDATA[
|
||||
MathJax.Hub.Config(
|
||||
{
|
||||
TeX: {
|
||||
@@ -15,3 +15,4 @@ MathJax.Hub.Config(
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
Mask operations on matrices {#tutorial_mat_mask_operations}
|
||||
===========================
|
||||
|
||||
@prev_tutorial{tutorial_how_to_scan_images}
|
||||
@next_tutorial{tutorial_mat_operations}
|
||||
|
||||
Mask operations on matrices are quite simple. The idea is that we recalculate each pixels value in
|
||||
an image according to a mask matrix (also known as kernel). This mask holds values that will adjust
|
||||
how much influence neighboring pixels (and the current pixel) have on the new pixel value. From a
|
||||
@@ -25,113 +28,150 @@ the zero-zero index) on the pixel you want to calculate and sum up the pixel val
|
||||
the overlapped matrix values. It's the same thing, however in case of large matrices the latter
|
||||
notation is a lot easier to look over.
|
||||
|
||||
@add_toggle_cpp
|
||||
Now let us see how we can make this happen by using the basic pixel access method or by using the
|
||||
@ref cv::filter2D function.
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
Now let us see how we can make this happen by using the basic pixel access method or by using the
|
||||
**Imgproc.filter2D()** function.
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
Now let us see how we can make this happen by using the basic pixel access method or by using the
|
||||
**cv2.filter2D()** function.
|
||||
@end_toggle
|
||||
|
||||
The Basic Method
|
||||
----------------
|
||||
|
||||
Here's a function that will do this:
|
||||
@code{.cpp}
|
||||
void Sharpen(const Mat& myImage, Mat& Result)
|
||||
{
|
||||
CV_Assert(myImage.depth() == CV_8U); // accept only uchar images
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp basic_method
|
||||
|
||||
Result.create(myImage.size(), myImage.type());
|
||||
const int nChannels = myImage.channels();
|
||||
|
||||
for(int j = 1; j < myImage.rows - 1; ++j)
|
||||
{
|
||||
const uchar* previous = myImage.ptr<uchar>(j - 1);
|
||||
const uchar* current = myImage.ptr<uchar>(j );
|
||||
const uchar* next = myImage.ptr<uchar>(j + 1);
|
||||
|
||||
uchar* output = Result.ptr<uchar>(j);
|
||||
|
||||
for(int i = nChannels; i < nChannels * (myImage.cols - 1); ++i)
|
||||
{
|
||||
*output++ = saturate_cast<uchar>(5 * current[i]
|
||||
-current[i - nChannels] - current[i + nChannels] - previous[i] - next[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Result.row(0).setTo(Scalar(0));
|
||||
Result.row(Result.rows - 1).setTo(Scalar(0));
|
||||
Result.col(0).setTo(Scalar(0));
|
||||
Result.col(Result.cols - 1).setTo(Scalar(0));
|
||||
}
|
||||
@endcode
|
||||
At first we make sure that the input images data is in unsigned char format. For this we use the
|
||||
@ref cv::CV_Assert function that throws an error when the expression inside it is false.
|
||||
@code{.cpp}
|
||||
CV_Assert(myImage.depth() == CV_8U); // accept only uchar images
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp 8_bit
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java basic_method
|
||||
|
||||
At first we make sure that the input images data in unsigned 8 bit format.
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java 8_bit
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py basic_method
|
||||
|
||||
At first we make sure that the input images data in unsigned 8 bit format.
|
||||
@code{.py}
|
||||
my_image = cv2.cvtColor(my_image, cv2.CV_8U)
|
||||
@endcode
|
||||
|
||||
@end_toggle
|
||||
|
||||
We create an output image with the same size and the same type as our input. As you can see in the
|
||||
@ref tutorial_how_to_scan_images_storing "storing" section, depending on the number of channels we may have one or more
|
||||
subcolumns. We will iterate through them via pointers so the total number of elements depends from
|
||||
subcolumns.
|
||||
|
||||
@add_toggle_cpp
|
||||
We will iterate through them via pointers so the total number of elements depends on
|
||||
this number.
|
||||
@code{.cpp}
|
||||
Result.create(myImage.size(), myImage.type());
|
||||
const int nChannels = myImage.channels();
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp create_channels
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java create_channels
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@code{.py}
|
||||
height, width, n_channels = my_image.shape
|
||||
result = np.zeros(my_image.shape, my_image.dtype)
|
||||
@endcode
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_cpp
|
||||
We'll use the plain C [] operator to access pixels. Because we need to access multiple rows at the
|
||||
same time we'll acquire the pointers for each of them (a previous, a current and a next line). We
|
||||
need another pointer to where we're going to save the calculation. Then simply access the right
|
||||
items with the [] operator. For moving the output pointer ahead we simply increase this (with one
|
||||
byte) after each operation:
|
||||
@code{.cpp}
|
||||
for(int j = 1; j < myImage.rows - 1; ++j)
|
||||
{
|
||||
const uchar* previous = myImage.ptr<uchar>(j - 1);
|
||||
const uchar* current = myImage.ptr<uchar>(j );
|
||||
const uchar* next = myImage.ptr<uchar>(j + 1);
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp basic_method_loop
|
||||
|
||||
uchar* output = Result.ptr<uchar>(j);
|
||||
|
||||
for(int i = nChannels; i < nChannels * (myImage.cols - 1); ++i)
|
||||
{
|
||||
*output++ = saturate_cast<uchar>(5 * current[i]
|
||||
-current[i - nChannels] - current[i + nChannels] - previous[i] - next[i]);
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
On the borders of the image the upper notation results inexistent pixel locations (like minus one -
|
||||
minus one). In these points our formula is undefined. A simple solution is to not apply the kernel
|
||||
in these points and, for example, set the pixels on the borders to zeros:
|
||||
@code{.cpp}
|
||||
Result.row(0).setTo(Scalar(0)); // The top row
|
||||
Result.row(Result.rows - 1).setTo(Scalar(0)); // The bottom row
|
||||
Result.col(0).setTo(Scalar(0)); // The left column
|
||||
Result.col(Result.cols - 1).setTo(Scalar(0)); // The right column
|
||||
@endcode
|
||||
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp borders
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
We need to access multiple rows and columns which can be done by adding or subtracting 1 to the current center (i,j).
|
||||
Then we apply the sum and put the new value in the Result matrix.
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java basic_method_loop
|
||||
|
||||
On the borders of the image the upper notation results in inexistent pixel locations (like (-1,-1)).
|
||||
In these points our formula is undefined. A simple solution is to not apply the kernel
|
||||
in these points and, for example, set the pixels on the borders to zeros:
|
||||
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java borders
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
We need to access multiple rows and columns which can be done by adding or subtracting 1 to the current center (i,j).
|
||||
Then we apply the sum and put the new value in the Result matrix.
|
||||
@snippet samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py basic_method_loop
|
||||
@end_toggle
|
||||
|
||||
The filter2D function
|
||||
---------------------
|
||||
|
||||
Applying such filters are so common in image processing that in OpenCV there exist a function that
|
||||
will take care of applying the mask (also called a kernel in some places). For this you first need
|
||||
to define a *Mat* object that holds the mask:
|
||||
@code{.cpp}
|
||||
Mat kern = (Mat_<char>(3,3) << 0, -1, 0,
|
||||
-1, 5, -1,
|
||||
0, -1, 0);
|
||||
@endcode
|
||||
Then call the @ref cv::filter2D function specifying the input, the output image and the kernell to
|
||||
to define an object that holds the mask:
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp kern
|
||||
|
||||
Then call the @ref cv::filter2D function specifying the input, the output image and the kernel to
|
||||
use:
|
||||
@code{.cpp}
|
||||
filter2D(I, K, I.depth(), kern);
|
||||
@endcode
|
||||
The function even has a fifth optional argument to specify the center of the kernel, and a sixth one
|
||||
for determining what to do in the regions where the operation is undefined (borders). Using this
|
||||
function has the advantage that it's shorter, less verbose and because there are some optimization
|
||||
techniques implemented it is usually faster than the *hand-coded method*. For example in my test
|
||||
while the second one took only 13 milliseconds the first took around 31 milliseconds. Quite some
|
||||
difference.
|
||||
@snippet samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp filter2D
|
||||
|
||||
The function even has a fifth optional argument to specify the center of the kernel, a sixth
|
||||
for adding an optional value to the filtered pixels before storing them in K and a seventh one
|
||||
for determining what to do in the regions where the operation is undefined (borders).
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java kern
|
||||
|
||||
Then call the **Imgproc.filter2D()** function specifying the input, the output image and the kernel to
|
||||
use:
|
||||
@snippet samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java filter2D
|
||||
The function even has a fifth optional argument to specify the center of the kernel, a sixth
|
||||
for adding an optional value to the filtered pixels before storing them in K and a seventh one
|
||||
for determining what to do in the regions where the operation is undefined (borders).
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py kern
|
||||
|
||||
Then call the **cv2.filter2D()** function specifying the input, the output image and the kernell to
|
||||
use:
|
||||
@snippet samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py filter2D
|
||||
@end_toggle
|
||||
|
||||
This function is shorter, less verbose and, because there are some optimizations, it is usually faster
|
||||
than the *hand-coded method*. For example in my test while the second one took only 13
|
||||
milliseconds the first took around 31 milliseconds. Quite some difference.
|
||||
|
||||
For example:
|
||||
|
||||

|
||||
|
||||
@add_toggle_cpp
|
||||
You can download this source code from [here
|
||||
](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp) or look in the
|
||||
OpenCV source code libraries sample directory at
|
||||
@@ -139,9 +179,15 @@ OpenCV source code libraries sample directory at
|
||||
|
||||
Check out an instance of running the program on our [YouTube
|
||||
channel](http://www.youtube.com/watch?v=7PF1tAU9se4) .
|
||||
@youtube{7PF1tAU9se4}
|
||||
@end_toggle
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe width="560" height="349" src="https://www.youtube.com/embed/7PF1tAU9se4?hd=1" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@add_toggle_java
|
||||
You can look in the OpenCV source code libraries sample directory at
|
||||
`samples/java/tutorial_code/core/mat_mask_operations/MatMaskOperations.java`.
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
You can look in the OpenCV source code libraries sample directory at
|
||||
`samples/python/tutorial_code/core/mat_mask_operations/mat_mask_operations.py`.
|
||||
@end_toggle
|
||||
|
||||
@@ -25,6 +25,8 @@ understanding how to manipulate the images on a pixel level.
|
||||
|
||||
- @subpage tutorial_mat_mask_operations
|
||||
|
||||
*Languages:* C++, Java, Python
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Bernát Gábor
|
||||
|
||||
@@ -85,9 +85,9 @@ Explanation
|
||||
while( true )
|
||||
{
|
||||
/// Each 1 sec. Press ESC to exit the program
|
||||
int c = waitKey( 1000 );
|
||||
char c = (char)waitKey( 1000 );
|
||||
|
||||
if( (char)c == 27 )
|
||||
if( c == 27 )
|
||||
{ break; }
|
||||
|
||||
/// Update map_x & map_y. Then apply remap
|
||||
|
||||
@@ -93,6 +93,7 @@ Let's check the general structure of the program:
|
||||
|
||||
- Perform an infinite loop waiting for user input.
|
||||
@snippet cpp/tutorial_code/ImgProc/Pyramids.cpp infinite_loop
|
||||
|
||||
Our program exits if the user presses *ESC*. Besides, it has two options:
|
||||
|
||||
- **Perform upsampling (after pressing 'u')**
|
||||
|
||||
@@ -439,6 +439,83 @@ Then include this snippet into documentation:
|
||||
compatibility with the old rST documentation. But newly created samples should be included with the
|
||||
_snippet_ command, since this method is less affected by the changes in processed file.
|
||||
|
||||
### Toggle buttons inclusion commands {#tutorial_documentation_toggle_buttons_commands_include}
|
||||
|
||||
Toggle buttons are used to display the selected configuration (e.g. programming language, OS, IDE).
|
||||
|
||||
To use the buttons in documentation, _add_toggle_ and _end_toggle_ commands are used.
|
||||
|
||||
The command _add_toggle_ can be
|
||||
- general: _add_toggle{Button Name}_
|
||||
- for C++: _add_toggle_cpp_
|
||||
- for Java: _add_toggle_java_
|
||||
- for Python: _add_toggle_python_
|
||||
|
||||
Example:
|
||||
@verbatim
|
||||
@add_toggle{Button Name}
|
||||
|
||||
text / code / doxygen commands
|
||||
|
||||
@end_toggle
|
||||
@endverbatim
|
||||
|
||||
For example using toggle buttons with text and [code](@ref tutorial_documentation_commands_include) snippets:
|
||||
|
||||
@verbatim
|
||||
|
||||
### Buttons Example
|
||||
|
||||
@add_toggle_cpp
|
||||
|
||||
Text for C++ button
|
||||
@snippet samples/cpp/tutorial_code/introduction/documentation/documentation.cpp hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
|
||||
Text for Java button
|
||||
@snippet samples/java/tutorial_code/introduction/documentation/Documentation.java hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
|
||||
Text for Python button
|
||||
@snippet samples/python/tutorial_code/introduction/documentation/documentation.py hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
@endverbatim
|
||||
|
||||
Result looks like this:
|
||||
|
||||
### Buttons Example
|
||||
|
||||
@add_toggle_cpp
|
||||
|
||||
Text for C++ button
|
||||
@snippet samples/cpp/tutorial_code/introduction/documentation/documentation.cpp hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
|
||||
Text for Java button
|
||||
@snippet samples/java/tutorial_code/introduction/documentation/Documentation.java hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
|
||||
Text for Python button
|
||||
@snippet samples/python/tutorial_code/introduction/documentation/documentation.py hello_world
|
||||
|
||||
@end_toggle
|
||||
|
||||
As you can see, the buttons are added automatically under the previous heading.
|
||||
|
||||
### Grouping commands {#tutorial_documentation_commands_group}
|
||||
|
||||
All code entities should be put into named groups representing OpenCV modules and their internal
|
||||
@@ -536,6 +613,8 @@ Write the tutorial {#tutorial_documentation_steps_tutorial}
|
||||
|
||||
If you want to insert code blocks from this file into your tutorial, mark them with special doxygen comments (see [here](@ref tutorial_documentation_commands_include)).
|
||||
|
||||
If you want to write the tutorial in more than one programming language, use the toggle buttons for alternative comments and code (see [here](@ref tutorial_documentation_toggle_buttons_commands_include)).
|
||||
|
||||
3. Collect results of the application work. It can be "before/after" images or some numbers
|
||||
representing performance or even a video.
|
||||
|
||||
@@ -552,22 +631,21 @@ Write the tutorial {#tutorial_documentation_steps_tutorial}
|
||||
|
||||
5. Modify your new page:
|
||||
- Add page title and identifier, usually prefixed with <em>"tutorial_"</em> (see [here](@ref tutorial_documentation_md_page)).
|
||||
You can add a link to the previous and next tutorial using the identifier
|
||||
@verbatim
|
||||
@prev_tutorial{identifier}
|
||||
@next_tutorial{identifier}
|
||||
@endverbatim
|
||||
@warning Do **not** write the **hashtag (#)**, example: \n Incorrect: @verbatim @prev_tutorial{#tutorial_documentation} @endverbatim Correct: @verbatim @prev_tutorial{tutorial_documentation} @endverbatim
|
||||
- Add brief description of your idea and tutorial goals.
|
||||
- Describe your program and/or its interesting pieces.
|
||||
- Describe your results, insert previously added images or other results.
|
||||
|
||||
To add a video use _htmlonly_, _endhtmlonly_ commands with raw html block inside:
|
||||
To add a youtube video, e.g. www.youtube.com/watch?v= **ViPN810E0SU**, use _youtube_{**Video ID**}:
|
||||
@verbatim
|
||||
@htmlonly
|
||||
<div align="center">
|
||||
<iframe
|
||||
title="my title" width="560" height="349"
|
||||
src="http://www.youtube.com/embed/ViPN810E0SU?rel=0&loop=1"
|
||||
frameborder="0" allowfullscreen align="middle">
|
||||
</iframe>
|
||||
</div>
|
||||
@endhtmlonly
|
||||
@youtube{ViPN810E0SU}
|
||||
@endverbatim
|
||||
|
||||
- Add bibliographic references if any (see [here](@ref tutorial_documentation_commands_cite)).
|
||||
|
||||
6. Add newly created tutorial to the corresponding table of contents. Just find
|
||||
@@ -576,6 +654,8 @@ Write the tutorial {#tutorial_documentation_steps_tutorial}
|
||||
@verbatim
|
||||
- @subpage tutorial_windows_visual_studio_image_watch
|
||||
|
||||
_Languages:_ C++, Java, Python
|
||||
|
||||
_Compatibility:_ \>= OpenCV 2.4
|
||||
|
||||
_Author:_ Wolf Kienzle
|
||||
|
||||
@@ -18,9 +18,9 @@ Code
|
||||
----
|
||||
|
||||
This tutorial code's is shown lines below. You can also download it from
|
||||
[here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
|
||||
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
|
||||
. The second version (using LBP for face detection) can be [found
|
||||
here](https://github.com/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
|
||||
here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
|
||||
@include samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
|
||||
|
||||
Explanation
|
||||
|
||||
@@ -2085,7 +2085,7 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
|
||||
Mat corners = _corners.getMat();
|
||||
if( corners.empty() )
|
||||
return;
|
||||
Mat image = _image.getMat(); CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat(); CvMat c_image = image;
|
||||
int nelems = corners.checkVector(2, CV_32F, true);
|
||||
CV_Assert(nelems >= 0);
|
||||
cvDrawChessboardCorners( &c_image, patternSize, corners.ptr<CvPoint2D32f>(),
|
||||
|
||||
@@ -3234,54 +3234,20 @@ void cv::composeRT( InputArray _rvec1, InputArray _tvec1,
|
||||
c_tvec2 = tvec2, c_rvec3 = rvec3, c_tvec3 = tvec3;
|
||||
CvMat c_dr3dr1, c_dr3dt1, c_dr3dr2, c_dr3dt2, c_dt3dr1, c_dt3dt1, c_dt3dr2, c_dt3dt2;
|
||||
CvMat *p_dr3dr1=0, *p_dr3dt1=0, *p_dr3dr2=0, *p_dr3dt2=0, *p_dt3dr1=0, *p_dt3dt1=0, *p_dt3dr2=0, *p_dt3dt2=0;
|
||||
|
||||
if( _dr3dr1.needed() )
|
||||
{
|
||||
_dr3dr1.create(3, 3, rtype);
|
||||
p_dr3dr1 = &(c_dr3dr1 = _dr3dr1.getMat());
|
||||
#define CV_COMPOSE_RT_PARAM(name) \
|
||||
Mat name; \
|
||||
if (_ ## name.needed())\
|
||||
{ \
|
||||
_ ## name.create(3, 3, rtype); \
|
||||
name = _ ## name.getMat(); \
|
||||
p_ ## name = &(c_ ## name = name); \
|
||||
}
|
||||
|
||||
if( _dr3dt1.needed() )
|
||||
{
|
||||
_dr3dt1.create(3, 3, rtype);
|
||||
p_dr3dt1 = &(c_dr3dt1 = _dr3dt1.getMat());
|
||||
}
|
||||
|
||||
if( _dr3dr2.needed() )
|
||||
{
|
||||
_dr3dr2.create(3, 3, rtype);
|
||||
p_dr3dr2 = &(c_dr3dr2 = _dr3dr2.getMat());
|
||||
}
|
||||
|
||||
if( _dr3dt2.needed() )
|
||||
{
|
||||
_dr3dt2.create(3, 3, rtype);
|
||||
p_dr3dt2 = &(c_dr3dt2 = _dr3dt2.getMat());
|
||||
}
|
||||
|
||||
if( _dt3dr1.needed() )
|
||||
{
|
||||
_dt3dr1.create(3, 3, rtype);
|
||||
p_dt3dr1 = &(c_dt3dr1 = _dt3dr1.getMat());
|
||||
}
|
||||
|
||||
if( _dt3dt1.needed() )
|
||||
{
|
||||
_dt3dt1.create(3, 3, rtype);
|
||||
p_dt3dt1 = &(c_dt3dt1 = _dt3dt1.getMat());
|
||||
}
|
||||
|
||||
if( _dt3dr2.needed() )
|
||||
{
|
||||
_dt3dr2.create(3, 3, rtype);
|
||||
p_dt3dr2 = &(c_dt3dr2 = _dt3dr2.getMat());
|
||||
}
|
||||
|
||||
if( _dt3dt2.needed() )
|
||||
{
|
||||
_dt3dt2.create(3, 3, rtype);
|
||||
p_dt3dt2 = &(c_dt3dt2 = _dt3dt2.getMat());
|
||||
}
|
||||
CV_COMPOSE_RT_PARAM(dr3dr1); CV_COMPOSE_RT_PARAM(dr3dt1);
|
||||
CV_COMPOSE_RT_PARAM(dr3dr2); CV_COMPOSE_RT_PARAM(dr3dt2);
|
||||
CV_COMPOSE_RT_PARAM(dt3dr1); CV_COMPOSE_RT_PARAM(dt3dt1);
|
||||
CV_COMPOSE_RT_PARAM(dt3dr2); CV_COMPOSE_RT_PARAM(dt3dt2);
|
||||
#undef CV_COMPOSE_RT_PARAM
|
||||
|
||||
cvComposeRT(&c_rvec1, &c_tvec1, &c_rvec2, &c_tvec2, &c_rvec3, &c_tvec3,
|
||||
p_dr3dr1, p_dr3dt1, p_dr3dr2, p_dr3dt2,
|
||||
@@ -3306,7 +3272,8 @@ void cv::projectPoints( InputArray _opoints,
|
||||
CvMat *pdpdrot=0, *pdpdt=0, *pdpdf=0, *pdpdc=0, *pdpddist=0;
|
||||
|
||||
_ipoints.create(npoints, 1, CV_MAKETYPE(depth, 2), -1, true);
|
||||
CvMat c_imagePoints = _ipoints.getMat();
|
||||
Mat imagePoints = _ipoints.getMat();
|
||||
CvMat c_imagePoints(imagePoints);
|
||||
CvMat c_objectPoints = opoints;
|
||||
Mat cameraMatrix = _cameraMatrix.getMat();
|
||||
|
||||
@@ -3674,24 +3641,25 @@ cv::Vec3d cv::RQDecomp3x3( InputArray _Mmat,
|
||||
Mat M = _Mmat.getMat();
|
||||
_Rmat.create(3, 3, M.type());
|
||||
_Qmat.create(3, 3, M.type());
|
||||
Mat Rmat = _Rmat.getMat();
|
||||
Mat Qmat = _Qmat.getMat();
|
||||
Vec3d eulerAngles;
|
||||
|
||||
CvMat matM = M, matR = _Rmat.getMat(), matQ = _Qmat.getMat(), Qx, Qy, Qz, *pQx=0, *pQy=0, *pQz=0;
|
||||
if( _Qx.needed() )
|
||||
{
|
||||
_Qx.create(3, 3, M.type());
|
||||
pQx = &(Qx = _Qx.getMat());
|
||||
}
|
||||
if( _Qy.needed() )
|
||||
{
|
||||
_Qy.create(3, 3, M.type());
|
||||
pQy = &(Qy = _Qy.getMat());
|
||||
}
|
||||
if( _Qz.needed() )
|
||||
{
|
||||
_Qz.create(3, 3, M.type());
|
||||
pQz = &(Qz = _Qz.getMat());
|
||||
CvMat matM = M, matR = Rmat, matQ = Qmat;
|
||||
#define CV_RQDecomp3x3_PARAM(name) \
|
||||
Mat name; \
|
||||
CvMat c_ ## name, *p ## name = NULL; \
|
||||
if( _ ## name.needed() ) \
|
||||
{ \
|
||||
_ ## name.create(3, 3, M.type()); \
|
||||
name = _ ## name.getMat(); \
|
||||
c_ ## name = name; p ## name = &c_ ## name; \
|
||||
}
|
||||
|
||||
CV_RQDecomp3x3_PARAM(Qx);
|
||||
CV_RQDecomp3x3_PARAM(Qy);
|
||||
CV_RQDecomp3x3_PARAM(Qz);
|
||||
#undef CV_RQDecomp3x3_PARAM
|
||||
cvRQDecomp3x3(&matM, &matR, &matQ, pQx, pQy, pQz, (CvPoint3D64f*)&eulerAngles[0]);
|
||||
return eulerAngles;
|
||||
}
|
||||
@@ -3709,28 +3677,28 @@ void cv::decomposeProjectionMatrix( InputArray _projMatrix, OutputArray _cameraM
|
||||
_cameraMatrix.create(3, 3, type);
|
||||
_rotMatrix.create(3, 3, type);
|
||||
_transVect.create(4, 1, type);
|
||||
CvMat c_projMatrix = projMatrix, c_cameraMatrix = _cameraMatrix.getMat();
|
||||
CvMat c_rotMatrix = _rotMatrix.getMat(), c_transVect = _transVect.getMat();
|
||||
CvMat c_rotMatrixX, *p_rotMatrixX = 0;
|
||||
CvMat c_rotMatrixY, *p_rotMatrixY = 0;
|
||||
CvMat c_rotMatrixZ, *p_rotMatrixZ = 0;
|
||||
Mat cameraMatrix = _cameraMatrix.getMat();
|
||||
Mat rotMatrix = _rotMatrix.getMat();
|
||||
Mat transVect = _transVect.getMat();
|
||||
CvMat c_projMatrix = projMatrix, c_cameraMatrix = cameraMatrix;
|
||||
CvMat c_rotMatrix = rotMatrix, c_transVect = transVect;
|
||||
CvPoint3D64f *p_eulerAngles = 0;
|
||||
|
||||
if( _rotMatrixX.needed() )
|
||||
{
|
||||
_rotMatrixX.create(3, 3, type);
|
||||
p_rotMatrixX = &(c_rotMatrixX = _rotMatrixX.getMat());
|
||||
}
|
||||
if( _rotMatrixY.needed() )
|
||||
{
|
||||
_rotMatrixY.create(3, 3, type);
|
||||
p_rotMatrixY = &(c_rotMatrixY = _rotMatrixY.getMat());
|
||||
}
|
||||
if( _rotMatrixZ.needed() )
|
||||
{
|
||||
_rotMatrixZ.create(3, 3, type);
|
||||
p_rotMatrixZ = &(c_rotMatrixZ = _rotMatrixZ.getMat());
|
||||
#define CV_decomposeProjectionMatrix_PARAM(name) \
|
||||
Mat name; \
|
||||
CvMat c_ ## name, *p_ ## name = NULL; \
|
||||
if( _ ## name.needed() ) \
|
||||
{ \
|
||||
_ ## name.create(3, 3, type); \
|
||||
name = _ ## name.getMat(); \
|
||||
c_ ## name = name; p_ ## name = &c_ ## name; \
|
||||
}
|
||||
|
||||
CV_decomposeProjectionMatrix_PARAM(rotMatrixX);
|
||||
CV_decomposeProjectionMatrix_PARAM(rotMatrixY);
|
||||
CV_decomposeProjectionMatrix_PARAM(rotMatrixZ);
|
||||
#undef CV_decomposeProjectionMatrix_PARAM
|
||||
|
||||
if( _eulerAngles.needed() )
|
||||
{
|
||||
_eulerAngles.create(3, 1, CV_64F, -1, true);
|
||||
|
||||
@@ -366,7 +366,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
||||
PixType* tempBuf = (PixType*)(disp2ptr + width);
|
||||
|
||||
// add P2 to every C(x,y). it saves a few operations in the inner loops
|
||||
for( k = 0; k < width1*D; k++ )
|
||||
for(k = 0; k < (int)CSBufSize; k++ )
|
||||
Cbuf[k] = (CostType)P2;
|
||||
|
||||
for( int pass = 1; pass <= npasses; pass++ )
|
||||
|
||||
@@ -1306,7 +1306,8 @@ void CV_ProjectPointsTest_C::project( const Mat& opoints, const Mat& rvec, const
|
||||
dpdf.create(npoints*2, 2, CV_64F);
|
||||
dpdc.create(npoints*2, 2, CV_64F);
|
||||
dpddist.create(npoints*2, distCoeffs.rows + distCoeffs.cols - 1, CV_64F);
|
||||
CvMat _objectPoints = opoints, _imagePoints = Mat(ipoints);
|
||||
Mat imagePoints(ipoints);
|
||||
CvMat _objectPoints = opoints, _imagePoints = imagePoints;
|
||||
CvMat _rvec = rvec, _tvec = tvec, _cameraMatrix = cameraMatrix, _distCoeffs = distCoeffs;
|
||||
CvMat _dpdrot = dpdrot, _dpdt = dpdt, _dpdf = dpdf, _dpdc = dpdc, _dpddist = dpddist;
|
||||
|
||||
|
||||
@@ -242,4 +242,18 @@ void CV_ChessboardSubpixelTest::generateIntrinsicParams()
|
||||
|
||||
TEST(Calib3d_ChessboardSubPixDetector, accuracy) { CV_ChessboardSubpixelTest test; test.safe_run(); }
|
||||
|
||||
TEST(Calib3d_CornerSubPix, regression_7204)
|
||||
{
|
||||
cv::Mat image(cv::Size(70, 38), CV_8UC1, cv::Scalar::all(0));
|
||||
image(cv::Rect(65, 26, 5, 5)).setTo(cv::Scalar::all(255));
|
||||
image(cv::Rect(55, 31, 8, 1)).setTo(cv::Scalar::all(255));
|
||||
image(cv::Rect(56, 35, 14, 2)).setTo(cv::Scalar::all(255));
|
||||
image(cv::Rect(66, 24, 4, 2)).setTo(cv::Scalar::all(255));
|
||||
image.at<uchar>(24, 69) = 0;
|
||||
std::vector<cv::Point2f> corners;
|
||||
corners.push_back(cv::Point2f(65, 30));
|
||||
cv::cornerSubPix(image, corners, cv::Size(3, 3), cv::Size(-1, -1),
|
||||
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -794,6 +794,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 +812,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 +879,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 +925,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
|
||||
@@ -1328,6 +1370,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
|
||||
@@ -1478,6 +1526,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
|
||||
@@ -2016,6 +2069,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
|
||||
@@ -2085,6 +2140,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);
|
||||
@@ -2189,6 +2245,7 @@ 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
|
||||
@@ -2273,6 +2330,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();
|
||||
@@ -2294,6 +2352,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).
|
||||
|
||||
@@ -386,6 +386,23 @@ Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
create(_sz, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
create(_sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const Mat& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
||||
@@ -719,6 +736,12 @@ Mat Mat::operator()(const Range* ranges) const
|
||||
return Mat(*this, ranges);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat Mat::operator()(const std::vector<Range>& ranges) const
|
||||
{
|
||||
return Mat(*this, ranges);
|
||||
}
|
||||
|
||||
inline
|
||||
bool Mat::isContinuous() const
|
||||
{
|
||||
@@ -1366,6 +1389,11 @@ Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges)
|
||||
: Mat(m, ranges)
|
||||
{}
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const std::vector<Range>& ranges)
|
||||
: Mat(m, ranges)
|
||||
{}
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_(const Mat& m)
|
||||
: Mat()
|
||||
@@ -1597,6 +1625,12 @@ Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const
|
||||
return Mat_<_Tp>(*this, ranges);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector<Range>& ranges) const
|
||||
{
|
||||
return Mat_<_Tp>(*this, ranges);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp* Mat_<_Tp>::operator [](int y)
|
||||
{
|
||||
@@ -3523,6 +3557,12 @@ UMat UMat::operator()(const Range* ranges) const
|
||||
return UMat(*this, ranges);
|
||||
}
|
||||
|
||||
inline
|
||||
UMat UMat::operator()(const std::vector<Range>& ranges) const
|
||||
{
|
||||
return UMat(*this, ranges);
|
||||
}
|
||||
|
||||
inline
|
||||
bool UMat::isContinuous() const
|
||||
{
|
||||
|
||||
@@ -483,8 +483,10 @@ public:
|
||||
@param pts The points array for storing rectangle vertices.
|
||||
*/
|
||||
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
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#define OPENCV_VERSION_HPP
|
||||
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 1
|
||||
#define CV_VERSION_MINOR 2
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_STATUS "-dev"
|
||||
|
||||
|
||||
@@ -4644,31 +4644,50 @@ static bool _openvx_cvt(const T* src, size_t sstep,
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
if(!(continuousSize.width > 0 && continuousSize.height > 0 && sstep > 0 && dstep > 0))
|
||||
if(!(continuousSize.width > 0 && continuousSize.height > 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CV_Assert(sstep / sizeof(T) == dstep / sizeof(DT));
|
||||
|
||||
//.height is for number of continuous pieces
|
||||
//.width is for length of one piece
|
||||
Size imgSize = continuousSize;
|
||||
if(continuousSize.height == 1)
|
||||
{
|
||||
//continuous case
|
||||
imgSize.width = sstep / sizeof(T);
|
||||
imgSize.height = continuousSize.width / (sstep / sizeof(T));
|
||||
if(sstep / sizeof(T) == dstep / sizeof(DT) && sstep / sizeof(T) > 0 &&
|
||||
continuousSize.width % (sstep / sizeof(T)) == 0)
|
||||
{
|
||||
//continuous n-lines image
|
||||
imgSize.width = sstep / sizeof(T);
|
||||
imgSize.height = continuousSize.width / (sstep / sizeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
//1-row image with possibly incorrect step
|
||||
sstep = continuousSize.width * sizeof(T);
|
||||
dstep = continuousSize.width * sizeof(DT);
|
||||
}
|
||||
}
|
||||
|
||||
int srcType = DataType<T>::type, dstType = DataType<DT>::type;
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType<T>::type),
|
||||
|
||||
// Other conversions are marked as "experimental"
|
||||
if(context.vendorID() == VX_ID_KHRONOS &&
|
||||
!(srcType == CV_8U && dstType == CV_16S) &&
|
||||
!(srcType == CV_16S && dstType == CV_8U))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(srcType),
|
||||
Image::createAddressing(imgSize.width, imgSize.height,
|
||||
(vx_uint32)sizeof(T), (vx_uint32)sstep),
|
||||
(void*)src);
|
||||
Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType<DT>::type),
|
||||
Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(dstType),
|
||||
Image::createAddressing(imgSize.width, imgSize.height,
|
||||
(vx_uint32)sizeof(DT), (vx_uint32)dstep),
|
||||
(void*)dst);
|
||||
@@ -4726,7 +4745,7 @@ cvt_( const T* src, size_t sstep,
|
||||
DT* dst, size_t dstep, Size size )
|
||||
{
|
||||
CV_OVX_RUN(
|
||||
false,
|
||||
true,
|
||||
openvx_cvt(src, sstep, dst, dstep, size)
|
||||
)
|
||||
|
||||
|
||||
+141
-130
@@ -3412,6 +3412,125 @@ static bool ocl_mulSpectrums( InputArray _srcA, InputArray _srcB,
|
||||
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
#define VAL(buf, elem) (((T*)((char*)data ## buf + (step ## buf * (elem))))[0])
|
||||
#define MUL_SPECTRUMS_COL(A, B, C) \
|
||||
VAL(C, 0) = VAL(A, 0) * VAL(B, 0); \
|
||||
for (size_t j = 1; j <= rows - 2; j += 2) \
|
||||
{ \
|
||||
double a_re = VAL(A, j), a_im = VAL(A, j + 1); \
|
||||
double b_re = VAL(B, j), b_im = VAL(B, j + 1); \
|
||||
if (conjB) b_im = -b_im; \
|
||||
double c_re = a_re * b_re - a_im * b_im; \
|
||||
double c_im = a_re * b_im + a_im * b_re; \
|
||||
VAL(C, j) = (T)c_re; VAL(C, j + 1) = (T)c_im; \
|
||||
} \
|
||||
if ((rows & 1) == 0) \
|
||||
VAL(C, rows-1) = VAL(A, rows-1) * VAL(B, rows-1)
|
||||
|
||||
template <typename T, bool conjB> static inline
|
||||
void mulSpectrums_processCol_noinplace(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows)
|
||||
{
|
||||
MUL_SPECTRUMS_COL(A, B, C);
|
||||
}
|
||||
|
||||
template <typename T, bool conjB> static inline
|
||||
void mulSpectrums_processCol_inplaceA(const T* dataB, T* dataAC, size_t stepB, size_t stepAC, size_t rows)
|
||||
{
|
||||
MUL_SPECTRUMS_COL(AC, B, AC);
|
||||
}
|
||||
template <typename T, bool conjB, bool inplaceA> static inline
|
||||
void mulSpectrums_processCol(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows)
|
||||
{
|
||||
if (inplaceA)
|
||||
mulSpectrums_processCol_inplaceA<T, conjB>(dataB, dataC, stepB, stepC, rows);
|
||||
else
|
||||
mulSpectrums_processCol_noinplace<T, conjB>(dataA, dataB, dataC, stepA, stepB, stepC, rows);
|
||||
}
|
||||
#undef MUL_SPECTRUMS_COL
|
||||
#undef VAL
|
||||
|
||||
template <typename T, bool conjB, bool inplaceA> static inline
|
||||
void mulSpectrums_processCols(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows, size_t cols)
|
||||
{
|
||||
mulSpectrums_processCol<T, conjB, inplaceA>(dataA, dataB, dataC, stepA, stepB, stepC, rows);
|
||||
if ((cols & 1) == 0)
|
||||
{
|
||||
mulSpectrums_processCol<T, conjB, inplaceA>(dataA + cols - 1, dataB + cols - 1, dataC + cols - 1, stepA, stepB, stepC, rows);
|
||||
}
|
||||
}
|
||||
|
||||
#define VAL(buf, elem) (data ## buf[(elem)])
|
||||
#define MUL_SPECTRUMS_ROW(A, B, C) \
|
||||
for (size_t j = j0; j < j1; j += 2) \
|
||||
{ \
|
||||
double a_re = VAL(A, j), a_im = VAL(A, j + 1); \
|
||||
double b_re = VAL(B, j), b_im = VAL(B, j + 1); \
|
||||
if (conjB) b_im = -b_im; \
|
||||
double c_re = a_re * b_re - a_im * b_im; \
|
||||
double c_im = a_re * b_im + a_im * b_re; \
|
||||
VAL(C, j) = (T)c_re; VAL(C, j + 1) = (T)c_im; \
|
||||
}
|
||||
template <typename T, bool conjB> static inline
|
||||
void mulSpectrums_processRow_noinplace(const T* dataA, const T* dataB, T* dataC, size_t j0, size_t j1)
|
||||
{
|
||||
MUL_SPECTRUMS_ROW(A, B, C);
|
||||
}
|
||||
template <typename T, bool conjB> static inline
|
||||
void mulSpectrums_processRow_inplaceA(const T* dataB, T* dataAC, size_t j0, size_t j1)
|
||||
{
|
||||
MUL_SPECTRUMS_ROW(AC, B, AC);
|
||||
}
|
||||
template <typename T, bool conjB, bool inplaceA> static inline
|
||||
void mulSpectrums_processRow(const T* dataA, const T* dataB, T* dataC, size_t j0, size_t j1)
|
||||
{
|
||||
if (inplaceA)
|
||||
mulSpectrums_processRow_inplaceA<T, conjB>(dataB, dataC, j0, j1);
|
||||
else
|
||||
mulSpectrums_processRow_noinplace<T, conjB>(dataA, dataB, dataC, j0, j1);
|
||||
}
|
||||
#undef MUL_SPECTRUMS_ROW
|
||||
#undef VAL
|
||||
|
||||
template <typename T, bool conjB, bool inplaceA> static inline
|
||||
void mulSpectrums_processRows(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows, size_t cols, size_t j0, size_t j1, bool is_1d_CN1)
|
||||
{
|
||||
while (rows-- > 0)
|
||||
{
|
||||
if (is_1d_CN1)
|
||||
dataC[0] = dataA[0]*dataB[0];
|
||||
mulSpectrums_processRow<T, conjB, inplaceA>(dataA, dataB, dataC, j0, j1);
|
||||
if (is_1d_CN1 && (cols & 1) == 0)
|
||||
dataC[j1] = dataA[j1]*dataB[j1];
|
||||
|
||||
dataA = (const T*)(((char*)dataA) + stepA);
|
||||
dataB = (const T*)(((char*)dataB) + stepB);
|
||||
dataC = (T*)(((char*)dataC) + stepC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T, bool conjB, bool inplaceA> static inline
|
||||
void mulSpectrums_Impl_(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows, size_t cols, size_t j0, size_t j1, bool is_1d, bool isCN1)
|
||||
{
|
||||
if (!is_1d && isCN1)
|
||||
{
|
||||
mulSpectrums_processCols<T, conjB, inplaceA>(dataA, dataB, dataC, stepA, stepB, stepC, rows, cols);
|
||||
}
|
||||
mulSpectrums_processRows<T, conjB, inplaceA>(dataA, dataB, dataC, stepA, stepB, stepC, rows, cols, j0, j1, is_1d && isCN1);
|
||||
}
|
||||
template <typename T, bool conjB> static inline
|
||||
void mulSpectrums_Impl(const T* dataA, const T* dataB, T* dataC, size_t stepA, size_t stepB, size_t stepC, size_t rows, size_t cols, size_t j0, size_t j1, bool is_1d, bool isCN1)
|
||||
{
|
||||
if (dataA == dataC)
|
||||
mulSpectrums_Impl_<T, conjB, true>(dataA, dataB, dataC, stepA, stepB, stepC, rows, cols, j0, j1, is_1d, isCN1);
|
||||
else
|
||||
mulSpectrums_Impl_<T, conjB, false>(dataA, dataB, dataC, stepA, stepB, stepC, rows, cols, j0, j1, is_1d, isCN1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void cv::mulSpectrums( InputArray _srcA, InputArray _srcB,
|
||||
OutputArray _dst, int flags, bool conjB )
|
||||
{
|
||||
@@ -3422,8 +3541,7 @@ void cv::mulSpectrums( InputArray _srcA, InputArray _srcB,
|
||||
|
||||
Mat srcA = _srcA.getMat(), srcB = _srcB.getMat();
|
||||
int depth = srcA.depth(), cn = srcA.channels(), type = srcA.type();
|
||||
int rows = srcA.rows, cols = srcA.cols;
|
||||
int j, k;
|
||||
size_t rows = srcA.rows, cols = srcA.cols;
|
||||
|
||||
CV_Assert( type == srcB.type() && srcA.size() == srcB.size() );
|
||||
CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 );
|
||||
@@ -3431,149 +3549,42 @@ void cv::mulSpectrums( InputArray _srcA, InputArray _srcB,
|
||||
_dst.create( srcA.rows, srcA.cols, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
bool is_1d = (flags & DFT_ROWS) || (rows == 1 || (cols == 1 &&
|
||||
srcA.isContinuous() && srcB.isContinuous() && dst.isContinuous()));
|
||||
// correct inplace support
|
||||
// Case 'dst.data == srcA.data' is handled by implementation,
|
||||
// because it is used frequently (filter2D, matchTemplate)
|
||||
if (dst.data == srcB.data)
|
||||
srcB = srcB.clone(); // workaround for B only
|
||||
|
||||
bool is_1d = (flags & DFT_ROWS)
|
||||
|| (rows == 1)
|
||||
|| (cols == 1 && srcA.isContinuous() && srcB.isContinuous() && dst.isContinuous());
|
||||
|
||||
if( is_1d && !(flags & DFT_ROWS) )
|
||||
cols = cols + rows - 1, rows = 1;
|
||||
|
||||
int ncols = cols*cn;
|
||||
int j0 = cn == 1;
|
||||
int j1 = ncols - (cols % 2 == 0 && cn == 1);
|
||||
bool isCN1 = cn == 1;
|
||||
size_t j0 = isCN1 ? 1 : 0;
|
||||
size_t j1 = cols*cn - (((cols & 1) == 0 && cn == 1) ? 1 : 0);
|
||||
|
||||
if( depth == CV_32F )
|
||||
if (depth == CV_32F)
|
||||
{
|
||||
const float* dataA = srcA.ptr<float>();
|
||||
const float* dataB = srcB.ptr<float>();
|
||||
float* dataC = dst.ptr<float>();
|
||||
|
||||
size_t stepA = srcA.step/sizeof(dataA[0]);
|
||||
size_t stepB = srcB.step/sizeof(dataB[0]);
|
||||
size_t stepC = dst.step/sizeof(dataC[0]);
|
||||
|
||||
if( !is_1d && cn == 1 )
|
||||
{
|
||||
for( k = 0; k < (cols % 2 ? 1 : 2); k++ )
|
||||
{
|
||||
if( k == 1 )
|
||||
dataA += cols - 1, dataB += cols - 1, dataC += cols - 1;
|
||||
dataC[0] = dataA[0]*dataB[0];
|
||||
if( rows % 2 == 0 )
|
||||
dataC[(rows-1)*stepC] = dataA[(rows-1)*stepA]*dataB[(rows-1)*stepB];
|
||||
if( !conjB )
|
||||
for( j = 1; j <= rows - 2; j += 2 )
|
||||
{
|
||||
double re = (double)dataA[j*stepA]*dataB[j*stepB] -
|
||||
(double)dataA[(j+1)*stepA]*dataB[(j+1)*stepB];
|
||||
double im = (double)dataA[j*stepA]*dataB[(j+1)*stepB] +
|
||||
(double)dataA[(j+1)*stepA]*dataB[j*stepB];
|
||||
dataC[j*stepC] = (float)re; dataC[(j+1)*stepC] = (float)im;
|
||||
}
|
||||
else
|
||||
for( j = 1; j <= rows - 2; j += 2 )
|
||||
{
|
||||
double re = (double)dataA[j*stepA]*dataB[j*stepB] +
|
||||
(double)dataA[(j+1)*stepA]*dataB[(j+1)*stepB];
|
||||
double im = (double)dataA[(j+1)*stepA]*dataB[j*stepB] -
|
||||
(double)dataA[j*stepA]*dataB[(j+1)*stepB];
|
||||
dataC[j*stepC] = (float)re; dataC[(j+1)*stepC] = (float)im;
|
||||
}
|
||||
if( k == 1 )
|
||||
dataA -= cols - 1, dataB -= cols - 1, dataC -= cols - 1;
|
||||
}
|
||||
}
|
||||
|
||||
for( ; rows--; dataA += stepA, dataB += stepB, dataC += stepC )
|
||||
{
|
||||
if( is_1d && cn == 1 )
|
||||
{
|
||||
dataC[0] = dataA[0]*dataB[0];
|
||||
if( cols % 2 == 0 )
|
||||
dataC[j1] = dataA[j1]*dataB[j1];
|
||||
}
|
||||
|
||||
if( !conjB )
|
||||
for( j = j0; j < j1; j += 2 )
|
||||
{
|
||||
double re = (double)dataA[j]*dataB[j] - (double)dataA[j+1]*dataB[j+1];
|
||||
double im = (double)dataA[j+1]*dataB[j] + (double)dataA[j]*dataB[j+1];
|
||||
dataC[j] = (float)re; dataC[j+1] = (float)im;
|
||||
}
|
||||
else
|
||||
for( j = j0; j < j1; j += 2 )
|
||||
{
|
||||
double re = (double)dataA[j]*dataB[j] + (double)dataA[j+1]*dataB[j+1];
|
||||
double im = (double)dataA[j+1]*dataB[j] - (double)dataA[j]*dataB[j+1];
|
||||
dataC[j] = (float)re; dataC[j+1] = (float)im;
|
||||
}
|
||||
}
|
||||
if (!conjB)
|
||||
mulSpectrums_Impl<float, false>(dataA, dataB, dataC, srcA.step, srcB.step, dst.step, rows, cols, j0, j1, is_1d, isCN1);
|
||||
else
|
||||
mulSpectrums_Impl<float, true>(dataA, dataB, dataC, srcA.step, srcB.step, dst.step, rows, cols, j0, j1, is_1d, isCN1);
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* dataA = srcA.ptr<double>();
|
||||
const double* dataB = srcB.ptr<double>();
|
||||
double* dataC = dst.ptr<double>();
|
||||
|
||||
size_t stepA = srcA.step/sizeof(dataA[0]);
|
||||
size_t stepB = srcB.step/sizeof(dataB[0]);
|
||||
size_t stepC = dst.step/sizeof(dataC[0]);
|
||||
|
||||
if( !is_1d && cn == 1 )
|
||||
{
|
||||
for( k = 0; k < (cols % 2 ? 1 : 2); k++ )
|
||||
{
|
||||
if( k == 1 )
|
||||
dataA += cols - 1, dataB += cols - 1, dataC += cols - 1;
|
||||
dataC[0] = dataA[0]*dataB[0];
|
||||
if( rows % 2 == 0 )
|
||||
dataC[(rows-1)*stepC] = dataA[(rows-1)*stepA]*dataB[(rows-1)*stepB];
|
||||
if( !conjB )
|
||||
for( j = 1; j <= rows - 2; j += 2 )
|
||||
{
|
||||
double re = dataA[j*stepA]*dataB[j*stepB] -
|
||||
dataA[(j+1)*stepA]*dataB[(j+1)*stepB];
|
||||
double im = dataA[j*stepA]*dataB[(j+1)*stepB] +
|
||||
dataA[(j+1)*stepA]*dataB[j*stepB];
|
||||
dataC[j*stepC] = re; dataC[(j+1)*stepC] = im;
|
||||
}
|
||||
else
|
||||
for( j = 1; j <= rows - 2; j += 2 )
|
||||
{
|
||||
double re = dataA[j*stepA]*dataB[j*stepB] +
|
||||
dataA[(j+1)*stepA]*dataB[(j+1)*stepB];
|
||||
double im = dataA[(j+1)*stepA]*dataB[j*stepB] -
|
||||
dataA[j*stepA]*dataB[(j+1)*stepB];
|
||||
dataC[j*stepC] = re; dataC[(j+1)*stepC] = im;
|
||||
}
|
||||
if( k == 1 )
|
||||
dataA -= cols - 1, dataB -= cols - 1, dataC -= cols - 1;
|
||||
}
|
||||
}
|
||||
|
||||
for( ; rows--; dataA += stepA, dataB += stepB, dataC += stepC )
|
||||
{
|
||||
if( is_1d && cn == 1 )
|
||||
{
|
||||
dataC[0] = dataA[0]*dataB[0];
|
||||
if( cols % 2 == 0 )
|
||||
dataC[j1] = dataA[j1]*dataB[j1];
|
||||
}
|
||||
|
||||
if( !conjB )
|
||||
for( j = j0; j < j1; j += 2 )
|
||||
{
|
||||
double re = dataA[j]*dataB[j] - dataA[j+1]*dataB[j+1];
|
||||
double im = dataA[j+1]*dataB[j] + dataA[j]*dataB[j+1];
|
||||
dataC[j] = re; dataC[j+1] = im;
|
||||
}
|
||||
else
|
||||
for( j = j0; j < j1; j += 2 )
|
||||
{
|
||||
double re = dataA[j]*dataB[j] + dataA[j+1]*dataB[j+1];
|
||||
double im = dataA[j+1]*dataB[j] - dataA[j]*dataB[j+1];
|
||||
dataC[j] = re; dataC[j+1] = im;
|
||||
}
|
||||
}
|
||||
if (!conjB)
|
||||
mulSpectrums_Impl<double, false>(dataA, dataB, dataC, srcA.step, srcB.step, dst.step, rows, cols, j0, j1, is_1d, isCN1);
|
||||
else
|
||||
mulSpectrums_Impl<double, true>(dataA, dataB, dataC, srcA.step, srcB.step, dst.step, rows, cols, j0, j1, is_1d, isCN1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,15 +46,7 @@
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
|
||||
#ifdef HAVE_LAPACK_MKL
|
||||
#include <mkl_cblas.h>
|
||||
#include <mkl_lapack.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAPACK_GENERIC
|
||||
#include <lapacke.h>
|
||||
#include <cblas.h>
|
||||
#endif
|
||||
#include "opencv_lapack.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -439,6 +439,11 @@ void Mat::create(int d, const int* _sizes, int _type)
|
||||
finalizeHdr(*this);
|
||||
}
|
||||
|
||||
void Mat::create(const std::vector<int>& _sizes, int _type)
|
||||
{
|
||||
create((int)_sizes.size(), _sizes.data(), _type);
|
||||
}
|
||||
|
||||
void Mat::copySize(const Mat& m)
|
||||
{
|
||||
setSize(*this, m.dims, 0, 0);
|
||||
@@ -541,6 +546,17 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(const std::vector<int>& _sizes, int _type, void* _data, const size_t* _steps)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
flags |= CV_MAT_TYPE(_type);
|
||||
datastart = data = (uchar*)_data;
|
||||
setSize(*this, (int)_sizes.size(), _sizes.data(), _steps, true);
|
||||
finalizeHdr(*this);
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(const Mat& m, const Range* ranges)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows)
|
||||
@@ -567,6 +583,31 @@ Mat::Mat(const Mat& m, const Range* ranges)
|
||||
updateContinuityFlag(*this);
|
||||
}
|
||||
|
||||
Mat::Mat(const Mat& m, const std::vector<Range>& ranges)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
int d = m.dims;
|
||||
|
||||
CV_Assert((int)ranges.size() == d);
|
||||
for (int i = 0; i < d; i++)
|
||||
{
|
||||
Range r = ranges[i];
|
||||
CV_Assert(r == Range::all() || (0 <= r.start && r.start < r.end && r.end <= m.size[i]));
|
||||
}
|
||||
*this = m;
|
||||
for (int i = 0; i < d; i++)
|
||||
{
|
||||
Range r = ranges[i];
|
||||
if (r != Range::all() && r != Range(0, size.p[i]))
|
||||
{
|
||||
size.p[i] = r.end - r.start;
|
||||
data += r.start*step.p[i];
|
||||
flags |= SUBMATRIX_FLAG;
|
||||
}
|
||||
}
|
||||
updateContinuityFlag(*this);
|
||||
}
|
||||
|
||||
static Mat cvMatNDToMat(const CvMatND* m, bool copyData)
|
||||
{
|
||||
@@ -5550,6 +5591,16 @@ Rect RotatedRect::boundingRect() const
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Rect_<float> RotatedRect::boundingRect2f() const
|
||||
{
|
||||
Point2f pt[4];
|
||||
points(pt);
|
||||
Rect_<float> r(Point_<float>(min(min(min(pt[0].x, pt[1].x), pt[2].x), pt[3].x), min(min(min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
|
||||
Point_<float>(max(max(max(pt[0].x, pt[1].x), pt[2].x), pt[3].x), max(max(max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// glue
|
||||
|
||||
@@ -386,6 +386,11 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
|
||||
addref();
|
||||
}
|
||||
|
||||
void UMat::create(const std::vector<int>& _sizes, int _type, UMatUsageFlags _usageFlags)
|
||||
{
|
||||
create((int)_sizes.size(), _sizes.data(), _type, _usageFlags);
|
||||
}
|
||||
|
||||
void UMat::copySize(const UMat& m)
|
||||
{
|
||||
setSize(*this, m.dims, 0, 0);
|
||||
@@ -507,6 +512,31 @@ UMat::UMat(const UMat& m, const Range* ranges)
|
||||
updateContinuityFlag(*this);
|
||||
}
|
||||
|
||||
UMat::UMat(const UMat& m, const std::vector<Range>& ranges)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
|
||||
{
|
||||
int i, d = m.dims;
|
||||
|
||||
CV_Assert((int)ranges.size() == d);
|
||||
for (i = 0; i < d; i++)
|
||||
{
|
||||
Range r = ranges[i];
|
||||
CV_Assert(r == Range::all() || (0 <= r.start && r.start < r.end && r.end <= m.size[i]));
|
||||
}
|
||||
*this = m;
|
||||
for (i = 0; i < d; i++)
|
||||
{
|
||||
Range r = ranges[i];
|
||||
if (r != Range::all() && r != Range(0, size.p[i]))
|
||||
{
|
||||
size.p[i] = r.end - r.start;
|
||||
offset += r.start*step.p[i];
|
||||
flags |= SUBMATRIX_FLAG;
|
||||
}
|
||||
}
|
||||
updateContinuityFlag(*this);
|
||||
}
|
||||
|
||||
UMat UMat::diag(int d) const
|
||||
{
|
||||
CV_Assert( dims <= 2 );
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#include "test_precomp.hpp"
|
||||
#include <cmath>
|
||||
#ifndef NAN
|
||||
#include <limits> // numeric_limits<T>::quiet_NaN()
|
||||
#define NAN std::numeric_limits<float>::quiet_NaN()
|
||||
#endif
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
@@ -1895,7 +1891,7 @@ TEST(MinMaxLoc, regression_4955_nans)
|
||||
cv::Mat one_mat(2, 2, CV_32F, cv::Scalar(1));
|
||||
cv::minMaxLoc(one_mat, NULL, NULL, NULL, NULL);
|
||||
|
||||
cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(NAN));
|
||||
cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(std::numeric_limits<float>::quiet_NaN()));
|
||||
cv::minMaxLoc(nan_mat, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,9 +419,6 @@ static void fixCCS( Mat& mat, int cols, int flags )
|
||||
}
|
||||
}
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1700
|
||||
#pragma optimize("", off)
|
||||
#endif
|
||||
static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
{
|
||||
dst.create(src1.rows, src1.cols, src1.type());
|
||||
@@ -430,12 +427,27 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
CV_Assert( src1.size == src2.size && src1.type() == src2.type() &&
|
||||
(src1.type() == CV_32FC2 || src1.type() == CV_64FC2) );
|
||||
|
||||
const Mat* src1_ = &src1;
|
||||
Mat src1_tmp;
|
||||
if (dst.data == src1.data)
|
||||
{
|
||||
src1_tmp = src1.clone();
|
||||
src1_ = &src1_tmp;
|
||||
}
|
||||
const Mat* src2_ = &src2;
|
||||
Mat src2_tmp;
|
||||
if (dst.data == src2.data)
|
||||
{
|
||||
src2_tmp = src2.clone();
|
||||
src2_ = &src2_tmp;
|
||||
}
|
||||
|
||||
for( i = 0; i < dst.rows; i++ )
|
||||
{
|
||||
if( depth == CV_32F )
|
||||
{
|
||||
const float* a = src1.ptr<float>(i);
|
||||
const float* b = src2.ptr<float>(i);
|
||||
const float* a = src1_->ptr<float>(i);
|
||||
const float* b = src2_->ptr<float>(i);
|
||||
float* c = dst.ptr<float>(i);
|
||||
|
||||
if( !(flags & CV_DXT_MUL_CONJ) )
|
||||
@@ -459,8 +471,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* a = src1.ptr<double>(i);
|
||||
const double* b = src2.ptr<double>(i);
|
||||
const double* a = src1_->ptr<double>(i);
|
||||
const double* b = src2_->ptr<double>(i);
|
||||
double* c = dst.ptr<double>(i);
|
||||
|
||||
if( !(flags & CV_DXT_MUL_CONJ) )
|
||||
@@ -484,9 +496,6 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined _MSC_VER && _MSC_VER >= 1700
|
||||
#pragma optimize("", on)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -778,9 +787,7 @@ public:
|
||||
protected:
|
||||
void run_func();
|
||||
void prepare_to_validation( int test_case_idx );
|
||||
#if defined(__aarch64__) && defined(NDEBUG)
|
||||
double get_success_error_level( int test_case_idx, int i, int j );
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -788,31 +795,19 @@ CxCore_MulSpectrumsTest::CxCore_MulSpectrumsTest() : CxCore_DXTBaseTest( true, t
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__aarch64__) && defined(NDEBUG)
|
||||
double CxCore_MulSpectrumsTest::get_success_error_level( int test_case_idx, int i, int j )
|
||||
{
|
||||
(void)test_case_idx;
|
||||
CV_Assert(i == OUTPUT);
|
||||
CV_Assert(j == 0);
|
||||
int elem_depth = CV_MAT_DEPTH(cvGetElemType(test_array[i][j]));
|
||||
if( elem_depth <= CV_32F )
|
||||
{
|
||||
return ArrayTest::get_success_error_level( test_case_idx, i, j );
|
||||
}
|
||||
switch( test_case_idx )
|
||||
{
|
||||
// Usual threshold is too strict for these test cases due to the difference of fmsub and fsub
|
||||
case 399:
|
||||
case 420:
|
||||
return DBL_EPSILON * 20000;
|
||||
case 65:
|
||||
case 161:
|
||||
case 287:
|
||||
case 351:
|
||||
case 458:
|
||||
return DBL_EPSILON * 10000;
|
||||
default:
|
||||
return ArrayTest::get_success_error_level( test_case_idx, i, j );
|
||||
}
|
||||
CV_Assert(elem_depth == CV_32F || elem_depth == CV_64F);
|
||||
|
||||
element_wise_relative_error = false;
|
||||
double maxInputValue = 1000; // ArrayTest::get_minmax_bounds
|
||||
double err = 8 * maxInputValue; // result = A*B + C*D
|
||||
return (elem_depth == CV_32F ? FLT_EPSILON : DBL_EPSILON) * err;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CxCore_MulSpectrumsTest::run_func()
|
||||
{
|
||||
|
||||
@@ -1546,3 +1546,28 @@ TEST(Mat, regression_5917_clone_empty)
|
||||
|
||||
ASSERT_NO_THROW(cloned = source.clone());
|
||||
}
|
||||
|
||||
TEST(Mat, regression_7873_mat_vector_initialize)
|
||||
{
|
||||
std::vector<int> dims;
|
||||
dims.push_back(12);
|
||||
dims.push_back(3);
|
||||
dims.push_back(2);
|
||||
Mat multi_mat(dims, CV_32FC1, cv::Scalar(0));
|
||||
|
||||
ASSERT_EQ(3, multi_mat.dims);
|
||||
ASSERT_EQ(12, multi_mat.size[0]);
|
||||
ASSERT_EQ(3, multi_mat.size[1]);
|
||||
ASSERT_EQ(2, multi_mat.size[2]);
|
||||
|
||||
std::vector<Range> ranges;
|
||||
ranges.push_back(Range(1, 2));
|
||||
ranges.push_back(Range::all());
|
||||
ranges.push_back(Range::all());
|
||||
Mat sub_mat = multi_mat(ranges);
|
||||
|
||||
ASSERT_EQ(3, sub_mat.dims);
|
||||
ASSERT_EQ(1, sub_mat.size[0]);
|
||||
ASSERT_EQ(3, sub_mat.size[1]);
|
||||
ASSERT_EQ(2, sub_mat.size[2]);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ CV_EXPORTS Ptr<Filter> createGaussianFilter(int srcType, int dstType, Size ksize
|
||||
- **MORPH_GRADIENT** morphological gradient
|
||||
- **MORPH_TOPHAT** "top hat"
|
||||
- **MORPH_BLACKHAT** "black hat"
|
||||
@param srcType Input/output image type. Only CV_8UC1 and CV_8UC4 are supported.
|
||||
@param srcType Input/output image type. Only CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4 are supported.
|
||||
@param kernel 2D 8-bit structuring element for the morphological operation.
|
||||
@param anchor Anchor position within the structuring element. Negative values mean that the anchor
|
||||
is at the center.
|
||||
|
||||
@@ -525,14 +525,17 @@ namespace
|
||||
void apply(InputArray src, OutputArray dst, Stream& stream = Stream::Null());
|
||||
|
||||
private:
|
||||
typedef NppStatus (*nppMorfFilter_t)(const Npp8u* pSrc, Npp32s nSrcStep, Npp8u* pDst, Npp32s nDstStep, NppiSize oSizeROI,
|
||||
const Npp8u* pMask, NppiSize oMaskSize, NppiPoint oAnchor);
|
||||
typedef NppStatus (*nppMorfFilter8u_t)(const Npp8u* pSrc, Npp32s nSrcStep, Npp8u* pDst, Npp32s nDstStep, NppiSize oSizeROI,
|
||||
const Npp8u* pMask, NppiSize oMaskSize, NppiPoint oAnchor);
|
||||
typedef NppStatus (*nppMorfFilter32f_t)(const Npp32f* pSrc, Npp32s nSrcStep, Npp32f* pDst, Npp32s nDstStep, NppiSize oSizeROI,
|
||||
const Npp8u* pMask, NppiSize oMaskSize, NppiPoint oAnchor);
|
||||
|
||||
int type_;
|
||||
GpuMat kernel_;
|
||||
Point anchor_;
|
||||
int iters_;
|
||||
nppMorfFilter_t func_;
|
||||
nppMorfFilter8u_t func8u_;
|
||||
nppMorfFilter32f_t func32f_;
|
||||
|
||||
GpuMat srcBorder_;
|
||||
GpuMat buf_;
|
||||
@@ -541,14 +544,19 @@ namespace
|
||||
MorphologyFilter::MorphologyFilter(int op, int srcType, InputArray _kernel, Point anchor, int iterations) :
|
||||
type_(srcType), anchor_(anchor), iters_(iterations)
|
||||
{
|
||||
static const nppMorfFilter_t funcs[2][5] =
|
||||
static const nppMorfFilter8u_t funcs8u[2][5] =
|
||||
{
|
||||
{0, nppiErode_8u_C1R, 0, 0, nppiErode_8u_C4R },
|
||||
{0, nppiDilate_8u_C1R, 0, 0, nppiDilate_8u_C4R }
|
||||
};
|
||||
static const nppMorfFilter32f_t funcs32f[2][5] =
|
||||
{
|
||||
{0, nppiErode_32f_C1R, 0, 0, nppiErode_32f_C4R },
|
||||
{0, nppiDilate_32f_C1R, 0, 0, nppiDilate_32f_C4R }
|
||||
};
|
||||
|
||||
CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE );
|
||||
CV_Assert( srcType == CV_8UC1 || srcType == CV_8UC4 );
|
||||
CV_Assert( srcType == CV_8UC1 || srcType == CV_8UC4 || srcType == CV_32FC1 || srcType == CV_32FC4 );
|
||||
|
||||
Mat kernel = _kernel.getMat();
|
||||
Size ksize = !kernel.empty() ? _kernel.size() : Size(3, 3);
|
||||
@@ -579,7 +587,14 @@ namespace
|
||||
kernel_ = cuda::createContinuous(kernel.size(), CV_8UC1);
|
||||
kernel_.upload(kernel8U);
|
||||
|
||||
func_ = funcs[op][CV_MAT_CN(srcType)];
|
||||
if(srcType == CV_8UC1 || srcType == CV_8UC4)
|
||||
{
|
||||
func8u_ = funcs8u[op][CV_MAT_CN(srcType)];
|
||||
}
|
||||
else if(srcType == CV_32FC1 || srcType == CV_32FC4)
|
||||
{
|
||||
func32f_ = funcs32f[op][CV_MAT_CN(srcType)];
|
||||
}
|
||||
}
|
||||
|
||||
void MorphologyFilter::apply(InputArray _src, OutputArray _dst, Stream& _stream)
|
||||
@@ -618,15 +633,31 @@ namespace
|
||||
oAnchor.x = anchor_.x;
|
||||
oAnchor.y = anchor_.y;
|
||||
|
||||
nppSafeCall( func_(srcRoi.ptr<Npp8u>(), static_cast<int>(srcRoi.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
|
||||
for(int i = 1; i < iters_; ++i)
|
||||
if (type_ == CV_8UC1 || type_ == CV_8UC4)
|
||||
{
|
||||
dst.copyTo(bufRoi, _stream);
|
||||
nppSafeCall( func8u_(srcRoi.ptr<Npp8u>(), static_cast<int>(srcRoi.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
|
||||
nppSafeCall( func_(bufRoi.ptr<Npp8u>(), static_cast<int>(bufRoi.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
for(int i = 1; i < iters_; ++i)
|
||||
{
|
||||
dst.copyTo(bufRoi, _stream);
|
||||
|
||||
nppSafeCall( func8u_(bufRoi.ptr<Npp8u>(), static_cast<int>(bufRoi.step), dst.ptr<Npp8u>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
}
|
||||
}
|
||||
else if (type_ == CV_32FC1 || type_ == CV_32FC4)
|
||||
{
|
||||
nppSafeCall( func32f_(srcRoi.ptr<Npp32f>(), static_cast<int>(srcRoi.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
|
||||
for(int i = 1; i < iters_; ++i)
|
||||
{
|
||||
dst.copyTo(bufRoi, _stream);
|
||||
|
||||
nppSafeCall( func32f_(bufRoi.ptr<Npp32f>(), static_cast<int>(bufRoi.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step),
|
||||
oSizeROI, kernel_.ptr<Npp8u>(), oMaskSize, oAnchor) );
|
||||
}
|
||||
}
|
||||
|
||||
if (stream == 0)
|
||||
|
||||
@@ -45,6 +45,7 @@ The references are:
|
||||
#include "fast_score.hpp"
|
||||
#include "opencl_kernels_features2d.hpp"
|
||||
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
#if defined _MSC_VER
|
||||
# pragma warning( disable : 4127)
|
||||
#endif
|
||||
@@ -329,6 +330,67 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
static bool openvx_FAST(InputArray _img, std::vector<KeyPoint>& keypoints,
|
||||
int _threshold, bool nonmaxSuppression, int type)
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
// Nonmax suppression is done differently in OpenCV than in OpenVX
|
||||
// 9/16 is the only supported mode in OpenVX
|
||||
if(nonmaxSuppression || type != FastFeatureDetector::TYPE_9_16)
|
||||
return false;
|
||||
|
||||
Mat imgMat = _img.getMat();
|
||||
if(imgMat.empty() || imgMat.type() != CV_8UC1)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
Image img = Image::createFromHandle(context, Image::matTypeToFormat(imgMat.type()),
|
||||
Image::createAddressing(imgMat), (void*)imgMat.data);
|
||||
ivx::Scalar threshold = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, _threshold);
|
||||
vx_size capacity = imgMat.cols * imgMat.rows;
|
||||
Array corners = Array::create(context, VX_TYPE_KEYPOINT, capacity);
|
||||
|
||||
ivx::Scalar numCorners = ivx::Scalar::create<VX_TYPE_SIZE>(context, 0);
|
||||
|
||||
IVX_CHECK_STATUS(vxuFastCorners(context, img, threshold, (vx_bool)nonmaxSuppression, corners, numCorners));
|
||||
|
||||
size_t nPoints = numCorners.getValue<vx_size>();
|
||||
keypoints.clear(); keypoints.reserve(nPoints);
|
||||
std::vector<vx_keypoint_t> vxCorners;
|
||||
corners.copyTo(vxCorners);
|
||||
for(size_t i = 0; i < nPoints; i++)
|
||||
{
|
||||
vx_keypoint_t kp = vxCorners[i];
|
||||
//if nonmaxSuppression is false, kp.strength is undefined
|
||||
keypoints.push_back(KeyPoint((float)kp.x, (float)kp.y, 7.f, -1, kp.strength));
|
||||
}
|
||||
|
||||
#ifdef VX_VERSION_1_1
|
||||
//we should take user memory back before release
|
||||
//(it's not done automatically according to standard)
|
||||
img.swapHandle();
|
||||
#endif
|
||||
}
|
||||
catch (RuntimeError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
catch (WrapperError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -342,6 +404,9 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
|
||||
}
|
||||
#endif
|
||||
|
||||
CV_OVX_RUN(true,
|
||||
openvx_FAST(_img, keypoints, threshold, nonmax_suppression, type))
|
||||
|
||||
switch(type) {
|
||||
case FastFeatureDetector::TYPE_5_8:
|
||||
FAST_t<8>(_img, keypoints, threshold, nonmax_suppression);
|
||||
|
||||
@@ -970,7 +970,9 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
|
||||
//ROI handling
|
||||
const int HARRIS_BLOCK_SIZE = 9;
|
||||
int halfPatchSize = patchSize / 2;
|
||||
int border = std::max(edgeThreshold, std::max(halfPatchSize, HARRIS_BLOCK_SIZE/2))+1;
|
||||
// sqrt(2.0) is for handling patch rotation
|
||||
int descPatchSize = cvCeil(halfPatchSize*sqrt(2.0));
|
||||
int border = std::max(edgeThreshold, std::max(descPatchSize, HARRIS_BLOCK_SIZE/2))+1;
|
||||
|
||||
bool useOCL = ocl::useOpenCL() && OCL_FORCE_CHECK(_image.isUMat() || _descriptors.isUMat());
|
||||
|
||||
|
||||
@@ -90,3 +90,36 @@ TEST(Features2D_ORB, _1996)
|
||||
|
||||
ASSERT_EQ(0, roiViolations);
|
||||
}
|
||||
|
||||
TEST(Features2D_ORB, crash)
|
||||
{
|
||||
cv::Mat image = cv::Mat::zeros(cv::Size(1920, 1080), CV_8UC3);
|
||||
|
||||
int nfeatures = 8000;
|
||||
float orbScaleFactor = 1.2f;
|
||||
int nlevels = 18;
|
||||
int edgeThreshold = 4;
|
||||
int firstLevel = 0;
|
||||
int WTA_K = 2;
|
||||
int scoreType = cv::ORB::HARRIS_SCORE;
|
||||
int patchSize = 47;
|
||||
int fastThreshold = 20;
|
||||
|
||||
Ptr<ORB> orb = cv::ORB::create(nfeatures, orbScaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize, fastThreshold);
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
|
||||
cv::KeyPoint kp;
|
||||
kp.pt.x = 443;
|
||||
kp.pt.y = 5;
|
||||
kp.size = 47;
|
||||
kp.angle = 53.4580612f;
|
||||
kp.response = 0.0000470733867f;
|
||||
kp.octave = 0;
|
||||
kp.class_id = -1;
|
||||
|
||||
keypoints.push_back(kp);
|
||||
|
||||
ASSERT_NO_THROW(orb->compute(image, keypoints, descriptors));
|
||||
}
|
||||
|
||||
@@ -320,6 +320,15 @@ CV_EXPORTS_W void destroyAllWindows();
|
||||
|
||||
CV_EXPORTS_W int startWindowThread();
|
||||
|
||||
/** @brief Similar to #waitKey, but returns full key code.
|
||||
|
||||
@note
|
||||
|
||||
Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc
|
||||
|
||||
*/
|
||||
CV_EXPORTS_W int waitKeyEx(int delay = 0);
|
||||
|
||||
/** @brief Waits for a pressed key.
|
||||
|
||||
The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay
|
||||
|
||||
@@ -201,11 +201,26 @@ double cv::getWindowProperty(const String& winname, int prop_id)
|
||||
return cvGetWindowProperty(winname.c_str(), prop_id);
|
||||
}
|
||||
|
||||
int cv::waitKey(int delay)
|
||||
int cv::waitKeyEx(int delay)
|
||||
{
|
||||
return cvWaitKey(delay);
|
||||
}
|
||||
|
||||
int cv::waitKey(int delay)
|
||||
{
|
||||
int code = waitKeyEx(delay);
|
||||
#ifndef HAVE_WINRT
|
||||
static int use_legacy = -1;
|
||||
if (use_legacy < 0)
|
||||
{
|
||||
use_legacy = getenv("OPENCV_LEGACY_WAITKEY") != NULL ? 1 : 0;
|
||||
}
|
||||
if (use_legacy > 0)
|
||||
return code;
|
||||
#endif
|
||||
return code & 0xff;
|
||||
}
|
||||
|
||||
int cv::createTrackbar(const String& trackbarName, const String& winName,
|
||||
int* value, int count, TrackbarCallback callback,
|
||||
void* userdata)
|
||||
|
||||
@@ -90,7 +90,7 @@ file(GLOB imgcodecs_ext_hdrs
|
||||
|
||||
if(IOS)
|
||||
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
|
||||
list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework CoreImage" "-framework QuartzCore" "-framework AssetsLibrary")
|
||||
list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework QuartzCore" "-framework AssetsLibrary")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
|
||||
@@ -221,19 +221,14 @@ namespace cv
|
||||
|
||||
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
|
||||
return false; //Process isolated borders only
|
||||
vx_border_t border;
|
||||
vx_enum border;
|
||||
switch (borderType & ~BORDER_ISOLATED)
|
||||
{
|
||||
case BORDER_CONSTANT:
|
||||
border.mode = VX_BORDER_CONSTANT;
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
border.constant_value.U8 = (vx_uint8)(0);
|
||||
#else
|
||||
border.constant_value = (vx_uint32)(0);
|
||||
#endif
|
||||
border = VX_BORDER_CONSTANT;
|
||||
break;
|
||||
case BORDER_REPLICATE:
|
||||
border.mode = VX_BORDER_REPLICATE;
|
||||
border = VX_BORDER_REPLICATE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -259,8 +254,8 @@ namespace cv
|
||||
|
||||
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
|
||||
//since OpenVX standart says nothing about thread-safety for now
|
||||
vx_border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(border);
|
||||
ivx::border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(border, (vx_uint8)(0));
|
||||
if (dtype == CV_16SC1 && ksize == 3 && ((dx | dy) == 1) && (dx + dy) == 1)
|
||||
{
|
||||
if(dx)
|
||||
|
||||
@@ -1099,7 +1099,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
|
||||
edge[2];
|
||||
|
||||
int delta = 1 << shift >> 1;
|
||||
int i, y, imin = 0, left = 0, right = 1;
|
||||
int i, y, imin = 0;
|
||||
int edges = npts;
|
||||
int64 xmin, xmax, ymin, ymax;
|
||||
uchar* ptr = img.ptr();
|
||||
@@ -1181,44 +1181,46 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
|
||||
{
|
||||
if( y >= edge[i].ye )
|
||||
{
|
||||
int idx = edge[i].idx, di = edge[i].di;
|
||||
int64 xs = 0, xe;
|
||||
int idx0 = edge[i].idx, di = edge[i].di;
|
||||
int idx = idx0 + di;
|
||||
if (idx >= npts) idx -= npts;
|
||||
int ty = 0;
|
||||
|
||||
for(;;)
|
||||
for (; edges-- > 0; )
|
||||
{
|
||||
ty = (int)((v[idx].y + delta) >> shift);
|
||||
if( ty > y || edges == 0 )
|
||||
if (ty > y)
|
||||
{
|
||||
int64 xs = v[idx0].x;
|
||||
int64 xe = v[idx].x;
|
||||
if (shift != XY_SHIFT)
|
||||
{
|
||||
xs <<= XY_SHIFT - shift;
|
||||
xe <<= XY_SHIFT - shift;
|
||||
}
|
||||
|
||||
edge[i].ye = ty;
|
||||
edge[i].dx = ((xe - xs)*2 + (ty - y)) / (2 * (ty - y));
|
||||
edge[i].x = xs;
|
||||
edge[i].idx = idx;
|
||||
break;
|
||||
xs = v[idx].x;
|
||||
}
|
||||
idx0 = idx;
|
||||
idx += di;
|
||||
idx -= ((idx < npts) - 1) & npts; /* idx -= idx >= npts ? npts : 0 */
|
||||
edges--;
|
||||
if (idx >= npts) idx -= npts;
|
||||
}
|
||||
|
||||
xs <<= XY_SHIFT - shift;
|
||||
xe = v[idx].x << (XY_SHIFT - shift);
|
||||
|
||||
/* no more edges */
|
||||
if( y >= ty)
|
||||
return;
|
||||
|
||||
edge[i].ye = ty;
|
||||
edge[i].dx = ((xe - xs)*2 + (ty - y)) / (2 * (ty - y));
|
||||
edge[i].x = xs;
|
||||
edge[i].idx = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( edge[left].x > edge[right].x )
|
||||
if (y >= 0)
|
||||
{
|
||||
left ^= 1;
|
||||
right ^= 1;
|
||||
}
|
||||
int left = 0, right = 1;
|
||||
if (edge[0].x > edge[1].x)
|
||||
{
|
||||
left = 1, right = 0;
|
||||
}
|
||||
|
||||
if( y >= 0 )
|
||||
{
|
||||
int xx1 = (int)((edge[left].x + delta1) >> XY_SHIFT);
|
||||
int xx2 = (int)((edge[right].x + delta2) >> XY_SHIFT);
|
||||
|
||||
@@ -1231,9 +1233,13 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
|
||||
ICV_HLINE( ptr, xx1, xx2, color, pix_size );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO optimize scan for negative y
|
||||
}
|
||||
|
||||
edge[left].x += edge[left].dx;
|
||||
edge[right].x += edge[right].dx;
|
||||
edge[0].x += edge[0].dx;
|
||||
edge[1].x += edge[1].dx;
|
||||
ptr += img.step;
|
||||
}
|
||||
while( ++y <= (int)ymax );
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
@@ -262,6 +264,95 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
struct VxKeypointsComparator
|
||||
{
|
||||
bool operator () (const vx_keypoint_t& a, const vx_keypoint_t& b)
|
||||
{
|
||||
return a.strength > b.strength;
|
||||
}
|
||||
};
|
||||
|
||||
static bool openvx_harris(Mat image, OutputArray _corners,
|
||||
int _maxCorners, double _qualityLevel, double _minDistance,
|
||||
int _blockSize, double _harrisK)
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
if(image.type() != CV_8UC1) return false;
|
||||
|
||||
//OpenVX implementations don't have to provide other sizes
|
||||
if(!(_blockSize == 3 || _blockSize == 5 || _blockSize == 7)) return false;
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
|
||||
Image ovxImage = Image::createFromHandle(context, Image::matTypeToFormat(image.type()),
|
||||
Image::createAddressing(image), image.data);
|
||||
//The minimum threshold which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
|
||||
//set to 0, we'll filter it later by threshold
|
||||
ivx::Scalar strengthThresh = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, 0);
|
||||
|
||||
//The gradient window size to use on the input.
|
||||
vx_int32 gradientSize = 3;
|
||||
|
||||
//The block window size used to compute the harris corner score
|
||||
vx_int32 blockSize = _blockSize;
|
||||
|
||||
//The scalar sensitivity threshold k from the Harris-Stephens equation
|
||||
ivx::Scalar sensivity = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, _harrisK);
|
||||
|
||||
//The radial Euclidean distance for non-maximum suppression
|
||||
ivx::Scalar minDistance = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, _minDistance);
|
||||
|
||||
vx_size capacity = image.cols * image.rows;
|
||||
Array corners = Array::create(context, VX_TYPE_KEYPOINT, capacity);
|
||||
ivx::Scalar numCorners = ivx::Scalar::create<VX_TYPE_SIZE>(context, 0);
|
||||
|
||||
IVX_CHECK_STATUS(vxuHarrisCorners(context, ovxImage, strengthThresh, minDistance, sensivity,
|
||||
gradientSize, blockSize, corners, numCorners));
|
||||
|
||||
std::vector<vx_keypoint_t> vxKeypoints;
|
||||
corners.copyTo(vxKeypoints);
|
||||
|
||||
std::sort(vxKeypoints.begin(), vxKeypoints.end(), VxKeypointsComparator());
|
||||
|
||||
vx_float32 maxStrength = 0.0f;
|
||||
if(vxKeypoints.size() > 0)
|
||||
maxStrength = vxKeypoints[0].strength;
|
||||
size_t maxKeypoints = min((size_t)_maxCorners, vxKeypoints.size());
|
||||
std::vector<Point2f> keypoints;
|
||||
keypoints.reserve(maxKeypoints);
|
||||
for(size_t i = 0; i < maxKeypoints; i++)
|
||||
{
|
||||
vx_keypoint_t kp = vxKeypoints[i];
|
||||
if(kp.strength < maxStrength*_qualityLevel) break;
|
||||
keypoints.push_back(Point2f((float)kp.x, (float)kp.y));
|
||||
}
|
||||
|
||||
Mat(keypoints).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);
|
||||
|
||||
#ifdef VX_VERSION_1_1
|
||||
//we should take user memory back before release
|
||||
//(it's not done automatically according to standard)
|
||||
ovxImage.swapHandle();
|
||||
#endif
|
||||
}
|
||||
catch (RuntimeError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
catch (WrapperError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
@@ -285,6 +376,10 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||
return;
|
||||
}
|
||||
|
||||
// Disabled due to bad accuracy
|
||||
CV_OVX_RUN(false && useHarrisDetector && _mask.empty(),
|
||||
openvx_harris(image, _corners, maxCorners, qualityLevel, minDistance, blockSize, harrisK))
|
||||
|
||||
if( useHarrisDetector )
|
||||
cornerHarris( image, eig, blockSize, 3, harrisK );
|
||||
else
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
#include "hal_replacement.hpp"
|
||||
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
namespace cv
|
||||
@@ -4750,6 +4752,94 @@ static bool ocl_logPolar(InputArray _src, OutputArray _dst,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
static bool openvx_remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, const Scalar& borderValue)
|
||||
{
|
||||
vx_interpolation_type_e inter_type;
|
||||
switch (interpolation)
|
||||
{
|
||||
case INTER_LINEAR:
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
inter_type = VX_INTERPOLATION_BILINEAR;
|
||||
#else
|
||||
inter_type = VX_INTERPOLATION_TYPE_BILINEAR;
|
||||
#endif
|
||||
break;
|
||||
case INTER_NEAREST:
|
||||
/* NEAREST_NEIGHBOR mode disabled since OpenCV round half to even while OpenVX sample implementation round half up
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
inter_type = VX_INTERPOLATION_NEAREST_NEIGHBOR;
|
||||
#else
|
||||
inter_type = VX_INTERPOLATION_TYPE_NEAREST_NEIGHBOR;
|
||||
#endif
|
||||
if (!map1.empty())
|
||||
for (int y = 0; y < map1.rows; ++y)
|
||||
{
|
||||
float* line = map1.ptr<float>(y);
|
||||
for (int x = 0; x < map1.cols; ++x)
|
||||
line[x] = cvRound(line[x]);
|
||||
}
|
||||
if (!map2.empty())
|
||||
for (int y = 0; y < map2.rows; ++y)
|
||||
{
|
||||
float* line = map2.ptr<float>(y);
|
||||
for (int x = 0; x < map2.cols; ++x)
|
||||
line[x] = cvRound(line[x]);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case INTER_AREA://AREA interpolation mode is unsupported
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ivx::Context::create();
|
||||
|
||||
Mat a;
|
||||
if (dst.data != src.data)
|
||||
a = src;
|
||||
else
|
||||
src.copyTo(a);
|
||||
|
||||
ivx::Image
|
||||
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
|
||||
ivx::Image::createAddressing(a.cols, a.rows, 1, (vx_int32)(a.step)), a.data),
|
||||
ib = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
|
||||
ivx::Image::createAddressing(dst.cols, dst.rows, 1, (vx_int32)(dst.step)), dst.data);
|
||||
|
||||
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
|
||||
//since OpenVX standart says nothing about thread-safety for now
|
||||
ivx::border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(VX_BORDER_CONSTANT, (vx_uint8)(borderValue[0]));
|
||||
|
||||
ivx::Remap map = ivx::Remap::create(ctx, src.cols, src.rows, dst.cols, dst.rows);
|
||||
if (map1.empty()) map.setMappings(map2);
|
||||
else if (map2.empty()) map.setMappings(map1);
|
||||
else map.setMappings(map1, map2);
|
||||
ivx::IVX_CHECK_STATUS(vxuRemap(ctx, ia, map, inter_type, ib));
|
||||
#ifdef VX_VERSION_1_1
|
||||
ib.swapHandle();
|
||||
ia.swapHandle();
|
||||
#endif
|
||||
|
||||
ctx.setImmediateBorder(prevBorder);
|
||||
}
|
||||
catch (ivx::RuntimeError & e)
|
||||
{
|
||||
CV_Error(CV_StsInternal, e.what());
|
||||
return false;
|
||||
}
|
||||
catch (ivx::WrapperError & e)
|
||||
{
|
||||
CV_Error(CV_StsInternal, e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP && IPP_DISABLE_BLOCK
|
||||
|
||||
typedef IppStatus (CV_STDCALL * ippiRemap)(const void * pSrc, IppiSize srcSize, int srcStep, IppiRect srcRoi,
|
||||
@@ -4852,6 +4942,17 @@ void cv::remap( InputArray _src, OutputArray _dst,
|
||||
Mat src = _src.getMat(), map1 = _map1.getMat(), map2 = _map2.getMat();
|
||||
_dst.create( map1.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
|
||||
CV_OVX_RUN(
|
||||
src.type() == CV_8UC1 && dst.type() == CV_8UC1 &&
|
||||
(borderType& ~BORDER_ISOLATED) == BORDER_CONSTANT &&
|
||||
((map1.type() == CV_32FC2 && map2.empty() && map1.size == dst.size) ||
|
||||
(map1.type() == CV_32FC1 && map2.type() == CV_32FC1 && map1.size == dst.size && map2.size == dst.size) ||
|
||||
(map1.empty() && map2.type() == CV_32FC2 && map2.size == dst.size)) &&
|
||||
((borderType & BORDER_ISOLATED) != 0 || !src.isSubmatrix()),
|
||||
openvx_remap(src, dst, map1, map2, interpolation, borderValue));
|
||||
|
||||
CV_Assert( dst.cols < SHRT_MAX && dst.rows < SHRT_MAX && src.cols < SHRT_MAX && src.rows < SHRT_MAX );
|
||||
|
||||
if( dst.data == src.data )
|
||||
|
||||
@@ -167,6 +167,9 @@ static void divSpectrums( InputArray _srcA, InputArray _srcB, OutputArray _dst,
|
||||
_dst.create( srcA.rows, srcA.cols, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_Assert(dst.data != srcA.data); // non-inplace check
|
||||
CV_Assert(dst.data != srcB.data); // non-inplace check
|
||||
|
||||
bool is_1d = (flags & DFT_ROWS) || (rows == 1 || (cols == 1 &&
|
||||
srcA.isContinuous() && srcB.isContinuous() && dst.isContinuous()));
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -1254,6 +1256,82 @@ static bool ipp_pyrdown( InputArray _src, OutputArray _dst, const Size& _dsz, in
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
namespace cv
|
||||
{
|
||||
static bool openvx_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
Mat srcMat = _src.getMat();
|
||||
|
||||
CV_Assert(!srcMat.empty());
|
||||
|
||||
Size ssize = _src.size();
|
||||
Size acceptableSize = Size((ssize.width + 1) / 2, (ssize.height + 1) / 2);
|
||||
|
||||
// OpenVX limitations
|
||||
if((srcMat.type() != CV_8U) ||
|
||||
(borderType != BORDER_REPLICATE) ||
|
||||
(_dsz != acceptableSize && _dsz.area() != 0))
|
||||
return false;
|
||||
|
||||
// The only border mode which is supported by both cv::pyrDown() and OpenVX
|
||||
// and produces predictable results
|
||||
ivx::border_t borderMode;
|
||||
borderMode.mode = VX_BORDER_REPLICATE;
|
||||
|
||||
_dst.create( acceptableSize, srcMat.type() );
|
||||
Mat dstMat = _dst.getMat();
|
||||
|
||||
CV_Assert( ssize.width > 0 && ssize.height > 0 &&
|
||||
std::abs(acceptableSize.width*2 - ssize.width) <= 2 &&
|
||||
std::abs(acceptableSize.height*2 - ssize.height) <= 2 );
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
if(context.vendorID() == VX_ID_KHRONOS)
|
||||
{
|
||||
// This implementation performs floor-like rounding
|
||||
// (OpenCV uses floor(x+0.5)-like rounding)
|
||||
// and ignores border mode (and loses 1px size border)
|
||||
return false;
|
||||
}
|
||||
|
||||
Image srcImg = Image::createFromHandle(context, Image::matTypeToFormat(srcMat.type()),
|
||||
Image::createAddressing(srcMat), (void*)srcMat.data);
|
||||
Image dstImg = Image::createFromHandle(context, Image::matTypeToFormat(dstMat.type()),
|
||||
Image::createAddressing(dstMat), (void*)dstMat.data);
|
||||
|
||||
ivx::Scalar kernelSize = ivx::Scalar::create<VX_TYPE_INT32>(context, 5);
|
||||
Graph graph = Graph::create(context);
|
||||
ivx::Node halfNode = ivx::Node::create(graph, VX_KERNEL_HALFSCALE_GAUSSIAN, srcImg, dstImg, kernelSize);
|
||||
halfNode.setBorder(borderMode);
|
||||
graph.verify();
|
||||
graph.process();
|
||||
|
||||
#ifdef VX_VERSION_1_1
|
||||
//we should take user memory back before release
|
||||
//(it's not done automatically according to standard)
|
||||
srcImg.swapHandle(); dstImg.swapHandle();
|
||||
#endif
|
||||
}
|
||||
catch (RuntimeError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
catch (WrapperError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -1263,6 +1341,9 @@ void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borde
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
ocl_pyrDown(_src, _dst, _dsz, borderType))
|
||||
|
||||
CV_OVX_RUN(_src.dims() <= 2,
|
||||
openvx_pyrDown(_src, _dst, _dsz, borderType))
|
||||
|
||||
Mat src = _src.getMat();
|
||||
Size dsz = _dsz.area() == 0 ? Size((src.cols + 1)/2, (src.rows + 1)/2) : _dsz;
|
||||
_dst.create( dsz, src.type() );
|
||||
|
||||
@@ -1662,19 +1662,14 @@ namespace cv
|
||||
|
||||
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
|
||||
return false; //Process isolated borders only
|
||||
vx_border_t border;
|
||||
vx_enum border;
|
||||
switch (borderType & ~BORDER_ISOLATED)
|
||||
{
|
||||
case BORDER_CONSTANT:
|
||||
border.mode = VX_BORDER_CONSTANT;
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
border.constant_value.U8 = (vx_uint8)(0);
|
||||
#else
|
||||
border.constant_value = (vx_uint32)(0);
|
||||
#endif
|
||||
border = VX_BORDER_CONSTANT;
|
||||
break;
|
||||
case BORDER_REPLICATE:
|
||||
border.mode = VX_BORDER_REPLICATE;
|
||||
border = VX_BORDER_REPLICATE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -1701,7 +1696,7 @@ namespace cv
|
||||
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
|
||||
//since OpenVX standart says nothing about thread-safety for now
|
||||
ivx::border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(border);
|
||||
ctx.setImmediateBorder(border, (vx_uint8)(0));
|
||||
if (ddepth == CV_8U && ksize.width == 3 && ksize.height == 3 && normalize)
|
||||
{
|
||||
ivx::IVX_CHECK_STATUS(vxuBox3x3(ctx, ia, ib));
|
||||
@@ -2229,19 +2224,14 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
|
||||
|
||||
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
|
||||
return false; //Process isolated borders only
|
||||
vx_border_t border;
|
||||
vx_enum border;
|
||||
switch (borderType & ~BORDER_ISOLATED)
|
||||
{
|
||||
case BORDER_CONSTANT:
|
||||
border.mode = VX_BORDER_CONSTANT;
|
||||
#if VX_VERSION > VX_VERSION_1_0
|
||||
border.constant_value.U8 = (vx_uint8)(0);
|
||||
#else
|
||||
border.constant_value = (vx_uint32)(0);
|
||||
#endif
|
||||
border = VX_BORDER_CONSTANT;
|
||||
break;
|
||||
case BORDER_REPLICATE:
|
||||
border.mode = VX_BORDER_REPLICATE;
|
||||
border = VX_BORDER_REPLICATE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -2268,7 +2258,7 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
|
||||
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
|
||||
//since OpenVX standart says nothing about thread-safety for now
|
||||
ivx::border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(border);
|
||||
ctx.setImmediateBorder(border, (vx_uint8)(0));
|
||||
if (ksize.width == 3 && ksize.height == 3 && (sigma1 == 0.0 || (sigma1 - 0.8) < DBL_EPSILON) && (sigma2 == 0.0 || (sigma2 - 0.8) < DBL_EPSILON))
|
||||
{
|
||||
ivx::IVX_CHECK_STATUS(vxuGaussian3x3(ctx, ia, ib));
|
||||
@@ -3369,9 +3359,6 @@ namespace cv
|
||||
Mat src = _src.getMat();
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
vx_border_t border;
|
||||
border.mode = VX_BORDER_REPLICATE;
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = ivx::Context::create();
|
||||
@@ -3395,7 +3382,7 @@ namespace cv
|
||||
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
|
||||
//since OpenVX standart says nothing about thread-safety for now
|
||||
ivx::border_t prevBorder = ctx.immediateBorder();
|
||||
ctx.setImmediateBorder(border);
|
||||
ctx.setImmediateBorder(VX_BORDER_REPLICATE);
|
||||
#ifdef VX_VERSION_1_1
|
||||
if (ksize == 3)
|
||||
#endif
|
||||
|
||||
@@ -410,47 +410,6 @@ _exit_:
|
||||
|
||||
TEST(Imgproc_FindContours, accuracy) { CV_FindContourTest test; test.safe_run(); }
|
||||
|
||||
TEST(Core_Drawing, _914)
|
||||
{
|
||||
const int rows = 256;
|
||||
const int cols = 256;
|
||||
|
||||
Mat img(rows, cols, CV_8UC1, Scalar(255));
|
||||
|
||||
line(img, Point(0, 10), Point(255, 10), Scalar(0), 2, 4);
|
||||
line(img, Point(-5, 20), Point(260, 20), Scalar(0), 2, 4);
|
||||
line(img, Point(10, 0), Point(10, 255), Scalar(0), 2, 4);
|
||||
|
||||
double x0 = 0.0/pow(2.0, -2.0);
|
||||
double x1 = 255.0/pow(2.0, -2.0);
|
||||
double y = 30.5/pow(2.0, -2.0);
|
||||
|
||||
line(img, Point(int(x0), int(y)), Point(int(x1), int(y)), Scalar(0), 2, 4, 2);
|
||||
|
||||
int pixelsDrawn = rows*cols - countNonZero(img);
|
||||
ASSERT_EQ( (3*rows + cols)*3 - 3*9, pixelsDrawn);
|
||||
}
|
||||
|
||||
TEST(Core_Drawing, polylines_empty)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts; // empty
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 0);
|
||||
}
|
||||
|
||||
TEST(Core_Drawing, polylines)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts;
|
||||
pts.push_back(Point(0, 0));
|
||||
pts.push_back(Point(20, 0));
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 21);
|
||||
}
|
||||
|
||||
//rotate/flip a quadrant appropriately
|
||||
static void rot(int n, int *x, int *y, int rx, int ry)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
@@ -60,7 +62,7 @@ protected:
|
||||
void CV_DrawingTest::run( int )
|
||||
{
|
||||
Mat testImg, valImg;
|
||||
const string fname = "drawing/image.png";
|
||||
const string fname = "../highgui/drawing/image.png";
|
||||
string path = ts->get_data_path(), filename;
|
||||
filename = path + fname;
|
||||
|
||||
@@ -69,9 +71,15 @@ void CV_DrawingTest::run( int )
|
||||
valImg = imread( filename );
|
||||
if( valImg.empty() )
|
||||
{
|
||||
imwrite( filename, testImg );
|
||||
//ts->printf( ts->LOG, "test image can not be read");
|
||||
//ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
//imwrite( filename, testImg );
|
||||
ts->printf( ts->LOG, "test image can not be read");
|
||||
#ifdef HAVE_PNG
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
#else
|
||||
ts->printf( ts->LOG, "PNG image support is not available");
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -543,11 +551,9 @@ void CV_DrawingTest_Far::draw(Mat& img)
|
||||
img = img(Rect(32768, 0, 600, 400)).clone();
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
TEST(Imgcodecs_Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
TEST(Imgcodecs_Drawing, far_regression) { CV_DrawingTest_Far test; test.safe_run(); }
|
||||
#endif
|
||||
TEST(Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
TEST(Drawing, far_regression) { CV_DrawingTest_Far test; test.safe_run(); }
|
||||
|
||||
class CV_FillConvexPolyTest : public cvtest::BaseTest
|
||||
{
|
||||
@@ -581,7 +587,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Imgcodecs_Drawing, fillconvexpoly_clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
TEST(Drawing, fillconvexpoly_clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
|
||||
class CV_DrawingTest_UTF8 : public cvtest::BaseTest
|
||||
{
|
||||
@@ -655,8 +661,69 @@ protected:
|
||||
img->copyTo(sub);
|
||||
shift += img->size().height + 1;
|
||||
}
|
||||
imwrite("/tmp/all_fonts.png", result);
|
||||
//imwrite("/tmp/all_fonts.png", result);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Drawing, utf8_support) { CV_DrawingTest_UTF8 test; test.safe_run(); }
|
||||
TEST(Drawing, utf8_support) { CV_DrawingTest_UTF8 test; test.safe_run(); }
|
||||
|
||||
|
||||
TEST(Drawing, _914)
|
||||
{
|
||||
const int rows = 256;
|
||||
const int cols = 256;
|
||||
|
||||
Mat img(rows, cols, CV_8UC1, Scalar(255));
|
||||
|
||||
line(img, Point(0, 10), Point(255, 10), Scalar(0), 2, 4);
|
||||
line(img, Point(-5, 20), Point(260, 20), Scalar(0), 2, 4);
|
||||
line(img, Point(10, 0), Point(10, 255), Scalar(0), 2, 4);
|
||||
|
||||
double x0 = 0.0/pow(2.0, -2.0);
|
||||
double x1 = 255.0/pow(2.0, -2.0);
|
||||
double y = 30.5/pow(2.0, -2.0);
|
||||
|
||||
line(img, Point(int(x0), int(y)), Point(int(x1), int(y)), Scalar(0), 2, 4, 2);
|
||||
|
||||
int pixelsDrawn = rows*cols - countNonZero(img);
|
||||
ASSERT_EQ( (3*rows + cols)*3 - 3*9, pixelsDrawn);
|
||||
}
|
||||
|
||||
TEST(Drawing, polylines_empty)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts; // empty
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 0);
|
||||
}
|
||||
|
||||
TEST(Drawing, polylines)
|
||||
{
|
||||
Mat img(100, 100, CV_8UC1, Scalar(0));
|
||||
vector<Point> pts;
|
||||
pts.push_back(Point(0, 0));
|
||||
pts.push_back(Point(20, 0));
|
||||
polylines(img, pts, false, Scalar(255));
|
||||
int cnt = countNonZero(img);
|
||||
ASSERT_EQ(cnt, 21);
|
||||
}
|
||||
|
||||
|
||||
TEST(Drawing, putText_no_garbage)
|
||||
{
|
||||
Size sz(640, 480);
|
||||
Mat mat = Mat::zeros(sz, CV_8UC1);
|
||||
|
||||
mat = Scalar::all(0);
|
||||
putText(mat, "029", Point(10, 350), 0, 10, Scalar(128), 15);
|
||||
|
||||
EXPECT_EQ(0, cv::countNonZero(mat(Rect(0, 0, 10, sz.height))));
|
||||
EXPECT_EQ(0, cv::countNonZero(mat(Rect(sz.width-10, 0, 10, sz.height))));
|
||||
EXPECT_EQ(0, cv::countNonZero(mat(Rect(205, 0, 10, sz.height))));
|
||||
EXPECT_EQ(0, cv::countNonZero(mat(Rect(405, 0, 10, sz.height))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -57,6 +57,16 @@ public class OpenCVLoader
|
||||
*/
|
||||
public static final String OPENCV_VERSION_2_4_11 = "2.4.11";
|
||||
|
||||
/**
|
||||
* OpenCV Library version 2.4.12.
|
||||
*/
|
||||
public static final String OPENCV_VERSION_2_4_12 = "2.4.12";
|
||||
|
||||
/**
|
||||
* OpenCV Library version 2.4.13.
|
||||
*/
|
||||
public static final String OPENCV_VERSION_2_4_13 = "2.4.13";
|
||||
|
||||
/**
|
||||
* OpenCV Library version 3.0.0.
|
||||
*/
|
||||
@@ -67,6 +77,10 @@ public class OpenCVLoader
|
||||
*/
|
||||
public static final String OPENCV_VERSION_3_1_0 = "3.1.0";
|
||||
|
||||
/**
|
||||
* OpenCV Library version 3.2.0.
|
||||
*/
|
||||
public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
|
||||
|
||||
/**
|
||||
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
|
||||
|
||||
@@ -74,6 +74,7 @@ float StatModel::calcError( const Ptr<TrainData>& data, bool testerr, OutputArra
|
||||
int i, n = (int)sidx.total();
|
||||
bool isclassifier = isClassifier();
|
||||
Mat responses = data->getResponses();
|
||||
int responses_type = responses.type();
|
||||
|
||||
if( n == 0 )
|
||||
n = data->getNSamples();
|
||||
@@ -91,7 +92,7 @@ float StatModel::calcError( const Ptr<TrainData>& data, bool testerr, OutputArra
|
||||
int si = sidx_ptr ? sidx_ptr[i] : i;
|
||||
Mat sample = layout == ROW_SAMPLE ? samples.row(si) : samples.col(si);
|
||||
float val = predict(sample);
|
||||
float val0 = responses.at<float>(si);
|
||||
float val0 = (responses_type == CV_32S) ? (float)responses.at<int>(si) : responses.at<float>(si);
|
||||
|
||||
if( isclassifier )
|
||||
err += fabs(val - val0) > FLT_EPSILON;
|
||||
|
||||
@@ -382,6 +382,8 @@ public:
|
||||
|
||||
bool train( const Ptr<TrainData>& trainData, int flags )
|
||||
{
|
||||
if (impl.getCVFolds() != 0)
|
||||
CV_Error(Error::StsBadArg, "Cross validation for RTrees is not implemented");
|
||||
return impl.train(trainData, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -1087,7 +1087,7 @@ void HOGDescriptorTester::detect(const Mat& img,
|
||||
}
|
||||
|
||||
const double eps = FLT_EPSILON * 100;
|
||||
double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2);
|
||||
double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2 + NORM_RELATIVE);
|
||||
if (diff_norm > eps)
|
||||
{
|
||||
ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n"
|
||||
@@ -1167,7 +1167,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector<float>& descriptors,
|
||||
std::vector<float> actual_descriptors;
|
||||
actual_hog->compute(img, actual_descriptors, winStride, padding, locations);
|
||||
|
||||
double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2);
|
||||
double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2 + NORM_RELATIVE);
|
||||
const double eps = FLT_EPSILON * 100;
|
||||
if (diff_norm > eps)
|
||||
{
|
||||
@@ -1316,7 +1316,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
|
||||
const double eps = FLT_EPSILON * 100;
|
||||
for (i = 0; i < 2; ++i)
|
||||
{
|
||||
double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2);
|
||||
double diff_norm = cvtest::norm(actual_mats[i], reference_mats[i], NORM_L2 + NORM_RELATIVE);
|
||||
if (diff_norm > eps)
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"
|
||||
|
||||
@@ -814,6 +814,7 @@ void cv::inpaint( InputArray _src, InputArray _mask, OutputArray _dst,
|
||||
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
_dst.create( src.size(), src.type() );
|
||||
CvMat c_src = src, c_mask = mask, c_dst = _dst.getMat();
|
||||
Mat dst = _dst.getMat();
|
||||
CvMat c_src = src, c_mask = mask, c_dst = dst;
|
||||
cvInpaint( &c_src, &c_mask, &c_dst, inpaintRange, flags );
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ if __name__ == '__main__':
|
||||
img = render.getNextFrame()
|
||||
cv2.imshow('img', img)
|
||||
|
||||
ch = 0xFF & cv2.waitKey(3)
|
||||
if ch == 27:
|
||||
ch = cv2.waitKey(3)
|
||||
if ch == 27:
|
||||
break
|
||||
cv2.destroyAllWindows()
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
@@ -63,6 +63,7 @@ static bool log_power_checkpoints;
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <pthread.h>
|
||||
#include <cerrno>
|
||||
static void setCurrentThreadAffinityMask(int mask)
|
||||
{
|
||||
pid_t pid=gettid();
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#include "opencl_kernels_video.hpp"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
|
||||
#include "opencv2/core/openvx/ovx_defs.hpp"
|
||||
|
||||
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
|
||||
|
||||
namespace
|
||||
@@ -1055,8 +1057,156 @@ namespace
|
||||
return sparse(_prevImg.getUMat(), _nextImg.getUMat(), _prevPts.getUMat(), umatNextPts, umatStatus, umatErr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENVX
|
||||
bool openvx_pyrlk(InputArray _prevImg, InputArray _nextImg, InputArray _prevPts, InputOutputArray _nextPts,
|
||||
OutputArray _status, OutputArray _err)
|
||||
{
|
||||
using namespace ivx;
|
||||
|
||||
// Pyramids as inputs are not acceptable because there's no (direct or simple) way
|
||||
// to build vx_pyramid on user data
|
||||
if(_prevImg.kind() != _InputArray::MAT || _nextImg.kind() != _InputArray::MAT)
|
||||
return false;
|
||||
|
||||
Mat prevImgMat = _prevImg.getMat(), nextImgMat = _nextImg.getMat();
|
||||
|
||||
if(prevImgMat.type() != CV_8UC1 || nextImgMat.type() != CV_8UC1)
|
||||
return false;
|
||||
|
||||
CV_Assert(prevImgMat.size() == nextImgMat.size());
|
||||
Mat prevPtsMat = _prevPts.getMat();
|
||||
int checkPrev = prevPtsMat.checkVector(2, CV_32F, false);
|
||||
CV_Assert( checkPrev >= 0 );
|
||||
size_t npoints = checkPrev;
|
||||
|
||||
if( !(flags & OPTFLOW_USE_INITIAL_FLOW) )
|
||||
_nextPts.create(prevPtsMat.size(), prevPtsMat.type(), -1, true);
|
||||
Mat nextPtsMat = _nextPts.getMat();
|
||||
CV_Assert( nextPtsMat.checkVector(2, CV_32F, false) == (int)npoints );
|
||||
|
||||
_status.create((int)npoints, 1, CV_8U, -1, true);
|
||||
Mat statusMat = _status.getMat();
|
||||
uchar* status = statusMat.ptr();
|
||||
for(size_t i = 0; i < npoints; i++ )
|
||||
status[i] = true;
|
||||
|
||||
// OpenVX doesn't return detection errors
|
||||
if( _err.needed() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Context context = Context::create();
|
||||
|
||||
if(context.vendorID() == VX_ID_KHRONOS)
|
||||
{
|
||||
// PyrLK in OVX 1.0.1 performs vxCommitImagePatch incorrecty and crashes
|
||||
if(VX_VERSION == VX_VERSION_1_0)
|
||||
return false;
|
||||
// Implementation ignores border mode
|
||||
// So check that minimal size of image in pyramid is big enough
|
||||
int width = prevImgMat.cols, height = prevImgMat.rows;
|
||||
for(int i = 0; i < maxLevel+1; i++)
|
||||
{
|
||||
if(width < winSize.width + 1 || height < winSize.height + 1)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
width /= 2; height /= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image prevImg = Image::createFromHandle(context, Image::matTypeToFormat(prevImgMat.type()),
|
||||
Image::createAddressing(prevImgMat), (void*)prevImgMat.data);
|
||||
Image nextImg = Image::createFromHandle(context, Image::matTypeToFormat(nextImgMat.type()),
|
||||
Image::createAddressing(nextImgMat), (void*)nextImgMat.data);
|
||||
|
||||
Graph graph = Graph::create(context);
|
||||
|
||||
Pyramid prevPyr = Pyramid::createVirtual(graph, (vx_size)maxLevel+1, VX_SCALE_PYRAMID_HALF,
|
||||
prevImg.width(), prevImg.height(), prevImg.format());
|
||||
Pyramid nextPyr = Pyramid::createVirtual(graph, (vx_size)maxLevel+1, VX_SCALE_PYRAMID_HALF,
|
||||
nextImg.width(), nextImg.height(), nextImg.format());
|
||||
|
||||
ivx::Node::create(graph, VX_KERNEL_GAUSSIAN_PYRAMID, prevImg, prevPyr);
|
||||
ivx::Node::create(graph, VX_KERNEL_GAUSSIAN_PYRAMID, nextImg, nextPyr);
|
||||
|
||||
Array prevPts = Array::create(context, VX_TYPE_KEYPOINT, npoints);
|
||||
Array estimatedPts = Array::create(context, VX_TYPE_KEYPOINT, npoints);
|
||||
Array nextPts = Array::create(context, VX_TYPE_KEYPOINT, npoints);
|
||||
|
||||
std::vector<vx_keypoint_t> vxPrevPts(npoints), vxEstPts(npoints), vxNextPts(npoints);
|
||||
for(size_t i = 0; i < npoints; i++)
|
||||
{
|
||||
vx_keypoint_t& prevPt = vxPrevPts[i]; vx_keypoint_t& estPt = vxEstPts[i];
|
||||
prevPt.x = prevPtsMat.at<Point2f>(i).x; prevPt.y = prevPtsMat.at<Point2f>(i).y;
|
||||
estPt.x = nextPtsMat.at<Point2f>(i).x; estPt.y = nextPtsMat.at<Point2f>(i).y;
|
||||
prevPt.tracking_status = estPt.tracking_status = vx_true_e;
|
||||
}
|
||||
prevPts.addItems(vxPrevPts); estimatedPts.addItems(vxEstPts);
|
||||
|
||||
if( (criteria.type & TermCriteria::COUNT) == 0 )
|
||||
criteria.maxCount = 30;
|
||||
else
|
||||
criteria.maxCount = std::min(std::max(criteria.maxCount, 0), 100);
|
||||
if( (criteria.type & TermCriteria::EPS) == 0 )
|
||||
criteria.epsilon = 0.01;
|
||||
else
|
||||
criteria.epsilon = std::min(std::max(criteria.epsilon, 0.), 10.);
|
||||
criteria.epsilon *= criteria.epsilon;
|
||||
|
||||
vx_enum termEnum = (criteria.type == TermCriteria::COUNT) ? VX_TERM_CRITERIA_ITERATIONS :
|
||||
(criteria.type == TermCriteria::EPS) ? VX_TERM_CRITERIA_EPSILON :
|
||||
VX_TERM_CRITERIA_BOTH;
|
||||
|
||||
//minEigThreshold is fixed to 0.0001f
|
||||
ivx::Scalar termination = ivx::Scalar::create<VX_TYPE_ENUM>(context, termEnum);
|
||||
ivx::Scalar epsilon = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, criteria.epsilon);
|
||||
ivx::Scalar numIterations = ivx::Scalar::create<VX_TYPE_UINT32>(context, criteria.maxCount);
|
||||
ivx::Scalar useInitial = ivx::Scalar::create<VX_TYPE_BOOL>(context, (vx_bool)(flags & OPTFLOW_USE_INITIAL_FLOW));
|
||||
//assume winSize is square
|
||||
ivx::Scalar windowSize = ivx::Scalar::create<VX_TYPE_SIZE>(context, (vx_size)winSize.width);
|
||||
|
||||
ivx::Node::create(graph, VX_KERNEL_OPTICAL_FLOW_PYR_LK, prevPyr, nextPyr, prevPts, estimatedPts,
|
||||
nextPts, termination, epsilon, numIterations, useInitial, windowSize);
|
||||
|
||||
graph.verify();
|
||||
graph.process();
|
||||
|
||||
nextPts.copyTo(vxNextPts);
|
||||
for(size_t i = 0; i < npoints; i++)
|
||||
{
|
||||
vx_keypoint_t kp = vxNextPts[i];
|
||||
nextPtsMat.at<Point2f>(i) = Point2f(kp.x, kp.y);
|
||||
statusMat.at<uchar>(i) = (bool)kp.tracking_status;
|
||||
}
|
||||
|
||||
#ifdef VX_VERSION_1_1
|
||||
//we should take user memory back before release
|
||||
//(it's not done automatically according to standard)
|
||||
prevImg.swapHandle(); nextImg.swapHandle();
|
||||
#endif
|
||||
}
|
||||
catch (RuntimeError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
catch (WrapperError & e)
|
||||
{
|
||||
VX_DbgThrow(e.what());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
void SparsePyrLKOpticalFlowImpl::calc( InputArray _prevImg, InputArray _nextImg,
|
||||
InputArray _prevPts, InputOutputArray _nextPts,
|
||||
OutputArray _status, OutputArray _err)
|
||||
@@ -1068,6 +1218,10 @@ void SparsePyrLKOpticalFlowImpl::calc( InputArray _prevImg, InputArray _nextImg,
|
||||
ocl::Image2D::isFormatSupported(CV_32F, 1, false),
|
||||
ocl_calcOpticalFlowPyrLK(_prevImg, _nextImg, _prevPts, _nextPts, _status, _err))
|
||||
|
||||
// Disabled due to bad accuracy
|
||||
CV_OVX_RUN(false,
|
||||
openvx_pyrlk(_prevImg, _nextImg, _prevPts, _nextPts, _status, _err))
|
||||
|
||||
Mat prevPtsMat = _prevPts.getMat();
|
||||
const int derivDepth = DataType<cv::detail::deriv_type>::depth;
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ if(HAVE_AVFOUNDATION)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
|
||||
else()
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation_mac.mm)
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework Cocoa" "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore")
|
||||
list(APPEND VIDEOIO_LIBRARIES "-framework Cocoa" "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class Builder:
|
||||
# Add extra data
|
||||
apkxmldest = check_dir(os.path.join(apkdest, "res", "xml"), create=True)
|
||||
apklibdest = check_dir(os.path.join(apkdest, "libs", abi.name), create=True)
|
||||
for ver, d in self.extra_packs + [("3.1.0", os.path.join(self.libdest, "lib"))]:
|
||||
for ver, d in self.extra_packs + [("3.2.0", os.path.join(self.libdest, "lib"))]:
|
||||
r = ET.Element("library", attrib={"version": ver})
|
||||
log.info("Adding libraries from %s", d)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv.engine"
|
||||
android:versionCode="310@ANDROID_PLATFORM_ID@"
|
||||
android:versionName="3.10">
|
||||
android:versionCode="320@ANDROID_PLATFORM_ID@"
|
||||
android:versionName="3.20">
|
||||
|
||||
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" android:targetSdkVersion="22"/>
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
|
||||
@@ -134,7 +134,7 @@ public class OpenCVEngineService extends Service {
|
||||
|
||||
@Override
|
||||
public int getEngineVersion() throws RemoteException {
|
||||
int version = 3100;
|
||||
int version = 3200;
|
||||
try {
|
||||
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
@@ -10,14 +10,16 @@ from Google Play.
|
||||
If Google Play is not available (i.e. on emulator, developer board, etc), you can install it
|
||||
manually using adb tool:
|
||||
|
||||
adb install <path-to-OpenCV-sdk>/apk/OpenCV_3.1.0_Manager_3.10_<platform>.apk
|
||||
adb install <path-to-OpenCV-sdk>/apk/OpenCV_<version>_Manager_<app_version>_<platform>.apk
|
||||
|
||||
Use the list below to determine proper OpenCV Manager package for your device:
|
||||
Example: OpenCV_3.2.0-dev_Manager_3.20_armeabi-v7a.apk
|
||||
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_armeabi.apk - armeabi (ARMv5, ARMv6)
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_armeabi-v7a.apk - armeabi-v7a (ARMv7-A + NEON)
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_arm64-v8a.apk - arm64-v8a (ARM64-v8a)
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_mips.apk - mips (MIPS)
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_mips64.apk - mips64 (MIPS64)
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_x86.apk - x86
|
||||
- OpenCV_3.1.0-dev_Manager_3.10_x86_64.apk - x86_64
|
||||
Use the list of platforms below to determine proper OpenCV Manager package for your device:
|
||||
|
||||
- armeabi (ARMv5, ARMv6)
|
||||
- armeabi-v7a (ARMv7-A + NEON)
|
||||
- arm64-v8a
|
||||
- mips
|
||||
- mips64
|
||||
- x86
|
||||
- x86_64
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>opencv.org</groupId>
|
||||
<artifactId>opencv</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.0</version>
|
||||
<name>OpenCV</name>
|
||||
<licenses>
|
||||
<license>
|
||||
|
||||
@@ -351,7 +351,7 @@ int main( int argc, char** argv )
|
||||
for( k = 0; k < small_canvas.rows; k += 16 )
|
||||
line(small_canvas, Point(0, k), Point(small_canvas.cols, k), Scalar(0,255,0), 1);
|
||||
imshow("rectified", small_canvas);
|
||||
int c = waitKey(0);
|
||||
char c = (char)waitKey(0);
|
||||
if( c == 27 || c == 'q' || c == 'Q' )
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -493,9 +493,9 @@ int main( int argc, char** argv )
|
||||
}
|
||||
|
||||
imshow("Image View", view);
|
||||
int key = 0xff & waitKey(capture.isOpened() ? 50 : 500);
|
||||
char key = (char)waitKey(capture.isOpened() ? 50 : 500);
|
||||
|
||||
if( (key & 255) == 27 )
|
||||
if( key == 27 )
|
||||
break;
|
||||
|
||||
if( key == 'u' && mode == CALIBRATED )
|
||||
@@ -536,8 +536,8 @@ int main( int argc, char** argv )
|
||||
//undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
|
||||
remap(view, rview, map1, map2, INTER_LINEAR);
|
||||
imshow("Image View", rview);
|
||||
int c = 0xff & waitKey();
|
||||
if( (c & 255) == 27 || c == 'q' || c == 'Q' )
|
||||
char c = (char)waitKey();
|
||||
if( c == 27 || c == 'q' || c == 'Q' )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ int main()
|
||||
|
||||
for(;;)
|
||||
{
|
||||
char key = (char) waitKey(0);
|
||||
char key = (char)waitKey(0);
|
||||
|
||||
if(key == 'd' && flag3 == 0)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@ int main( int argc, char** argv )
|
||||
|
||||
for(;;)
|
||||
{
|
||||
char key;
|
||||
int i, count = (unsigned)rng%100 + 1;
|
||||
|
||||
vector<Point> points;
|
||||
@@ -58,7 +57,7 @@ int main( int argc, char** argv )
|
||||
|
||||
imshow("hull", img);
|
||||
|
||||
key = (char)waitKey();
|
||||
char key = (char)waitKey();
|
||||
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ static void DrawOpenGLMSER(Mat img, Mat result)
|
||||
for (;;)
|
||||
{
|
||||
updateWindow("OpenGL");
|
||||
int key = waitKey(40);
|
||||
if ((key & 0xff) == 27)
|
||||
char key = (char)waitKey(40);
|
||||
if (key == 27)
|
||||
break;
|
||||
if (key == 0x20)
|
||||
rotateEnable = !rotateEnable;
|
||||
|
||||
@@ -133,7 +133,7 @@ int main( int argc, const char** argv )
|
||||
// Call to update the view
|
||||
onTrackbar(0, 0);
|
||||
|
||||
int c = waitKey(0) & 255;
|
||||
char c = (char)waitKey(0);
|
||||
|
||||
if( c == 27 )
|
||||
break;
|
||||
|
||||
@@ -72,9 +72,9 @@ int main( int argc, const char** argv )
|
||||
}
|
||||
if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) )
|
||||
{
|
||||
int c = inputName.empty() ? 0 : inputName[0] - '0';
|
||||
if(!capture.open(c))
|
||||
cout << "Capture from camera #" << c << " didn't work" << endl;
|
||||
int camera = inputName.empty() ? 0 : inputName[0] - '0';
|
||||
if(!capture.open(camera))
|
||||
cout << "Capture from camera #" << camera << " didn't work" << endl;
|
||||
}
|
||||
else if( inputName.size() )
|
||||
{
|
||||
@@ -104,7 +104,7 @@ int main( int argc, const char** argv )
|
||||
Mat frame1 = frame.clone();
|
||||
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
||||
|
||||
int c = waitKey(10);
|
||||
char c = (char)waitKey(10);
|
||||
if( c == 27 || c == 'q' || c == 'Q' )
|
||||
break;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int main( int argc, const char** argv )
|
||||
char buf[1000+1];
|
||||
while( fgets( buf, 1000, f ) )
|
||||
{
|
||||
int len = (int)strlen(buf), c;
|
||||
int len = (int)strlen(buf);
|
||||
while( len > 0 && isspace(buf[len-1]) )
|
||||
len--;
|
||||
buf[len] = '\0';
|
||||
@@ -136,7 +136,7 @@ int main( int argc, const char** argv )
|
||||
if( !image.empty() )
|
||||
{
|
||||
detectAndDraw( image, cascade, nestedCascade, scale, tryflip );
|
||||
c = waitKey(0);
|
||||
char c = (char)waitKey(0);
|
||||
if( c == 27 || c == 'q' || c == 'Q' )
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -105,13 +105,13 @@ int main( int argc, char** argv )
|
||||
{
|
||||
imshow("image", isColor ? image : gray);
|
||||
|
||||
int c = waitKey(0);
|
||||
if( (c & 255) == 27 )
|
||||
char c = (char)waitKey(0);
|
||||
if( c == 27 )
|
||||
{
|
||||
cout << "Exiting ...\n";
|
||||
break;
|
||||
}
|
||||
switch( (char)c )
|
||||
switch( c )
|
||||
{
|
||||
case 'c':
|
||||
if( isColor )
|
||||
|
||||
@@ -306,8 +306,8 @@ int main( int argc, char** argv )
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int c = waitKey(0);
|
||||
switch( (char) c )
|
||||
char c = (char)waitKey(0);
|
||||
switch( c )
|
||||
{
|
||||
case '\x1b':
|
||||
cout << "Exiting ..." << endl;
|
||||
|
||||
@@ -83,10 +83,10 @@ int main( int argc, char** argv )
|
||||
convertScaleAbs(laplace, result, (sigma+1)*0.25);
|
||||
imshow("Laplacian", result);
|
||||
|
||||
int c = waitKey(30);
|
||||
char c = (char)waitKey(30);
|
||||
if( c == ' ' )
|
||||
smoothType = smoothType == GAUSSIAN ? BLUR : smoothType == BLUR ? MEDIAN : GAUSSIAN;
|
||||
if( c == 'q' || c == 'Q' || (c & 255) == 27 )
|
||||
if( c == 'q' || c == 'Q' || c == 27 )
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,21 +82,19 @@ int main( int argc, char** argv )
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int c;
|
||||
|
||||
OpenClose(open_close_pos, 0);
|
||||
ErodeDilate(erode_dilate_pos, 0);
|
||||
c = waitKey(0);
|
||||
char c = (char)waitKey(0);
|
||||
|
||||
if( (char)c == 27 )
|
||||
if( c == 27 )
|
||||
break;
|
||||
if( (char)c == 'e' )
|
||||
if( c == 'e' )
|
||||
element_shape = MORPH_ELLIPSE;
|
||||
else if( (char)c == 'r' )
|
||||
else if( c == 'r' )
|
||||
element_shape = MORPH_RECT;
|
||||
else if( (char)c == 'c' )
|
||||
else if( c == 'c' )
|
||||
element_shape = MORPH_CROSS;
|
||||
else if( (char)c == ' ' )
|
||||
else if( c == ' ' )
|
||||
element_shape = (element_shape + 1) % 3;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -183,9 +183,9 @@ int main(int argc, char** argv)
|
||||
// display until user presses q
|
||||
imshow(winName, reconstruction);
|
||||
|
||||
int key = 0;
|
||||
char key = 0;
|
||||
while(key != 'q')
|
||||
key = waitKey();
|
||||
key = (char)waitKey();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ int main(int, char* [])
|
||||
{
|
||||
VideoCapture video(0);
|
||||
Mat frame, curr, prev, curr64f, prev64f, hann;
|
||||
int key = 0;
|
||||
char key;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -37,10 +37,10 @@ int main(int, char* [])
|
||||
}
|
||||
|
||||
imshow("phase shift", frame);
|
||||
key = waitKey(2);
|
||||
key = (char)waitKey(2);
|
||||
|
||||
prev = curr.clone();
|
||||
} while((char)key != 27); // Esc to exit...
|
||||
} while(key != 27); // Esc to exit...
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ int main()
|
||||
|
||||
for(;;)
|
||||
{
|
||||
uchar key = (uchar)waitKey();
|
||||
char key = (char)waitKey();
|
||||
|
||||
if( key == 27 ) break;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char** argv)
|
||||
refineSegments(tmp_frame, bgmask, out_frame);
|
||||
imshow("video", tmp_frame);
|
||||
imshow("segmented", out_frame);
|
||||
int keycode = waitKey(30);
|
||||
char keycode = (char)waitKey(30);
|
||||
if( keycode == 27 )
|
||||
break;
|
||||
if( keycode == ' ' )
|
||||
|
||||
@@ -285,8 +285,8 @@ static int select3DBox(const string& windowname, const string& selWinName, const
|
||||
imshow(windowname, shownFrame);
|
||||
imshow(selWinName, selectedObjFrame);
|
||||
|
||||
int c = waitKey(30);
|
||||
if( (c & 255) == 27 )
|
||||
char c = (char)waitKey(30);
|
||||
if( c == 27 )
|
||||
{
|
||||
nobjpt = 0;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ int main(int argc, char** argv)
|
||||
|
||||
imshow("View", shownFrame);
|
||||
imshow("Selected Object", selectedObjFrame);
|
||||
int c = waitKey(imageList.empty() && !box.empty() ? 30 : 300);
|
||||
char c = (char)waitKey(imageList.empty() && !box.empty() ? 30 : 300);
|
||||
if( c == 'q' || c == 'Q' )
|
||||
break;
|
||||
if( c == '\r' || c == '\n' )
|
||||
|
||||
@@ -99,7 +99,7 @@ int main( int argc, const char** argv )
|
||||
Mat frame1 = frame.clone();
|
||||
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
||||
|
||||
int c = waitKey(10);
|
||||
char c = (char)waitKey(10);
|
||||
if( c == 27 || c == 'q' || c == 'Q' )
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -167,8 +167,8 @@ int main(int argc, char** argv)
|
||||
findSquares(image, squares);
|
||||
drawSquares(image, squares);
|
||||
|
||||
int c = waitKey();
|
||||
if( (char)c == 27 )
|
||||
char c = (char)waitKey();
|
||||
if( c == 27 )
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,26 +45,22 @@ int main( void )
|
||||
//![infinite_loop]
|
||||
for(;;)
|
||||
{
|
||||
int c;
|
||||
c = waitKey(0);
|
||||
char c = (char)waitKey(0);
|
||||
|
||||
if( (char)c == 27 )
|
||||
if( c == 27 )
|
||||
{ break; }
|
||||
if( (char)c == 'u' )
|
||||
{
|
||||
//![pyrup]
|
||||
pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
||||
//![pyrup]
|
||||
//![pyrup]
|
||||
if( c == 'u' )
|
||||
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
||||
printf( "** Zoom In: Image x 2 \n" );
|
||||
}
|
||||
else if( (char)c == 'd' )
|
||||
{
|
||||
//![pyrdown]
|
||||
pyrDown( tmp, dst, Size( tmp.cols/2, tmp.rows/2 ) );
|
||||
//![pyrdown]
|
||||
//![pyrup]
|
||||
//![pyrdown]
|
||||
else if( c == 'd' )
|
||||
{ pyrDown( tmp, dst, Size( tmp.cols/2, tmp.rows/2 ) );
|
||||
printf( "** Zoom Out: Image / 2 \n" );
|
||||
}
|
||||
|
||||
//![pyrdown]
|
||||
imshow( window_name, dst );
|
||||
|
||||
//![update_tmp]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user