init - 初始化项目
This commit is contained in:
7
3rdparty/openvx/CMakeLists.txt
vendored
Normal file
7
3rdparty/openvx/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
if(NOT HAVE_OPENVX)
|
||||
message(STATUS "OpenVX is not available, disabling openvx-related HAL and stuff")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPENCV_3P_OPENVX_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(hal)
|
||||
97
3rdparty/openvx/README.md
vendored
Normal file
97
3rdparty/openvx/README.md
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# C++ wrappers for OpenVX-1.x C API
|
||||
|
||||
## Core ideas:
|
||||
|
||||
* lightweight - minimal overhead vs standard C API
|
||||
* automatic references counting
|
||||
* exceptions instead of return codes
|
||||
* object-oriented design
|
||||
* (NYI) helpers for user-defined kernels & nodes
|
||||
* C++ 11 friendly
|
||||
|
||||
## Quick start sample
|
||||
|
||||
The following short sample gives basic knowledges on the wrappers usage:
|
||||
|
||||
```cpp
|
||||
#include "ivx.hpp"
|
||||
#include "ivx_lib_debug.hpp" // ivx::debug::*
|
||||
|
||||
int main()
|
||||
{
|
||||
vx_uint32 width = 640, height = 480;
|
||||
try
|
||||
{
|
||||
ivx::Context context = ivx::Context::create();
|
||||
ivx::Graph graph = ivx::Graph::create(context);
|
||||
ivx::Image
|
||||
gray = ivx::Image::create(context, width, height, VX_DF_IMAGE_U8),
|
||||
gb = ivx::Image::createVirtual(graph),
|
||||
res = ivx::Image::create(context, width, height, VX_DF_IMAGE_U8);
|
||||
|
||||
context.loadKernels("openvx-debug"); // ivx::debug::*
|
||||
|
||||
ivx::debug::fReadImage(context, inputPath, gray);
|
||||
|
||||
ivx::Node::create(graph, VX_KERNEL_GAUSSIAN_3x3, gray, gb);
|
||||
ivx::Node::create(
|
||||
graph,
|
||||
VX_KERNEL_THRESHOLD,
|
||||
gb,
|
||||
ivx::Threshold::createBinary(context, VX_TYPE_UINT8, 50),
|
||||
res
|
||||
);
|
||||
|
||||
graph.verify();
|
||||
graph.process();
|
||||
|
||||
ivx::debug::fWriteImage(context, res, "ovx-res-cpp.pgm");
|
||||
}
|
||||
catch (const ivx::RuntimeError& e)
|
||||
{
|
||||
printf("ErrorRuntime: code = %d(%x), message = %s\n", e.status(), e.status(), e.what());
|
||||
return e.status();
|
||||
}
|
||||
catch (const ivx::WrapperError& e)
|
||||
{
|
||||
printf("ErrorWrapper: message = %s\n", e.what());
|
||||
return -1;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
printf("runtime_error: message = %s\n", e.what());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
```
|
||||
## C++ API overview
|
||||
|
||||
The wrappers have **header-only** implementation that simplifies their integration to projects.
|
||||
All the API is inside `ivx` namespace (E.g. `class ivx::Graph`).
|
||||
|
||||
While the C++ API is pretty much the same for underlying OpenVX version **1.0** and **1.1**, there are alternative code branches for some features implementation that are selected at **compile time** via `#ifdef` preprocessor directives.
|
||||
E.g. external ref-counting is implemented for 1.0 version and native OpenVX one is used (via `vxRetainReference()` and `vxReleaseXYZ()`) for version 1.1.
|
||||
|
||||
Also there are some **C++ 11** features are used (e.g. rvalue ref-s) when their availability is detected at ***compile time***.
|
||||
|
||||
C++ exceptions are used for errors indication instead of return codes. There are two types of exceptions are defined: `RuntimeError` is thrown when OpenVX C call returned unsuccessful result and `WrapperError` is thrown when a problem is occured in the wrappers code. Both exception calsses are derived from `std::exception` (actually from its inheritants).
|
||||
|
||||
The so called **OpenVX objects** (e.g. `vx_image`) are represented as C++ classes in wrappers.
|
||||
All these classes use automatic ref-counting that allows development of exception-safe code.
|
||||
All these classes have `create()` or `createXYZ()` `static` methods for instances creation. (E.g. `Image::create()`, `Image::createVirtual()` and `Image::createFromHandle()`)
|
||||
Most of the wrapped OpenVX functions are represented as methods of the corresponding C++ classes, but in most cases they still accept C "object" types (e.g. `vx_image` or `vx_context`) that allows mixing of C and C++ OpenVX API use.
|
||||
E.g.:
|
||||
```cpp
|
||||
class Image
|
||||
{
|
||||
static Image create(vx_context context, vx_uint32 width, vx_uint32 height, vx_df_image format);
|
||||
static Image createVirtual(vx_graph graph, vx_uint32 width = 0, vx_uint32 height = 0, vx_df_image format = VX_DF_IMAGE_VIRT);
|
||||
// ...
|
||||
}
|
||||
```
|
||||
All the classes instances can automatically be converted to the corresponding C "object" types.
|
||||
|
||||
For more details please refer to C++ wrappers reference manual or directly to their source code.
|
||||
18
3rdparty/openvx/hal/CMakeLists.txt
vendored
Normal file
18
3rdparty/openvx/hal/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
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 PUBLIC ${OPENVX_LIBRARIES})
|
||||
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 "")
|
||||
4
3rdparty/openvx/hal/README.md
vendored
Normal file
4
3rdparty/openvx/hal/README.md
vendored
Normal file
@@ -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`
|
||||
1143
3rdparty/openvx/hal/openvx_hal.cpp
vendored
Normal file
1143
3rdparty/openvx/hal/openvx_hal.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
142
3rdparty/openvx/hal/openvx_hal.hpp
vendored
Normal file
142
3rdparty/openvx/hal/openvx_hal.hpp
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
#ifndef OPENCV_OPENVX_HAL_HPP_INCLUDED
|
||||
#define OPENCV_OPENVX_HAL_HPP_INCLUDED
|
||||
|
||||
#include "opencv2/core/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_warpPerspective(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_warpPerspective
|
||||
|
||||
#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
|
||||
3277
3rdparty/openvx/include/ivx.hpp
vendored
Normal file
3277
3rdparty/openvx/include/ivx.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
3rdparty/openvx/include/ivx_lib_debug.hpp
vendored
Normal file
42
3rdparty/openvx/include/ivx_lib_debug.hpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
// Copyright (C) 2016, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
/*
|
||||
C++ wrappers over OpenVX 1.x C API ("openvx-debug" module)
|
||||
Details: TBD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef IVX_LIB_DEBUG_HPP
|
||||
#define IVX_LIB_DEBUG_HPP
|
||||
|
||||
#include "ivx.hpp"
|
||||
|
||||
namespace ivx
|
||||
{
|
||||
namespace debug
|
||||
{
|
||||
/*
|
||||
* "openvx-debug" module
|
||||
*/
|
||||
|
||||
//
|
||||
void fReadImage(vx_context c, const std::string& path, vx_image img)
|
||||
{
|
||||
IVX_CHECK_STATUS( vxuFReadImage(c, (vx_char*)path.c_str(), img) );
|
||||
}
|
||||
|
||||
//
|
||||
void fWriteImage(vx_context c, vx_image img, const std::string& path)
|
||||
{
|
||||
IVX_CHECK_STATUS( vxuFWriteImage(c, img, (vx_char*)path.c_str()) );
|
||||
}
|
||||
|
||||
} // namespace debug
|
||||
} // namespace ivx
|
||||
|
||||
#endif //IVX_LIB_DEBUG_HPP
|
||||
Reference in New Issue
Block a user