Merging in master
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
set(the_description "The Core Functionality")
|
||||
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" OPTIONAL opencv_cudev)
|
||||
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}"
|
||||
OPTIONAL opencv_cudev
|
||||
WRAP java python)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
if(HAVE_WINRT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
|
||||
set(extra_libs "")
|
||||
|
||||
if(WINRT AND CMAKE_SYSTEM_NAME MATCHES WindowsStore AND CMAKE_SYSTEM_VERSION MATCHES "8.0")
|
||||
list(APPEND extra_libs ole32.lib)
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
@@ -22,7 +23,7 @@ ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version
|
||||
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
||||
|
||||
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS})
|
||||
ocv_create_module()
|
||||
ocv_create_module(${extra_libs})
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
ocv_add_perf_tests()
|
||||
|
@@ -545,8 +545,31 @@ The function returns the number of non-zero elements in src :
|
||||
*/
|
||||
CV_EXPORTS_W int countNonZero( InputArray src );
|
||||
|
||||
/** @brief returns the list of locations of non-zero pixels
|
||||
@todo document
|
||||
/** @brief Returns the list of locations of non-zero pixels
|
||||
|
||||
Given a binary matrix (likely returned from an operation such
|
||||
as threshold(), compare(), >, ==, etc, return all of
|
||||
the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
|
||||
For example:
|
||||
@code{.cpp}
|
||||
cv::Mat binaryImage; // input, binary image
|
||||
cv::Mat locations; // output, locations of non-zero pixels
|
||||
cv::findNonZero(binaryImage, locations);
|
||||
|
||||
// access pixel coordinates
|
||||
Point pnt = locations.at<Point>(i);
|
||||
@endcode
|
||||
or
|
||||
@code{.cpp}
|
||||
cv::Mat binaryImage; // input, binary image
|
||||
vector<Point> locations; // output, locations of non-zero pixels
|
||||
cv::findNonZero(binaryImage, locations);
|
||||
|
||||
// access pixel coordinates
|
||||
Point pnt = locations[i];
|
||||
@endcode
|
||||
@param src single-channel array (type CV_8UC1)
|
||||
@param idx the output array, type of cv::Mat or std::vector<Point>, corresponding to non-zero indices in the input
|
||||
*/
|
||||
CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );
|
||||
|
||||
@@ -2745,8 +2768,6 @@ public:
|
||||
//////////////////////////////////////// Algorithm ////////////////////////////////////
|
||||
|
||||
class CV_EXPORTS Algorithm;
|
||||
class CV_EXPORTS AlgorithmInfo;
|
||||
struct CV_EXPORTS AlgorithmInfoData;
|
||||
|
||||
template<typename _Tp> struct ParamType {};
|
||||
|
||||
@@ -2759,32 +2780,13 @@ matching, graph-cut etc.), background subtraction (which can be done using mixtu
|
||||
models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck
|
||||
etc.).
|
||||
|
||||
The class provides the following features for all derived classes:
|
||||
|
||||
- so called "virtual constructor". That is, each Algorithm derivative is registered at program
|
||||
start and you can get the list of registered algorithms and create instance of a particular
|
||||
algorithm by its name (see Algorithm::create). If you plan to add your own algorithms, it is
|
||||
good practice to add a unique prefix to your algorithms to distinguish them from other
|
||||
algorithms.
|
||||
- setting/retrieving algorithm parameters by name. If you used video capturing functionality
|
||||
from OpenCV videoio module, you are probably familar with cvSetCaptureProperty(),
|
||||
cvGetCaptureProperty(), VideoCapture::set() and VideoCapture::get(). Algorithm provides
|
||||
similar method where instead of integer id's you specify the parameter names as text strings.
|
||||
See Algorithm::set and Algorithm::get for details.
|
||||
- reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store
|
||||
all its parameters and then read them back. There is no need to re-implement it each time.
|
||||
|
||||
Here is example of SIFT use in your application via Algorithm interface:
|
||||
@code
|
||||
#include "opencv2/opencv.hpp"
|
||||
#include "opencv2/xfeatures2d.hpp"
|
||||
|
||||
using namespace cv::xfeatures2d;
|
||||
|
||||
...
|
||||
|
||||
Ptr<Feature2D> sift = SIFT::create();
|
||||
|
||||
FileStorage fs("sift_params.xml", FileStorage::READ);
|
||||
if( fs.isOpened() ) // if we have file with parameters, read them
|
||||
{
|
||||
@@ -2794,323 +2796,73 @@ Here is example of SIFT use in your application via Algorithm interface:
|
||||
else // else modify the parameters and store them; user can later edit the file to use different parameters
|
||||
{
|
||||
sift->setContrastThreshold(0.01f); // lower the contrast threshold, compared to the default value
|
||||
|
||||
{
|
||||
WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);
|
||||
sift->write(fs);
|
||||
WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);
|
||||
sift->write(fs);
|
||||
}
|
||||
}
|
||||
|
||||
Mat image = imread("myimage.png", 0), descriptors;
|
||||
vector<KeyPoint> keypoints;
|
||||
sift->detectAndCompute(image, noArray(), keypoints, descriptors);
|
||||
@endcode
|
||||
|
||||
Creating Own Algorithms
|
||||
-----------------------
|
||||
If you want to make your own algorithm, derived from Algorithm, you should basically follow a few
|
||||
conventions and add a little semi-standard piece of code to your class:
|
||||
- Make a class and specify Algorithm as its base class.
|
||||
- The algorithm parameters should be the class members. See Algorithm::get() for the list of
|
||||
possible types of the parameters.
|
||||
- Add public virtual method `AlgorithmInfo* info() const;` to your class.
|
||||
- Add constructor function, AlgorithmInfo instance and implement the info() method. The simplest
|
||||
way is to take <https://github.com/Itseez/opencv/tree/master/modules/ml/src/ml_init.cpp> as
|
||||
the reference and modify it according to the list of your parameters.
|
||||
- Add some public function (e.g. `initModule_<mymodule>()`) that calls info() of your algorithm
|
||||
and put it into the same source file as info() implementation. This is to force C++ linker to
|
||||
include this object file into the target application. See Algorithm::create() for details.
|
||||
*/
|
||||
class CV_EXPORTS_W Algorithm
|
||||
{
|
||||
public:
|
||||
Algorithm();
|
||||
virtual ~Algorithm();
|
||||
/**Returns the algorithm name*/
|
||||
String name() const;
|
||||
|
||||
/** @brief returns the algorithm parameter
|
||||
|
||||
The method returns value of the particular parameter. Since the compiler can not deduce the
|
||||
type of the returned parameter, you should specify it explicitly in angle brackets. Here are
|
||||
the allowed forms of get:
|
||||
|
||||
- myalgo.get\<int\>("param_name")
|
||||
- myalgo.get\<double\>("param_name")
|
||||
- myalgo.get\<bool\>("param_name")
|
||||
- myalgo.get\<String\>("param_name")
|
||||
- myalgo.get\<Mat\>("param_name")
|
||||
- myalgo.get\<vector\<Mat\> \>("param_name")
|
||||
- myalgo.get\<Algorithm\>("param_name") (it returns Ptr\<Algorithm\>).
|
||||
|
||||
In some cases the actual type of the parameter can be cast to the specified type, e.g. integer
|
||||
parameter can be cast to double, bool can be cast to int. But "dangerous" transformations
|
||||
(string\<-\>number, double-\>int, 1x1 Mat\<-\>number, ...) are not performed and the method
|
||||
will throw an exception. In the case of Mat or vector\<Mat\> parameters the method does not
|
||||
clone the matrix data, so do not modify the matrices. Use Algorithm::set instead - slower, but
|
||||
more safe.
|
||||
@param name The parameter name.
|
||||
*/
|
||||
template<typename _Tp> typename ParamType<_Tp>::member_type get(const String& name) const;
|
||||
/** @overload */
|
||||
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
|
||||
|
||||
CV_WRAP int getInt(const String& name) const;
|
||||
CV_WRAP double getDouble(const String& name) const;
|
||||
CV_WRAP bool getBool(const String& name) const;
|
||||
CV_WRAP String getString(const String& name) const;
|
||||
CV_WRAP Mat getMat(const String& name) const;
|
||||
CV_WRAP std::vector<Mat> getMatVector(const String& name) const;
|
||||
CV_WRAP Ptr<Algorithm> getAlgorithm(const String& name) const;
|
||||
|
||||
/** @brief Sets the algorithm parameter
|
||||
|
||||
The method sets value of the particular parameter. Some of the algorithm
|
||||
parameters may be declared as read-only. If you try to set such a
|
||||
parameter, you will get exception with the corresponding error message.
|
||||
@param name The parameter name.
|
||||
@param value The parameter value.
|
||||
*/
|
||||
void set(const String& name, int value);
|
||||
void set(const String& name, double value);
|
||||
void set(const String& name, bool value);
|
||||
void set(const String& name, const String& value);
|
||||
void set(const String& name, const Mat& value);
|
||||
void set(const String& name, const std::vector<Mat>& value);
|
||||
void set(const String& name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void set(const String& name, const Ptr<_Tp>& value);
|
||||
|
||||
CV_WRAP void setInt(const String& name, int value);
|
||||
CV_WRAP void setDouble(const String& name, double value);
|
||||
CV_WRAP void setBool(const String& name, bool value);
|
||||
CV_WRAP void setString(const String& name, const String& value);
|
||||
CV_WRAP void setMat(const String& name, const Mat& value);
|
||||
CV_WRAP void setMatVector(const String& name, const std::vector<Mat>& value);
|
||||
CV_WRAP void setAlgorithm(const String& name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void setAlgorithm(const String& name, const Ptr<_Tp>& value);
|
||||
|
||||
void set(const char* name, int value);
|
||||
void set(const char* name, double value);
|
||||
void set(const char* name, bool value);
|
||||
void set(const char* name, const String& value);
|
||||
void set(const char* name, const Mat& value);
|
||||
void set(const char* name, const std::vector<Mat>& value);
|
||||
void set(const char* name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void set(const char* name, const Ptr<_Tp>& value);
|
||||
|
||||
void setInt(const char* name, int value);
|
||||
void setDouble(const char* name, double value);
|
||||
void setBool(const char* name, bool value);
|
||||
void setString(const char* name, const String& value);
|
||||
void setMat(const char* name, const Mat& value);
|
||||
void setMatVector(const char* name, const std::vector<Mat>& value);
|
||||
void setAlgorithm(const char* name, const Ptr<Algorithm>& value);
|
||||
template<typename _Tp> void setAlgorithm(const char* name, const Ptr<_Tp>& value);
|
||||
|
||||
CV_WRAP String paramHelp(const String& name) const;
|
||||
int paramType(const char* name) const;
|
||||
CV_WRAP int paramType(const String& name) const;
|
||||
CV_WRAP void getParams(CV_OUT std::vector<String>& names) const;
|
||||
|
||||
/** @brief Stores algorithm parameters in a file storage
|
||||
|
||||
The method stores all the algorithm parameters (in alphabetic order) to
|
||||
the file storage. The method is virtual. If you define your own
|
||||
Algorithm derivative, your can override the method and store some extra
|
||||
information. However, it's rarely needed. Here are some examples:
|
||||
- SIFT feature detector (from xfeatures2d module). The class only
|
||||
stores algorithm parameters and no keypoints or their descriptors.
|
||||
Therefore, it's enough to store the algorithm parameters, which is
|
||||
what Algorithm::write() does. Therefore, there is no dedicated
|
||||
SIFT::write().
|
||||
- Background subtractor (from video module). It has the algorithm
|
||||
parameters and also it has the current background model. However,
|
||||
the background model is not stored. First, it's rather big. Then,
|
||||
if you have stored the background model, it would likely become
|
||||
irrelevant on the next run (because of shifted camera, changed
|
||||
background, different lighting etc.). Therefore,
|
||||
BackgroundSubtractorMOG and BackgroundSubtractorMOG2 also rely on
|
||||
the standard Algorithm::write() to store just the algorithm
|
||||
parameters.
|
||||
- Expectation Maximization (from ml module). The algorithm finds
|
||||
mixture of gaussians that approximates user data best of all. In
|
||||
this case the model may be re-used on the next run to test new
|
||||
data against the trained statistical model. So EM needs to store
|
||||
the model. However, since the model is described by a few
|
||||
parameters that are available as read-only algorithm parameters
|
||||
(i.e. they are available via EM::get()), EM also relies on
|
||||
Algorithm::write() to store both EM parameters and the model
|
||||
(represented by read-only algorithm parameters).
|
||||
@param fs File storage.
|
||||
*/
|
||||
virtual void write(FileStorage& fs) const;
|
||||
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
|
||||
The method reads all the algorithm parameters from the specified node of
|
||||
a file storage. Similarly to Algorithm::write(), if you implement an
|
||||
algorithm that needs to read some extra data and/or re-compute some
|
||||
internal data, you may override the method.
|
||||
@param fn File node of the file storage.
|
||||
*/
|
||||
virtual void read(const FileNode& fn);
|
||||
|
||||
typedef Algorithm* (*Constructor)(void);
|
||||
typedef int (Algorithm::*Getter)() const;
|
||||
typedef void (Algorithm::*Setter)(int);
|
||||
|
||||
/** @brief Returns the list of registered algorithms
|
||||
|
||||
This static method returns the list of registered algorithms in
|
||||
alphabetical order. Here is how to use it :
|
||||
@code{.cpp}
|
||||
vector<String> algorithms;
|
||||
Algorithm::getList(algorithms);
|
||||
cout << "Algorithms: " << algorithms.size() << endl;
|
||||
for (size_t i=0; i < algorithms.size(); i++)
|
||||
cout << algorithms[i] << endl;
|
||||
@endcode
|
||||
@param algorithms The output vector of algorithm names.
|
||||
*/
|
||||
CV_WRAP static void getList(CV_OUT std::vector<String>& algorithms);
|
||||
CV_WRAP static Ptr<Algorithm> _create(const String& name);
|
||||
|
||||
/** @brief Creates algorithm instance by name
|
||||
|
||||
This static method creates a new instance of the specified algorithm. If
|
||||
there is no such algorithm, the method will silently return a null
|
||||
pointer. Also, you should specify the particular Algorithm subclass as
|
||||
_Tp (or simply Algorithm if you do not know it at that point). :
|
||||
@code{.cpp}
|
||||
Ptr<BackgroundSubtractor> bgfg = Algorithm::create<BackgroundSubtractor>("BackgroundSubtractor.MOG2");
|
||||
@endcode
|
||||
@note This is important note about seemingly mysterious behavior of
|
||||
Algorithm::create() when it returns NULL while it should not. The reason
|
||||
is simple - Algorithm::create() resides in OpenCV's core module and the
|
||||
algorithms are implemented in other modules. If you create algorithms
|
||||
dynamically, C++ linker may decide to throw away the modules where the
|
||||
actual algorithms are implemented, since you do not call any functions
|
||||
from the modules. To avoid this problem, you need to call
|
||||
initModule_\<modulename\>(); somewhere in the beginning of the program
|
||||
before Algorithm::create(). For example, call initModule_xfeatures2d()
|
||||
in order to use SURF/SIFT, call initModule_ml() to use expectation
|
||||
maximization etc.
|
||||
@param name The algorithm name, one of the names returned by Algorithm::getList().
|
||||
*/
|
||||
template<typename _Tp> static Ptr<_Tp> create(const String& name);
|
||||
|
||||
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }
|
||||
};
|
||||
|
||||
/** @todo document */
|
||||
class CV_EXPORTS AlgorithmInfo
|
||||
{
|
||||
public:
|
||||
friend class Algorithm;
|
||||
AlgorithmInfo(const String& name, Algorithm::Constructor create);
|
||||
~AlgorithmInfo();
|
||||
void get(const Algorithm* algo, const char* name, int argType, void* value) const;
|
||||
void addParam_(Algorithm& algo, const char* name, int argType,
|
||||
void* value, bool readOnly,
|
||||
Algorithm::Getter getter, Algorithm::Setter setter,
|
||||
const String& help=String());
|
||||
String paramHelp(const char* name) const;
|
||||
int paramType(const char* name) const;
|
||||
void getParams(std::vector<String>& names) const;
|
||||
Algorithm();
|
||||
virtual ~Algorithm();
|
||||
|
||||
void write(const Algorithm* algo, FileStorage& fs) const;
|
||||
void read(Algorithm* algo, const FileNode& fn) const;
|
||||
String name() const;
|
||||
/** @brief Stores algorithm parameters in a file storage
|
||||
*/
|
||||
virtual void write(FileStorage& fs) const { (void)fs; }
|
||||
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
int& value, bool readOnly=false,
|
||||
int (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(int)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
bool& value, bool readOnly=false,
|
||||
int (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(int)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
double& value, bool readOnly=false,
|
||||
double (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(double)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
String& value, bool readOnly=false,
|
||||
String (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const String&)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
Mat& value, bool readOnly=false,
|
||||
Mat (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const Mat&)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
std::vector<Mat>& value, bool readOnly=false,
|
||||
std::vector<Mat> (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const std::vector<Mat>&)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
Ptr<Algorithm>& value, bool readOnly=false,
|
||||
Ptr<Algorithm> (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const Ptr<Algorithm>&)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
float& value, bool readOnly=false,
|
||||
float (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(float)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
unsigned int& value, bool readOnly=false,
|
||||
unsigned int (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(unsigned int)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
uint64& value, bool readOnly=false,
|
||||
uint64 (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(uint64)=0,
|
||||
const String& help=String());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
uchar& value, bool readOnly=false,
|
||||
uchar (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(uchar)=0,
|
||||
const String& help=String());
|
||||
template<typename _Tp, typename _Base> void addParam(Algorithm& algo, const char* name,
|
||||
Ptr<_Tp>& value, bool readOnly=false,
|
||||
Ptr<_Tp> (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
||||
const String& help=String());
|
||||
template<typename _Tp> void addParam(Algorithm& algo, const char* name,
|
||||
Ptr<_Tp>& value, bool readOnly=false,
|
||||
Ptr<_Tp> (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const Ptr<_Tp>&)=0,
|
||||
const String& help=String());
|
||||
protected:
|
||||
AlgorithmInfoData* data;
|
||||
void set(Algorithm* algo, const char* name, int argType,
|
||||
const void* value, bool force=false) const;
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
*/
|
||||
virtual void read(const FileNode& fn) { (void)fn; }
|
||||
};
|
||||
|
||||
/** @todo document */
|
||||
struct CV_EXPORTS Param
|
||||
{
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9, UCHAR=11 };
|
||||
// define properties
|
||||
|
||||
Param();
|
||||
Param(int _type, bool _readonly, int _offset,
|
||||
Algorithm::Getter _getter=0,
|
||||
Algorithm::Setter _setter=0,
|
||||
const String& _help=String());
|
||||
int type;
|
||||
int offset;
|
||||
bool readonly;
|
||||
Algorithm::Getter getter;
|
||||
Algorithm::Setter setter;
|
||||
String help;
|
||||
#define CV_PURE_PROPERTY(type, name) \
|
||||
CV_WRAP virtual type get##name() const = 0; \
|
||||
CV_WRAP virtual void set##name(type val) = 0;
|
||||
|
||||
#define CV_PURE_PROPERTY_S(type, name) \
|
||||
CV_WRAP virtual type get##name() const = 0; \
|
||||
CV_WRAP virtual void set##name(const type & val) = 0;
|
||||
|
||||
#define CV_PURE_PROPERTY_RO(type, name) \
|
||||
CV_WRAP virtual type get##name() const = 0;
|
||||
|
||||
// basic property implementation
|
||||
|
||||
#define CV_IMPL_PROPERTY_RO(type, name, member) \
|
||||
inline type get##name() const { return member; }
|
||||
|
||||
#define CV_HELP_IMPL_PROPERTY(r_type, w_type, name, member) \
|
||||
CV_IMPL_PROPERTY_RO(r_type, name, member) \
|
||||
inline void set##name(w_type val) { member = val; }
|
||||
|
||||
#define CV_HELP_WRAP_PROPERTY(r_type, w_type, name, internal_name, internal_obj) \
|
||||
r_type get##name() const { return internal_obj.get##internal_name(); } \
|
||||
void set##name(w_type val) { internal_obj.set##internal_name(val); }
|
||||
|
||||
#define CV_IMPL_PROPERTY(type, name, member) CV_HELP_IMPL_PROPERTY(type, type, name, member)
|
||||
#define CV_IMPL_PROPERTY_S(type, name, member) CV_HELP_IMPL_PROPERTY(type, const type &, name, member)
|
||||
|
||||
#define CV_WRAP_PROPERTY(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, type, name, internal_name, internal_obj)
|
||||
#define CV_WRAP_PROPERTY_S(type, name, internal_name, internal_obj) CV_HELP_WRAP_PROPERTY(type, const type &, name, internal_name, internal_obj)
|
||||
|
||||
#define CV_WRAP_SAME_PROPERTY(type, name, internal_obj) CV_WRAP_PROPERTY(type, name, name, internal_obj)
|
||||
#define CV_WRAP_SAME_PROPERTY_S(type, name, internal_obj) CV_WRAP_PROPERTY_S(type, name, name, internal_obj)
|
||||
|
||||
struct Param {
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
|
||||
UNSIGNED_INT=8, UINT64=9, UCHAR=11 };
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<> struct ParamType<bool>
|
||||
{
|
||||
typedef bool const_param_type;
|
||||
|
@@ -191,7 +191,7 @@
|
||||
# include "arm_neon.h"
|
||||
# define CV_NEON 1
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
#elif defined(__ARM_NEON__)
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
@@ -817,7 +817,7 @@ Vec<_Tp, n> Matx<_Tp, m, n>::solve(const Vec<_Tp, m>& rhs, int method) const
|
||||
template<typename _Tp, int m> static inline
|
||||
double determinant(const Matx<_Tp, m, m>& a)
|
||||
{
|
||||
return internal::Matx_DetOp<_Tp, m>()(a);
|
||||
return cv::internal::Matx_DetOp<_Tp, m>()(a);
|
||||
}
|
||||
|
||||
template<typename _Tp, int m, int n> static inline
|
||||
@@ -960,25 +960,25 @@ Vec<_Tp, cn> Vec<_Tp, cn>::mul(const Vec<_Tp, cn>& v) const
|
||||
template<> inline
|
||||
Vec<float, 2> Vec<float, 2>::conj() const
|
||||
{
|
||||
return internal::conjugate(*this);
|
||||
return cv::internal::conjugate(*this);
|
||||
}
|
||||
|
||||
template<> inline
|
||||
Vec<double, 2> Vec<double, 2>::conj() const
|
||||
{
|
||||
return internal::conjugate(*this);
|
||||
return cv::internal::conjugate(*this);
|
||||
}
|
||||
|
||||
template<> inline
|
||||
Vec<float, 4> Vec<float, 4>::conj() const
|
||||
{
|
||||
return internal::conjugate(*this);
|
||||
return cv::internal::conjugate(*this);
|
||||
}
|
||||
|
||||
template<> inline
|
||||
Vec<double, 4> Vec<double, 4>::conj() const
|
||||
{
|
||||
return internal::conjugate(*this);
|
||||
return cv::internal::conjugate(*this);
|
||||
}
|
||||
|
||||
template<typename _Tp, int cn> inline
|
||||
|
@@ -184,6 +184,7 @@ public:
|
||||
// After fix restore code in arithm.cpp: ocl_compare()
|
||||
inline bool isAMD() const { return vendorID() == VENDOR_AMD; }
|
||||
inline bool isIntel() const { return vendorID() == VENDOR_INTEL; }
|
||||
inline bool isNVidia() const { return vendorID() == VENDOR_NVIDIA; }
|
||||
|
||||
int maxClockFrequency() const;
|
||||
int maxComputeUnits() const;
|
||||
|
@@ -193,7 +193,7 @@ Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
|
||||
Matx<_Tp, n, m> b;
|
||||
bool ok;
|
||||
if( method == DECOMP_LU || method == DECOMP_CHOLESKY )
|
||||
ok = internal::Matx_FastInvOp<_Tp, m>()(*this, b, method);
|
||||
ok = cv::internal::Matx_FastInvOp<_Tp, m>()(*this, b, method);
|
||||
else
|
||||
{
|
||||
Mat A(*this, false), B(b, false);
|
||||
@@ -209,7 +209,7 @@ Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) c
|
||||
Matx<_Tp, n, l> x;
|
||||
bool ok;
|
||||
if( method == DECOMP_LU || method == DECOMP_CHOLESKY )
|
||||
ok = internal::Matx_FastSolveOp<_Tp, m, l>()(*this, rhs, x, method);
|
||||
ok = cv::internal::Matx_FastSolveOp<_Tp, m, l>()(*this, rhs, x, method);
|
||||
else
|
||||
{
|
||||
Mat A(*this, false), B(rhs, false), X(x, false);
|
||||
@@ -412,84 +412,6 @@ int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout)
|
||||
return print(Formatter::get()->format(cv::Mat(matx)), stream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////// Algorithm //////////////////////////////////////////
|
||||
|
||||
template<typename _Tp> inline
|
||||
Ptr<_Tp> Algorithm::create(const String& name)
|
||||
{
|
||||
return _create(name).dynamicCast<_Tp>();
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
void Algorithm::set(const char* _name, const Ptr<_Tp>& value)
|
||||
{
|
||||
Ptr<Algorithm> algo_ptr = value. template dynamicCast<cv::Algorithm>();
|
||||
if (!algo_ptr) {
|
||||
CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set");
|
||||
}
|
||||
info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
void Algorithm::set(const String& _name, const Ptr<_Tp>& value)
|
||||
{
|
||||
this->set<_Tp>(_name.c_str(), value);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value)
|
||||
{
|
||||
Ptr<Algorithm> algo_ptr = value. template ptr<cv::Algorithm>();
|
||||
if (!algo_ptr) {
|
||||
CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set");
|
||||
}
|
||||
info()->set(this, _name, ParamType<Algorithm>::type, &algo_ptr);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
void Algorithm::setAlgorithm(const String& _name, const Ptr<_Tp>& value)
|
||||
{
|
||||
this->set<_Tp>(_name.c_str(), value);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
typename ParamType<_Tp>::member_type Algorithm::get(const String& _name) const
|
||||
{
|
||||
typename ParamType<_Tp>::member_type value;
|
||||
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
typename ParamType<_Tp>::member_type Algorithm::get(const char* _name) const
|
||||
{
|
||||
typename ParamType<_Tp>::member_type value;
|
||||
info()->get(this, _name, ParamType<_Tp>::type, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Base> inline
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly,
|
||||
Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
||||
const String& help)
|
||||
{
|
||||
//TODO: static assert: _Tp inherits from _Base
|
||||
addParam_(algo, parameter, ParamType<_Base>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter, Ptr<_Tp>& value, bool readOnly,
|
||||
Ptr<_Tp> (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr<_Tp>&),
|
||||
const String& help)
|
||||
{
|
||||
//TODO: static assert: _Tp inherits from Algorithm
|
||||
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
/****************************************************************************************\
|
||||
|
@@ -914,7 +914,7 @@ void write(FileStorage& fs, const Range& r )
|
||||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const std::vector<_Tp>& vec )
|
||||
{
|
||||
internal::VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
|
||||
cv::internal::VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
|
||||
w(vec);
|
||||
}
|
||||
|
||||
@@ -922,63 +922,63 @@ void write( FileStorage& fs, const std::vector<_Tp>& vec )
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Point_<_Tp>& pt )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, pt);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Point3_<_Tp>& pt )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, pt);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Size_<_Tp>& sz )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, sz);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Complex<_Tp>& c )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, c);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Rect_<_Tp>& r )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, r);
|
||||
}
|
||||
|
||||
template<typename _Tp, int cn> static inline
|
||||
void write(FileStorage& fs, const String& name, const Vec<_Tp, cn>& v )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, v);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write(FileStorage& fs, const String& name, const Scalar_<_Tp>& s )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, s);
|
||||
}
|
||||
|
||||
static inline
|
||||
void write(FileStorage& fs, const String& name, const Range& r )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
|
||||
write(fs, r);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
|
||||
{
|
||||
internal::WriteStructContext ws(fs, name, FileNode::SEQ+(DataType<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||
cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+(DataType<_Tp>::fmt != 0 ? FileNode::FLOW : 0));
|
||||
write(fs, vec);
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ void read(const FileNode& node, short& value, short default_value)
|
||||
template<typename _Tp> static inline
|
||||
void read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount = (size_t)INT_MAX )
|
||||
{
|
||||
internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
cv::internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
r(vec, maxCount);
|
||||
}
|
||||
|
||||
@@ -1101,7 +1101,7 @@ FileNodeIterator& operator >> (FileNodeIterator& it, _Tp& value)
|
||||
template<typename _Tp> static inline
|
||||
FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec)
|
||||
{
|
||||
internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
cv::internal::VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it);
|
||||
r(vec, (size_t)INT_MAX);
|
||||
return it;
|
||||
}
|
||||
|
@@ -129,40 +129,6 @@ namespace cv
|
||||
CV_EXPORTS const char* currentParallelFramework();
|
||||
} //namespace cv
|
||||
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
static inline ::cv::Algorithm* create##classname##_hidden() \
|
||||
{ \
|
||||
return new classname; \
|
||||
} \
|
||||
\
|
||||
static inline ::cv::Ptr< ::cv::Algorithm> create##classname##_ptr_hidden() \
|
||||
{ \
|
||||
return ::cv::makePtr<classname>(); \
|
||||
} \
|
||||
\
|
||||
static inline ::cv::AlgorithmInfo& classname##_info() \
|
||||
{ \
|
||||
static ::cv::AlgorithmInfo classname##_info_var(algname, create##classname##_hidden); \
|
||||
return classname##_info_var; \
|
||||
} \
|
||||
\
|
||||
static ::cv::AlgorithmInfo& classname##_info_auto = classname##_info(); \
|
||||
\
|
||||
::cv::AlgorithmInfo* classname::info() const \
|
||||
{ \
|
||||
static volatile bool initialized = false; \
|
||||
\
|
||||
if( !initialized ) \
|
||||
{ \
|
||||
initialized = true; \
|
||||
classname obj; \
|
||||
memberinit; \
|
||||
} \
|
||||
return &classname##_info(); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Common declarations *
|
||||
\****************************************************************************************/
|
||||
@@ -303,6 +269,15 @@ typedef enum CvStatus
|
||||
}
|
||||
CvStatus;
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
namespace tegra {
|
||||
|
||||
CV_EXPORTS bool useTegra();
|
||||
CV_EXPORTS void setUseTegra(bool flag);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_CORE_PRIVATE_HPP__
|
||||
|
4
modules/core/misc/java/filelist
Normal file
4
modules/core/misc/java/filelist
Normal file
@@ -0,0 +1,4 @@
|
||||
include/opencv2/core/base.hpp
|
||||
include/opencv2/core.hpp
|
||||
include/opencv2/core/utility.hpp
|
||||
misc/java/src/cpp/core_manual.hpp
|
21
modules/core/misc/java/src/cpp/core_manual.cpp
Normal file
21
modules/core/misc/java/src/cpp/core_manual.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#define LOG_TAG "org.opencv.core.Core"
|
||||
#include "common.h"
|
||||
#include "core_manual.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
static int quietCallback( int, const char*, const char*, const char*, int, void* )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace cv {
|
||||
|
||||
void setErrorVerbosity(bool verbose)
|
||||
{
|
||||
if(verbose)
|
||||
cv::redirectError(0);
|
||||
else
|
||||
cv::redirectError((cv::ErrorCallback)quietCallback);
|
||||
}
|
||||
|
||||
}
|
33
modules/core/misc/java/src/cpp/core_manual.hpp
Normal file
33
modules/core/misc/java/src/cpp/core_manual.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
CV_EXPORTS_W void setErrorVerbosity(bool verbose);
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
namespace cv
|
||||
{
|
||||
CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
CV_EXPORTS_W void compare(InputArray src1, Scalar src2, OutputArray dst, int cmpop);
|
||||
|
||||
CV_EXPORTS_W void min(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
CV_EXPORTS_W void max(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
}
|
||||
#endif //0
|
15
modules/core/misc/java/src/java/core+CvException.java
Normal file
15
modules/core/misc/java/src/java/core+CvException.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CvException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CvException [" + super.toString() + "]";
|
||||
}
|
||||
}
|
136
modules/core/misc/java/src/java/core+CvType.java
Normal file
136
modules/core/misc/java/src/java/core+CvType.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public final class CvType {
|
||||
|
||||
// type depth constants
|
||||
public static final int
|
||||
CV_8U = 0, CV_8S = 1,
|
||||
CV_16U = 2, CV_16S = 3,
|
||||
CV_32S = 4,
|
||||
CV_32F = 5,
|
||||
CV_64F = 6,
|
||||
CV_USRTYPE1 = 7;
|
||||
|
||||
// predefined type constants
|
||||
public static final int
|
||||
CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4),
|
||||
CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4),
|
||||
CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4),
|
||||
CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4),
|
||||
CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4),
|
||||
CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4),
|
||||
CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4);
|
||||
|
||||
private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT);
|
||||
|
||||
public static final int makeType(int depth, int channels) {
|
||||
if (channels <= 0 || channels >= CV_CN_MAX) {
|
||||
throw new java.lang.UnsupportedOperationException(
|
||||
"Channels count should be 1.." + (CV_CN_MAX - 1));
|
||||
}
|
||||
if (depth < 0 || depth >= CV_DEPTH_MAX) {
|
||||
throw new java.lang.UnsupportedOperationException(
|
||||
"Data type depth should be 0.." + (CV_DEPTH_MAX - 1));
|
||||
}
|
||||
return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT);
|
||||
}
|
||||
|
||||
public static final int CV_8UC(int ch) {
|
||||
return makeType(CV_8U, ch);
|
||||
}
|
||||
|
||||
public static final int CV_8SC(int ch) {
|
||||
return makeType(CV_8S, ch);
|
||||
}
|
||||
|
||||
public static final int CV_16UC(int ch) {
|
||||
return makeType(CV_16U, ch);
|
||||
}
|
||||
|
||||
public static final int CV_16SC(int ch) {
|
||||
return makeType(CV_16S, ch);
|
||||
}
|
||||
|
||||
public static final int CV_32SC(int ch) {
|
||||
return makeType(CV_32S, ch);
|
||||
}
|
||||
|
||||
public static final int CV_32FC(int ch) {
|
||||
return makeType(CV_32F, ch);
|
||||
}
|
||||
|
||||
public static final int CV_64FC(int ch) {
|
||||
return makeType(CV_64F, ch);
|
||||
}
|
||||
|
||||
public static final int channels(int type) {
|
||||
return (type >> CV_CN_SHIFT) + 1;
|
||||
}
|
||||
|
||||
public static final int depth(int type) {
|
||||
return type & (CV_DEPTH_MAX - 1);
|
||||
}
|
||||
|
||||
public static final boolean isInteger(int type) {
|
||||
return depth(type) < CV_32F;
|
||||
}
|
||||
|
||||
public static final int ELEM_SIZE(int type) {
|
||||
switch (depth(type)) {
|
||||
case CV_8U:
|
||||
case CV_8S:
|
||||
return channels(type);
|
||||
case CV_16U:
|
||||
case CV_16S:
|
||||
return 2 * channels(type);
|
||||
case CV_32S:
|
||||
case CV_32F:
|
||||
return 4 * channels(type);
|
||||
case CV_64F:
|
||||
return 8 * channels(type);
|
||||
default:
|
||||
throw new java.lang.UnsupportedOperationException(
|
||||
"Unsupported CvType value: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String typeToString(int type) {
|
||||
String s;
|
||||
switch (depth(type)) {
|
||||
case CV_8U:
|
||||
s = "CV_8U";
|
||||
break;
|
||||
case CV_8S:
|
||||
s = "CV_8S";
|
||||
break;
|
||||
case CV_16U:
|
||||
s = "CV_16U";
|
||||
break;
|
||||
case CV_16S:
|
||||
s = "CV_16S";
|
||||
break;
|
||||
case CV_32S:
|
||||
s = "CV_32S";
|
||||
break;
|
||||
case CV_32F:
|
||||
s = "CV_32F";
|
||||
break;
|
||||
case CV_64F:
|
||||
s = "CV_64F";
|
||||
break;
|
||||
case CV_USRTYPE1:
|
||||
s = "CV_USRTYPE1";
|
||||
break;
|
||||
default:
|
||||
throw new java.lang.UnsupportedOperationException(
|
||||
"Unsupported CvType value: " + type);
|
||||
}
|
||||
|
||||
int ch = channels(type);
|
||||
if (ch <= 4)
|
||||
return s + "C" + ch;
|
||||
else
|
||||
return s + "C(" + ch + ")";
|
||||
}
|
||||
|
||||
}
|
61
modules/core/misc/java/src/java/core+DMatch.java
Normal file
61
modules/core/misc/java/src/java/core+DMatch.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//C++: class DMatch
|
||||
|
||||
/**
|
||||
* Structure for matching: query descriptor index, train descriptor index, train
|
||||
* image index and distance between descriptors.
|
||||
*/
|
||||
public class DMatch {
|
||||
|
||||
/**
|
||||
* Query descriptor index.
|
||||
*/
|
||||
public int queryIdx;
|
||||
/**
|
||||
* Train descriptor index.
|
||||
*/
|
||||
public int trainIdx;
|
||||
/**
|
||||
* Train image index.
|
||||
*/
|
||||
public int imgIdx;
|
||||
|
||||
// javadoc: DMatch::distance
|
||||
public float distance;
|
||||
|
||||
// javadoc: DMatch::DMatch()
|
||||
public DMatch() {
|
||||
this(-1, -1, Float.MAX_VALUE);
|
||||
}
|
||||
|
||||
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance)
|
||||
public DMatch(int _queryIdx, int _trainIdx, float _distance) {
|
||||
queryIdx = _queryIdx;
|
||||
trainIdx = _trainIdx;
|
||||
imgIdx = -1;
|
||||
distance = _distance;
|
||||
}
|
||||
|
||||
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance)
|
||||
public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) {
|
||||
queryIdx = _queryIdx;
|
||||
trainIdx = _trainIdx;
|
||||
imgIdx = _imgIdx;
|
||||
distance = _distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Less is better.
|
||||
*/
|
||||
public boolean lessThan(DMatch it) {
|
||||
return distance < it.distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx
|
||||
+ ", imgIdx=" + imgIdx + ", distance=" + distance + "]";
|
||||
}
|
||||
|
||||
}
|
83
modules/core/misc/java/src/java/core+KeyPoint.java
Normal file
83
modules/core/misc/java/src/java/core+KeyPoint.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
|
||||
//javadoc: KeyPoint
|
||||
public class KeyPoint {
|
||||
|
||||
/**
|
||||
* Coordinates of the keypoint.
|
||||
*/
|
||||
public Point pt;
|
||||
/**
|
||||
* Diameter of the useful keypoint adjacent area.
|
||||
*/
|
||||
public float size;
|
||||
/**
|
||||
* Computed orientation of the keypoint (-1 if not applicable).
|
||||
*/
|
||||
public float angle;
|
||||
/**
|
||||
* The response, by which the strongest keypoints have been selected. Can
|
||||
* be used for further sorting or subsampling.
|
||||
*/
|
||||
public float response;
|
||||
/**
|
||||
* Octave (pyramid layer), from which the keypoint has been extracted.
|
||||
*/
|
||||
public int octave;
|
||||
/**
|
||||
* Object ID, that can be used to cluster keypoints by an object they
|
||||
* belong to.
|
||||
*/
|
||||
public int class_id;
|
||||
|
||||
// javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id)
|
||||
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
|
||||
{
|
||||
pt = new Point(x, y);
|
||||
size = _size;
|
||||
angle = _angle;
|
||||
response = _response;
|
||||
octave = _octave;
|
||||
class_id = _class_id;
|
||||
}
|
||||
|
||||
// javadoc: KeyPoint::KeyPoint()
|
||||
public KeyPoint()
|
||||
{
|
||||
this(0, 0, 0, -1, 0, 0, -1);
|
||||
}
|
||||
|
||||
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave)
|
||||
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave)
|
||||
{
|
||||
this(x, y, _size, _angle, _response, _octave, -1);
|
||||
}
|
||||
|
||||
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response)
|
||||
public KeyPoint(float x, float y, float _size, float _angle, float _response)
|
||||
{
|
||||
this(x, y, _size, _angle, _response, 0, -1);
|
||||
}
|
||||
|
||||
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle)
|
||||
public KeyPoint(float x, float y, float _size, float _angle)
|
||||
{
|
||||
this(x, y, _size, _angle, 0, 0, -1);
|
||||
}
|
||||
|
||||
// javadoc: KeyPoint::KeyPoint(x, y, _size)
|
||||
public KeyPoint(float x, float y, float _size)
|
||||
{
|
||||
this(x, y, _size, -1, 0, 0, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle
|
||||
+ ", response=" + response + ", octave=" + octave
|
||||
+ ", class_id=" + class_id + "]";
|
||||
}
|
||||
|
||||
}
|
1316
modules/core/misc/java/src/java/core+Mat.java
Normal file
1316
modules/core/misc/java/src/java/core+Mat.java
Normal file
File diff suppressed because it is too large
Load Diff
79
modules/core/misc/java/src/java/core+MatOfByte.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfByte.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfByte extends Mat {
|
||||
// 8UC(x)
|
||||
private static final int _depth = CvType.CV_8U;
|
||||
private static final int _channels = 1;
|
||||
|
||||
public MatOfByte() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfByte(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfByte fromNativeAddr(long addr) {
|
||||
return new MatOfByte(addr);
|
||||
}
|
||||
|
||||
public MatOfByte(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfByte(byte...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(byte...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public byte[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
byte[] a = new byte[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Byte> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Byte ab[] = lb.toArray(new Byte[0]);
|
||||
byte a[] = new byte[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Byte> toList() {
|
||||
byte[] a = toArray();
|
||||
Byte ab[] = new Byte[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
83
modules/core/misc/java/src/java/core+MatOfDMatch.java
Normal file
83
modules/core/misc/java/src/java/core+MatOfDMatch.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.DMatch;
|
||||
|
||||
public class MatOfDMatch extends Mat {
|
||||
// 32FC4
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfDMatch() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfDMatch(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat: " + toString());
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfDMatch fromNativeAddr(long addr) {
|
||||
return new MatOfDMatch(addr);
|
||||
}
|
||||
|
||||
public MatOfDMatch(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat: " + toString());
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDMatch(DMatch...ap) {
|
||||
super();
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
|
||||
public void fromArray(DMatch...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
DMatch m = a[i];
|
||||
buff[_channels*i+0] = m.queryIdx;
|
||||
buff[_channels*i+1] = m.trainIdx;
|
||||
buff[_channels*i+2] = m.imgIdx;
|
||||
buff[_channels*i+3] = m.distance;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public DMatch[] toArray() {
|
||||
int num = (int) total();
|
||||
DMatch[] a = new DMatch[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<DMatch> ldm) {
|
||||
DMatch adm[] = ldm.toArray(new DMatch[0]);
|
||||
fromArray(adm);
|
||||
}
|
||||
|
||||
public List<DMatch> toList() {
|
||||
DMatch[] adm = toArray();
|
||||
return Arrays.asList(adm);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfDouble.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfDouble.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfDouble extends Mat {
|
||||
// 64FC(x)
|
||||
private static final int _depth = CvType.CV_64F;
|
||||
private static final int _channels = 1;
|
||||
|
||||
public MatOfDouble() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfDouble(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfDouble fromNativeAddr(long addr) {
|
||||
return new MatOfDouble(addr);
|
||||
}
|
||||
|
||||
public MatOfDouble(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDouble(double...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(double...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public double[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
double[] a = new double[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Double> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Double ab[] = lb.toArray(new Double[0]);
|
||||
double a[] = new double[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Double> toList() {
|
||||
double[] a = toArray();
|
||||
Double ab[] = new Double[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfFloat.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfFloat.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfFloat extends Mat {
|
||||
// 32FC1
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 1;
|
||||
|
||||
public MatOfFloat() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfFloat(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfFloat fromNativeAddr(long addr) {
|
||||
return new MatOfFloat(addr);
|
||||
}
|
||||
|
||||
public MatOfFloat(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat(float...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(float...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public float[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
float[] a = new float[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Float> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Float ab[] = lb.toArray(new Float[0]);
|
||||
float a[] = new float[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Float> toList() {
|
||||
float[] a = toArray();
|
||||
Float ab[] = new Float[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfFloat4.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfFloat4.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfFloat4 extends Mat {
|
||||
// 32FC4
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfFloat4() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfFloat4(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfFloat4 fromNativeAddr(long addr) {
|
||||
return new MatOfFloat4(addr);
|
||||
}
|
||||
|
||||
public MatOfFloat4(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat4(float...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(float...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public float[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
float[] a = new float[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Float> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Float ab[] = lb.toArray(new Float[0]);
|
||||
float a[] = new float[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Float> toList() {
|
||||
float[] a = toArray();
|
||||
Float ab[] = new Float[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfFloat6.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfFloat6.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfFloat6 extends Mat {
|
||||
// 32FC6
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 6;
|
||||
|
||||
public MatOfFloat6() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfFloat6(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfFloat6 fromNativeAddr(long addr) {
|
||||
return new MatOfFloat6(addr);
|
||||
}
|
||||
|
||||
public MatOfFloat6(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat6(float...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(float...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public float[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
float[] a = new float[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Float> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Float ab[] = lb.toArray(new Float[0]);
|
||||
float a[] = new float[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Float> toList() {
|
||||
float[] a = toArray();
|
||||
Float ab[] = new Float[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
80
modules/core/misc/java/src/java/core+MatOfInt.java
Normal file
80
modules/core/misc/java/src/java/core+MatOfInt.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfInt extends Mat {
|
||||
// 32SC1
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 1;
|
||||
|
||||
public MatOfInt() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfInt(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfInt fromNativeAddr(long addr) {
|
||||
return new MatOfInt(addr);
|
||||
}
|
||||
|
||||
public MatOfInt(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt(int...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(int...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public int[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
int[] a = new int[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Integer> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Integer ab[] = lb.toArray(new Integer[0]);
|
||||
int a[] = new int[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Integer> toList() {
|
||||
int[] a = toArray();
|
||||
Integer ab[] = new Integer[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
80
modules/core/misc/java/src/java/core+MatOfInt4.java
Normal file
80
modules/core/misc/java/src/java/core+MatOfInt4.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfInt4 extends Mat {
|
||||
// 32SC4
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfInt4() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfInt4(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfInt4 fromNativeAddr(long addr) {
|
||||
return new MatOfInt4(addr);
|
||||
}
|
||||
|
||||
public MatOfInt4(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt4(int...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(int...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public int[] toArray() {
|
||||
int num = checkVector(_channels, _depth);
|
||||
if(num < 0)
|
||||
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
|
||||
int[] a = new int[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Integer> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Integer ab[] = lb.toArray(new Integer[0]);
|
||||
int a[] = new int[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Integer> toList() {
|
||||
int[] a = toArray();
|
||||
Integer ab[] = new Integer[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
86
modules/core/misc/java/src/java/core+MatOfKeyPoint.java
Normal file
86
modules/core/misc/java/src/java/core+MatOfKeyPoint.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.KeyPoint;
|
||||
|
||||
public class MatOfKeyPoint extends Mat {
|
||||
// 32FC7
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 7;
|
||||
|
||||
public MatOfKeyPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfKeyPoint(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfKeyPoint fromNativeAddr(long addr) {
|
||||
return new MatOfKeyPoint(addr);
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(KeyPoint...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(KeyPoint...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
KeyPoint kp = a[i];
|
||||
buff[_channels*i+0] = (float) kp.pt.x;
|
||||
buff[_channels*i+1] = (float) kp.pt.y;
|
||||
buff[_channels*i+2] = kp.size;
|
||||
buff[_channels*i+3] = kp.angle;
|
||||
buff[_channels*i+4] = kp.response;
|
||||
buff[_channels*i+5] = kp.octave;
|
||||
buff[_channels*i+6] = kp.class_id;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public KeyPoint[] toArray() {
|
||||
int num = (int) total();
|
||||
KeyPoint[] a = new KeyPoint[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new KeyPoint( buff[_channels*i+0], buff[_channels*i+1], buff[_channels*i+2], buff[_channels*i+3],
|
||||
buff[_channels*i+4], (int) buff[_channels*i+5], (int) buff[_channels*i+6] );
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<KeyPoint> lkp) {
|
||||
KeyPoint akp[] = lkp.toArray(new KeyPoint[0]);
|
||||
fromArray(akp);
|
||||
}
|
||||
|
||||
public List<KeyPoint> toList() {
|
||||
KeyPoint[] akp = toArray();
|
||||
return Arrays.asList(akp);
|
||||
}
|
||||
}
|
78
modules/core/misc/java/src/java/core+MatOfPoint.java
Normal file
78
modules/core/misc/java/src/java/core+MatOfPoint.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint extends Mat {
|
||||
// 32SC2
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfPoint(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfPoint fromNativeAddr(long addr) {
|
||||
return new MatOfPoint(addr);
|
||||
}
|
||||
|
||||
public MatOfPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(new Point[0]);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
78
modules/core/misc/java/src/java/core+MatOfPoint2f.java
Normal file
78
modules/core/misc/java/src/java/core+MatOfPoint2f.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint2f extends Mat {
|
||||
// 32FC2
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint2f() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfPoint2f(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfPoint2f fromNativeAddr(long addr) {
|
||||
return new MatOfPoint2f(addr);
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(new Point[0]);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfPoint3.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfPoint3.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3 extends Mat {
|
||||
// 32SC3
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfPoint3(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfPoint3 fromNativeAddr(long addr) {
|
||||
return new MatOfPoint3(addr);
|
||||
}
|
||||
|
||||
public MatOfPoint3(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
buff[_channels*i+2] = (int) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(new Point3[0]);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+MatOfPoint3f.java
Normal file
79
modules/core/misc/java/src/java/core+MatOfPoint3f.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3f extends Mat {
|
||||
// 32FC3
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3f() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfPoint3f(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfPoint3f fromNativeAddr(long addr) {
|
||||
return new MatOfPoint3f(addr);
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
buff[_channels*i+2] = (float) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(new Point3[0]);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
81
modules/core/misc/java/src/java/core+MatOfRect.java
Normal file
81
modules/core/misc/java/src/java/core+MatOfRect.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfRect extends Mat {
|
||||
// 32SC4
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfRect() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MatOfRect(long addr) {
|
||||
super(addr);
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public static MatOfRect fromNativeAddr(long addr) {
|
||||
return new MatOfRect(addr);
|
||||
}
|
||||
|
||||
public MatOfRect(Mat m) {
|
||||
super(m, Range.all());
|
||||
if( !empty() && checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incompatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfRect(Rect...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Rect...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Rect r = a[i];
|
||||
buff[_channels*i+0] = (int) r.x;
|
||||
buff[_channels*i+1] = (int) r.y;
|
||||
buff[_channels*i+2] = (int) r.width;
|
||||
buff[_channels*i+3] = (int) r.height;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
|
||||
public Rect[] toArray() {
|
||||
int num = (int) total();
|
||||
Rect[] a = new Rect[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
|
||||
return a;
|
||||
}
|
||||
public void fromList(List<Rect> lr) {
|
||||
Rect ap[] = lr.toArray(new Rect[0]);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Rect> toList() {
|
||||
Rect[] ar = toArray();
|
||||
return Arrays.asList(ar);
|
||||
}
|
||||
}
|
68
modules/core/misc/java/src/java/core+Point.java
Normal file
68
modules/core/misc/java/src/java/core+Point.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Point_
|
||||
public class Point {
|
||||
|
||||
public double x, y;
|
||||
|
||||
public Point(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Point() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Point(double[] vals) {
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
x = vals.length > 0 ? vals[0] : 0;
|
||||
y = vals.length > 1 ? vals[1] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Point clone() {
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public double dot(Point p) {
|
||||
return x * p.x + y * p.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(x);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(y);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Point)) return false;
|
||||
Point it = (Point) obj;
|
||||
return x == it.x && y == it.y;
|
||||
}
|
||||
|
||||
public boolean inside(Rect r) {
|
||||
return r.contains(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + x + ", " + y + "}";
|
||||
}
|
||||
}
|
79
modules/core/misc/java/src/java/core+Point3.java
Normal file
79
modules/core/misc/java/src/java/core+Point3.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Point3_
|
||||
public class Point3 {
|
||||
|
||||
public double x, y, z;
|
||||
|
||||
public Point3(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Point3() {
|
||||
this(0, 0, 0);
|
||||
}
|
||||
|
||||
public Point3(Point p) {
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
public Point3(double[] vals) {
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
x = vals.length > 0 ? vals[0] : 0;
|
||||
y = vals.length > 1 ? vals[1] : 0;
|
||||
z = vals.length > 2 ? vals[2] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Point3 clone() {
|
||||
return new Point3(x, y, z);
|
||||
}
|
||||
|
||||
public double dot(Point3 p) {
|
||||
return x * p.x + y * p.y + z * p.z;
|
||||
}
|
||||
|
||||
public Point3 cross(Point3 p) {
|
||||
return new Point3(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(x);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(y);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(z);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Point3)) return false;
|
||||
Point3 it = (Point3) obj;
|
||||
return x == it.x && y == it.y && z == it.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + x + ", " + y + ", " + z + "}";
|
||||
}
|
||||
}
|
82
modules/core/misc/java/src/java/core+Range.java
Normal file
82
modules/core/misc/java/src/java/core+Range.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Range
|
||||
public class Range {
|
||||
|
||||
public int start, end;
|
||||
|
||||
public Range(int s, int e) {
|
||||
this.start = s;
|
||||
this.end = e;
|
||||
}
|
||||
|
||||
public Range() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Range(double[] vals) {
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
start = vals.length > 0 ? (int) vals[0] : 0;
|
||||
end = vals.length > 1 ? (int) vals[1] : 0;
|
||||
} else {
|
||||
start = 0;
|
||||
end = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return empty() ? 0 : end - start;
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
return end <= start;
|
||||
}
|
||||
|
||||
public static Range all() {
|
||||
return new Range(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Range intersection(Range r1) {
|
||||
Range r = new Range(Math.max(r1.start, this.start), Math.min(r1.end, this.end));
|
||||
r.end = Math.max(r.end, r.start);
|
||||
return r;
|
||||
}
|
||||
|
||||
public Range shift(int delta) {
|
||||
return new Range(start + delta, end + delta);
|
||||
}
|
||||
|
||||
public Range clone() {
|
||||
return new Range(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(start);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(end);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Range)) return false;
|
||||
Range it = (Range) obj;
|
||||
return start == it.start && end == it.end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + start + ", " + end + ")";
|
||||
}
|
||||
}
|
100
modules/core/misc/java/src/java/core+Rect.java
Normal file
100
modules/core/misc/java/src/java/core+Rect.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Rect_
|
||||
public class Rect {
|
||||
|
||||
public int x, y, width, height;
|
||||
|
||||
public Rect(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Rect() {
|
||||
this(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Rect(Point p1, Point p2) {
|
||||
x = (int) (p1.x < p2.x ? p1.x : p2.x);
|
||||
y = (int) (p1.y < p2.y ? p1.y : p2.y);
|
||||
width = (int) (p1.x > p2.x ? p1.x : p2.x) - x;
|
||||
height = (int) (p1.y > p2.y ? p1.y : p2.y) - y;
|
||||
}
|
||||
|
||||
public Rect(Point p, Size s) {
|
||||
this((int) p.x, (int) p.y, (int) s.width, (int) s.height);
|
||||
}
|
||||
|
||||
public Rect(double[] vals) {
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
x = vals.length > 0 ? (int) vals[0] : 0;
|
||||
y = vals.length > 1 ? (int) vals[1] : 0;
|
||||
width = vals.length > 2 ? (int) vals[2] : 0;
|
||||
height = vals.length > 3 ? (int) vals[3] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect clone() {
|
||||
return new Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
public Point tl() {
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public Point br() {
|
||||
return new Point(x + width, y + height);
|
||||
}
|
||||
|
||||
public Size size() {
|
||||
return new Size(width, height);
|
||||
}
|
||||
|
||||
public double area() {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
public boolean contains(Point p) {
|
||||
return x <= p.x && p.x < x + width && y <= p.y && p.y < y + height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(height);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(width);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(x);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(y);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Rect)) return false;
|
||||
Rect it = (Rect) obj;
|
||||
return x == it.x && y == it.y && width == it.width && height == it.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + x + ", " + y + ", " + width + "x" + height + "}";
|
||||
}
|
||||
}
|
113
modules/core/misc/java/src/java/core+RotatedRect.java
Normal file
113
modules/core/misc/java/src/java/core+RotatedRect.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:RotatedRect_
|
||||
public class RotatedRect {
|
||||
|
||||
public Point center;
|
||||
public Size size;
|
||||
public double angle;
|
||||
|
||||
public RotatedRect() {
|
||||
this.center = new Point();
|
||||
this.size = new Size();
|
||||
this.angle = 0;
|
||||
}
|
||||
|
||||
public RotatedRect(Point c, Size s, double a) {
|
||||
this.center = c.clone();
|
||||
this.size = s.clone();
|
||||
this.angle = a;
|
||||
}
|
||||
|
||||
public RotatedRect(double[] vals) {
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
center.x = vals.length > 0 ? (double) vals[0] : 0;
|
||||
center.y = vals.length > 1 ? (double) vals[1] : 0;
|
||||
size.width = vals.length > 2 ? (double) vals[2] : 0;
|
||||
size.height = vals.length > 3 ? (double) vals[3] : 0;
|
||||
angle = vals.length > 4 ? (double) vals[4] : 0;
|
||||
} else {
|
||||
center.x = 0;
|
||||
center.x = 0;
|
||||
size.width = 0;
|
||||
size.height = 0;
|
||||
angle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void points(Point pt[])
|
||||
{
|
||||
double _angle = angle * Math.PI / 180.0;
|
||||
double b = (double) Math.cos(_angle) * 0.5f;
|
||||
double a = (double) Math.sin(_angle) * 0.5f;
|
||||
|
||||
pt[0] = new Point(
|
||||
center.x - a * size.height - b * size.width,
|
||||
center.y + b * size.height - a * size.width);
|
||||
|
||||
pt[1] = new Point(
|
||||
center.x + a * size.height - b * size.width,
|
||||
center.y - b * size.height - a * size.width);
|
||||
|
||||
pt[2] = new Point(
|
||||
2 * center.x - pt[0].x,
|
||||
2 * center.y - pt[0].y);
|
||||
|
||||
pt[3] = new Point(
|
||||
2 * center.x - pt[1].x,
|
||||
2 * center.y - pt[1].y);
|
||||
}
|
||||
|
||||
public Rect boundingRect()
|
||||
{
|
||||
Point pt[] = new Point[4];
|
||||
points(pt);
|
||||
Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
||||
(int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
|
||||
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
|
||||
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
|
||||
r.width -= r.x - 1;
|
||||
r.height -= r.y - 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
public RotatedRect clone() {
|
||||
return new RotatedRect(center, size, angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(center.x);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(center.y);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(size.width);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(size.height);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(angle);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof RotatedRect)) return false;
|
||||
RotatedRect it = (RotatedRect) obj;
|
||||
return center.equals(it.center) && size.equals(it.size) && angle == it.angle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{ " + center + " " + size + " * " + angle + " }";
|
||||
}
|
||||
}
|
90
modules/core/misc/java/src/java/core+Scalar.java
Normal file
90
modules/core/misc/java/src/java/core+Scalar.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Scalar_
|
||||
public class Scalar {
|
||||
|
||||
public double val[];
|
||||
|
||||
public Scalar(double v0, double v1, double v2, double v3) {
|
||||
val = new double[] { v0, v1, v2, v3 };
|
||||
}
|
||||
|
||||
public Scalar(double v0, double v1, double v2) {
|
||||
val = new double[] { v0, v1, v2, 0 };
|
||||
}
|
||||
|
||||
public Scalar(double v0, double v1) {
|
||||
val = new double[] { v0, v1, 0, 0 };
|
||||
}
|
||||
|
||||
public Scalar(double v0) {
|
||||
val = new double[] { v0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
public Scalar(double[] vals) {
|
||||
if (vals != null && vals.length == 4)
|
||||
val = vals.clone();
|
||||
else {
|
||||
val = new double[4];
|
||||
set(vals);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
val[0] = vals.length > 0 ? vals[0] : 0;
|
||||
val[1] = vals.length > 1 ? vals[1] : 0;
|
||||
val[2] = vals.length > 2 ? vals[2] : 0;
|
||||
val[3] = vals.length > 3 ? vals[3] : 0;
|
||||
} else
|
||||
val[0] = val[1] = val[2] = val[3] = 0;
|
||||
}
|
||||
|
||||
public static Scalar all(double v) {
|
||||
return new Scalar(v, v, v, v);
|
||||
}
|
||||
|
||||
public Scalar clone() {
|
||||
return new Scalar(val);
|
||||
}
|
||||
|
||||
public Scalar mul(Scalar it, double scale) {
|
||||
return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale,
|
||||
val[2] * it.val[2] * scale, val[3] * it.val[3] * scale);
|
||||
}
|
||||
|
||||
public Scalar mul(Scalar it) {
|
||||
return mul(it, 1);
|
||||
}
|
||||
|
||||
public Scalar conj() {
|
||||
return new Scalar(val[0], -val[1], -val[2], -val[3]);
|
||||
}
|
||||
|
||||
public boolean isReal() {
|
||||
return val[1] == 0 && val[2] == 0 && val[3] == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + java.util.Arrays.hashCode(val);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Scalar)) return false;
|
||||
Scalar it = (Scalar) obj;
|
||||
if (!java.util.Arrays.equals(val, it.val)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]";
|
||||
}
|
||||
|
||||
}
|
69
modules/core/misc/java/src/java/core+Size.java
Normal file
69
modules/core/misc/java/src/java/core+Size.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:Size_
|
||||
public class Size {
|
||||
|
||||
public double width, height;
|
||||
|
||||
public Size(double width, double height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Size() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Size(Point p) {
|
||||
width = p.x;
|
||||
height = p.y;
|
||||
}
|
||||
|
||||
public Size(double[] vals) {
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
width = vals.length > 0 ? vals[0] : 0;
|
||||
height = vals.length > 1 ? vals[1] : 0;
|
||||
} else {
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double area() {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
public Size clone() {
|
||||
return new Size(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(height);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(width);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Size)) return false;
|
||||
Size it = (Size) obj;
|
||||
return width == it.width && height == it.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (int)width + "x" + (int)height;
|
||||
}
|
||||
|
||||
}
|
92
modules/core/misc/java/src/java/core+TermCriteria.java
Normal file
92
modules/core/misc/java/src/java/core+TermCriteria.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package org.opencv.core;
|
||||
|
||||
//javadoc:TermCriteria
|
||||
public class TermCriteria {
|
||||
|
||||
/**
|
||||
* The maximum number of iterations or elements to compute
|
||||
*/
|
||||
public static final int COUNT = 1;
|
||||
/**
|
||||
* The maximum number of iterations or elements to compute
|
||||
*/
|
||||
public static final int MAX_ITER = COUNT;
|
||||
/**
|
||||
* The desired accuracy threshold or change in parameters at which the iterative algorithm is terminated.
|
||||
*/
|
||||
public static final int EPS = 2;
|
||||
|
||||
public int type;
|
||||
public int maxCount;
|
||||
public double epsilon;
|
||||
|
||||
/**
|
||||
* Termination criteria for iterative algorithms.
|
||||
*
|
||||
* @param type
|
||||
* the type of termination criteria: COUNT, EPS or COUNT + EPS.
|
||||
* @param maxCount
|
||||
* the maximum number of iterations/elements.
|
||||
* @param epsilon
|
||||
* the desired accuracy.
|
||||
*/
|
||||
public TermCriteria(int type, int maxCount, double epsilon) {
|
||||
this.type = type;
|
||||
this.maxCount = maxCount;
|
||||
this.epsilon = epsilon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Termination criteria for iterative algorithms.
|
||||
*/
|
||||
public TermCriteria() {
|
||||
this(0, 0, 0.0);
|
||||
}
|
||||
|
||||
public TermCriteria(double[] vals) {
|
||||
set(vals);
|
||||
}
|
||||
|
||||
public void set(double[] vals) {
|
||||
if (vals != null) {
|
||||
type = vals.length > 0 ? (int) vals[0] : 0;
|
||||
maxCount = vals.length > 1 ? (int) vals[1] : 0;
|
||||
epsilon = vals.length > 2 ? (double) vals[2] : 0;
|
||||
} else {
|
||||
type = 0;
|
||||
maxCount = 0;
|
||||
epsilon = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public TermCriteria clone() {
|
||||
return new TermCriteria(type, maxCount, epsilon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(type);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(maxCount);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(epsilon);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof TermCriteria)) return false;
|
||||
TermCriteria it = (TermCriteria) obj;
|
||||
return type == it.type && maxCount == it.maxCount && epsilon == it.epsilon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{ type: " + type + ", maxCount: " + maxCount + ", epsilon: " + epsilon + "}";
|
||||
}
|
||||
}
|
2013
modules/core/misc/java/test/CoreTest.java
Normal file
2013
modules/core/misc/java/test/CoreTest.java
Normal file
File diff suppressed because it is too large
Load Diff
63
modules/core/misc/java/test/CvTypeTest.java
Normal file
63
modules/core/misc/java/test/CvTypeTest.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class CvTypeTest extends OpenCVTestCase {
|
||||
|
||||
public void testMakeType() {
|
||||
assertEquals(CvType.CV_8UC4, CvType.makeType(CvType.CV_8U, 4));
|
||||
}
|
||||
|
||||
public void testCV_8UC() {
|
||||
assertEquals(CvType.CV_8UC4, CvType.CV_8UC(4));
|
||||
}
|
||||
|
||||
public void testCV_8SC() {
|
||||
assertEquals(CvType.CV_8SC4, CvType.CV_8SC(4));
|
||||
}
|
||||
|
||||
public void testCV_16UC() {
|
||||
assertEquals(CvType.CV_16UC4, CvType.CV_16UC(4));
|
||||
}
|
||||
|
||||
public void testCV_16SC() {
|
||||
assertEquals(CvType.CV_16SC4, CvType.CV_16SC(4));
|
||||
}
|
||||
|
||||
public void testCV_32SC() {
|
||||
assertEquals(CvType.CV_32SC4, CvType.CV_32SC(4));
|
||||
}
|
||||
|
||||
public void testCV_32FC() {
|
||||
assertEquals(CvType.CV_32FC4, CvType.CV_32FC(4));
|
||||
}
|
||||
|
||||
public void testCV_64FC() {
|
||||
assertEquals(CvType.CV_64FC4, CvType.CV_64FC(4));
|
||||
}
|
||||
|
||||
public void testChannels() {
|
||||
assertEquals(1, CvType.channels(CvType.CV_64F));
|
||||
}
|
||||
|
||||
public void testDepth() {
|
||||
assertEquals(CvType.CV_64F, CvType.depth(CvType.CV_64FC3));
|
||||
}
|
||||
|
||||
public void testIsInteger() {
|
||||
assertFalse(CvType.isInteger(CvType.CV_32FC3));
|
||||
assertTrue(CvType.isInteger(CvType.CV_16S));
|
||||
}
|
||||
|
||||
public void testELEM_SIZE() {
|
||||
assertEquals(3 * 8, CvType.ELEM_SIZE(CvType.CV_64FC3));
|
||||
}
|
||||
|
||||
public void testTypeToString() {
|
||||
assertEquals("CV_32FC1", CvType.typeToString(CvType.CV_32F));
|
||||
assertEquals("CV_32FC3", CvType.typeToString(CvType.CV_32FC3));
|
||||
assertEquals("CV_32FC(128)", CvType.typeToString(CvType.CV_32FC(128)));
|
||||
}
|
||||
|
||||
}
|
44
modules/core/misc/java/test/DMatchTest.java
Normal file
44
modules/core/misc/java/test/DMatchTest.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.DMatch;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class DMatchTest extends TestCase {
|
||||
public void testDMatch() {
|
||||
new DMatch();
|
||||
}
|
||||
|
||||
public void testDMatchIntIntFloat() {
|
||||
DMatch dm1 = new DMatch(1, 4, 4.0f);
|
||||
|
||||
assertEquals(1, dm1.queryIdx);
|
||||
assertEquals(4, dm1.trainIdx);
|
||||
assertEquals(4.0f, dm1.distance);
|
||||
}
|
||||
|
||||
public void testDMatchIntIntIntFloat() {
|
||||
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
|
||||
|
||||
assertEquals(2, dm2.queryIdx);
|
||||
assertEquals(6, dm2.trainIdx);
|
||||
assertEquals(-1, dm2.imgIdx);
|
||||
assertEquals(8.0f, dm2.distance);
|
||||
}
|
||||
|
||||
public void testLessThan() {
|
||||
DMatch dm1 = new DMatch(1, 4, 4.0f);
|
||||
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
|
||||
assertTrue(dm1.lessThan(dm2));
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
|
||||
|
||||
String actual = dm2.toString();
|
||||
|
||||
String expected = "DMatch [queryIdx=2, trainIdx=6, imgIdx=-1, distance=8.0]";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
71
modules/core/misc/java/test/KeyPointTest.java
Normal file
71
modules/core/misc/java/test/KeyPointTest.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class KeyPointTest extends OpenCVTestCase {
|
||||
|
||||
private float angle;
|
||||
private int classId;
|
||||
private KeyPoint keyPoint;
|
||||
private int octave;
|
||||
private float response;
|
||||
private float size;
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
keyPoint = null;
|
||||
x = 1.0f;
|
||||
y = 2.0f;
|
||||
size = 3.0f;
|
||||
angle = 30.0f;
|
||||
response = 2.0f;
|
||||
octave = 1;
|
||||
classId = 1;
|
||||
}
|
||||
|
||||
public void testKeyPoint() {
|
||||
keyPoint = new KeyPoint();
|
||||
assertPointEquals(new Point(0, 0), keyPoint.pt, EPS);
|
||||
}
|
||||
|
||||
public void testKeyPointFloatFloatFloat() {
|
||||
keyPoint = new KeyPoint(x, y, size);
|
||||
assertPointEquals(new Point(1, 2), keyPoint.pt, EPS);
|
||||
}
|
||||
|
||||
public void testKeyPointFloatFloatFloatFloat() {
|
||||
keyPoint = new KeyPoint(x, y, size, 10.0f);
|
||||
assertEquals(10.0f, keyPoint.angle);
|
||||
}
|
||||
|
||||
public void testKeyPointFloatFloatFloatFloatFloat() {
|
||||
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f);
|
||||
assertEquals(1.0f, keyPoint.response);
|
||||
}
|
||||
|
||||
public void testKeyPointFloatFloatFloatFloatFloatInt() {
|
||||
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1);
|
||||
assertEquals(1, keyPoint.octave);
|
||||
}
|
||||
|
||||
public void testKeyPointFloatFloatFloatFloatFloatIntInt() {
|
||||
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1, 1);
|
||||
assertEquals(1, keyPoint.class_id);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
keyPoint = new KeyPoint(x, y, size, angle, response, octave, classId);
|
||||
|
||||
String actual = keyPoint.toString();
|
||||
|
||||
String expected = "KeyPoint [pt={1.0, 2.0}, size=3.0, angle=30.0, response=2.0, octave=1, class_id=1]";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
1004
modules/core/misc/java/test/MatTest.java
Normal file
1004
modules/core/misc/java/test/MatTest.java
Normal file
File diff suppressed because it is too large
Load Diff
107
modules/core/misc/java/test/Point3Test.java
Normal file
107
modules/core/misc/java/test/Point3Test.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Point3;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class Point3Test extends OpenCVTestCase {
|
||||
|
||||
private Point3 p1;
|
||||
private Point3 p2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
p1 = new Point3(2, 2, 2);
|
||||
p2 = new Point3(1, 1, 1);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
Point3 truth = new Point3(1, 1, 1);
|
||||
p1 = truth.clone();
|
||||
assertEquals(truth, p1);
|
||||
}
|
||||
|
||||
public void testCross() {
|
||||
Point3 dstPoint = p1.cross(p2);
|
||||
Point3 truth = new Point3(0, 0, 0);
|
||||
assertEquals(truth, dstPoint);
|
||||
}
|
||||
|
||||
public void testDot() {
|
||||
double result = p1.dot(p2);
|
||||
assertEquals(6.0, result);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
boolean flag = p1.equals(p1);
|
||||
assertTrue(flag);
|
||||
|
||||
flag = p1.equals(p2);
|
||||
assertFalse(flag);
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(p1.hashCode(), p1.hashCode());
|
||||
}
|
||||
|
||||
public void testPoint3() {
|
||||
p1 = new Point3();
|
||||
|
||||
assertNotNull(p1);
|
||||
assertTrue(0 == p1.x);
|
||||
assertTrue(0 == p1.y);
|
||||
assertTrue(0 == p1.z);
|
||||
}
|
||||
|
||||
public void testPoint3DoubleArray() {
|
||||
double[] vals = { 1, 2, 3 };
|
||||
p1 = new Point3(vals);
|
||||
|
||||
assertTrue(1 == p1.x);
|
||||
assertTrue(2 == p1.y);
|
||||
assertTrue(3 == p1.z);
|
||||
}
|
||||
|
||||
public void testPoint3DoubleDoubleDouble() {
|
||||
p1 = new Point3(1, 2, 3);
|
||||
|
||||
assertEquals(1., p1.x);
|
||||
assertEquals(2., p1.y);
|
||||
assertEquals(3., p1.z);
|
||||
}
|
||||
|
||||
public void testPoint3Point() {
|
||||
Point p = new Point(2, 3);
|
||||
p1 = new Point3(p);
|
||||
|
||||
assertEquals(2., p1.x);
|
||||
assertEquals(3., p1.y);
|
||||
assertEquals(0., p1.z);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
p1.set(vals1);
|
||||
|
||||
assertEquals(0., p1.x);
|
||||
assertEquals(0., p1.y);
|
||||
assertEquals(0., p1.z);
|
||||
|
||||
double[] vals2 = { 3, 6, 10 };
|
||||
p1.set(vals2);
|
||||
|
||||
assertEquals(3., p1.x);
|
||||
assertEquals(6., p1.y);
|
||||
assertEquals(10., p1.z);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = p1.toString();
|
||||
String expected = "{2.0, 2.0, 2.0}";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
||||
}
|
93
modules/core/misc/java/test/PointTest.java
Normal file
93
modules/core/misc/java/test/PointTest.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class PointTest extends OpenCVTestCase {
|
||||
|
||||
private Point p1;
|
||||
private Point p2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
p1 = new Point(2, 2);
|
||||
p2 = new Point(1, 1);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
Point truth = new Point(1, 1);
|
||||
Point dstPoint = truth.clone();
|
||||
assertEquals(truth, dstPoint);
|
||||
}
|
||||
|
||||
public void testDot() {
|
||||
double result = p1.dot(p2);
|
||||
assertEquals(4.0, result);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
boolean flag = p1.equals(p1);
|
||||
assertTrue(flag);
|
||||
|
||||
flag = p1.equals(p2);
|
||||
assertFalse(flag);
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(p1.hashCode(), p1.hashCode());
|
||||
}
|
||||
|
||||
public void testInside() {
|
||||
Rect rect = new Rect(0, 0, 5, 3);
|
||||
assertTrue(p1.inside(rect));
|
||||
|
||||
Point p2 = new Point(3, 3);
|
||||
assertFalse(p2.inside(rect));
|
||||
}
|
||||
|
||||
public void testPoint() {
|
||||
Point p = new Point();
|
||||
|
||||
assertNotNull(p);
|
||||
assertEquals(0.0, p.x);
|
||||
assertEquals(0.0, p.y);
|
||||
}
|
||||
|
||||
public void testPointDoubleArray() {
|
||||
double[] vals = { 2, 4 };
|
||||
Point p = new Point(vals);
|
||||
|
||||
assertEquals(2.0, p.x);
|
||||
assertEquals(4.0, p.y);
|
||||
}
|
||||
|
||||
public void testPointDoubleDouble() {
|
||||
p1 = new Point(7, 5);
|
||||
|
||||
assertNotNull(p1);
|
||||
assertEquals(7.0, p1.x);
|
||||
assertEquals(5.0, p1.y);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
p1.set(vals1);
|
||||
assertEquals(0.0, p1.x);
|
||||
assertEquals(0.0, p1.y);
|
||||
|
||||
double[] vals2 = { 6, 10 };
|
||||
p2.set(vals2);
|
||||
assertEquals(6.0, p2.x);
|
||||
assertEquals(10.0, p2.y);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = p1.toString();
|
||||
String expected = "{2.0, 2.0}";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
113
modules/core/misc/java/test/RangeTest.java
Normal file
113
modules/core/misc/java/test/RangeTest.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Range;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class RangeTest extends OpenCVTestCase {
|
||||
|
||||
Range r1;
|
||||
Range r2;
|
||||
Range range;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
range = new Range();
|
||||
r1 = new Range(1, 11);
|
||||
r2 = new Range(1, 1);
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
range = Range.all();
|
||||
assertEquals(Integer.MIN_VALUE, range.start);
|
||||
assertEquals(Integer.MAX_VALUE, range.end);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
Range dstRange = new Range();
|
||||
dstRange = r1.clone();
|
||||
assertEquals(r1, dstRange);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
boolean flag;
|
||||
|
||||
flag = r1.empty();
|
||||
assertFalse(flag);
|
||||
|
||||
flag = r2.empty();
|
||||
assertTrue(flag);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
assertFalse(r2.equals(r1));
|
||||
|
||||
range = r1.clone();
|
||||
assertTrue(r1.equals(range));
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(r1.hashCode(), r1.hashCode());
|
||||
}
|
||||
|
||||
public void testIntersection() {
|
||||
range = r1.intersection(r2);
|
||||
assertEquals(r2, range);
|
||||
}
|
||||
|
||||
public void testRange() {
|
||||
range = new Range();
|
||||
|
||||
assertNotNull(range);
|
||||
assertEquals(0, range.start);
|
||||
assertEquals(0, range.end);
|
||||
}
|
||||
|
||||
public void testRangeDoubleArray() {
|
||||
double[] vals = { 2, 4 };
|
||||
Range r = new Range(vals);
|
||||
|
||||
assertTrue(2 == r.start);
|
||||
assertTrue(4 == r.end);
|
||||
}
|
||||
|
||||
public void testRangeIntInt() {
|
||||
r1 = new Range(12, 13);
|
||||
|
||||
assertNotNull(r1);
|
||||
assertEquals(12, r1.start);
|
||||
assertEquals(13, r1.end);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
r1.set(vals1);
|
||||
assertEquals(0, r1.start);
|
||||
assertEquals(0, r1.end);
|
||||
|
||||
double[] vals2 = { 6, 10 };
|
||||
r2.set(vals2);
|
||||
assertEquals(6, r2.start);
|
||||
assertEquals(10, r2.end);
|
||||
}
|
||||
|
||||
public void testShift() {
|
||||
int delta = 1;
|
||||
range = range.shift(delta);
|
||||
assertEquals(r2, range);
|
||||
}
|
||||
|
||||
public void testSize() {
|
||||
assertEquals(10, r1.size());
|
||||
|
||||
assertEquals(0, r2.size());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = r1.toString();
|
||||
String expected = "[1, 11)";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
163
modules/core/misc/java/test/RectTest.java
Normal file
163
modules/core/misc/java/test/RectTest.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class RectTest extends OpenCVTestCase {
|
||||
|
||||
private Rect r;
|
||||
private Rect rect;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
r = new Rect();
|
||||
rect = new Rect(0, 0, 10, 10);
|
||||
}
|
||||
|
||||
public void testArea() {
|
||||
double area;
|
||||
area = rect.area();
|
||||
assertEquals(100.0, area);
|
||||
}
|
||||
|
||||
public void testBr() {
|
||||
Point p_br = new Point();
|
||||
p_br = rect.br();
|
||||
Point truth = new Point(10, 10);
|
||||
assertEquals(truth, p_br);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
r = rect.clone();
|
||||
assertEquals(rect, r);
|
||||
}
|
||||
|
||||
public void testContains() {
|
||||
Rect rect = new Rect(0, 0, 10, 10);
|
||||
|
||||
Point p_inner = new Point(5, 5);
|
||||
Point p_outer = new Point(5, 55);
|
||||
Point p_bl = new Point(0, 0);
|
||||
Point p_br = new Point(10, 0);
|
||||
Point p_tl = new Point(0, 10);
|
||||
Point p_tr = new Point(10, 10);
|
||||
|
||||
assertTrue(rect.contains(p_inner));
|
||||
assertTrue(rect.contains(p_bl));
|
||||
|
||||
assertFalse(rect.contains(p_outer));
|
||||
assertFalse(rect.contains(p_br));
|
||||
assertFalse(rect.contains(p_tl));
|
||||
assertFalse(rect.contains(p_tr));
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
boolean flag;
|
||||
flag = rect.equals(r);
|
||||
assertFalse(flag);
|
||||
|
||||
r = rect.clone();
|
||||
flag = rect.equals(r);
|
||||
assertTrue(flag);
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(rect.hashCode(), rect.hashCode());
|
||||
}
|
||||
|
||||
public void testRect() {
|
||||
r = new Rect();
|
||||
|
||||
assertEquals(0, r.x);
|
||||
assertEquals(0, r.y);
|
||||
assertEquals(0, r.width);
|
||||
assertEquals(0, r.height);
|
||||
}
|
||||
|
||||
public void testRectDoubleArray() {
|
||||
double[] vals = { 1, 3, 5, 2 };
|
||||
r = new Rect(vals);
|
||||
|
||||
assertEquals(1, r.x);
|
||||
assertEquals(3, r.y);
|
||||
assertEquals(5, r.width);
|
||||
assertEquals(2, r.height);
|
||||
}
|
||||
|
||||
public void testRectIntIntIntInt() {
|
||||
r = new Rect(1, 3, 5, 2);
|
||||
|
||||
assertNotNull(rect);
|
||||
assertEquals(0, rect.x);
|
||||
assertEquals(0, rect.y);
|
||||
assertEquals(10, rect.width);
|
||||
assertEquals(10, rect.height);
|
||||
}
|
||||
|
||||
public void testRectPointPoint() {
|
||||
Point p1 = new Point(4, 4);
|
||||
Point p2 = new Point(2, 3);
|
||||
|
||||
r = new Rect(p1, p2);
|
||||
assertNotNull(r);
|
||||
assertEquals(2, r.x);
|
||||
assertEquals(3, r.y);
|
||||
assertEquals(2, r.width);
|
||||
assertEquals(1, r.height);
|
||||
}
|
||||
|
||||
public void testRectPointSize() {
|
||||
Point p1 = new Point(4, 4);
|
||||
Size sz = new Size(3, 1);
|
||||
r = new Rect(p1, sz);
|
||||
|
||||
assertEquals(4, r.x);
|
||||
assertEquals(4, r.y);
|
||||
assertEquals(3, r.width);
|
||||
assertEquals(1, r.height);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
Rect r1 = new Rect(vals1);
|
||||
|
||||
assertEquals(0, r1.x);
|
||||
assertEquals(0, r1.y);
|
||||
assertEquals(0, r1.width);
|
||||
assertEquals(0, r1.height);
|
||||
|
||||
double[] vals2 = { 2, 2, 10, 5 };
|
||||
r = new Rect(vals2);
|
||||
|
||||
assertEquals(2, r.x);
|
||||
assertEquals(2, r.y);
|
||||
assertEquals(10, r.width);
|
||||
assertEquals(5, r.height);
|
||||
}
|
||||
|
||||
public void testSize() {
|
||||
Size s1 = new Size(0, 0);
|
||||
assertEquals(s1, r.size());
|
||||
|
||||
Size s2 = new Size(10, 10);
|
||||
assertEquals(s2, rect.size());
|
||||
}
|
||||
|
||||
public void testTl() {
|
||||
Point p_tl = new Point();
|
||||
p_tl = rect.tl();
|
||||
Point truth = new Point(0, 0);
|
||||
assertEquals(truth, p_tl);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = rect.toString();
|
||||
String expected = "{0, 0, 10x10}";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
191
modules/core/misc/java/test/RotatedRectTest.java
Normal file
191
modules/core/misc/java/test/RotatedRectTest.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.RotatedRect;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class RotatedRectTest extends OpenCVTestCase {
|
||||
|
||||
private double angle;
|
||||
private Point center;
|
||||
private Size size;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
center = new Point(matSize / 2, matSize / 2);
|
||||
size = new Size(matSize / 4, matSize / 2);
|
||||
angle = 40;
|
||||
}
|
||||
|
||||
public void testBoundingRect() {
|
||||
size = new Size(matSize / 2, matSize / 2);
|
||||
assertEquals(size.height, size.width);
|
||||
double length = size.height;
|
||||
|
||||
angle = 45;
|
||||
RotatedRect rr = new RotatedRect(center, size, angle);
|
||||
|
||||
Rect r = rr.boundingRect();
|
||||
double halfDiagonal = length * Math.sqrt(2) / 2;
|
||||
|
||||
assertTrue((r.x == Math.floor(center.x - halfDiagonal)) && (r.y == Math.floor(center.y - halfDiagonal)));
|
||||
|
||||
assertTrue((r.br().x >= Math.ceil(center.x + halfDiagonal)) && (r.br().y >= Math.ceil(center.y + halfDiagonal)));
|
||||
|
||||
assertTrue((r.br().x - Math.ceil(center.x + halfDiagonal)) <= 1 && (r.br().y - Math.ceil(center.y + halfDiagonal)) <= 1);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
RotatedRect rrect = new RotatedRect(center, size, angle);
|
||||
RotatedRect clone = rrect.clone();
|
||||
|
||||
assertTrue(clone != null);
|
||||
assertTrue(rrect.center.equals(clone.center));
|
||||
assertTrue(rrect.size.equals(clone.size));
|
||||
assertTrue(rrect.angle == clone.angle);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
Point center2 = new Point(matSize / 3, matSize / 1.5);
|
||||
Size size2 = new Size(matSize / 2, matSize / 4);
|
||||
double angle2 = 0;
|
||||
|
||||
RotatedRect rrect1 = new RotatedRect(center, size, angle);
|
||||
RotatedRect rrect2 = new RotatedRect(center2, size2, angle2);
|
||||
RotatedRect rrect3 = rrect1;
|
||||
RotatedRect clone1 = rrect1.clone();
|
||||
RotatedRect clone2 = rrect2.clone();
|
||||
|
||||
assertTrue(rrect1.equals(rrect3));
|
||||
assertTrue(!rrect1.equals(rrect2));
|
||||
|
||||
assertTrue(rrect2.equals(clone2));
|
||||
clone2.angle = 10;
|
||||
assertTrue(!rrect2.equals(clone2));
|
||||
|
||||
assertTrue(rrect1.equals(clone1));
|
||||
|
||||
clone1.center.x += 1;
|
||||
assertTrue(!rrect1.equals(clone1));
|
||||
|
||||
clone1.center.x -= 1;
|
||||
assertTrue(rrect1.equals(clone1));
|
||||
|
||||
clone1.size.width += 1;
|
||||
assertTrue(!rrect1.equals(clone1));
|
||||
|
||||
assertTrue(!rrect1.equals(size));
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
RotatedRect rr = new RotatedRect(center, size, angle);
|
||||
assertEquals(rr.hashCode(), rr.hashCode());
|
||||
}
|
||||
|
||||
public void testPoints() {
|
||||
RotatedRect rrect = new RotatedRect(center, size, angle);
|
||||
|
||||
Point p[] = new Point[4];
|
||||
rrect.points(p);
|
||||
|
||||
boolean is_p0_irrational = (100 * p[0].x != (int) (100 * p[0].x)) && (100 * p[0].y != (int) (100 * p[0].y));
|
||||
boolean is_p1_irrational = (100 * p[1].x != (int) (100 * p[1].x)) && (100 * p[1].y != (int) (100 * p[1].y));
|
||||
boolean is_p2_irrational = (100 * p[2].x != (int) (100 * p[2].x)) && (100 * p[2].y != (int) (100 * p[2].y));
|
||||
boolean is_p3_irrational = (100 * p[3].x != (int) (100 * p[3].x)) && (100 * p[3].y != (int) (100 * p[3].y));
|
||||
|
||||
assertTrue(is_p0_irrational && is_p1_irrational && is_p2_irrational && is_p3_irrational);
|
||||
|
||||
assertTrue("Symmetric points 0 and 2",
|
||||
Math.abs((p[0].x + p[2].x) / 2 - center.x) + Math.abs((p[0].y + p[2].y) / 2 - center.y) < EPS);
|
||||
|
||||
assertTrue("Symmetric points 1 and 3",
|
||||
Math.abs((p[1].x + p[3].x) / 2 - center.x) + Math.abs((p[1].y + p[3].y) / 2 - center.y) < EPS);
|
||||
|
||||
assertTrue("Orthogonal vectors 01 and 12",
|
||||
Math.abs((p[1].x - p[0].x) * (p[2].x - p[1].x) +
|
||||
(p[1].y - p[0].y) * (p[2].y - p[1].y)) < EPS);
|
||||
|
||||
assertTrue("Orthogonal vectors 12 and 23",
|
||||
Math.abs((p[2].x - p[1].x) * (p[3].x - p[2].x) +
|
||||
(p[2].y - p[1].y) * (p[3].y - p[2].y)) < EPS);
|
||||
|
||||
assertTrue("Orthogonal vectors 23 and 30",
|
||||
Math.abs((p[3].x - p[2].x) * (p[0].x - p[3].x) +
|
||||
(p[3].y - p[2].y) * (p[0].y - p[3].y)) < EPS);
|
||||
|
||||
assertTrue("Orthogonal vectors 30 and 01",
|
||||
Math.abs((p[0].x - p[3].x) * (p[1].x - p[0].x) +
|
||||
(p[0].y - p[3].y) * (p[1].y - p[0].y)) < EPS);
|
||||
|
||||
assertTrue("Length of the vector 01",
|
||||
Math.abs((p[1].x - p[0].x) * (p[1].x - p[0].x) +
|
||||
(p[1].y - p[0].y) * (p[1].y - p[0].y) - size.height * size.height) < EPS);
|
||||
|
||||
assertTrue("Length of the vector 21",
|
||||
Math.abs((p[1].x - p[2].x) * (p[1].x - p[2].x) +
|
||||
(p[1].y - p[2].y) * (p[1].y - p[2].y) - size.width * size.width) < EPS);
|
||||
|
||||
assertTrue("Angle of the vector 21 with the axes", Math.abs((p[2].x - p[1].x) / size.width - Math.cos(angle * Math.PI / 180)) < EPS);
|
||||
}
|
||||
|
||||
public void testRotatedRect() {
|
||||
RotatedRect rr = new RotatedRect();
|
||||
|
||||
assertTrue(rr != null);
|
||||
assertTrue(rr.center != null);
|
||||
assertTrue(rr.size != null);
|
||||
assertTrue(rr.angle == 0.0);
|
||||
}
|
||||
|
||||
public void testRotatedRectDoubleArray() {
|
||||
double[] vals = { 1.5, 2.6, 3.7, 4.2, 5.1 };
|
||||
RotatedRect rr = new RotatedRect(vals);
|
||||
|
||||
assertNotNull(rr);
|
||||
assertEquals(1.5, rr.center.x);
|
||||
assertEquals(2.6, rr.center.y);
|
||||
assertEquals(3.7, rr.size.width);
|
||||
assertEquals(4.2, rr.size.height);
|
||||
assertEquals(5.1, rr.angle);
|
||||
}
|
||||
|
||||
public void testRotatedRectPointSizeDouble() {
|
||||
RotatedRect rr = new RotatedRect(center, size, 40);
|
||||
|
||||
assertTrue(rr != null);
|
||||
assertTrue(rr.center != null);
|
||||
assertTrue(rr.size != null);
|
||||
assertTrue(rr.angle == 40.0);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
RotatedRect r1 = new RotatedRect(center, size, 40);
|
||||
|
||||
r1.set(vals1);
|
||||
|
||||
assertEquals(0., r1.angle);
|
||||
assertPointEquals(new Point(0, 0), r1.center, EPS);
|
||||
assertSizeEquals(new Size(0, 0), r1.size, EPS);
|
||||
|
||||
double[] vals2 = { 1, 2, 3, 4, 5 };
|
||||
RotatedRect r2 = new RotatedRect(center, size, 40);
|
||||
|
||||
r2.set(vals2);
|
||||
|
||||
assertEquals(5., r2.angle);
|
||||
assertPointEquals(new Point(1, 2), r2.center, EPS);
|
||||
assertSizeEquals(new Size(3, 4), r2.size, EPS);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = new RotatedRect(new Point(1, 2), new Size(10, 12), 4.5).toString();
|
||||
String expected = "{ {1.0, 2.0} 10x12 * 4.5 }";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
110
modules/core/misc/java/test/ScalarTest.java
Normal file
110
modules/core/misc/java/test/ScalarTest.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class ScalarTest extends OpenCVTestCase {
|
||||
|
||||
private Scalar dstScalar;
|
||||
private Scalar s1;
|
||||
private Scalar s2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
s1 = new Scalar(1.0);
|
||||
s2 = Scalar.all(1.0);
|
||||
dstScalar = null;
|
||||
}
|
||||
|
||||
public void testAll() {
|
||||
dstScalar = Scalar.all(2.0);
|
||||
Scalar truth = new Scalar(2.0, 2.0, 2.0, 2.0);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
dstScalar = s2.clone();
|
||||
assertEquals(s2, dstScalar);
|
||||
}
|
||||
|
||||
public void testConj() {
|
||||
dstScalar = s2.conj();
|
||||
Scalar truth = new Scalar(1, -1, -1, -1);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
dstScalar = s2.clone();
|
||||
assertTrue(s2.equals(dstScalar));
|
||||
|
||||
assertFalse(s2.equals(s1));
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(s2.hashCode(), s2.hashCode());
|
||||
}
|
||||
|
||||
public void testIsReal() {
|
||||
assertTrue(s1.isReal());
|
||||
|
||||
assertFalse(s2.isReal());
|
||||
}
|
||||
|
||||
public void testMulScalar() {
|
||||
dstScalar = s2.mul(s1);
|
||||
assertEquals(s1, dstScalar);
|
||||
}
|
||||
|
||||
public void testMulScalarDouble() {
|
||||
double multiplier = 2.0;
|
||||
dstScalar = s2.mul(s1, multiplier);
|
||||
Scalar truth = new Scalar(2);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testScalarDouble() {
|
||||
Scalar truth = new Scalar(1);
|
||||
assertEquals(truth, s1);
|
||||
}
|
||||
|
||||
public void testScalarDoubleArray() {
|
||||
double[] vals = { 2.0, 4.0, 5.0, 3.0 };
|
||||
dstScalar = new Scalar(vals);
|
||||
|
||||
Scalar truth = new Scalar(2.0, 4.0, 5.0, 3.0);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testScalarDoubleDouble() {
|
||||
dstScalar = new Scalar(2, 5);
|
||||
Scalar truth = new Scalar(2.0, 5.0, 0.0, 0.0);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testScalarDoubleDoubleDouble() {
|
||||
dstScalar = new Scalar(2.0, 5.0, 5.0);
|
||||
Scalar truth = new Scalar(2.0, 5.0, 5.0, 0.0);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testScalarDoubleDoubleDoubleDouble() {
|
||||
dstScalar = new Scalar(2.0, 5.0, 5.0, 9.0);
|
||||
Scalar truth = new Scalar(2.0, 5.0, 5.0, 9.0);
|
||||
assertEquals(truth, dstScalar);
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals = { 1.0, 1.0, 1.0, 1.0 };
|
||||
s1.set(vals);
|
||||
assertEquals(s2, s1);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = s2.toString();
|
||||
String expected = "[1.0, 1.0, 1.0, 1.0]";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
93
modules/core/misc/java/test/SizeTest.java
Normal file
93
modules/core/misc/java/test/SizeTest.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class SizeTest extends OpenCVTestCase {
|
||||
|
||||
Size dstSize;
|
||||
Size sz1;
|
||||
Size sz2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
sz1 = new Size(10.0, 10.0);
|
||||
sz2 = new Size(-1, -1);
|
||||
dstSize = null;
|
||||
}
|
||||
|
||||
public void testArea() {
|
||||
double area = sz1.area();
|
||||
assertEquals(100.0, area);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
dstSize = sz1.clone();
|
||||
assertEquals(sz1, dstSize);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
assertFalse(sz1.equals(sz2));
|
||||
|
||||
sz2 = sz1.clone();
|
||||
assertTrue(sz1.equals(sz2));
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(sz1.hashCode(), sz1.hashCode());
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
sz2.set(vals1);
|
||||
assertEquals(0., sz2.width);
|
||||
assertEquals(0., sz2.height);
|
||||
|
||||
double[] vals2 = { 9, 12 };
|
||||
sz1.set(vals2);
|
||||
assertEquals(9., sz1.width);
|
||||
assertEquals(12., sz1.height);
|
||||
}
|
||||
|
||||
public void testSize() {
|
||||
dstSize = new Size();
|
||||
|
||||
assertNotNull(dstSize);
|
||||
assertEquals(0., dstSize.width);
|
||||
assertEquals(0., dstSize.height);
|
||||
}
|
||||
|
||||
public void testSizeDoubleArray() {
|
||||
double[] vals = { 10, 20 };
|
||||
sz2 = new Size(vals);
|
||||
|
||||
assertEquals(10., sz2.width);
|
||||
assertEquals(20., sz2.height);
|
||||
}
|
||||
|
||||
public void testSizeDoubleDouble() {
|
||||
assertNotNull(sz1);
|
||||
|
||||
assertEquals(10.0, sz1.width);
|
||||
assertEquals(10.0, sz1.height);
|
||||
}
|
||||
|
||||
public void testSizePoint() {
|
||||
Point p = new Point(2, 4);
|
||||
sz1 = new Size(p);
|
||||
|
||||
assertNotNull(sz1);
|
||||
assertEquals(2.0, sz1.width);
|
||||
assertEquals(4.0, sz1.height);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = sz1.toString();
|
||||
String expected = "10x10";
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
86
modules/core/misc/java/test/TermCriteriaTest.java
Normal file
86
modules/core/misc/java/test/TermCriteriaTest.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.TermCriteria;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class TermCriteriaTest extends OpenCVTestCase {
|
||||
|
||||
private TermCriteria tc1;
|
||||
private TermCriteria tc2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
tc1 = new TermCriteria();
|
||||
tc2 = new TermCriteria(2, 4, EPS);
|
||||
}
|
||||
|
||||
public void testClone() {
|
||||
tc1 = tc2.clone();
|
||||
assertEquals(tc2, tc1);
|
||||
}
|
||||
|
||||
public void testEqualsObject() {
|
||||
assertFalse(tc2.equals(tc1));
|
||||
|
||||
tc1 = tc2.clone();
|
||||
assertTrue(tc2.equals(tc1));
|
||||
}
|
||||
|
||||
public void testHashCode() {
|
||||
assertEquals(tc2.hashCode(), tc2.hashCode());
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
double[] vals1 = {};
|
||||
tc1.set(vals1);
|
||||
|
||||
assertEquals(0, tc1.type);
|
||||
assertEquals(0, tc1.maxCount);
|
||||
assertEquals(0.0, tc1.epsilon);
|
||||
|
||||
double[] vals2 = { 9, 8, 0.002 };
|
||||
tc2.set(vals2);
|
||||
|
||||
assertEquals(9, tc2.type);
|
||||
assertEquals(8, tc2.maxCount);
|
||||
assertEquals(0.002, tc2.epsilon);
|
||||
}
|
||||
|
||||
public void testTermCriteria() {
|
||||
tc1 = new TermCriteria();
|
||||
|
||||
assertNotNull(tc1);
|
||||
assertEquals(0, tc1.type);
|
||||
assertEquals(0, tc1.maxCount);
|
||||
assertEquals(0.0, tc1.epsilon);
|
||||
}
|
||||
|
||||
public void testTermCriteriaDoubleArray() {
|
||||
double[] vals = { 3, 2, 0.007 };
|
||||
tc1 = new TermCriteria(vals);
|
||||
|
||||
assertEquals(3, tc1.type);
|
||||
assertEquals(2, tc1.maxCount);
|
||||
assertEquals(0.007, tc1.epsilon);
|
||||
}
|
||||
|
||||
public void testTermCriteriaIntIntDouble() {
|
||||
tc1 = new TermCriteria(2, 4, EPS);
|
||||
|
||||
assertNotNull(tc2);
|
||||
assertEquals(2, tc2.type);
|
||||
assertEquals(4, tc2.maxCount);
|
||||
assertEquals(EPS, tc2.epsilon);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
String actual = tc2.toString();
|
||||
double eps = EPS;
|
||||
String expected = "{ type: 2, maxCount: 4, epsilon: " + eps + "}";
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -2256,51 +2256,54 @@ void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray mask, int dtype )
|
||||
{
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat();
|
||||
bool src1Scalar = checkScalar(src1, _src2.type(), kind1, kind2);
|
||||
bool src2Scalar = checkScalar(src2, _src1.type(), kind2, kind1);
|
||||
|
||||
if (!src1Scalar && !src2Scalar &&
|
||||
src1.depth() == CV_8U && src2.type() == src1.type() &&
|
||||
src1.dims == 2 && src2.size() == src1.size() &&
|
||||
mask.empty())
|
||||
if (tegra::useTegra())
|
||||
{
|
||||
if (dtype < 0)
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat();
|
||||
bool src1Scalar = checkScalar(src1, _src2.type(), kind1, kind2);
|
||||
bool src2Scalar = checkScalar(src2, _src1.type(), kind2, kind1);
|
||||
|
||||
if (!src1Scalar && !src2Scalar &&
|
||||
src1.depth() == CV_8U && src2.type() == src1.type() &&
|
||||
src1.dims == 2 && src2.size() == src1.size() &&
|
||||
mask.empty())
|
||||
{
|
||||
if (_dst.fixedType())
|
||||
if (dtype < 0)
|
||||
{
|
||||
dtype = _dst.depth();
|
||||
if (_dst.fixedType())
|
||||
{
|
||||
dtype = _dst.depth();
|
||||
}
|
||||
else
|
||||
{
|
||||
dtype = src1.depth();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dtype = src1.depth();
|
||||
}
|
||||
}
|
||||
|
||||
dtype = CV_MAT_DEPTH(dtype);
|
||||
dtype = CV_MAT_DEPTH(dtype);
|
||||
|
||||
if (!_dst.fixedType() || dtype == _dst.depth())
|
||||
{
|
||||
_dst.create(src1.size(), CV_MAKE_TYPE(dtype, src1.channels()));
|
||||
if (!_dst.fixedType() || dtype == _dst.depth())
|
||||
{
|
||||
_dst.create(src1.size(), CV_MAKE_TYPE(dtype, src1.channels()));
|
||||
|
||||
if (dtype == CV_16S)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u16s(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_32F)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u32f(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_8S)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u8s(src1, src2, dst))
|
||||
return;
|
||||
if (dtype == CV_16S)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u16s(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_32F)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u32f(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_8S)
|
||||
{
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u8s(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -504,7 +504,7 @@ cvInitNArrayIterator( int count, CvArr** arrs,
|
||||
CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator )
|
||||
{
|
||||
assert( iterator != 0 );
|
||||
int i, dims, size = 0;
|
||||
int i, dims;
|
||||
|
||||
for( dims = iterator->dims; dims > 0; dims-- )
|
||||
{
|
||||
@@ -514,7 +514,7 @@ CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator )
|
||||
if( --iterator->stack[dims-1] > 0 )
|
||||
break;
|
||||
|
||||
size = iterator->hdr[0]->dim[dims-1].size;
|
||||
const int size = iterator->hdr[0]->dim[dims-1].size;
|
||||
|
||||
for( i = 0; i < iterator->count; i++ )
|
||||
iterator->ptr[i] -= (size_t)size*iterator->hdr[i]->dim[dims-1].step;
|
||||
@@ -856,7 +856,6 @@ cvCreateData( CvArr* arr )
|
||||
else if( CV_IS_MATND_HDR( arr ))
|
||||
{
|
||||
CvMatND* mat = (CvMatND*)arr;
|
||||
int i;
|
||||
size_t total_size = CV_ELEM_SIZE(mat->type);
|
||||
|
||||
if( mat->dim[0].size == 0 )
|
||||
@@ -872,6 +871,7 @@ cvCreateData( CvArr* arr )
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for( i = mat->dims - 1; i >= 0; i-- )
|
||||
{
|
||||
size_t size = (size_t)mat->dim[i].step*mat->dim[i].size;
|
||||
@@ -1055,16 +1055,19 @@ cvGetRawData( const CvArr* arr, uchar** data, int* step, CvSize* roi_size )
|
||||
|
||||
if( roi_size || step )
|
||||
{
|
||||
int i, size1 = mat->dim[0].size, size2 = 1;
|
||||
|
||||
if( mat->dims > 2 )
|
||||
for( i = 1; i < mat->dims; i++ )
|
||||
size1 *= mat->dim[i].size;
|
||||
else
|
||||
size2 = mat->dim[1].size;
|
||||
|
||||
if( roi_size )
|
||||
{
|
||||
int size1 = mat->dim[0].size, size2 = 1;
|
||||
|
||||
if( mat->dims > 2 )
|
||||
{
|
||||
int i;
|
||||
for( i = 1; i < mat->dims; i++ )
|
||||
size1 *= mat->dim[i].size;
|
||||
}
|
||||
else
|
||||
size2 = mat->dim[1].size;
|
||||
|
||||
roi_size->width = size2;
|
||||
roi_size->height = size1;
|
||||
}
|
||||
@@ -2458,7 +2461,6 @@ cvGetMat( const CvArr* array, CvMat* mat,
|
||||
else if( allowND && CV_IS_MATND_HDR(src) )
|
||||
{
|
||||
CvMatND* matnd = (CvMatND*)src;
|
||||
int i;
|
||||
int size1 = matnd->dim[0].size, size2 = 1;
|
||||
|
||||
if( !src->data.ptr )
|
||||
@@ -2468,8 +2470,11 @@ cvGetMat( const CvArr* array, CvMat* mat,
|
||||
CV_Error( CV_StsBadArg, "Only continuous nD arrays are supported here" );
|
||||
|
||||
if( matnd->dims > 2 )
|
||||
{
|
||||
int i;
|
||||
for( i = 1; i < matnd->dims; i++ )
|
||||
size2 *= matnd->dim[i].size;
|
||||
}
|
||||
else
|
||||
size2 = matnd->dims == 1 ? 1 : matnd->dim[1].size;
|
||||
|
||||
@@ -2785,7 +2790,6 @@ cvGetImage( const CvArr* array, IplImage* img )
|
||||
{
|
||||
IplImage* result = 0;
|
||||
const IplImage* src = (const IplImage*)array;
|
||||
int depth;
|
||||
|
||||
if( !img )
|
||||
CV_Error( CV_StsNullPtr, "" );
|
||||
@@ -2800,7 +2804,7 @@ cvGetImage( const CvArr* array, IplImage* img )
|
||||
if( mat->data.ptr == 0 )
|
||||
CV_Error( CV_StsNullPtr, "" );
|
||||
|
||||
depth = cvIplDepth(mat->type);
|
||||
int depth = cvIplDepth(mat->type);
|
||||
|
||||
cvInitImageHeader( img, cvSize(mat->cols, mat->rows),
|
||||
depth, CV_MAT_CN(mat->type) );
|
||||
|
@@ -136,7 +136,6 @@ namespace cv
|
||||
dprintf(("d first time\n"));print_matrix(d);
|
||||
dprintf(("r\n"));print_matrix(r);
|
||||
|
||||
double beta=0;
|
||||
for(int count=0;count<_termcrit.maxCount;count++){
|
||||
minimizeOnTheLine(_Function,proxy_x,d,minimizeOnTheLine_buf1,minimizeOnTheLine_buf2);
|
||||
r.copyTo(r_old);
|
||||
@@ -147,7 +146,7 @@ namespace cv
|
||||
break;
|
||||
}
|
||||
r_norm_sq=r_norm_sq*r_norm_sq;
|
||||
beta=MAX(0.0,(r_norm_sq-r.dot(r_old))/r_norm_sq);
|
||||
double beta=MAX(0.0,(r_norm_sq-r.dot(r_old))/r_norm_sq);
|
||||
d=r+beta*d;
|
||||
}
|
||||
|
||||
|
@@ -115,10 +115,10 @@ copyMask_<uchar>(const uchar* _src, size_t sstep, const uchar* mask, size_t mste
|
||||
}
|
||||
}
|
||||
#elif CV_NEON
|
||||
uint8x16_t v_zero = vdupq_n_u8(0);
|
||||
uint8x16_t v_one = vdupq_n_u8(1);
|
||||
for( ; x <= size.width - 16; x += 16 )
|
||||
{
|
||||
uint8x16_t v_mask = vcgtq_u8(vld1q_u8(mask + x), v_zero);
|
||||
uint8x16_t v_mask = vcgeq_u8(vld1q_u8(mask + x), v_one);
|
||||
uint8x16_t v_dst = vld1q_u8(dst + x), v_src = vld1q_u8(src + x);
|
||||
vst1q_u8(dst + x, vbslq_u8(v_mask, v_src, v_dst));
|
||||
}
|
||||
@@ -165,10 +165,10 @@ copyMask_<ushort>(const uchar* _src, size_t sstep, const uchar* mask, size_t mst
|
||||
}
|
||||
}
|
||||
#elif CV_NEON
|
||||
uint8x8_t v_zero = vdup_n_u8(0);
|
||||
uint8x8_t v_one = vdup_n_u8(1);
|
||||
for( ; x <= size.width - 8; x += 8 )
|
||||
{
|
||||
uint8x8_t v_mask = vcgt_u8(vld1_u8(mask + x), v_zero);
|
||||
uint8x8_t v_mask = vcge_u8(vld1_u8(mask + x), v_one);
|
||||
uint8x8x2_t v_mask2 = vzip_u8(v_mask, v_mask);
|
||||
uint16x8_t v_mask_res = vreinterpretq_u16_u8(vcombine_u8(v_mask2.val[0], v_mask2.val[1]));
|
||||
|
||||
|
@@ -56,14 +56,14 @@ namespace
|
||||
|
||||
struct DIR
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
WIN32_FIND_DATAW data;
|
||||
#else
|
||||
WIN32_FIND_DATA data;
|
||||
#endif
|
||||
HANDLE handle;
|
||||
dirent ent;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
DIR() { }
|
||||
~DIR()
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace
|
||||
{
|
||||
DIR* dir = new DIR;
|
||||
dir->ent.d_name = 0;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
cv::String full_path = cv::String(path) + "\\*";
|
||||
wchar_t wfull_path[MAX_PATH];
|
||||
size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH);
|
||||
@@ -99,7 +99,7 @@ namespace
|
||||
|
||||
dirent* readdir(DIR* dir)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
if (dir->ent.d_name != 0)
|
||||
{
|
||||
if (::FindNextFileW(dir->handle, &dir->data) != TRUE)
|
||||
@@ -147,7 +147,7 @@ static bool isDir(const cv::String& path, DIR* dir)
|
||||
else
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
wchar_t wpath[MAX_PATH];
|
||||
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
|
||||
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
|
||||
|
@@ -180,10 +180,9 @@ public:
|
||||
const int K = centers.rows;
|
||||
const int dims = centers.cols;
|
||||
|
||||
const float *sample;
|
||||
for( int i = begin; i<end; ++i)
|
||||
{
|
||||
sample = data.ptr<float>(i);
|
||||
const float *sample = data.ptr<float>(i);
|
||||
int k_best = 0;
|
||||
double min_dist = DBL_MAX;
|
||||
|
||||
|
@@ -127,7 +127,7 @@ static void FastAtan2_32f(const float *Y, const float *X, float *angle, int len,
|
||||
float scale = angleInDegrees ? 1 : (float)(CV_PI/180);
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if (tegra::FastAtan2_32f(Y, X, angle, len, scale))
|
||||
if (tegra::useTegra() && tegra::FastAtan2_32f(Y, X, angle, len, scale))
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
@@ -205,9 +205,12 @@ public:
|
||||
|
||||
void deallocate(UMatData* u) const
|
||||
{
|
||||
if(!u)
|
||||
return;
|
||||
|
||||
CV_Assert(u->urefcount >= 0);
|
||||
CV_Assert(u->refcount >= 0);
|
||||
if(u && u->refcount == 0)
|
||||
if(u->refcount == 0)
|
||||
{
|
||||
if( !(u->flags & UMatData::USER_ALLOCATED) )
|
||||
{
|
||||
|
@@ -64,7 +64,15 @@
|
||||
// TODO Move to some common place
|
||||
static bool getBoolParameter(const char* name, bool defaultValue)
|
||||
{
|
||||
/*
|
||||
* If your system doesn't support getenv(), define NO_GETENV to disable
|
||||
* this feature.
|
||||
*/
|
||||
#ifdef NO_GETENV
|
||||
const char* envValue = NULL;
|
||||
#else
|
||||
const char* envValue = getenv(name);
|
||||
#endif
|
||||
if (envValue == NULL)
|
||||
{
|
||||
return defaultValue;
|
||||
@@ -85,7 +93,7 @@ static bool getBoolParameter(const char* name, bool defaultValue)
|
||||
// TODO Move to some common place
|
||||
static size_t getConfigurationParameterForSize(const char* name, size_t defaultValue)
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef NO_GETENV
|
||||
const char* envValue = NULL;
|
||||
#else
|
||||
const char* envValue = getenv(name);
|
||||
@@ -728,7 +736,7 @@ static void* initOpenCLAndLoad(const char* funcname)
|
||||
static HMODULE handle = 0;
|
||||
if (!handle)
|
||||
{
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
if(!initialized)
|
||||
{
|
||||
handle = LoadLibraryA("OpenCL.dll");
|
||||
@@ -2231,7 +2239,7 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
static cl_device_id selectOpenCLDevice()
|
||||
{
|
||||
return NULL;
|
||||
|
@@ -69,7 +69,7 @@
|
||||
#define HAVE_GCD
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1600
|
||||
#if defined _MSC_VER && _MSC_VER >= 1600 && !defined(WINRT)
|
||||
#define HAVE_CONCURRENCY
|
||||
#endif
|
||||
|
||||
@@ -458,7 +458,7 @@ int cv::getNumberOfCPUs(void)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
SYSTEM_INFO sysinfo;
|
||||
#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT)
|
||||
#if defined(_M_ARM) || defined(_M_X64) || defined(WINRT)
|
||||
GetNativeSystemInfo( &sysinfo );
|
||||
#else
|
||||
GetSystemInfo( &sysinfo );
|
||||
|
@@ -5548,7 +5548,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
|
||||
|
||||
void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>& keypoints)
|
||||
{
|
||||
internal::WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
|
||||
cv::internal::WriteStructContext ws(fs, objname, CV_NODE_SEQ + CV_NODE_FLOW);
|
||||
|
||||
int i, npoints = (int)keypoints.size();
|
||||
for( i = 0; i < npoints; i++ )
|
||||
|
@@ -236,6 +236,9 @@ struct CoreTLSData
|
||||
{
|
||||
CoreTLSData() : device(0), useOpenCL(-1), useIPP(-1), useCollection(false)
|
||||
{
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
useTegra = -1;
|
||||
#endif
|
||||
#ifdef CV_COLLECT_IMPL_DATA
|
||||
implFlags = 0;
|
||||
#endif
|
||||
@@ -246,6 +249,9 @@ struct CoreTLSData
|
||||
ocl::Queue oclQueue;
|
||||
int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized
|
||||
int useIPP; // 1 - use, 0 - do not use, -1 - auto/not initialized
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
int useTegra; // 1 - use, 0 - do not use, -1 - auto/not initialized
|
||||
#endif
|
||||
bool useCollection; // enable/disable impl data collection
|
||||
|
||||
#ifdef CV_COLLECT_IMPL_DATA
|
||||
|
@@ -517,9 +517,11 @@ static const uchar * initPopcountTable()
|
||||
unsigned int j = 0u;
|
||||
#if CV_POPCNT
|
||||
if (checkHardwareSupport(CV_CPU_POPCNT))
|
||||
{
|
||||
for( ; j < 256u; j++ )
|
||||
tab[j] = (uchar)(8 - _mm_popcnt_u32(j));
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
for( ; j < 256u; j++ )
|
||||
{
|
||||
int val = 0;
|
||||
@@ -527,7 +529,6 @@ static const uchar * initPopcountTable()
|
||||
val += (j & mask) == 0;
|
||||
tab[j] = (uchar)val;
|
||||
}
|
||||
#endif
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@@ -2113,6 +2114,12 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
|
||||
int ddepth = -1, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL)
|
||||
{
|
||||
const ocl::Device & dev = ocl::Device::getDefault();
|
||||
|
||||
#ifdef ANDROID
|
||||
if (dev.isNVidia())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = !_mask.empty(),
|
||||
haveSrc2 = _src2.kind() != _InputArray::NONE;
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
|
||||
@@ -2884,6 +2891,12 @@ static NormDiffFunc getNormDiffFunc(int normType, int depth)
|
||||
static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & result )
|
||||
{
|
||||
const ocl::Device & d = ocl::Device::getDefault();
|
||||
|
||||
#ifdef ANDROID
|
||||
if (d.isNVidia())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
bool doubleSupport = d.doubleFPConfig() > 0,
|
||||
haveMask = _mask.kind() != _InputArray::NONE;
|
||||
@@ -3249,6 +3262,11 @@ namespace cv {
|
||||
|
||||
static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask, double & result )
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (ocl::Device::getDefault().isNVidia())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
Scalar sc1, sc2;
|
||||
int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
bool relative = (normType & NORM_RELATIVE) != 0;
|
||||
|
@@ -109,7 +109,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#include <wrl/client.h>
|
||||
#ifndef __cplusplus_winrt
|
||||
#include <windows.storage.h>
|
||||
@@ -159,7 +159,7 @@ std::wstring GetTempFileNameWinRT(std::wstring prefix)
|
||||
UINT(g.Data4[2]), UINT(g.Data4[3]), UINT(g.Data4[4]),
|
||||
UINT(g.Data4[5]), UINT(g.Data4[6]), UINT(g.Data4[7]));
|
||||
|
||||
return prefix + std::wstring(guidStr);
|
||||
return prefix.append(std::wstring(guidStr));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -319,14 +319,17 @@ struct HWFeatures
|
||||
}
|
||||
|
||||
#if defined ANDROID || defined __linux__
|
||||
#ifdef __aarch64__
|
||||
f.have[CV_CPU_NEON] = true;
|
||||
#else
|
||||
int cpufile = open("/proc/self/auxv", O_RDONLY);
|
||||
|
||||
if (cpufile >= 0)
|
||||
{
|
||||
Elf32_auxv_t auxv;
|
||||
const size_t size_auxv_t = sizeof(Elf32_auxv_t);
|
||||
const size_t size_auxv_t = sizeof(auxv);
|
||||
|
||||
while (read(cpufile, &auxv, sizeof(Elf32_auxv_t)) == size_auxv_t)
|
||||
while ((size_t)read(cpufile, &auxv, size_auxv_t) == size_auxv_t)
|
||||
{
|
||||
if (auxv.a_type == AT_HWCAP)
|
||||
{
|
||||
@@ -337,7 +340,8 @@ struct HWFeatures
|
||||
|
||||
close(cpufile);
|
||||
}
|
||||
#elif (defined __clang__ || defined __APPLE__) && defined __ARM_NEON__
|
||||
#endif
|
||||
#elif (defined __clang__ || defined __APPLE__) && (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__))
|
||||
f.have[CV_CPU_NEON] = true;
|
||||
#endif
|
||||
|
||||
@@ -385,6 +389,12 @@ void setUseOptimized( bool flag )
|
||||
useOptimizedFlag = flag;
|
||||
currentFeatures = flag ? &featuresEnabled : &featuresDisabled;
|
||||
USE_SSE2 = currentFeatures->have[CV_CPU_SSE2];
|
||||
|
||||
ipp::setUseIPP(flag);
|
||||
ocl::setUseOpenCL(flag);
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
::tegra::setUseTegra(flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool useOptimized(void)
|
||||
@@ -532,24 +542,20 @@ String format( const char* fmt, ... )
|
||||
String tempfile( const char* suffix )
|
||||
{
|
||||
String fname;
|
||||
#ifndef HAVE_WINRT
|
||||
#ifndef WINRT
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
RoInitialize(RO_INIT_MULTITHREADED);
|
||||
std::wstring temp_dir = L"";
|
||||
const wchar_t* opencv_temp_dir = GetTempPathWinRT().c_str();
|
||||
if (opencv_temp_dir)
|
||||
temp_dir = std::wstring(opencv_temp_dir);
|
||||
std::wstring temp_dir = GetTempPathWinRT();
|
||||
|
||||
std::wstring temp_file;
|
||||
temp_file = GetTempFileNameWinRT(L"ocv");
|
||||
std::wstring temp_file = GetTempFileNameWinRT(L"ocv");
|
||||
if (temp_file.empty())
|
||||
return String();
|
||||
|
||||
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
||||
temp_file = temp_dir.append(std::wstring(L"\\")).append(temp_file);
|
||||
DeleteFileW(temp_file.c_str());
|
||||
|
||||
char aname[MAX_PATH];
|
||||
@@ -945,7 +951,7 @@ public:
|
||||
#pragma warning(disable:4505) // unreferenced local function has been removed
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
// using C++11 thread attribute for local thread data
|
||||
static __declspec( thread ) TLSStorage* g_tlsdata = NULL;
|
||||
|
||||
@@ -996,10 +1002,10 @@ public:
|
||||
}
|
||||
return d;
|
||||
}
|
||||
#endif //HAVE_WINRT
|
||||
#endif //WINRT
|
||||
|
||||
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
|
||||
#ifdef HAVE_WINRT
|
||||
#ifdef WINRT
|
||||
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
#endif
|
||||
|
||||
@@ -1259,4 +1265,34 @@ void setUseIPP(bool flag)
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
|
||||
namespace tegra {
|
||||
|
||||
bool useTegra()
|
||||
{
|
||||
cv::CoreTLSData* data = cv::getCoreTlsData().get();
|
||||
|
||||
if (data->useTegra < 0)
|
||||
{
|
||||
const char* pTegraEnv = getenv("OPENCV_TEGRA");
|
||||
if (pTegraEnv && (cv::String(pTegraEnv) == "disabled"))
|
||||
data->useTegra = false;
|
||||
else
|
||||
data->useTegra = true;
|
||||
}
|
||||
|
||||
return (data->useTegra > 0);
|
||||
}
|
||||
|
||||
void setUseTegra(bool flag)
|
||||
{
|
||||
cv::CoreTLSData* data = cv::getCoreTlsData().get();
|
||||
data->useTegra = flag;
|
||||
}
|
||||
|
||||
} // namespace tegra
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
|
@@ -1,119 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/core/private.cuda.hpp"
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
using namespace testing;
|
||||
using namespace cv;
|
||||
using namespace cv::cuda;
|
||||
|
||||
struct BufferPoolTest : TestWithParam<DeviceInfo>
|
||||
{
|
||||
void RunSimpleTest(Stream& stream, HostMem& dst_1, HostMem& dst_2)
|
||||
{
|
||||
BufferPool pool(stream);
|
||||
|
||||
{
|
||||
GpuMat buf0 = pool.getBuffer(Size(640, 480), CV_8UC1);
|
||||
EXPECT_FALSE( buf0.empty() );
|
||||
|
||||
buf0.setTo(Scalar::all(0), stream);
|
||||
|
||||
GpuMat buf1 = pool.getBuffer(Size(640, 480), CV_8UC1);
|
||||
EXPECT_FALSE( buf1.empty() );
|
||||
|
||||
buf0.convertTo(buf1, buf1.type(), 1.0, 1.0, stream);
|
||||
|
||||
buf1.download(dst_1, stream);
|
||||
}
|
||||
|
||||
{
|
||||
GpuMat buf2 = pool.getBuffer(Size(1280, 1024), CV_32SC1);
|
||||
EXPECT_FALSE( buf2.empty() );
|
||||
|
||||
buf2.setTo(Scalar::all(2), stream);
|
||||
|
||||
buf2.download(dst_2, stream);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckSimpleTest(HostMem& dst_1, HostMem& dst_2)
|
||||
{
|
||||
EXPECT_MAT_NEAR(Mat(Size(640, 480), CV_8UC1, Scalar::all(1)), dst_1, 0.0);
|
||||
EXPECT_MAT_NEAR(Mat(Size(1280, 1024), CV_32SC1, Scalar::all(2)), dst_2, 0.0);
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(BufferPoolTest, FromNullStream)
|
||||
{
|
||||
HostMem dst_1, dst_2;
|
||||
|
||||
RunSimpleTest(Stream::Null(), dst_1, dst_2);
|
||||
|
||||
CheckSimpleTest(dst_1, dst_2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(BufferPoolTest, From2Streams)
|
||||
{
|
||||
HostMem dst1_1, dst1_2;
|
||||
HostMem dst2_1, dst2_2;
|
||||
|
||||
Stream stream1, stream2;
|
||||
RunSimpleTest(stream1, dst1_1, dst1_2);
|
||||
RunSimpleTest(stream2, dst2_1, dst2_2);
|
||||
|
||||
stream1.waitForCompletion();
|
||||
stream2.waitForCompletion();
|
||||
|
||||
CheckSimpleTest(dst1_1, dst1_2);
|
||||
CheckSimpleTest(dst2_1, dst2_2);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA_Stream, BufferPoolTest, ALL_DEVICES);
|
||||
|
||||
#endif // HAVE_CUDA
|
@@ -1,364 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SetTo
|
||||
|
||||
PARAM_TEST_CASE(GpuMat_SetTo, cv::cuda::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
int type;
|
||||
bool useRoi;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
size = GET_PARAM(1);
|
||||
type = GET_PARAM(2);
|
||||
useRoi = GET_PARAM(3);
|
||||
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(GpuMat_SetTo, Zero)
|
||||
{
|
||||
cv::Scalar zero = cv::Scalar::all(0);
|
||||
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(zero);
|
||||
|
||||
EXPECT_MAT_NEAR(cv::Mat::zeros(size, type), mat, 0.0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(GpuMat_SetTo, SameVal)
|
||||
{
|
||||
cv::Scalar val = cv::Scalar::all(randomDouble(0.0, 255.0));
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(val);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(val);
|
||||
|
||||
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
CUDA_TEST_P(GpuMat_SetTo, DifferentVal)
|
||||
{
|
||||
cv::Scalar val = randomScalar(0.0, 255.0);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(val);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(val);
|
||||
|
||||
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
CUDA_TEST_P(GpuMat_SetTo, Masked)
|
||||
{
|
||||
cv::Scalar val = randomScalar(0.0, 255.0);
|
||||
cv::Mat mat_gold = randomMat(size, type);
|
||||
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat mat = createMat(size, type, useRoi);
|
||||
mat.setTo(val, loadMat(mask));
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat mat = loadMat(mat_gold, useRoi);
|
||||
mat.setTo(val, loadMat(mask, useRoi));
|
||||
|
||||
mat_gold.setTo(val, mask);
|
||||
|
||||
EXPECT_MAT_NEAR(mat_gold, mat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA, GpuMat_SetTo, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
ALL_TYPES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CopyTo
|
||||
|
||||
PARAM_TEST_CASE(GpuMat_CopyTo, cv::cuda::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
int type;
|
||||
bool useRoi;
|
||||
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
size = GET_PARAM(1);
|
||||
type = GET_PARAM(2);
|
||||
useRoi = GET_PARAM(3);
|
||||
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(GpuMat_CopyTo, WithOutMask)
|
||||
{
|
||||
cv::Mat src = randomMat(size, type);
|
||||
|
||||
cv::cuda::GpuMat d_src = loadMat(src, useRoi);
|
||||
cv::cuda::GpuMat dst = createMat(size, type, useRoi);
|
||||
d_src.copyTo(dst);
|
||||
|
||||
EXPECT_MAT_NEAR(src, dst, 0.0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(GpuMat_CopyTo, Masked)
|
||||
{
|
||||
cv::Mat src = randomMat(size, type);
|
||||
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src);
|
||||
cv::cuda::GpuMat dst;
|
||||
d_src.copyTo(dst, loadMat(mask, useRoi));
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src, useRoi);
|
||||
cv::cuda::GpuMat dst = loadMat(cv::Mat::zeros(size, type), useRoi);
|
||||
d_src.copyTo(dst, loadMat(mask, useRoi));
|
||||
|
||||
cv::Mat dst_gold = cv::Mat::zeros(size, type);
|
||||
src.copyTo(dst_gold, mask);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA, GpuMat_CopyTo, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
ALL_TYPES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ConvertTo
|
||||
|
||||
PARAM_TEST_CASE(GpuMat_ConvertTo, cv::cuda::DeviceInfo, cv::Size, MatDepth, MatDepth, UseRoi)
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
int depth1;
|
||||
int depth2;
|
||||
bool useRoi;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
size = GET_PARAM(1);
|
||||
depth1 = GET_PARAM(2);
|
||||
depth2 = GET_PARAM(3);
|
||||
useRoi = GET_PARAM(4);
|
||||
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(GpuMat_ConvertTo, WithOutScaling)
|
||||
{
|
||||
cv::Mat src = randomMat(size, depth1);
|
||||
|
||||
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src);
|
||||
cv::cuda::GpuMat dst;
|
||||
d_src.convertTo(dst, depth2);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src, useRoi);
|
||||
cv::cuda::GpuMat dst = createMat(size, depth2, useRoi);
|
||||
d_src.convertTo(dst, depth2);
|
||||
|
||||
cv::Mat dst_gold;
|
||||
src.convertTo(dst_gold, depth2);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth2 < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
CUDA_TEST_P(GpuMat_ConvertTo, WithScaling)
|
||||
{
|
||||
cv::Mat src = randomMat(size, depth1);
|
||||
double a = randomDouble(0.0, 1.0);
|
||||
double b = randomDouble(-10.0, 10.0);
|
||||
|
||||
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::cuda::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src);
|
||||
cv::cuda::GpuMat dst;
|
||||
d_src.convertTo(dst, depth2, a, b);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(cv::Error::StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cuda::GpuMat d_src = loadMat(src, useRoi);
|
||||
cv::cuda::GpuMat dst = createMat(size, depth2, useRoi);
|
||||
d_src.convertTo(dst, depth2, a, b);
|
||||
|
||||
cv::Mat dst_gold;
|
||||
src.convertTo(dst_gold, depth2, a, b);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth2 < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA, GpuMat_ConvertTo, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
ALL_DEPTH,
|
||||
ALL_DEPTH,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ensureSizeIsEnough
|
||||
|
||||
struct EnsureSizeIsEnough : testing::TestWithParam<cv::cuda::DeviceInfo>
|
||||
{
|
||||
virtual void SetUp()
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo = GetParam();
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(EnsureSizeIsEnough, BufferReuse)
|
||||
{
|
||||
cv::cuda::GpuMat buffer(100, 100, CV_8U);
|
||||
cv::cuda::GpuMat old = buffer;
|
||||
|
||||
// don't reallocate memory
|
||||
cv::cuda::ensureSizeIsEnough(10, 20, CV_8U, buffer);
|
||||
EXPECT_EQ(10, buffer.rows);
|
||||
EXPECT_EQ(20, buffer.cols);
|
||||
EXPECT_EQ(CV_8UC1, buffer.type());
|
||||
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
|
||||
|
||||
// don't reallocate memory
|
||||
cv::cuda::ensureSizeIsEnough(20, 30, CV_8U, buffer);
|
||||
EXPECT_EQ(20, buffer.rows);
|
||||
EXPECT_EQ(30, buffer.cols);
|
||||
EXPECT_EQ(CV_8UC1, buffer.type());
|
||||
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA, EnsureSizeIsEnough, ALL_DEVICES);
|
||||
|
||||
#endif // HAVE_CUDA
|
@@ -1,456 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../test_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_CUDA) && defined(HAVE_OPENGL)
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/core/opengl.hpp"
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Buffer
|
||||
|
||||
PARAM_TEST_CASE(Buffer, cv::Size, MatType)
|
||||
{
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
cv::namedWindow("test", cv::WINDOW_OPENGL);
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
cv::destroyAllWindows();
|
||||
}
|
||||
|
||||
cv::Size size;
|
||||
int type;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
type = GET_PARAM(1);
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(Buffer, Constructor1)
|
||||
{
|
||||
cv::ogl::Buffer buf(size.height, size.width, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
EXPECT_EQ(size.height, buf.rows());
|
||||
EXPECT_EQ(size.width, buf.cols());
|
||||
EXPECT_EQ(type, buf.type());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, Constructor2)
|
||||
{
|
||||
cv::ogl::Buffer buf(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
EXPECT_EQ(size.height, buf.rows());
|
||||
EXPECT_EQ(size.width, buf.cols());
|
||||
EXPECT_EQ(type, buf.type());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, ConstructorFromMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, ConstructorFromGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
cv::cuda::GpuMat d_gold(gold);
|
||||
|
||||
cv::ogl::Buffer buf(d_gold, cv::ogl::Buffer::ARRAY_BUFFER);
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, ConstructorFromBuffer)
|
||||
{
|
||||
cv::ogl::Buffer buf_gold(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::ogl::Buffer buf(buf_gold);
|
||||
|
||||
EXPECT_EQ(buf_gold.bufId(), buf.bufId());
|
||||
EXPECT_EQ(buf_gold.rows(), buf.rows());
|
||||
EXPECT_EQ(buf_gold.cols(), buf.cols());
|
||||
EXPECT_EQ(buf_gold.type(), buf.type());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, Create)
|
||||
{
|
||||
cv::ogl::Buffer buf;
|
||||
buf.create(size.height, size.width, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
EXPECT_EQ(size.height, buf.rows());
|
||||
EXPECT_EQ(size.width, buf.cols());
|
||||
EXPECT_EQ(type, buf.type());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, CopyFromMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf;
|
||||
buf.copyFrom(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, CopyFromGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
cv::cuda::GpuMat d_gold(gold);
|
||||
|
||||
cv::ogl::Buffer buf;
|
||||
buf.copyFrom(d_gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, CopyFromBuffer)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::ogl::Buffer buf;
|
||||
buf.copyFrom(buf_gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
EXPECT_NE(buf_gold.bufId(), buf.bufId());
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, CopyToGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::cuda::GpuMat dst;
|
||||
buf.copyTo(dst);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, dst, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, CopyToBuffer)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::ogl::Buffer dst;
|
||||
buf.copyTo(dst);
|
||||
dst.setAutoRelease(true);
|
||||
|
||||
EXPECT_NE(buf.bufId(), dst.bufId());
|
||||
|
||||
cv::Mat bufData;
|
||||
dst.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, Clone)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::ogl::Buffer dst = buf.clone(cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
EXPECT_NE(buf.bufId(), dst.bufId());
|
||||
|
||||
cv::Mat bufData;
|
||||
dst.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, MapHostRead)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::Mat dst = buf.mapHost(cv::ogl::Buffer::READ_ONLY);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, dst, 0);
|
||||
|
||||
buf.unmapHost();
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, MapHostWrite)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::Mat dst = buf.mapHost(cv::ogl::Buffer::WRITE_ONLY);
|
||||
gold.copyTo(dst);
|
||||
buf.unmapHost();
|
||||
dst.release();
|
||||
|
||||
cv::Mat bufData;
|
||||
buf.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Buffer, MapDevice)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type);
|
||||
|
||||
cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
|
||||
|
||||
cv::cuda::GpuMat dst = buf.mapDevice();
|
||||
|
||||
EXPECT_MAT_NEAR(gold, dst, 0);
|
||||
|
||||
buf.unmapDevice();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OpenGL, Buffer, testing::Combine(DIFFERENT_SIZES, ALL_TYPES));
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Texture2D
|
||||
|
||||
PARAM_TEST_CASE(Texture2D, cv::Size, MatType)
|
||||
{
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
cv::namedWindow("test", cv::WINDOW_OPENGL);
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
cv::destroyAllWindows();
|
||||
}
|
||||
|
||||
cv::Size size;
|
||||
int type;
|
||||
int depth;
|
||||
int cn;
|
||||
cv::ogl::Texture2D::Format format;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
type = GET_PARAM(1);
|
||||
|
||||
depth = CV_MAT_DEPTH(type);
|
||||
cn = CV_MAT_CN(type);
|
||||
format = cn == 1 ? cv::ogl::Texture2D::DEPTH_COMPONENT : cn == 3 ? cv::ogl::Texture2D::RGB : cn == 4 ? cv::ogl::Texture2D::RGBA : cv::ogl::Texture2D::NONE;
|
||||
}
|
||||
};
|
||||
|
||||
CUDA_TEST_P(Texture2D, Constructor1)
|
||||
{
|
||||
cv::ogl::Texture2D tex(size.height, size.width, format, true);
|
||||
|
||||
EXPECT_EQ(size.height, tex.rows());
|
||||
EXPECT_EQ(size.width, tex.cols());
|
||||
EXPECT_EQ(format, tex.format());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, Constructor2)
|
||||
{
|
||||
cv::ogl::Texture2D tex(size, format, true);
|
||||
|
||||
EXPECT_EQ(size.height, tex.rows());
|
||||
EXPECT_EQ(size.width, tex.cols());
|
||||
EXPECT_EQ(format, tex.format());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, ConstructorFromMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
|
||||
cv::ogl::Texture2D tex(gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, ConstructorFromGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
cv::cuda::GpuMat d_gold(gold);
|
||||
|
||||
cv::ogl::Texture2D tex(d_gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, ConstructorFromBuffer)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::PIXEL_UNPACK_BUFFER, true);
|
||||
|
||||
cv::ogl::Texture2D tex(buf_gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, ConstructorFromTexture2D)
|
||||
{
|
||||
cv::ogl::Texture2D tex_gold(size, format, true);
|
||||
cv::ogl::Texture2D tex(tex_gold);
|
||||
|
||||
EXPECT_EQ(tex_gold.texId(), tex.texId());
|
||||
EXPECT_EQ(tex_gold.rows(), tex.rows());
|
||||
EXPECT_EQ(tex_gold.cols(), tex.cols());
|
||||
EXPECT_EQ(tex_gold.format(), tex.format());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, Create)
|
||||
{
|
||||
cv::ogl::Texture2D tex;
|
||||
tex.create(size.height, size.width, format, true);
|
||||
|
||||
EXPECT_EQ(size.height, tex.rows());
|
||||
EXPECT_EQ(size.width, tex.cols());
|
||||
EXPECT_EQ(format, tex.format());
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, CopyFromMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
|
||||
cv::ogl::Texture2D tex;
|
||||
tex.copyFrom(gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, CopyFromGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
cv::cuda::GpuMat d_gold(gold);
|
||||
|
||||
cv::ogl::Texture2D tex;
|
||||
tex.copyFrom(d_gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, CopyFromBuffer)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::PIXEL_UNPACK_BUFFER, true);
|
||||
|
||||
cv::ogl::Texture2D tex;
|
||||
tex.copyFrom(buf_gold, true);
|
||||
|
||||
cv::Mat texData;
|
||||
tex.copyTo(texData, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, CopyToGpuMat)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
|
||||
cv::ogl::Texture2D tex(gold, true);
|
||||
|
||||
cv::cuda::GpuMat dst;
|
||||
tex.copyTo(dst, depth);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, dst, 1e-2);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Texture2D, CopyToBuffer)
|
||||
{
|
||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||
|
||||
cv::ogl::Texture2D tex(gold, true);
|
||||
|
||||
cv::ogl::Buffer dst;
|
||||
tex.copyTo(dst, depth, true);
|
||||
|
||||
cv::Mat bufData;
|
||||
dst.copyTo(bufData);
|
||||
|
||||
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OpenGL, Texture2D, testing::Combine(DIFFERENT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
|
||||
|
||||
#endif
|
@@ -1,153 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
struct Async : testing::TestWithParam<cv::cuda::DeviceInfo>
|
||||
{
|
||||
cv::cuda::HostMem src;
|
||||
cv::cuda::GpuMat d_src;
|
||||
|
||||
cv::cuda::HostMem dst;
|
||||
cv::cuda::GpuMat d_dst;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo = GetParam();
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
|
||||
src = cv::cuda::HostMem(cv::cuda::HostMem::PAGE_LOCKED);
|
||||
|
||||
cv::Mat m = randomMat(cv::Size(128, 128), CV_8UC1);
|
||||
m.copyTo(src);
|
||||
}
|
||||
};
|
||||
|
||||
void checkMemSet(int status, void* userData)
|
||||
{
|
||||
ASSERT_EQ(cudaSuccess, status);
|
||||
|
||||
Async* test = reinterpret_cast<Async*>(userData);
|
||||
|
||||
cv::cuda::HostMem src = test->src;
|
||||
cv::cuda::HostMem dst = test->dst;
|
||||
|
||||
cv::Mat dst_gold = cv::Mat::zeros(src.size(), src.type());
|
||||
|
||||
ASSERT_MAT_NEAR(dst_gold, dst, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Async, MemSet)
|
||||
{
|
||||
cv::cuda::Stream stream;
|
||||
|
||||
d_dst.upload(src);
|
||||
|
||||
d_dst.setTo(cv::Scalar::all(0), stream);
|
||||
d_dst.download(dst, stream);
|
||||
|
||||
Async* test = this;
|
||||
stream.enqueueHostCallback(checkMemSet, test);
|
||||
|
||||
stream.waitForCompletion();
|
||||
}
|
||||
|
||||
void checkConvert(int status, void* userData)
|
||||
{
|
||||
ASSERT_EQ(cudaSuccess, status);
|
||||
|
||||
Async* test = reinterpret_cast<Async*>(userData);
|
||||
|
||||
cv::cuda::HostMem src = test->src;
|
||||
cv::cuda::HostMem dst = test->dst;
|
||||
|
||||
cv::Mat dst_gold;
|
||||
src.createMatHeader().convertTo(dst_gold, CV_32S);
|
||||
|
||||
ASSERT_MAT_NEAR(dst_gold, dst, 0);
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Async, Convert)
|
||||
{
|
||||
cv::cuda::Stream stream;
|
||||
|
||||
d_src.upload(src, stream);
|
||||
d_src.convertTo(d_dst, CV_32S, stream);
|
||||
d_dst.download(dst, stream);
|
||||
|
||||
Async* test = this;
|
||||
stream.enqueueHostCallback(checkConvert, test);
|
||||
|
||||
stream.waitForCompletion();
|
||||
}
|
||||
|
||||
CUDA_TEST_P(Async, HostMemAllocator)
|
||||
{
|
||||
cv::cuda::Stream stream;
|
||||
|
||||
cv::Mat h_dst;
|
||||
h_dst.allocator = cv::cuda::HostMem::getAllocator();
|
||||
|
||||
d_src.upload(src, stream);
|
||||
d_src.convertTo(d_dst, CV_32S, stream);
|
||||
d_dst.download(h_dst, stream);
|
||||
|
||||
stream.waitForCompletion();
|
||||
|
||||
cv::Mat dst_gold;
|
||||
src.createMatHeader().convertTo(dst_gold, CV_32S);
|
||||
|
||||
ASSERT_MAT_NEAR(dst_gold, h_dst, 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA_Stream, Async, ALL_DEVICES);
|
||||
|
||||
#endif // HAVE_CUDA
|
@@ -331,7 +331,11 @@ OCL_TEST_P(Mul, Mat_Scale)
|
||||
OCL_OFF(cv::multiply(src1_roi, src2_roi, dst1_roi, val[0]));
|
||||
OCL_ON(cv::multiply(usrc1_roi, usrc2_roi, udst1_roi, val[0]));
|
||||
|
||||
#ifdef ANDROID
|
||||
Near(udst1_roi.depth() >= CV_32F ? 2e-1 : 1);
|
||||
#else
|
||||
Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,14 +7,4 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifndef HAVE_CUDA
|
||||
|
||||
CV_TEST_MAIN("cv")
|
||||
|
||||
#else
|
||||
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
CV_CUDA_TEST_MAIN("cv")
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user