From 8c25f9f28ac3295fea151f7025611479e6b3a67a Mon Sep 17 00:00:00 2001 From: Bahram Dahi Date: Mon, 20 May 2013 13:20:57 -0400 Subject: [PATCH 01/64] [3rd attempt] fixed HOGDescriptor::detectMultiScale() to group weights as well as ROIs --- modules/objdetect/src/hog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 1eab434f6..0ed9bbca4 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1060,7 +1060,9 @@ void HOGDescriptor::detectMultiScale( } else { - groupRectangles(foundLocations, (int)finalThreshold, 0.2); + vector dummy; + dummy.resize(foundLocations.size(), INT_MAX); + groupRectangles(foundLocations, (int)finalThreshold, 0.2, &dummy, &foundWeights); } } From dcad6ce65afa7eab3242fcfe1607998c6ed56772 Mon Sep 17 00:00:00 2001 From: Bahram Dahi Date: Fri, 24 May 2013 18:25:23 -0400 Subject: [PATCH 02/64] Reverted back to the previous method where a public method groupRectangles was added to HOGDescriptor to take care of ROI and weight grouping --- .../include/opencv2/objdetect/objdetect.hpp | 54 ++++++++---- modules/objdetect/src/cascadedetect.cpp | 18 ---- modules/objdetect/src/hog.cpp | 82 ++++++++++++++++++- 3 files changed, 115 insertions(+), 39 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp index 8d7efb0ba..d5d6f0b24 100644 --- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp @@ -192,12 +192,12 @@ typedef struct CvLSVMFilterObject{ // data type: STRUCT CvLatentSvmDetector // structure contains internal representation of trained Latent SVM detector -// num_filters - total number of filters (root plus part) in model -// num_components - number of components in model -// num_part_filters - array containing number of part filters for each component -// filters - root and part filters for all model components -// b - biases for all model components -// score_threshold - confidence level threshold +// num_filters - total number of filters (root plus part) in model +// num_components - number of components in model +// num_part_filters - array containing number of part filters for each component +// filters - root and part filters for all model components +// b - biases for all model components +// score_threshold - confidence level threshold typedef struct CvLatentSvmDetector { int num_filters; @@ -211,8 +211,8 @@ CvLatentSvmDetector; // data type: STRUCT CvObjectDetection // structure contains the bounding box and confidence level for detected object -// rect - bounding box for a detected object -// score - confidence level +// rect - bounding box for a detected object +// score - confidence level typedef struct CvObjectDetection { CvRect rect; @@ -228,7 +228,7 @@ typedef struct CvObjectDetection // API // CvLatentSvmDetector* cvLoadLatentSvmDetector(const char* filename); // INPUT -// filename - path to the file containing the parameters of +// filename - path to the file containing the parameters of - trained Latent SVM detector // OUTPUT // trained Latent SVM detector in internal representation @@ -241,7 +241,7 @@ CVAPI(CvLatentSvmDetector*) cvLoadLatentSvmDetector(const char* filename); // API // void cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector); // INPUT -// detector - CvLatentSvmDetector structure to be released +// detector - CvLatentSvmDetector structure to be released // OUTPUT */ CVAPI(void) cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector); @@ -252,16 +252,16 @@ CVAPI(void) cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector); // // API // CvSeq* cvLatentSvmDetectObjects(const IplImage* image, -// CvLatentSvmDetector* detector, -// CvMemStorage* storage, -// float overlap_threshold = 0.5f, +// CvLatentSvmDetector* detector, +// CvMemStorage* storage, +// float overlap_threshold = 0.5f, // int numThreads = -1); // INPUT -// image - image to detect objects in -// detector - Latent SVM detector in internal representation -// storage - memory storage to store the resultant sequence -// of the object candidate rectangles -// overlap_threshold - threshold for the non-maximum suppression algorithm +// image - image to detect objects in +// detector - Latent SVM detector in internal representation +// storage - memory storage to store the resultant sequence +// of the object candidate rectangles +// overlap_threshold - threshold for the non-maximum suppression algorithm = 0.5f [here will be the reference to original paper] // OUTPUT // sequence of detected objects (bounding boxes and confidence levels stored in CvObjectDetection structures) @@ -327,6 +327,23 @@ private: vector classNames; }; +// class for grouping object candidates, detected by Cascade Classifier, HOG etc. +// instance of the class is to be passed to cv::partition (see cxoperations.hpp) +class CV_EXPORTS SimilarRects +{ +public: + SimilarRects(double _eps) : eps(_eps) {} + inline bool operator()(const Rect& r1, const Rect& r2) const + { + double delta = eps*(std::min(r1.width, r2.width) + std::min(r1.height, r2.height))*0.5; + return std::abs(r1.x - r2.x) <= delta && + std::abs(r1.y - r2.y) <= delta && + std::abs(r1.x + r1.width - r2.x - r2.width) <= delta && + std::abs(r1.y + r1.height - r2.y - r2.height) <= delta; + } + double eps; +}; + CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, int groupThreshold, double eps=0.2); CV_EXPORTS_W void groupRectangles(CV_OUT CV_IN_OUT vector& rectList, CV_OUT vector& weights, int groupThreshold, double eps=0.2); CV_EXPORTS void groupRectangles( vector& rectList, int groupThreshold, double eps, vector* weights, vector* levelWeights ); @@ -611,6 +628,7 @@ public: // read/parse Dalal's alt model file void readALTModel(std::string modelfile); + void groupRectangles(vector& rectList, vector& weights, int groupThreshold, double eps) const; }; diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 46a232ed6..de46a6899 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -114,24 +114,6 @@ struct Logger namespace cv { -// class for grouping object candidates, detected by Cascade Classifier, HOG etc. -// instance of the class is to be passed to cv::partition (see cxoperations.hpp) -class CV_EXPORTS SimilarRects -{ -public: - SimilarRects(double _eps) : eps(_eps) {} - inline bool operator()(const Rect& r1, const Rect& r2) const - { - double delta = eps*(std::min(r1.width, r2.width) + std::min(r1.height, r2.height))*0.5; - return std::abs(r1.x - r2.x) <= delta && - std::abs(r1.y - r2.y) <= delta && - std::abs(r1.x + r1.width - r2.x - r2.width) <= delta && - std::abs(r1.y + r1.height - r2.y - r2.height) <= delta; - } - double eps; -}; - - void groupRectangles(vector& rectList, int groupThreshold, double eps, vector* weights, vector* levelWeights) { if( groupThreshold <= 0 || rectList.empty() ) diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 0ed9bbca4..9e5fd1ba5 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1060,9 +1060,7 @@ void HOGDescriptor::detectMultiScale( } else { - vector dummy; - dummy.resize(foundLocations.size(), INT_MAX); - groupRectangles(foundLocations, (int)finalThreshold, 0.2, &dummy, &foundWeights); + groupRectangles(foundLocations, foundWeights, (int)finalThreshold, 0.2); } } @@ -2636,4 +2634,82 @@ void HOGDescriptor::readALTModel(std::string modelfile) fclose(modelfl); } +void HOGDescriptor::groupRectangles(vector& rectList, vector& weights, int groupThreshold, double eps) const +{ + if( groupThreshold <= 0 || rectList.empty() ) + { + return; + } + + CV_Assert(rectList.size() == weights.size()); + + vector labels; + int nclasses = partition(rectList, labels, SimilarRects(eps)); + + vector> rrects(nclasses); + vector numInClass(nclasses, 0); + vector foundWeights(nclasses, DBL_MIN); + vector totalFactorsPerClass(nclasses, 1); + int i, j, nlabels = (int)labels.size(); + + for( i = 0; i < nlabels; i++ ) + { + int cls = labels[i]; + rrects[cls].x += rectList[i].x; + rrects[cls].y += rectList[i].y; + rrects[cls].width += rectList[i].width; + rrects[cls].height += rectList[i].height; + foundWeights[cls] = max(foundWeights[cls], weights[i]); + numInClass[cls]++; + } + + for( i = 0; i < nclasses; i++ ) + { + // find the average of all ROI in the cluster + cv::Rect_ r = rrects[i]; + float s = 1.f/numInClass[i]; + rrects[i] = cv::Rect_(cv::saturate_cast(r.x*s), + cv::saturate_cast(r.y*s), + cv::saturate_cast(r.width*s), + cv::saturate_cast(r.height*s)); + } + + rectList.clear(); + weights.clear(); + + for( i = 0; i < nclasses; i++ ) + { + cv::Rect r1 = rrects[i]; + int n1 = numInClass[i]; + double w1 = foundWeights[i]; + if( n1 <= groupThreshold ) + continue; + // filter out small rectangles inside large rectangles + for( j = 0; j < nclasses; j++ ) + { + int n2 = numInClass[j]; + + if( j == i || n2 <= groupThreshold ) + continue; + + cv::Rect r2 = rrects[j]; + + int dx = cv::saturate_cast( r2.width * eps ); + int dy = cv::saturate_cast( r2.height * eps ); + + if( r1.x >= r2.x - dx && + r1.y >= r2.y - dy && + r1.x + r1.width <= r2.x + r2.width + dx && + r1.y + r1.height <= r2.y + r2.height + dy && + (n2 > std::max(3, n1) || n1 < 3) ) + break; + } + + if( j == nclasses ) + { + rectList.push_back(r1); + weights.push_back(w1); + } + } +} } From e2d6a3abe599f3fc24756e984cd75fbdf7e0d82b Mon Sep 17 00:00:00 2001 From: Bahram Dahi Date: Fri, 24 May 2013 18:44:03 -0400 Subject: [PATCH 03/64] Added spacing in a nested template argument list. --- modules/objdetect/src/hog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 9e5fd1ba5..7287d57ec 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -2646,7 +2646,7 @@ void HOGDescriptor::groupRectangles(vector& rectList, vector& vector labels; int nclasses = partition(rectList, labels, SimilarRects(eps)); - vector> rrects(nclasses); + vector > rrects(nclasses); vector numInClass(nclasses, 0); vector foundWeights(nclasses, DBL_MIN); vector totalFactorsPerClass(nclasses, 1); @@ -2667,7 +2667,7 @@ void HOGDescriptor::groupRectangles(vector& rectList, vector& { // find the average of all ROI in the cluster cv::Rect_ r = rrects[i]; - float s = 1.f/numInClass[i]; + double s = 1.0/numInClass[i]; rrects[i] = cv::Rect_(cv::saturate_cast(r.x*s), cv::saturate_cast(r.y*s), cv::saturate_cast(r.width*s), From af2fc1a22aacf2bbd7e38806a307ba22123720cb Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 20 Jun 2013 16:11:04 +0400 Subject: [PATCH 04/64] added documentation for OpenGL interoperability --- modules/core/doc/core.rst | 1 + modules/core/doc/opengl_interop.rst | 543 +++++++++++++++++++++++++ modules/highgui/doc/user_interface.rst | 37 +- 3 files changed, 580 insertions(+), 1 deletion(-) create mode 100644 modules/core/doc/opengl_interop.rst diff --git a/modules/core/doc/core.rst b/modules/core/doc/core.rst index 7eb4e3e63..fc1afa644 100644 --- a/modules/core/doc/core.rst +++ b/modules/core/doc/core.rst @@ -14,4 +14,5 @@ core. The Core Functionality old_xml_yaml_persistence clustering utility_and_system_functions_and_macros + opengl_interop diff --git a/modules/core/doc/opengl_interop.rst b/modules/core/doc/opengl_interop.rst new file mode 100644 index 000000000..e0db36aec --- /dev/null +++ b/modules/core/doc/opengl_interop.rst @@ -0,0 +1,543 @@ +OpenGL interoperability +======================= + +.. highlight:: cpp + + + +General Information +------------------- +This section describes OpenGL interoperability. + +To enable OpenGL support, configure OpenCV using ``CMake`` with ``WITH_OPENGL=ON`` . +Currently OpenGL is supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not supported). +For GTK backend ``gtkglext-1.0`` library is required. + +To use OpenGL functionality you should first create OpenGL context (window or frame buffer). +You can do this with :ocv:func:`namedWindow` function or with other OpenGL toolkit (GLUT, for example). + + + +ogl::Buffer +----------- +Smart pointer for OpenGL buffer object with reference counting. + +.. ocv:class:: ogl::Buffer + +Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL context. +These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things. + +``ogl::Buffer`` has interface similar with :ocv:class:`Mat` interface and represents 2D array memory. + +``ogl::Buffer`` supports memory transfers between host and device and also can be mapped to CUDA memory. + + + +ogl::Buffer::Target +------------------- +The target defines how you intend to use the buffer object. + +.. ocv:enum:: ogl::Buffer::Target + + .. ocv:emember:: ARRAY_BUFFER + + The buffer will be used as a source for vertex data. + + .. ocv:emember:: ELEMENT_ARRAY_BUFFER + + The buffer will be used for indices (in ``glDrawElements`` or :ocv:func:`ogl::render`, for example). + + .. ocv:emember:: PIXEL_PACK_BUFFER + + The buffer will be used for reading from OpenGL textures. + + .. ocv:emember:: PIXEL_UNPACK_BUFFER + + The buffer will be used for writing to OpenGL textures. + + + +ogl::Buffer::Buffer +------------------- +The constructors. + +.. ocv:function:: ogl::Buffer::Buffer() + +.. ocv:function:: ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false) + +.. ocv:function:: ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false) + +.. ocv:function:: ogl::Buffer::Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + +.. ocv:function:: ogl::Buffer::Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + +.. ocv:function:: ogl::Buffer::Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) + + :param arows: Number of rows in a 2D array. + + :param acols: Number of columns in a 2D array. + + :param asize: 2D array size. + + :param atype: Array type ( ``CV_8UC1, ..., CV_64FC4`` ). See :ocv:class:`Mat` for details. + + :param abufId: Buffer object name. + + :param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or ``std::vector`` ). + + :param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` . + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + +Creates empty ``ogl::Buffer`` object, creates ``ogl::Buffer`` object from existed buffer ( ``abufId`` parameter), +allocates memory for ``ogl::Buffer`` object or copies from host/device memory. + + + +ogl::Buffer::create +------------------- +Allocates memory for ``ogl::Buffer`` object. + +.. ocv:function:: void ogl::Buffer::create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + +.. ocv:function:: void ogl::Buffer::create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + + :param arows: Number of rows in a 2D array. + + :param acols: Number of columns in a 2D array. + + :param asize: 2D array size. + + :param atype: Array type ( ``CV_8UC1, ..., CV_64FC4`` ). See :ocv:class:`Mat` for details. + + :param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` . + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + + + +ogl::Buffer::release +-------------------- +Decrements the reference counter and destroys the buffer object if needed. + +.. ocv:function:: void ogl::Buffer::release() + + + +ogl::Buffer::setAutoRelease +--------------------------- +Sets auto release mode. + +.. ocv:function:: void ogl::Buffer::setAutoRelease(bool flag) + + :param flag: Auto release mode (if true, release will be called in object's destructor). + +The lifetime of the OpenGL object is tied to the lifetime of the context. +If OpenGL context was bound to a window it could be released at any time (user can close a window). +If object's destructor is called after destruction of the context it will cause an error. +Thus ``ogl::Buffer`` doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). +This function can force ``ogl::Buffer`` destructor to destroy OpenGL object. + + + +ogl::Buffer::copyFrom +--------------------- +Copies from host/device memory to OpenGL buffer. + +.. ocv:function:: void ogl::Buffer::copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) + + :param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or ``std::vector`` ). + + :param target: Buffer usage. See :ocv:enum:`ogl::Buffer::Target` . + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + + + +ogl::Buffer::copyTo +------------------- +Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. + +.. ocv:function:: void ogl::Buffer::copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const + + :param arr: Destination array (host or device memory, can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` , ``std::vector`` or ``ogl::Buffer`` ). + + :param target: Buffer usage for destination buffer (if ``arr`` is OpenGL buffer). + + :param autoRelease: Auto release mode for destination buffer (if ``arr`` is OpenGL buffer). + + + +ogl::Buffer::clone +------------------ +Creates a full copy of the buffer object and the underlying data. + +.. ocv:function:: Buffer ogl::Buffer::clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const + + :param target: Buffer usage for destination buffer. + + :param autoRelease: Auto release mode for destination buffer. + + + +ogl::Buffer::bind +----------------- +Binds OpenGL buffer to the specified buffer binding point. + +.. ocv:function:: void ogl::Buffer::bind(Target target) const + + :param target: Binding point. See :ocv:enum:`ogl::Buffer::Target` . + + + +ogl::Buffer::unbind +------------------- +Unbind any buffers from the specified binding point. + +.. ocv:function:: static void ogl::Buffer::unbind(Target target) + + :param target: Binding point. See :ocv:enum:`ogl::Buffer::Target` . + + + +ogl::Buffer::mapHost +-------------------- +Maps OpenGL buffer to host memory. + +.. ocv:function:: Mat ogl::Buffer::mapHost(Access access) + + :param access: Access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. The symbolic constant must be ``ogl::Buffer::READ_ONLY`` , ``ogl::Buffer::WRITE_ONLY`` or ``ogl::Buffer::READ_WRITE`` . + +``mapHost`` maps to the client's address space the entire data store of the buffer object. +The data can then be directly read and/or written relative to the returned pointer, depending on the specified ``access`` policy. + +A mapped data store must be unmapped with :ocv:func:`ogl::Buffer::unmapHost` before its buffer object is used. + +This operation can lead to memory transfers between host and device. + +Only one buffer object can be mapped at a time. + + + +ogl::Buffer::unmapHost +---------------------- +Unmaps OpenGL buffer. + +.. ocv:function:: void ogl::Buffer::unmapHost() + + + +ogl::Buffer::mapDevice +---------------------- +Maps OpenGL buffer to CUDA device memory. + +.. ocv:function:: gpu::GpuMat ogl::Buffer::mapDevice() + +This operatation doesn't copy data. +Several buffer objects can be mapped to CUDA memory at a time. + +A mapped data store must be unmapped with :ocv:func:`ogl::Buffer::unmapDevice` before its buffer object is used. + + + +ogl::Buffer::unmapDevice +------------------------ +Unmaps OpenGL buffer. + +.. ocv:function:: void ogl::Buffer::unmapDevice() + + + +ogl::Texture2D +-------------- +Smart pointer for OpenGL 2D texture memory with reference counting. + +.. ocv:class:: ogl::Texture2D + + + +ogl::Texture2D::Format +---------------------- +An Image Format describes the way that the images in Textures store their data. + +.. ocv:enum:: ogl::Texture2D::Format + + .. ocv:emember:: NONE + .. ocv:emember:: DEPTH_COMPONENT + .. ocv:emember:: RGB + .. ocv:emember:: RGBA + + + +ogl::Texture2D::Texture2D +------------------------- +The constructors. + +.. ocv:function:: ogl::Texture2D::Texture2D() + +.. ocv:function:: ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false) + +.. ocv:function:: ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false) + +.. ocv:function:: ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease = false) + +.. ocv:function:: ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease = false) + +.. ocv:function:: ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease = false) + + :param arows: Number of rows. + + :param acols: Number of columns. + + :param asize: 2D array size. + + :param aformat: Image format. See :ocv:enum:`ogl::Texture2D::Format` . + + :param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or :ocv:class:`ogl::Buffer` ). + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + +Creates empty ``ogl::Texture2D`` object, allocates memory for ``ogl::Texture2D`` object or copies from host/device memory. + + + +ogl::Texture2D::create +---------------------- +Allocates memory for ``ogl::Texture2D`` object. + +.. ocv:function:: void ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoRelease = false) + +.. ocv:function:: void ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease = false) + + :param arows: Number of rows. + + :param acols: Number of columns. + + :param asize: 2D array size. + + :param aformat: Image format. See :ocv:enum:`ogl::Texture2D::Format` . + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + + + +ogl::Texture2D::release +----------------------- +Decrements the reference counter and destroys the texture object if needed. + +.. ocv:function:: void ogl::Texture2D::release() + + + +ogl::Texture2D::setAutoRelease +------------------------------ +Sets auto release mode. + +.. ocv:function:: void ogl::Texture2D::setAutoRelease(bool flag) + + :param flag: Auto release mode (if true, release will be called in object's destructor). + +The lifetime of the OpenGL object is tied to the lifetime of the context. +If OpenGL context was bound to a window it could be released at any time (user can close a window). +If object's destructor is called after destruction of the context it will cause an error. +Thus ``ogl::Texture2D`` doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). +This function can force ``ogl::Texture2D`` destructor to destroy OpenGL object. + + + +ogl::Texture2D::copyFrom +------------------------ +Copies from host/device memory to OpenGL texture. + +.. ocv:function:: void ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease = false) + + :param arr: Input array (host or device memory, it can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` or :ocv:class:`ogl::Buffer` ). + + :param autoRelease: Auto release mode (if true, release will be called in object's destructor). + + + +ogl::Texture2D::copyTo +---------------------- +Copies from OpenGL texture to host/device memory or another OpenGL texture object. + +.. ocv:function:: void ogl::Texture2D::copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const + + :param arr: Destination array (host or device memory, can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` , :ocv:class:`ogl::Buffer` or ``ogl::Texture2D`` ). + + :param ddepth: Destination depth. + + :param autoRelease: Auto release mode for destination buffer (if ``arr`` is OpenGL buffer or texture). + + + +ogl::Texture2D::bind +-------------------- +Binds texture to current active texture unit for ``GL_TEXTURE_2D`` target. + +.. ocv:function:: void ogl::Texture2D::bind() const + + + +ogl::Arrays +----------- +Wrapper for OpenGL Client-Side Vertex arrays. + +.. ocv:class:: ogl::Arrays + +``ogl::Arrays`` stores vertex data in :ocv:class:`ogl::Buffer` objects. + + + +ogl::Arrays::setVertexArray +--------------------------- +Sets an array of vertex coordinates. + +.. ocv:function:: void ogl::Arrays::setVertexArray(InputArray vertex) + + :param vertex: array with vertex coordinates, can be both host and device memory. + + + +ogl::Arrays::resetVertexArray +----------------------------- +Resets vertex coordinates. + +.. ocv:function:: void ogl::Arrays::resetVertexArray() + + + +ogl::Arrays::setColorArray +-------------------------- +Sets an array of vertex colors. + +.. ocv:function:: void ogl::Arrays::setColorArray(InputArray color) + + :param color: array with vertex colors, can be both host and device memory. + + + +ogl::Arrays::resetColorArray +---------------------------- +Resets vertex colors. + +.. ocv:function:: void ogl::Arrays::resetColorArray() + + + +ogl::Arrays::setNormalArray +--------------------------- +Sets an array of vertex normals. + +.. ocv:function:: void ogl::Arrays::setNormalArray(InputArray normal) + + :param normal: array with vertex normals, can be both host and device memory. + + + +ogl::Arrays::resetNormalArray +----------------------------- +Resets vertex normals. + +.. ocv:function:: void ogl::Arrays::resetNormalArray() + + + +ogl::Arrays::setTexCoordArray +----------------------------- +Sets an array of vertex texture coordinates. + +.. ocv:function:: void ogl::Arrays::setTexCoordArray(InputArray texCoord) + + :param texCoord: array with vertex texture coordinates, can be both host and device memory. + + + +ogl::Arrays::resetTexCoordArray +------------------------------- +Resets vertex texture coordinates. + +.. ocv:function:: void ogl::Arrays::resetTexCoordArray() + + + +ogl::Arrays::release +-------------------- +Releases all inner buffers. + +.. ocv:function:: void ogl::Arrays::release() + + + +ogl::Arrays::setAutoRelease +--------------------------- +Sets auto release mode all inner buffers. + +.. ocv:function:: void ogl::Arrays::setAutoRelease(bool flag) + + :param flag: Auto release mode. + + + +ogl::Arrays::bind +----------------- +Binds all vertex arrays. + +.. ocv:function:: void ogl::Arrays::bind() const + + + +ogl::Arrays::size +----------------- +Returns the vertex count. + +.. ocv:function:: int ogl::Arrays::size() const + + + +ogl::render +----------- +Render OpenGL texture or primitives. + +.. ocv:function:: void ogl::render(const Texture2D& tex, Rect_ wndRect = Rect_(0.0, 0.0, 1.0, 1.0), Rect_ texRect = Rect_(0.0, 0.0, 1.0, 1.0)) + +.. ocv:function:: void ogl::render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255)) + +.. ocv:function:: void ogl::render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255)) + + :param tex: Texture to draw. + + :param wndRect: Region of window, where to draw a texture (normalized coordinates). + + :param texRect: Region of texture to draw (normalized coordinates). + + :param arr: Array of privitives vertices. + + :param indices: Array of vertices indices (host or device memory). + + :param mode: Render mode. Available options: + + * **POINTS** + * **LINES** + * **LINE_LOOP** + * **LINE_STRIP** + * **TRIANGLES** + * **TRIANGLE_STRIP** + * **TRIANGLE_FAN** + * **QUADS** + * **QUAD_STRIP** + * **POLYGON** + + :param color: Color for all vertices. Will be used if ``arr`` doesn't contain color array. + + + +gpu::setGlDevice +---------------- +Sets a CUDA device and initializes it for the current thread with OpenGL interoperability. + +.. ocv:function:: void gpu::setGlDevice( int device = 0 ) + + :param device: System index of a GPU device starting with 0. + +This function should be explicitly called after OpenGL context creation and before any CUDA calls. diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index def8451a2..81d2de9ca 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -79,6 +79,7 @@ The function ``imshow`` displays an image in the specified window. If the window * If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255]. +If window was created with OpenGL support, ``imshow`` also support :ocv:class:`ogl::Buffer` , :ocv:class:`ogl::Texture2D` and :ocv:class:`gpu::GpuMat` as input. namedWindow --------------- @@ -94,7 +95,13 @@ Creates a window. :param name: Name of the window in the window caption that may be used as a window identifier. - :param flags: Flags of the window. Currently the only supported flag is ``CV_WINDOW_AUTOSIZE`` . If this is set, the window size is automatically adjusted to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually. + :param flags: Flags of the window. The supported flags are: + + * **WINDOW_NORMAL** If this is set, the user can resize the window (no constraint). + + * **WINDOW_AUTOSIZE** If this is set, the window size is automatically adjusted to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually. + + * **WINDOW_OPENGL** If this is set, the window will be created with OpenGL support. The function ``namedWindow`` creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names. @@ -256,3 +263,31 @@ The function ``waitKey`` waits for a key event infinitely (when .. note:: The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active. + +setOpenGlDrawCallback +--------------------- +Set OpenGL render handler for the specified window. + +.. ocv:function:: void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0) + + :param winname: Window name + + :param onOpenGlDraw: Draw callback. + + :param userdata: The optional parameter passed to the callback. + +setOpenGlContext +---------------- +Sets the specified window as current OpenGL context. + +.. ocv:function:: void setOpenGlContext(const string& winname) + + :param winname: Window name + +updateWindow +------------ +Force window to redraw its context and call draw callback ( :ocv:func:`setOpenGlDrawCallback` ). + +.. ocv:function:: void updateWindow(const string& winname) + + :param winname: Window name From 639450efdc0e5e3028dcedb3cebdc38b205a6c14 Mon Sep 17 00:00:00 2001 From: Philippe FOUBERT Date: Wed, 3 Jul 2013 00:19:22 +0200 Subject: [PATCH 05/64] PvAPI support on Windows with MinGW (PR #1038 applied to the branch 2.4) --- cmake/OpenCVFindLibsVideo.cmake | 9 ++++++++- modules/highgui/CMakeLists.txt | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 0ca4828fe..da61ad167 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -58,7 +58,14 @@ if(WITH_PVAPI) set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}") endif() - set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library") + if(WIN32) + if(MINGW) + set(PVAPI_DECLARATIONS "-DPVDECL=__stdcall") + endif(MINGW) + set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/PvAPI.lib" CACHE PATH "The PvAPI library") + else(WIN32) + set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library") + endif(WIN32) if(EXISTS "${PVAPI_LIBRARY}") set(HAVE_PVAPI TRUE) endif() diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 05ab99a78..8e2909843 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -197,6 +197,7 @@ endif(HAVE_FFMPEG) if(HAVE_PVAPI) add_definitions(-DHAVE_PVAPI) + add_definitions(${PVAPI_DECLARATIONS}) ocv_include_directories(${PVAPI_INCLUDE_PATH}) set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs}) list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY}) From aa2ca3aa8f1b5636d01ca2c252a0623d13103a6a Mon Sep 17 00:00:00 2001 From: Andrew Senin Date: Tue, 9 Jul 2013 00:33:39 +0400 Subject: [PATCH 06/64] Improve FPS on black and white Ximea cameras --- modules/highgui/src/cap_ximea.cpp | 55 ++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/modules/highgui/src/cap_ximea.cpp b/modules/highgui/src/cap_ximea.cpp index 5acf2c09d..98279e05b 100644 --- a/modules/highgui/src/cap_ximea.cpp +++ b/modules/highgui/src/cap_ximea.cpp @@ -52,6 +52,8 @@ void CvCaptureCAM_XIMEA::init() { xiGetNumberDevices( &numDevices); hmv = NULL; + frame = NULL; + timeout = 0; memset(&image, 0, sizeof(XI_IMG)); } @@ -60,6 +62,8 @@ void CvCaptureCAM_XIMEA::init() // Initialize camera input bool CvCaptureCAM_XIMEA::open( int wIndex ) { +#define HandleXiResult(res) if (res!=XI_OK) goto error; + int mvret = XI_OK; if(numDevices == 0) @@ -73,26 +77,42 @@ bool CvCaptureCAM_XIMEA::open( int wIndex ) // always use auto exposure/gain mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1); - if(mvret != XI_OK) goto error; - - // always use auto white ballance - mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1); - if(mvret != XI_OK) goto error; - - // default image format RGB24 - mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24); - if(mvret != XI_OK) goto error; + HandleXiResult(mvret); int width = 0; mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width); - if(mvret != XI_OK) goto error; + HandleXiResult(mvret); int height = 0; mvret = xiGetParamInt( hmv, XI_PRM_HEIGHT, &height); - if(mvret != XI_OK) goto error; + HandleXiResult(mvret); - // allocate frame buffer for RGB24 image - frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3); + int isColor = 0; + mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor); + HandleXiResult(mvret); + + if(isColor) // for color cameras + { + // default image format RGB24 + mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24); + HandleXiResult(mvret); + + // always use auto white ballance for color cameras + mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1); + HandleXiResult(mvret); + + // allocate frame buffer for RGB24 image + frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3); + } + else // for mono cameras + { + // default image format MONO8 + mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8); + HandleXiResult(mvret); + + // allocate frame buffer for MONO8 image + frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 1); + } //default capture timeout 10s timeout = 10000; @@ -118,9 +138,12 @@ void CvCaptureCAM_XIMEA::close() { if(frame) cvReleaseImage(&frame); - - xiStopAcquisition(hmv); - xiCloseDevice(hmv); + + if(hmv) + { + xiStopAcquisition(hmv); + xiCloseDevice(hmv); + } hmv = NULL; } From ac39bfb4ccf6966275631b8bb5694ac84e32408e Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 10 Jul 2013 16:02:07 +0400 Subject: [PATCH 07/64] Remove HAVE_CVCONFIG_H - it's always defined. --- CMakeLists.txt | 1 - modules/calib3d/src/precomp.hpp | 2 -- modules/contrib/src/precomp.hpp | 2 -- modules/core/src/precomp.hpp | 2 -- modules/features2d/src/precomp.hpp | 2 -- modules/flann/src/precomp.hpp | 2 -- modules/gpu/perf4au/main.cpp | 2 -- modules/gpu/src/precomp.hpp | 2 -- modules/highgui/test/test_precomp.hpp | 2 -- modules/imgproc/src/precomp.hpp | 2 -- modules/legacy/src/precomp.hpp | 2 -- modules/ml/src/precomp.hpp | 2 -- modules/nonfree/src/precomp.hpp | 2 -- modules/objdetect/src/precomp.hpp | 2 -- modules/objdetect/test/test_latentsvmdetector.cpp | 2 -- modules/ocl/src/precomp.hpp | 2 -- modules/photo/src/precomp.hpp | 2 -- modules/stitching/src/precomp.hpp | 2 -- modules/superres/perf/perf_precomp.hpp | 2 -- modules/superres/src/precomp.hpp | 2 -- modules/superres/test/test_precomp.hpp | 2 -- modules/ts/include/opencv2/ts/ts.hpp | 2 -- modules/video/src/precomp.hpp | 2 -- modules/videostab/src/precomp.hpp | 2 -- modules/world/src/precomp.hpp | 2 -- 25 files changed, 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f464b2263..444f3d702 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,7 +296,6 @@ endif() # Path for build/platform -specific headers # ---------------------------------------------------------------------------- set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h") -add_definitions(-DHAVE_CVCONFIG_H) ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR}) # ---------------------------------------------------------------------------- diff --git a/modules/calib3d/src/precomp.hpp b/modules/calib3d/src/precomp.hpp index 9b1f433ad..e96ba533f 100644 --- a/modules/calib3d/src/precomp.hpp +++ b/modules/calib3d/src/precomp.hpp @@ -42,9 +42,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/imgproc/imgproc.hpp" diff --git a/modules/contrib/src/precomp.hpp b/modules/contrib/src/precomp.hpp index 7c8e6bdf8..30232f763 100644 --- a/modules/contrib/src/precomp.hpp +++ b/modules/contrib/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/contrib/contrib.hpp" #include "opencv2/features2d/features2d.hpp" diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 84f7f5e2b..c53224e0a 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/core/core.hpp" #include "opencv2/core/core_c.h" diff --git a/modules/features2d/src/precomp.hpp b/modules/features2d/src/precomp.hpp index cbc1eb690..72f618600 100644 --- a/modules/features2d/src/precomp.hpp +++ b/modules/features2d/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/features2d/features2d.hpp" #include "opencv2/imgproc/imgproc.hpp" diff --git a/modules/flann/src/precomp.hpp b/modules/flann/src/precomp.hpp index fb5ee3f98..76d83992e 100644 --- a/modules/flann/src/precomp.hpp +++ b/modules/flann/src/precomp.hpp @@ -5,9 +5,7 @@ #include #include -#ifdef HAVE_CVCONFIG_H # include "cvconfig.h" -#endif #include "opencv2/core/core.hpp" #include "opencv2/core/internal.hpp" diff --git a/modules/gpu/perf4au/main.cpp b/modules/gpu/perf4au/main.cpp index f6a65ad63..f190bc1a9 100644 --- a/modules/gpu/perf4au/main.cpp +++ b/modules/gpu/perf4au/main.cpp @@ -42,9 +42,7 @@ #include -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/ts/ts.hpp" #include "opencv2/ts/gpu_perf.hpp" diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index 06d538640..d3a4467ea 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -47,9 +47,7 @@ #pragma warning( disable: 4251 4710 4711 4514 4996 ) #endif -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include #include diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index be06c0643..5e030810f 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -9,9 +9,7 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H # include "cvconfig.h" -#endif #include "opencv2/ts/ts.hpp" #include "opencv2/imgproc/imgproc.hpp" diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp index 842a15cea..20101b77b 100644 --- a/modules/imgproc/src/precomp.hpp +++ b/modules/imgproc/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" diff --git a/modules/legacy/src/precomp.hpp b/modules/legacy/src/precomp.hpp index 48b9e4a23..383b694ba 100644 --- a/modules/legacy/src/precomp.hpp +++ b/modules/legacy/src/precomp.hpp @@ -41,9 +41,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/legacy/legacy.hpp" diff --git a/modules/ml/src/precomp.hpp b/modules/ml/src/precomp.hpp index 63002a8e8..b4ae21a55 100644 --- a/modules/ml/src/precomp.hpp +++ b/modules/ml/src/precomp.hpp @@ -41,9 +41,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/ml/ml.hpp" #include "opencv2/core/core_c.h" diff --git a/modules/nonfree/src/precomp.hpp b/modules/nonfree/src/precomp.hpp index 6c46114c7..2abe6038a 100644 --- a/modules/nonfree/src/precomp.hpp +++ b/modules/nonfree/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" diff --git a/modules/objdetect/src/precomp.hpp b/modules/objdetect/src/precomp.hpp index 560ed45a2..37f3673a4 100644 --- a/modules/objdetect/src/precomp.hpp +++ b/modules/objdetect/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/imgproc/imgproc.hpp" diff --git a/modules/objdetect/test/test_latentsvmdetector.cpp b/modules/objdetect/test/test_latentsvmdetector.cpp index b595d7ac5..1efa55f50 100644 --- a/modules/objdetect/test/test_latentsvmdetector.cpp +++ b/modules/objdetect/test/test_latentsvmdetector.cpp @@ -44,9 +44,7 @@ #include -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #ifdef HAVE_TBB #include "tbb/task_scheduler_init.h" diff --git a/modules/ocl/src/precomp.hpp b/modules/ocl/src/precomp.hpp index 4f93eac42..8050b909b 100644 --- a/modules/ocl/src/precomp.hpp +++ b/modules/ocl/src/precomp.hpp @@ -52,9 +52,7 @@ #pragma warning( disable: 4267 4324 4244 4251 4710 4711 4514 4996 ) #endif -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include #include diff --git a/modules/photo/src/precomp.hpp b/modules/photo/src/precomp.hpp index 3185a18b8..196867625 100644 --- a/modules/photo/src/precomp.hpp +++ b/modules/photo/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/photo/photo.hpp" diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index 4849ace1e..1050856d3 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_STITCHING_PRECOMP_H__ #define __OPENCV_STITCHING_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" #include diff --git a/modules/superres/perf/perf_precomp.hpp b/modules/superres/perf/perf_precomp.hpp index f05203718..d64d5008c 100644 --- a/modules/superres/perf/perf_precomp.hpp +++ b/modules/superres/perf/perf_precomp.hpp @@ -51,9 +51,7 @@ #ifndef __OPENCV_PERF_PRECOMP_HPP__ #define __OPENCV_PERF_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/ts/ts.hpp" #include "opencv2/ts/gpu_perf.hpp" diff --git a/modules/superres/src/precomp.hpp b/modules/superres/src/precomp.hpp index 82b591b3c..5df45ed33 100644 --- a/modules/superres/src/precomp.hpp +++ b/modules/superres/src/precomp.hpp @@ -46,9 +46,7 @@ #include #include -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" #include "opencv2/core/core.hpp" diff --git a/modules/superres/test/test_precomp.hpp b/modules/superres/test/test_precomp.hpp index 0371c34a9..8102d432b 100644 --- a/modules/superres/test/test_precomp.hpp +++ b/modules/superres/test/test_precomp.hpp @@ -51,9 +51,7 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" #include "opencv2/core/core.hpp" diff --git a/modules/ts/include/opencv2/ts/ts.hpp b/modules/ts/include/opencv2/ts/ts.hpp index fcef5896c..5b5896098 100644 --- a/modules/ts/include/opencv2/ts/ts.hpp +++ b/modules/ts/include/opencv2/ts/ts.hpp @@ -1,9 +1,7 @@ #ifndef __OPENCV_GTESTCV_HPP__ #define __OPENCV_GTESTCV_HPP__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #ifndef GTEST_CREATE_SHARED_LIBRARY #ifdef BUILD_SHARED_LIBS #define GTEST_LINKED_AS_SHARED_LIBRARY 1 diff --git a/modules/video/src/precomp.hpp b/modules/video/src/precomp.hpp index 58fc55086..9b6077f1e 100644 --- a/modules/video/src/precomp.hpp +++ b/modules/video/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" diff --git a/modules/videostab/src/precomp.hpp b/modules/videostab/src/precomp.hpp index c1d8e3039..f718d0e8e 100644 --- a/modules/videostab/src/precomp.hpp +++ b/modules/videostab/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_HPP__ #define __OPENCV_PRECOMP_HPP__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include #include diff --git a/modules/world/src/precomp.hpp b/modules/world/src/precomp.hpp index 263095700..4d88e8c21 100644 --- a/modules/world/src/precomp.hpp +++ b/modules/world/src/precomp.hpp @@ -43,9 +43,7 @@ #ifndef __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__ -#ifdef HAVE_CVCONFIG_H #include "cvconfig.h" -#endif #include "opencv2/opencv_modules.hpp" #ifdef HAVE_OPENCV_VIDEO From 2d9b3a83344ece1e467e3c06580de6d9629be7b1 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 10 Jul 2013 17:20:48 +0400 Subject: [PATCH 08/64] Deleted a bunch of unused configuration macros. --- cmake/templates/cvconfig.h.cmake | 40 -------------------------------- 1 file changed, 40 deletions(-) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index f12730988..0b93d8a06 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -1,11 +1,3 @@ -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#cmakedefine CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#cmakedefine C_ALLOCA - /* Define to 1 if you have `alloca', as a function or macro. */ #cmakedefine HAVE_ALLOCA 1 @@ -70,24 +62,12 @@ /* Apple ImageIO Framework */ #cmakedefine HAVE_IMAGEIO -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - /* JPEG-2000 codec */ #cmakedefine HAVE_JASPER /* IJG JPEG codec */ #cmakedefine HAVE_JPEG -/* Define to 1 if you have the `dl' library (-ldl). */ -#cmakedefine HAVE_LIBDL 1 - -/* Define to 1 if you have the `gomp' library (-lgomp). */ -#cmakedefine HAVE_LIBGOMP 1 - -/* Define to 1 if you have the `m' library (-lm). */ -#cmakedefine HAVE_LIBM 1 - /* libpng/png.h needs to be included */ #cmakedefine HAVE_LIBPNG_PNG_H @@ -100,15 +80,9 @@ /* PNG codec */ #cmakedefine HAVE_PNG -/* Define to 1 if you have the `png_get_valid' function. */ -#cmakedefine HAVE_PNG_GET_VALID 1 - /* png.h needs to be included */ #cmakedefine HAVE_PNG_H -/* Define to 1 if you have the `png_set_tRNS_to_alpha' function. */ -#cmakedefine HAVE_PNG_SET_TRNS_TO_ALPHA 1 - /* QuickTime video libraries */ #cmakedefine HAVE_QUICKTIME @@ -130,9 +104,6 @@ /* OpenNI library */ #cmakedefine HAVE_OPENNI -/* LZ77 compression/decompression library (used for PNG) */ -#cmakedefine HAVE_ZLIB - /* Intel Integrated Performance Primitives */ #cmakedefine HAVE_IPP @@ -157,14 +128,6 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "${PACKAGE_VERSION}" -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#cmakedefine STACK_DIRECTION - /* Version number of package */ #define VERSION "${PACKAGE_VERSION}" @@ -226,9 +189,6 @@ /* OpenGL support*/ #cmakedefine HAVE_OPENGL -/* Clp support */ -#cmakedefine HAVE_CLP - /* Qt support */ #cmakedefine HAVE_QT From 4f9554eead4aab86ac189348d4194129a773e5ca Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 10 Jul 2013 17:43:46 +0400 Subject: [PATCH 09/64] Removed a few more unused configuration macros. I've left HAVE_LIBPTHREAD as a CMake variable, since TBB's build depends on it. Some macros in internal.hpp depended on HAVE_ALLOCA_H, but they were, in turn, unused, so I've just deleted them all. --- CMakeLists.txt | 5 +-- cmake/templates/cvconfig.h.cmake | 13 ------- .../core/include/opencv2/core/internal.hpp | 24 ------------- modules/core/src/persistence.cpp | 1 - modules/core/src/system.cpp | 36 +------------------ modules/highgui/src/grfmt_png.cpp | 1 - 6 files changed, 2 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 444f3d702..b4a6a5f01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -369,9 +369,6 @@ if(UNIX) include(CheckIncludeFile) if(NOT APPLE) - CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H) - CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA) - CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD) if(ANDROID) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m log) @@ -381,7 +378,7 @@ if(UNIX) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt) endif() else() - add_definitions(-DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H) + set(HAVE_LIBPTHREAD YES) endif() endif() diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 0b93d8a06..a1b97e5d3 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -1,10 +1,3 @@ -/* Define to 1 if you have `alloca', as a function or macro. */ -#cmakedefine HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#cmakedefine HAVE_ALLOCA_H 1 - /* Video for Windows support */ #cmakedefine HAVE_VFW @@ -71,9 +64,6 @@ /* libpng/png.h needs to be included */ #cmakedefine HAVE_LIBPNG_PNG_H -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#cmakedefine HAVE_LIBPTHREAD 1 - /* Define to 1 if you have the `lrint' function. */ #cmakedefine HAVE_LRINT 1 @@ -95,9 +85,6 @@ /* Unicap video capture library */ #cmakedefine HAVE_UNICAP -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H 1 - /* Xine video library */ #cmakedefine HAVE_XINE diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index 606c62f8f..5e8a03b66 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -340,25 +340,6 @@ namespace cv * Common declarations * \****************************************************************************************/ -/* get alloca declaration */ -#ifdef __GNUC__ -# undef alloca -# define alloca __builtin_alloca -# define CV_HAVE_ALLOCA 1 -#elif defined WIN32 || defined _WIN32 || \ - defined WINCE || defined _MSC_VER || defined __BORLANDC__ -# include -# define CV_HAVE_ALLOCA 1 -#elif defined HAVE_ALLOCA_H -# include -# define CV_HAVE_ALLOCA 1 -#elif defined HAVE_ALLOCA -# include -# define CV_HAVE_ALLOCA 1 -#else -# undef CV_HAVE_ALLOCA -#endif - #ifdef __GNUC__ # define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x))) #elif defined _MSC_VER @@ -367,11 +348,6 @@ namespace cv # define CV_DECL_ALIGNED(x) #endif -#if CV_HAVE_ALLOCA -/* ! DO NOT make it an inline function */ -# define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN ) -#endif - #ifndef CV_IMPL # define CV_IMPL CV_EXTERN_C #endif diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index a16b63e13..bf6a64c97 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -59,7 +59,6 @@ #endif #if USE_ZLIB -# undef HAVE_UNISTD_H //to avoid redefinition # ifndef _LFS64_LARGEFILE # define _LFS64_LARGEFILE 0 # endif diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index a891e94cc..7cc5f04e3 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -469,40 +469,6 @@ redirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata) } -/*CV_IMPL int -cvGuiBoxReport( int code, const char *func_name, const char *err_msg, - const char *file, int line, void* ) -{ -#if (!defined WIN32 && !defined _WIN32) || defined WINCE - return cvStdErrReport( code, func_name, err_msg, file, line, 0 ); -#else - if( code != CV_StsBackTrace && code != CV_StsAutoTrace ) - { - size_t msg_len = strlen(err_msg ? err_msg : "") + 1024; - char* message = (char*)alloca(msg_len); - char title[100]; - - wsprintf( message, "%s (%s)\nin function %s, %s(%d)\n\n" - "Press \"Abort\" to terminate application.\n" - "Press \"Retry\" to debug (if the app is running under debugger).\n" - "Press \"Ignore\" to continue (this is not safe).\n", - cvErrorStr(code), err_msg ? err_msg : "no description", - func_name, file, line ); - - wsprintf( title, "OpenCV GUI Error Handler" ); - - int answer = MessageBox( NULL, message, title, MB_ICONERROR|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL ); - - if( answer == IDRETRY ) - { - CV_DBG_BREAK(); - } - return answer != IDIGNORE; - } - return 0; -#endif -}*/ - CV_IMPL int cvCheckHardwareSupport(int feature) { CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE ); @@ -904,4 +870,4 @@ bool Mutex::trylock() { return impl->trylock(); } } -/* End of file. */ \ No newline at end of file +/* End of file. */ diff --git a/modules/highgui/src/grfmt_png.cpp b/modules/highgui/src/grfmt_png.cpp index 9bb5d32be..fb0fe6c39 100644 --- a/modules/highgui/src/grfmt_png.cpp +++ b/modules/highgui/src/grfmt_png.cpp @@ -51,7 +51,6 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ -#undef HAVE_UNISTD_H //to avoid redefinition #ifndef _LFS64_LARGEFILE # define _LFS64_LARGEFILE 0 #endif From ca8b621b4fec65c768b58c6581f61d65cd40cc30 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 10 Jul 2013 18:20:34 +0400 Subject: [PATCH 10/64] Refactored detecting several Apple-related technologies. Now the HAVE_* macros are set using cvconfig.h. Previously most of them already were there, but were always undefined. One, HAVE_COCOA, I had to add. This also makes the CMake code more consistent; now, WITH_* variables are always checked in cmake/*, while HAVE_* variables are checked in modules/highgui/CMakeLists.txt. --- cmake/OpenCVFindLibsGUI.cmake | 9 +++++++ cmake/OpenCVFindLibsGrfmt.cmake | 7 +++++- cmake/OpenCVFindLibsVideo.cmake | 10 ++++++++ cmake/templates/cvconfig.h.cmake | 3 +++ modules/highgui/CMakeLists.txt | 43 +++++++++++++------------------- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/cmake/OpenCVFindLibsGUI.cmake b/cmake/OpenCVFindLibsGUI.cmake index d685d23fe..04c77d8ec 100644 --- a/cmake/OpenCVFindLibsGUI.cmake +++ b/cmake/OpenCVFindLibsGUI.cmake @@ -65,3 +65,12 @@ if(WITH_OPENGL) endif() endif() endif(WITH_OPENGL) + +# --- Carbon & Cocoa --- +if(APPLE) + if(WITH_CARBON) + set(HAVE_CARBON YES) + elif(NOT IOS) + set(HAVE_COCOA YES) + endif() +endif() diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 33e428b7c..c8ebb3d8f 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -161,4 +161,9 @@ endif() #cmake 2.8.2 bug - it fails to determine zlib version if(ZLIB_FOUND) ocv_parse_header2(ZLIB "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_VERSION) -endif() \ No newline at end of file +endif() + +# --- Apple ImageIO --- +if(WITH_IMAGEIO) + set(HAVE_IMAGEIO YES) +endif() diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 0ca4828fe..c9127189e 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -228,3 +228,13 @@ if(WIN32) list(APPEND HIGHGUI_LIBRARIES winmm) endif() endif(WIN32) + +# --- Apple AV Foundation --- +if(WITH_AVFOUNDATION) + set(HAVE_AVFOUNDATION YES) +endif() + +# --- QuickTime --- +if(WITH_QUICKTIME) + set(HAVE_QUICKTIME YES) +endif() diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index a1b97e5d3..8aebbad60 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -16,6 +16,9 @@ /* Carbon windowing environment */ #cmakedefine HAVE_CARBON +/* Cocoa API */ +#cmakedefine HAVE_COCOA + /* IEEE1394 capturing support */ #cmakedefine HAVE_DC1394 diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 2b0a23209..c25108702 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -108,16 +108,12 @@ elseif(HAVE_WIN32UI) list(APPEND highgui_srcs src/window_w32.cpp) elseif(HAVE_GTK) list(APPEND highgui_srcs src/window_gtk.cpp) -elseif(APPLE) - if(WITH_CARBON) - add_definitions(-DHAVE_CARBON=1) - list(APPEND highgui_srcs src/window_carbon.cpp) - list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime") - elseif(NOT IOS) - add_definitions(-DHAVE_COCOA=1) - list(APPEND highgui_srcs src/window_cocoa.mm) - list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa") - endif() +elseif(HAVE_CARBON) + list(APPEND highgui_srcs src/window_carbon.cpp) + list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime") +elseif(HAVE_COCOA) + list(APPEND highgui_srcs src/window_cocoa.mm) + list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa") endif() if(WIN32 AND NOT ARM) @@ -210,26 +206,21 @@ if(HAVE_GIGE_API) list(APPEND highgui_srcs src/cap_giganetix.cpp) endif(HAVE_GIGE_API) -if(WITH_IMAGEIO) - add_definitions(-DHAVE_IMAGEIO=1) - if(IOS) - list(APPEND HIGHGUI_LIBRARIES "-framework ImageIO") - endif() -endif(WITH_IMAGEIO) +if(HAVE_IMAGEIO AND IOS) + list(APPEND HIGHGUI_LIBRARIES "-framework ImageIO") +endif() -if(WITH_AVFOUNDATION) - add_definitions(-DHAVE_AVFOUNDATION=1) +if(HAVE_AVFOUNDATION) list(APPEND highgui_srcs src/cap_avfoundation.mm) list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore") +endif() + +if(HAVE_QUICKTIME) + list(APPEND highgui_srcs src/cap_qt.cpp) + list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore") elseif(APPLE) - add_definitions(-DHAVE_QUICKTIME=1) - if(WITH_QUICKTIME) - list(APPEND highgui_srcs src/cap_qt.cpp) - list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore") - else() - list(APPEND highgui_srcs src/cap_qtkit.mm) - list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit") - endif() + list(APPEND highgui_srcs src/cap_qtkit.mm) + list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit") endif() if(IOS) From e2ef2a578178b804129d598948f7aa29ea9ef2e7 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 12:40:16 +0400 Subject: [PATCH 11/64] Refactored image format library finding logic. Now the HAVE_* macros are set in cvconfig.h. Most of them already were there, but were nonfunctional. --- cmake/OpenCVFindLibsGrfmt.cmake | 148 ++++++++++++++++--------------- cmake/templates/cvconfig.h.cmake | 5 +- modules/highgui/CMakeLists.txt | 17 ++-- 3 files changed, 84 insertions(+), 86 deletions(-) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index c8ebb3d8f..9381350c0 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -36,57 +36,59 @@ if(WITH_TIFF) ocv_parse_header("${TIFF_INCLUDE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION) endif() endif() -endif() -if(WITH_TIFF AND NOT TIFF_FOUND) - ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR) + if(NOT TIFF_FOUND) + ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR) - set(TIFF_LIBRARY libtiff) - set(TIFF_LIBRARIES ${TIFF_LIBRARY}) - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff") - set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}") - ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION) -endif() - -if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION) - set(TIFF_VERSION ${TIFF_VERSION_CLASSIC}) -endif() - -if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG) - set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION}) -endif() - -if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR) - list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR) - if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h") - file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*") - string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}") - unset(tiff_version_str) + set(TIFF_LIBRARY libtiff) + set(TIFF_LIBRARIES ${TIFF_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff") + set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}") + ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION) endif() - unset(_TIFF_INCLUDE_DIR) + + if(TIFF_VERSION_CLASSIC AND NOT TIFF_VERSION) + set(TIFF_VERSION ${TIFF_VERSION_CLASSIC}) + endif() + + if(TIFF_BIGTIFF_VERSION AND NOT TIFF_VERSION_BIG) + set(TIFF_VERSION_BIG ${TIFF_BIGTIFF_VERSION}) + endif() + + if(NOT TIFF_VERSION_STRING AND TIFF_INCLUDE_DIR) + list(GET TIFF_INCLUDE_DIR 0 _TIFF_INCLUDE_DIR) + if(EXISTS "${_TIFF_INCLUDE_DIR}/tiffvers.h") + file(STRINGS "${_TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*") + string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1" TIFF_VERSION_STRING "${tiff_version_str}") + unset(tiff_version_str) + endif() + unset(_TIFF_INCLUDE_DIR) + endif() + + set(HAVE_TIFF YES) endif() # --- libjpeg (optional) --- -if(WITH_JPEG AND NOT IOS) +if(WITH_JPEG) if(BUILD_JPEG) ocv_clear_vars(JPEG_FOUND) else() include(FindJPEG) endif() + + if(NOT JPEG_FOUND) + ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR) + + set(JPEG_LIBRARY libjpeg) + set(JPEG_LIBRARIES ${JPEG_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg") + set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}") + endif() + + ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION) + set(HAVE_JPEG YES) endif() -if(WITH_JPEG AND NOT JPEG_FOUND) - ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR) - - set(JPEG_LIBRARY libjpeg) - set(JPEG_LIBRARIES ${JPEG_LIBRARY}) - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg") - set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}") -endif() - -ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION) - - # --- libjasper (optional, should be searched after libjpeg) --- if(WITH_JASPER) if(BUILD_JASPER) @@ -94,19 +96,21 @@ if(WITH_JASPER) else() include(FindJasper) endif() -endif() -if(WITH_JASPER AND NOT JASPER_FOUND) - ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR) + if(NOT JASPER_FOUND) + ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR) - set(JASPER_LIBRARY libjasper) - set(JASPER_LIBRARIES ${JASPER_LIBRARY}) - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper") - set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}") -endif() + set(JASPER_LIBRARY libjasper) + set(JASPER_LIBRARIES ${JASPER_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper") + set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}") + endif() -if(NOT JASPER_VERSION_STRING) - ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "") + set(HAVE_JASPER YES) + + if(NOT JASPER_VERSION_STRING) + ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "") + endif() endif() # --- libpng (optional, should be searched after zlib) --- @@ -117,30 +121,30 @@ if(WITH_PNG AND NOT IOS) include(FindPNG) if(PNG_FOUND) include(CheckIncludeFile) - check_include_file("${PNG_PNG_INCLUDE_DIR}/png.h" HAVE_PNG_H) check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H) - if(HAVE_PNG_H) - ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) - elseif(HAVE_LIBPNG_PNG_H) + if(HAVE_LIBPNG_PNG_H) ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) + else() + ocv_parse_header("${PNG_PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) endif() endif() endif() + + if(NOT PNG_FOUND) + ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS) + + set(PNG_LIBRARY libpng) + set(PNG_LIBRARIES ${PNG_LIBRARY}) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng") + set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}") + set(PNG_DEFINITIONS "") + ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) + endif() + + set(HAVE_PNG YES) + set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}") endif() -if(WITH_PNG AND NOT PNG_FOUND) - ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_PNG_H HAVE_LIBPNG_PNG_H PNG_DEFINITIONS) - - set(PNG_LIBRARY libpng) - set(PNG_LIBRARIES ${PNG_LIBRARY}) - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng") - set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}") - set(PNG_DEFINITIONS "") - ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) -endif() - -set(PNG_VERSION "${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}") - # --- OpenEXR (optional) --- if(WITH_OPENEXR) if(BUILD_OPENEXR) @@ -148,14 +152,16 @@ if(WITH_OPENEXR) else() include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake") endif() -endif() -if(WITH_OPENEXR AND NOT OPENEXR_FOUND) - ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION) + if(NOT OPENEXR_FOUND) + ocv_clear_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION) - set(OPENEXR_LIBRARIES IlmImf) - set(OPENEXR_ILMIMF_LIBRARY IlmImf) - add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr") + set(OPENEXR_LIBRARIES IlmImf) + set(OPENEXR_ILMIMF_LIBRARY IlmImf) + add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr") + endif() + + set(HAVE_OPENEXR YES) endif() #cmake 2.8.2 bug - it fails to determine zlib version diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 8aebbad60..58f96a08f 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -53,7 +53,7 @@ #cmakedefine HAVE_GTK /* OpenEXR codec */ -#cmakedefine HAVE_ILMIMF +#cmakedefine HAVE_OPENEXR /* Apple ImageIO Framework */ #cmakedefine HAVE_IMAGEIO @@ -73,9 +73,6 @@ /* PNG codec */ #cmakedefine HAVE_PNG -/* png.h needs to be included */ -#cmakedefine HAVE_PNG_H - /* QuickTime video libraries */ #cmakedefine HAVE_QUICKTIME diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index c25108702..7b12ff047 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -9,38 +9,33 @@ ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera) ocv_clear_vars(GRFMT_LIBS) -if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR) +if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR) ocv_include_directories(${ZLIB_INCLUDE_DIR}) list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES}) endif() -if(WITH_JPEG) - add_definitions(-DHAVE_JPEG) +if(HAVE_JPEG) ocv_include_directories(${JPEG_INCLUDE_DIR}) list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES}) endif() -if(WITH_PNG) - add_definitions(-DHAVE_PNG) +if(HAVE_PNG) add_definitions(${PNG_DEFINITIONS}) ocv_include_directories(${PNG_INCLUDE_DIR}) list(APPEND GRFMT_LIBS ${PNG_LIBRARIES}) endif() -if(WITH_TIFF) - add_definitions(-DHAVE_TIFF) +if(HAVE_TIFF) ocv_include_directories(${TIFF_INCLUDE_DIR}) list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES}) endif() -if(WITH_JASPER) - add_definitions(-DHAVE_JASPER) +if(HAVE_JASPER) ocv_include_directories(${JASPER_INCLUDE_DIR}) list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES}) endif() -if(WITH_OPENEXR) - add_definitions(-DHAVE_OPENEXR) +if(HAVE_OPENEXR) include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS}) list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES}) endif() From eb8d9730cbd77fea6d91877a942e3c573cf7b5fa Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 12:55:34 +0400 Subject: [PATCH 12/64] Removed unused NEW_FFMPEG macro. --- 3rdparty/ffmpeg/ffmpeg_version.cmake | 1 - cmake/templates/cvconfig.h.cmake | 3 --- 2 files changed, 4 deletions(-) diff --git a/3rdparty/ffmpeg/ffmpeg_version.cmake b/3rdparty/ffmpeg/ffmpeg_version.cmake index 3f27077d6..e35e8c7a6 100644 --- a/3rdparty/ffmpeg/ffmpeg_version.cmake +++ b/3rdparty/ffmpeg/ffmpeg_version.cmake @@ -1,4 +1,3 @@ -set(NEW_FFMPEG 1) set(HAVE_FFMPEG_CODEC 1) set(HAVE_FFMPEG_FORMAT 1) set(HAVE_FFMPEG_UTIL 1) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 58f96a08f..482707475 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -34,9 +34,6 @@ /* FFMpeg video library */ #cmakedefine HAVE_FFMPEG -/* FFMpeg version flag */ -#cmakedefine NEW_FFMPEG - /* ffmpeg's libswscale */ #cmakedefine HAVE_FFMPEG_SWSCALE From 6f326220d3cf06e57cc9138f86a54f33514f6ce5 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 13:22:47 +0400 Subject: [PATCH 13/64] Removed the HAVE_LRINT macro, which is never set. --- cmake/templates/cvconfig.h.cmake | 3 --- modules/core/include/opencv2/core/types_c.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 482707475..90baa3f9d 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -64,9 +64,6 @@ /* libpng/png.h needs to be included */ #cmakedefine HAVE_LIBPNG_PNG_H -/* Define to 1 if you have the `lrint' function. */ -#cmakedefine HAVE_LRINT 1 - /* PNG codec */ #cmakedefine HAVE_PNG diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index 8db2fe766..285b5daa9 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -317,7 +317,7 @@ CV_INLINE int cvRound( double value ) return t; #elif defined _MSC_VER && defined _M_ARM && defined HAVE_TEGRA_OPTIMIZATION TEGRA_ROUND(value); -#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__ +#elif defined CV_ICC || defined __GNUC__ # ifdef HAVE_TEGRA_OPTIMIZATION TEGRA_ROUND(value); # else From 06742247be51fbe8cf600b683b92cd52dbaca511 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 14:26:47 +0400 Subject: [PATCH 14/64] Removed unused PACKAGE_* macros. --- cmake/OpenCVGenHeaders.cmake | 10 ---------- cmake/templates/cvconfig.h.cmake | 18 ------------------ modules/highgui/src/grfmt_jpeg2000.cpp | 6 ------ 3 files changed, 34 deletions(-) diff --git a/cmake/OpenCVGenHeaders.cmake b/cmake/OpenCVGenHeaders.cmake index d2d38c90a..c7129fefa 100644 --- a/cmake/OpenCVGenHeaders.cmake +++ b/cmake/OpenCVGenHeaders.cmake @@ -1,13 +1,3 @@ -# ---------------------------------------------------------------------------- -# Variables for cvconfig.h.cmake -# ---------------------------------------------------------------------------- -set(PACKAGE "opencv") -set(PACKAGE_BUGREPORT "opencvlibrary-devel@lists.sourceforge.net") -set(PACKAGE_NAME "opencv") -set(PACKAGE_STRING "${PACKAGE} ${OPENCV_VERSION}") -set(PACKAGE_TARNAME "${PACKAGE}") -set(PACKAGE_VERSION "${OPENCV_VERSION}") - # platform-specific config file configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.cmake" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h") diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 90baa3f9d..8f88ea370 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -91,24 +91,6 @@ /* OpenCV compiled as static or dynamic libs */ #cmakedefine BUILD_SHARED_LIBS -/* Name of package */ -#define PACKAGE "${PACKAGE}" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "${PACKAGE_NAME}" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "${PACKAGE_STRING}" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "${PACKAGE_TARNAME}" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "${PACKAGE_VERSION}" - /* Version number of package */ #define VERSION "${PACKAGE_VERSION}" diff --git a/modules/highgui/src/grfmt_jpeg2000.cpp b/modules/highgui/src/grfmt_jpeg2000.cpp index d9080e5d4..28818e30c 100644 --- a/modules/highgui/src/grfmt_jpeg2000.cpp +++ b/modules/highgui/src/grfmt_jpeg2000.cpp @@ -53,12 +53,6 @@ #endif #endif -#undef PACKAGE -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION #undef VERSION #include From 78cb920bc8f2fa8f823a7899e46f89eefd14d01b Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 14:28:41 +0400 Subject: [PATCH 15/64] Removed useless VERSION macro (and CMake variable) --- cmake/OpenCVGenPkgconfig.cmake | 1 - cmake/templates/cvconfig.h.cmake | 3 --- cmake/templates/opencv-XXX.pc.cmake.in | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake index 49d670734..7bfc7bc5a 100644 --- a/cmake/OpenCVGenPkgconfig.cmake +++ b/cmake/OpenCVGenPkgconfig.cmake @@ -12,7 +12,6 @@ set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}") set(libdir "") #TODO: need link paths for OpenCV_EXTRA_COMPONENTS set(includedir "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}") -set(VERSION ${OPENCV_VERSION}) if(CMAKE_BUILD_TYPE MATCHES "Release") set(ocv_optkind OPT) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 8f88ea370..6ebe1c694 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -91,9 +91,6 @@ /* OpenCV compiled as static or dynamic libs */ #cmakedefine BUILD_SHARED_LIBS -/* Version number of package */ -#define VERSION "${PACKAGE_VERSION}" - /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN diff --git a/cmake/templates/opencv-XXX.pc.cmake.in b/cmake/templates/opencv-XXX.pc.cmake.in index 4f6415cab..c9dedb0da 100644 --- a/cmake/templates/opencv-XXX.pc.cmake.in +++ b/cmake/templates/opencv-XXX.pc.cmake.in @@ -8,6 +8,6 @@ includedir_new=@includedir@ Name: OpenCV Description: Open Source Computer Vision Library -Version: @VERSION@ +Version: @OPENCV_VERSION@ Libs: @OpenCV_LIB_COMPONENTS@ Cflags: -I${includedir_old} -I${includedir_new} From 0b4d0a817142a3e85b3c8e6cd83717afa0535398 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 11 Jul 2013 16:01:46 +0400 Subject: [PATCH 16/64] Sorted cvconfig.h.cmake in alphabetical order. --- cmake/templates/cvconfig.h.cmake | 211 ++++++++++++++++--------------- 1 file changed, 106 insertions(+), 105 deletions(-) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index 6ebe1c694..f5950b64f 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -1,5 +1,20 @@ -/* Video for Windows support */ -#cmakedefine HAVE_VFW +/* OpenCV compiled as static or dynamic libs */ +#cmakedefine BUILD_SHARED_LIBS + +/* Compile for 'real' NVIDIA GPU architectures */ +#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}" + +/* Create PTX or BIN for 1.0 compute capability */ +#cmakedefine CUDA_ARCH_BIN_OR_PTX_10 + +/* NVIDIA GPU features are used */ +#define CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES}" + +/* Compile for 'virtual' NVIDIA PTX architectures */ +#define CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX}" + +/* AVFoundation video libraries */ +#cmakedefine HAVE_AVFOUNDATION /* V4L capturing support */ #cmakedefine HAVE_CAMV4L @@ -7,18 +22,30 @@ /* V4L2 capturing support */ #cmakedefine HAVE_CAMV4L2 -/* V4L2 capturing support in videoio.h */ -#cmakedefine HAVE_VIDEOIO - -/* V4L/V4L2 capturing support via libv4l */ -#cmakedefine HAVE_LIBV4L - /* Carbon windowing environment */ #cmakedefine HAVE_CARBON +/* AMD's Basic Linear Algebra Subprograms Library*/ +#cmakedefine HAVE_CLAMDBLAS + +/* AMD's OpenCL Fast Fourier Transform Library*/ +#cmakedefine HAVE_CLAMDFFT + /* Cocoa API */ #cmakedefine HAVE_COCOA +/* C= */ +#cmakedefine HAVE_CSTRIPES + +/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/ +#cmakedefine HAVE_CUBLAS + +/* NVidia Cuda Runtime API*/ +#cmakedefine HAVE_CUDA + +/* NVidia Cuda Fast Fourier Transform (FFT) API*/ +#cmakedefine HAVE_CUFFT + /* IEEE1394 capturing support */ #cmakedefine HAVE_DC1394 @@ -28,129 +55,103 @@ /* IEEE1394 capturing support - libdc1394 v2.x */ #cmakedefine HAVE_DC1394_2 +/* DirectShow Video Capture library */ +#cmakedefine HAVE_DSHOW + +/* Eigen Matrix & Linear Algebra Library */ +#cmakedefine HAVE_EIGEN + +/* FFMpeg video library */ +#cmakedefine HAVE_FFMPEG + +/* ffmpeg's libswscale */ +#cmakedefine HAVE_FFMPEG_SWSCALE + /* ffmpeg in Gentoo */ #cmakedefine HAVE_GENTOO_FFMPEG -/* FFMpeg video library */ -#cmakedefine HAVE_FFMPEG - -/* ffmpeg's libswscale */ -#cmakedefine HAVE_FFMPEG_SWSCALE - /* GStreamer multimedia framework */ -#cmakedefine HAVE_GSTREAMER +#cmakedefine HAVE_GSTREAMER /* GTK+ 2.0 Thread support */ -#cmakedefine HAVE_GTHREAD - -/* Win32 UI */ -#cmakedefine HAVE_WIN32UI +#cmakedefine HAVE_GTHREAD /* GTK+ 2.x toolkit */ -#cmakedefine HAVE_GTK - -/* OpenEXR codec */ -#cmakedefine HAVE_OPENEXR +#cmakedefine HAVE_GTK /* Apple ImageIO Framework */ -#cmakedefine HAVE_IMAGEIO - -/* JPEG-2000 codec */ -#cmakedefine HAVE_JASPER - -/* IJG JPEG codec */ -#cmakedefine HAVE_JPEG - -/* libpng/png.h needs to be included */ -#cmakedefine HAVE_LIBPNG_PNG_H - -/* PNG codec */ -#cmakedefine HAVE_PNG - -/* QuickTime video libraries */ -#cmakedefine HAVE_QUICKTIME - -/* AVFoundation video libraries */ -#cmakedefine HAVE_AVFOUNDATION - -/* TIFF codec */ -#cmakedefine HAVE_TIFF - -/* Unicap video capture library */ -#cmakedefine HAVE_UNICAP - -/* Xine video library */ -#cmakedefine HAVE_XINE - -/* OpenNI library */ -#cmakedefine HAVE_OPENNI +#cmakedefine HAVE_IMAGEIO /* Intel Integrated Performance Primitives */ -#cmakedefine HAVE_IPP +#cmakedefine HAVE_IPP -/* OpenCV compiled as static or dynamic libs */ -#cmakedefine BUILD_SHARED_LIBS +/* JPEG-2000 codec */ +#cmakedefine HAVE_JASPER -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#cmakedefine WORDS_BIGENDIAN +/* IJG JPEG codec */ +#cmakedefine HAVE_JPEG -/* Intel Threading Building Blocks */ -#cmakedefine HAVE_TBB +/* libpng/png.h needs to be included */ +#cmakedefine HAVE_LIBPNG_PNG_H -/* C= */ -#cmakedefine HAVE_CSTRIPES - -/* Eigen Matrix & Linear Algebra Library */ -#cmakedefine HAVE_EIGEN - -/* NVidia Cuda Runtime API*/ -#cmakedefine HAVE_CUDA - -/* NVidia Cuda Fast Fourier Transform (FFT) API*/ -#cmakedefine HAVE_CUFFT - -/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/ -#cmakedefine HAVE_CUBLAS - -/* NVidia Video Decoding API*/ -#cmakedefine HAVE_NVCUVID - -/* Compile for 'real' NVIDIA GPU architectures */ -#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}" - -/* Compile for 'virtual' NVIDIA PTX architectures */ -#define CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX}" - -/* NVIDIA GPU features are used */ -#define CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES}" - -/* Create PTX or BIN for 1.0 compute capability */ -#cmakedefine CUDA_ARCH_BIN_OR_PTX_10 - -/* OpenCL Support */ -#cmakedefine HAVE_OPENCL - -/* AMD's OpenCL Fast Fourier Transform Library*/ -#cmakedefine HAVE_CLAMDFFT - -/* AMD's Basic Linear Algebra Subprograms Library*/ -#cmakedefine HAVE_CLAMDBLAS - -/* DirectShow Video Capture library */ -#cmakedefine HAVE_DSHOW +/* V4L/V4L2 capturing support via libv4l */ +#cmakedefine HAVE_LIBV4L /* Microsoft Media Foundation Capture library */ #cmakedefine HAVE_MSMF -/* XIMEA camera support */ -#cmakedefine HAVE_XIMEA +/* NVidia Video Decoding API*/ +#cmakedefine HAVE_NVCUVID + +/* OpenCL Support */ +#cmakedefine HAVE_OPENCL + +/* OpenEXR codec */ +#cmakedefine HAVE_OPENEXR /* OpenGL support*/ #cmakedefine HAVE_OPENGL +/* OpenNI library */ +#cmakedefine HAVE_OPENNI + +/* PNG codec */ +#cmakedefine HAVE_PNG + /* Qt support */ #cmakedefine HAVE_QT /* Qt OpenGL support */ #cmakedefine HAVE_QT_OPENGL + +/* QuickTime video libraries */ +#cmakedefine HAVE_QUICKTIME + +/* Intel Threading Building Blocks */ +#cmakedefine HAVE_TBB + +/* TIFF codec */ +#cmakedefine HAVE_TIFF + +/* Unicap video capture library */ +#cmakedefine HAVE_UNICAP + +/* Video for Windows support */ +#cmakedefine HAVE_VFW + +/* V4L2 capturing support in videoio.h */ +#cmakedefine HAVE_VIDEOIO + +/* Win32 UI */ +#cmakedefine HAVE_WIN32UI + +/* XIMEA camera support */ +#cmakedefine HAVE_XIMEA + +/* Xine video library */ +#cmakedefine HAVE_XINE + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#cmakedefine WORDS_BIGENDIAN + From cdd9234fae9c55b3754dc7425b82cf0ff5fb7c25 Mon Sep 17 00:00:00 2001 From: yao Date: Mon, 15 Jul 2013 15:13:09 +0800 Subject: [PATCH 17/64] fix hog mismatch on cpu ocl --- modules/ocl/src/hog.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/ocl/src/hog.cpp b/modules/ocl/src/hog.cpp index 412afee8b..2e2b3a992 100644 --- a/modules/ocl/src/hog.cpp +++ b/modules/ocl/src/hog.cpp @@ -254,7 +254,7 @@ cv::ocl::HOGDescriptor::HOGDescriptor(Size win_size_, Size block_size_, Size blo effect_size = Size(0, 0); - if (queryDeviceInfo()) + if (queryDeviceInfo()) hog_device_cpu = true; else hog_device_cpu = false; @@ -1758,8 +1758,20 @@ void cv::ocl::device::hog::compute_hists(int nbins, args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); args.push_back( make_pair( smem, (void *)NULL)); - openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads, - localThreads, args, -1, -1); + + if(hog_device_cpu) + { + openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads, + localThreads, args, -1, -1, "-D CPU"); + }else + { + cl_kernel kernel = openCLGetKernelFromSource(clCxt, &objdetect_hog, kernelName); + int wave_size = queryDeviceInfo(kernel); + char opt[32] = {0}; + sprintf(opt, "-D WAVE_SIZE=%d", wave_size); + openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads, + localThreads, args, -1, -1, opt); + } } void cv::ocl::device::hog::normalize_hists(int nbins, From e5c396bb24be0a0bb5c5f96de0f9bf3f3685489b Mon Sep 17 00:00:00 2001 From: peng xiao Date: Mon, 15 Jul 2013 16:27:27 +0800 Subject: [PATCH 18/64] Add ocl::gftt performance test. --- modules/ocl/perf/perf_gftt.cpp | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 modules/ocl/perf/perf_gftt.cpp diff --git a/modules/ocl/perf/perf_gftt.cpp b/modules/ocl/perf/perf_gftt.cpp new file mode 100644 index 000000000..4eec240b0 --- /dev/null +++ b/modules/ocl/perf/perf_gftt.cpp @@ -0,0 +1,101 @@ +/*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) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Peng Xiao, pengxiao@outlook.com +// +// 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 oclMaterials 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 "precomp.hpp" + +///////////// GoodFeaturesToTrack //////////////////////// +PERFTEST(GoodFeaturesToTrack) +{ + using namespace cv; + + int maxCorners = 2000; + double qualityLevel = 0.01; + + std::string images[] = { "rubberwhale1.png", "aloeL.jpg" }; + + std::vector pts_gold, pts_ocl; + + for(int imgIdx = 0; imgIdx < sizeof(images)/sizeof(std::string); ++imgIdx) + { + Mat frame = imread(abspath(images[imgIdx]), IMREAD_GRAYSCALE); + CV_Assert(!frame.empty()); + + for(float minDistance = 0; minDistance < 4; minDistance += 3.0) + { + SUBTEST << "image = " << images[imgIdx] << "; "; + SUBTEST << "minDistance = " << minDistance << "; "; + + cv::goodFeaturesToTrack(frame, pts_gold, maxCorners, qualityLevel, minDistance); + + CPU_ON; + cv::goodFeaturesToTrack(frame, pts_gold, maxCorners, qualityLevel, minDistance); + CPU_OFF; + + cv::ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance); + + ocl::oclMat frame_ocl(frame), pts_oclmat; + + WARMUP_ON; + detector(frame_ocl, pts_oclmat); + WARMUP_OFF; + + detector.downloadPoints(pts_oclmat, pts_ocl); + + double diff = abs(static_cast(pts_gold.size() - pts_ocl.size())); + TestSystem::instance().setAccurate(diff == 0.0, diff); + + GPU_ON; + detector(frame_ocl, pts_oclmat); + GPU_OFF; + + GPU_FULL_ON; + frame_ocl.upload(frame); + detector(frame_ocl, pts_oclmat); + detector.downloadPoints(pts_oclmat, pts_ocl); + GPU_FULL_OFF; + } + } +} From ff735573045226bc9c24717428339df9d14d9861 Mon Sep 17 00:00:00 2001 From: peng xiao Date: Tue, 16 Jul 2013 08:48:09 +0800 Subject: [PATCH 19/64] Fix compilation error on Mac --- modules/ocl/perf/perf_gftt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ocl/perf/perf_gftt.cpp b/modules/ocl/perf/perf_gftt.cpp index 4eec240b0..bca6f398a 100644 --- a/modules/ocl/perf/perf_gftt.cpp +++ b/modules/ocl/perf/perf_gftt.cpp @@ -58,7 +58,7 @@ PERFTEST(GoodFeaturesToTrack) std::vector pts_gold, pts_ocl; - for(int imgIdx = 0; imgIdx < sizeof(images)/sizeof(std::string); ++imgIdx) + for(size_t imgIdx = 0; imgIdx < (sizeof(images)/sizeof(std::string)); ++imgIdx) { Mat frame = imread(abspath(images[imgIdx]), IMREAD_GRAYSCALE); CV_Assert(!frame.empty()); From f1060ac5147b550cef256a1ef533390949f31379 Mon Sep 17 00:00:00 2001 From: yao Date: Wed, 17 Jul 2013 14:35:44 +0800 Subject: [PATCH 20/64] a little simplify to pyrlk kernel --- modules/ocl/perf/perf_opticalflow.cpp | 4 +- modules/ocl/src/opencl/pyrlk.cl | 943 +++++++++++--------------- 2 files changed, 413 insertions(+), 534 deletions(-) diff --git a/modules/ocl/perf/perf_opticalflow.cpp b/modules/ocl/perf/perf_opticalflow.cpp index 936d7a77f..10763b5b0 100644 --- a/modules/ocl/perf/perf_opticalflow.cpp +++ b/modules/ocl/perf/perf_opticalflow.cpp @@ -48,8 +48,8 @@ ///////////// PyrLKOpticalFlow //////////////////////// PERFTEST(PyrLKOpticalFlow) { - std::string images1[] = {"rubberwhale1.png", "basketball1.png"}; - std::string images2[] = {"rubberwhale2.png", "basketball2.png"}; + std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"}; + std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"}; for (size_t i = 0; i < sizeof(images1) / sizeof(std::string); i++) { diff --git a/modules/ocl/src/opencl/pyrlk.cl b/modules/ocl/src/opencl/pyrlk.cl index 40a199395..02cf3afa4 100644 --- a/modules/ocl/src/opencl/pyrlk.cl +++ b/modules/ocl/src/opencl/pyrlk.cl @@ -17,6 +17,7 @@ // @Authors // Dachuan Zhao, dachuan@multicorewareinc.com // Yao Wang, bitwangyaoyao@gmail.com +// Xiaopeng Fu, fuxiaopeng2222@163.com // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: @@ -47,6 +48,7 @@ //#pragma OPENCL EXTENSION cl_amd_printf : enable #define BUFFER 64 +#define BUFFER2 BUFFER>>1 #ifndef WAVE_SIZE #define WAVE_SIZE 1 #endif @@ -58,53 +60,16 @@ void reduce3(float val1, float val2, float val3, __local float* smem1, __local smem3[tid] = val3; barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 32) + for(int i = BUFFER2; i > 0; i >>= 1) { - smem1[tid] += smem1[tid + 32]; - smem2[tid] += smem2[tid + 32]; - smem3[tid] += smem3[tid + 32]; + if(tid < i) + { + smem1[tid] += smem1[tid + i]; + smem2[tid] += smem2[tid + i]; + smem3[tid] += smem3[tid + i]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 16) - { - smem1[tid] += smem1[tid + 16]; - smem2[tid] += smem2[tid + 16]; - smem3[tid] += smem3[tid + 16]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 8) - { - smem1[tid] += smem1[tid + 8]; - smem2[tid] += smem2[tid + 8]; - smem3[tid] += smem3[tid + 8]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 4) - { - smem1[tid] += smem1[tid + 4]; - smem2[tid] += smem2[tid + 4]; - smem3[tid] += smem3[tid + 4]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 2) - { - smem1[tid] += smem1[tid + 2]; - smem2[tid] += smem2[tid + 2]; - smem3[tid] += smem3[tid + 2]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 1) - { - smem1[BUFFER] = smem1[tid] + smem1[tid + 1]; - smem2[BUFFER] = smem2[tid] + smem2[tid + 1]; - smem3[BUFFER] = smem3[tid] + smem3[tid + 1]; - } - barrier(CLK_LOCAL_MEM_FENCE); } void reduce2(float val1, float val2, volatile __local float* smem1, volatile __local float* smem2, int tid) @@ -113,47 +78,15 @@ void reduce2(float val1, float val2, volatile __local float* smem1, volatile __l smem2[tid] = val2; barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 32) + for(int i = BUFFER2; i > 0; i >>= 1) { - smem1[tid] += smem1[tid + 32]; - smem2[tid] += smem2[tid + 32]; + if(tid < i) + { + smem1[tid] += smem1[tid + i]; + smem2[tid] += smem2[tid + i]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 16) - { - smem1[tid] += smem1[tid + 16]; - smem2[tid] += smem2[tid + 16]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 8) - { - smem1[tid] += smem1[tid + 8]; - smem2[tid] += smem2[tid + 8]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 4) - { - smem1[tid] += smem1[tid + 4]; - smem2[tid] += smem2[tid + 4]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 2) - { - smem1[tid] += smem1[tid + 2]; - smem2[tid] += smem2[tid + 2]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 1) - { - smem1[BUFFER] = smem1[tid] + smem1[tid + 1]; - smem2[BUFFER] = smem2[tid] + smem2[tid + 1]; - } - barrier(CLK_LOCAL_MEM_FENCE); } void reduce1(float val1, volatile __local float* smem1, int tid) @@ -161,45 +94,18 @@ void reduce1(float val1, volatile __local float* smem1, int tid) smem1[tid] = val1; barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 32) + for(int i = BUFFER2; i > 0; i >>= 1) { - smem1[tid] += smem1[tid + 32]; + if(tid < i) + { + smem1[tid] += smem1[tid + i]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 16) - { - smem1[tid] += smem1[tid + 16]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 8) - { - smem1[tid] += smem1[tid + 8]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 4) - { - smem1[tid] += smem1[tid + 4]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 2) - { - smem1[tid] += smem1[tid + 2]; - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (tid < 1) - { - smem1[BUFFER] = smem1[tid] + smem1[tid + 1]; - } - barrier(CLK_LOCAL_MEM_FENCE); } #else -void reduce3(float val1, float val2, float val3, -__local volatile float* smem1, __local volatile float* smem2, __local volatile float* smem3, int tid) +void reduce3(float val1, float val2, float val3, + __local volatile float* smem1, __local volatile float* smem2, __local volatile float* smem3, int tid) { smem1[tid] = val1; smem2[tid] = val2; @@ -212,15 +118,19 @@ __local volatile float* smem1, __local volatile float* smem2, __local volatile f smem2[tid] += smem2[tid + 32]; smem3[tid] += smem3[tid + 32]; #if WAVE_SIZE < 32 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 16) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 16) + { #endif smem1[tid] += smem1[tid + 16]; smem2[tid] += smem2[tid + 16]; smem3[tid] += smem3[tid + 16]; #if WAVE_SIZE <16 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 8) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 8) + { #endif smem1[tid] += smem1[tid + 8]; smem2[tid] += smem2[tid + 8]; @@ -238,6 +148,7 @@ __local volatile float* smem1, __local volatile float* smem2, __local volatile f smem2[tid] += smem2[tid + 1]; smem3[tid] += smem3[tid + 1]; } + barrier(CLK_LOCAL_MEM_FENCE); } void reduce2(float val1, float val2, __local volatile float* smem1, __local volatile float* smem2, int tid) @@ -251,14 +162,18 @@ void reduce2(float val1, float val2, __local volatile float* smem1, __local vola smem1[tid] += smem1[tid + 32]; smem2[tid] += smem2[tid + 32]; #if WAVE_SIZE < 32 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 16) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 16) + { #endif smem1[tid] += smem1[tid + 16]; smem2[tid] += smem2[tid + 16]; #if WAVE_SIZE <16 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 8) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 8) + { #endif smem1[tid] += smem1[tid + 8]; smem2[tid] += smem2[tid + 8]; @@ -272,6 +187,7 @@ void reduce2(float val1, float val2, __local volatile float* smem1, __local vola smem1[tid] += smem1[tid + 1]; smem2[tid] += smem2[tid + 1]; } + barrier(CLK_LOCAL_MEM_FENCE); } void reduce1(float val1, __local volatile float* smem1, int tid) @@ -283,19 +199,24 @@ void reduce1(float val1, __local volatile float* smem1, int tid) { smem1[tid] += smem1[tid + 32]; #if WAVE_SIZE < 32 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 16) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 16) + { #endif smem1[tid] += smem1[tid + 16]; #if WAVE_SIZE <16 - } barrier(CLK_LOCAL_MEM_FENCE); - if (tid < 8) { + } + barrier(CLK_LOCAL_MEM_FENCE); + if (tid < 8) + { #endif smem1[tid] += smem1[tid + 8]; smem1[tid] += smem1[tid + 4]; smem1[tid] += smem1[tid + 2]; smem1[tid] += smem1[tid + 1]; } + barrier(CLK_LOCAL_MEM_FENCE); } #endif @@ -306,106 +227,100 @@ void reduce1(float val1, __local volatile float* smem1, int tid) __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR; void SetPatch(image2d_t I, float x, float y, - float* Pch, float* Dx, float* Dy, - float* A11, float* A12, float* A22) + float* Pch, float* Dx, float* Dy, + float* A11, float* A12, float* A22) { - *Pch = read_imagef(I, sampler, (float2)(x, y)).x; + *Pch = read_imagef(I, sampler, (float2)(x, y)).x; - float dIdx = 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x + 1, y)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)).x - - (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x - 1, y)).x + 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)).x); + float dIdx = 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x + 1, y)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)).x - + (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x - 1, y)).x + 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)).x); - float dIdy = 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x, y + 1)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)).x - - (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x, y - 1)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)).x); + float dIdy = 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x, y + 1)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)).x - + (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)).x + 10.0f * read_imagef(I, sampler, (float2)(x, y - 1)).x + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)).x); - *Dx = dIdx; - *Dy = dIdy; + *Dx = dIdx; + *Dy = dIdy; - *A11 += dIdx * dIdx; - *A12 += dIdx * dIdy; - *A22 += dIdy * dIdy; + *A11 += dIdx * dIdx; + *A12 += dIdx * dIdy; + *A22 += dIdy * dIdy; } void GetPatch(image2d_t J, float x, float y, - float* Pch, float* Dx, float* Dy, - float* b1, float* b2) + float* Pch, float* Dx, float* Dy, + float* b1, float* b2) { - float J_val = read_imagef(J, sampler, (float2)(x, y)).x; - float diff = (J_val - *Pch) * 32.0f; - *b1 += diff**Dx; - *b2 += diff**Dy; + float J_val = read_imagef(J, sampler, (float2)(x, y)).x; + float diff = (J_val - *Pch) * 32.0f; + *b1 += diff**Dx; + *b2 += diff**Dy; } void GetError(image2d_t J, const float x, const float y, const float* Pch, float* errval) { - float diff = read_imagef(J, sampler, (float2)(x,y)).x-*Pch; - *errval += fabs(diff); + float diff = read_imagef(J, sampler, (float2)(x,y)).x-*Pch; + *errval += fabs(diff); } void SetPatch4(image2d_t I, const float x, const float y, - float4* Pch, float4* Dx, float4* Dy, - float* A11, float* A12, float* A22) + float4* Pch, float4* Dx, float4* Dy, + float* A11, float* A12, float* A22) { - *Pch = read_imagef(I, sampler, (float2)(x, y)); + *Pch = read_imagef(I, sampler, (float2)(x, y)); - float4 dIdx = 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x + 1, y)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)) - - (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x - 1, y)) + 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1))); + float4 dIdx = 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x + 1, y)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)) - + (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x - 1, y)) + 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1))); - float4 dIdy = 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)) + 10.0f * read_imagef(I, sampler, (float2)(x, y + 1)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)) - - (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x, y - 1)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1))); + float4 dIdy = 3.0f * read_imagef(I, sampler, (float2)(x - 1, y + 1)) + 10.0f * read_imagef(I, sampler, (float2)(x, y + 1)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y + 1)) - + (3.0f * read_imagef(I, sampler, (float2)(x - 1, y - 1)) + 10.0f * read_imagef(I, sampler, (float2)(x, y - 1)) + 3.0f * read_imagef(I, sampler, (float2)(x + 1, y - 1))); - *Dx = dIdx; - *Dy = dIdy; - float4 sqIdx = dIdx * dIdx; - *A11 += sqIdx.x + sqIdx.y + sqIdx.z; - sqIdx = dIdx * dIdy; - *A12 += sqIdx.x + sqIdx.y + sqIdx.z; - sqIdx = dIdy * dIdy; - *A22 += sqIdx.x + sqIdx.y + sqIdx.z; + *Dx = dIdx; + *Dy = dIdy; + float4 sqIdx = dIdx * dIdx; + *A11 += sqIdx.x + sqIdx.y + sqIdx.z; + sqIdx = dIdx * dIdy; + *A12 += sqIdx.x + sqIdx.y + sqIdx.z; + sqIdx = dIdy * dIdy; + *A22 += sqIdx.x + sqIdx.y + sqIdx.z; } void GetPatch4(image2d_t J, const float x, const float y, - const float4* Pch, const float4* Dx, const float4* Dy, - float* b1, float* b2) + const float4* Pch, const float4* Dx, const float4* Dy, + float* b1, float* b2) { - float4 J_val = read_imagef(J, sampler, (float2)(x, y)); - float4 diff = (J_val - *Pch) * 32.0f; - float4 xdiff = diff* *Dx; - *b1 += xdiff.x + xdiff.y + xdiff.z; - xdiff = diff* *Dy; - *b2 += xdiff.x + xdiff.y + xdiff.z; + float4 J_val = read_imagef(J, sampler, (float2)(x, y)); + float4 diff = (J_val - *Pch) * 32.0f; + float4 xdiff = diff* *Dx; + *b1 += xdiff.x + xdiff.y + xdiff.z; + xdiff = diff* *Dy; + *b2 += xdiff.x + xdiff.y + xdiff.z; } void GetError4(image2d_t J, const float x, const float y, const float4* Pch, float* errval) { - float4 diff = read_imagef(J, sampler, (float2)(x,y))-*Pch; - *errval += fabs(diff.x) + fabs(diff.y) + fabs(diff.z); + float4 diff = read_imagef(J, sampler, (float2)(x,y))-*Pch; + *errval += fabs(diff.x) + fabs(diff.y) + fabs(diff.z); } #define GRIDSIZE 3 __kernel void lkSparse_C1_D5(image2d_t I, image2d_t J, - __global const float2* prevPts, int prevPtsStep, __global float2* nextPts, int nextPtsStep, __global uchar* status, __global float* err, - const int level, const int rows, const int cols, int PATCH_X, int PATCH_Y, int cn, int c_winSize_x, int c_winSize_y, int c_iters, char calcErr) + __global const float2* prevPts, int prevPtsStep, __global float2* nextPts, int nextPtsStep, __global uchar* status, __global float* err, + const int level, const int rows, const int cols, int PATCH_X, int PATCH_Y, int cn, int c_winSize_x, int c_winSize_y, int c_iters, char calcErr) { -#ifdef CPU - __local float smem1[BUFFER+1]; - __local float smem2[BUFFER+1]; - __local float smem3[BUFFER+1]; -#else __local float smem1[BUFFER]; __local float smem2[BUFFER]; __local float smem3[BUFFER]; -#endif - unsigned int xid=get_local_id(0); - unsigned int yid=get_local_id(1); - unsigned int gid=get_group_id(0); - unsigned int xsize=get_local_size(0); - unsigned int ysize=get_local_size(1); - int xBase, yBase, i, j, k; + unsigned int xid=get_local_id(0); + unsigned int yid=get_local_id(1); + unsigned int gid=get_group_id(0); + unsigned int xsize=get_local_size(0); + unsigned int ysize=get_local_size(1); + int xBase, yBase, i, j, k; - float2 c_halfWin = (float2)((c_winSize_x - 1)>>1, (c_winSize_y - 1)>>1); + float2 c_halfWin = (float2)((c_winSize_x - 1)>>1, (c_winSize_y - 1)>>1); const int tid = mad24(yid, xsize, xid); @@ -432,77 +347,71 @@ __kernel void lkSparse_C1_D5(image2d_t I, image2d_t J, float dIdx_patch[GRIDSIZE][GRIDSIZE]; float dIdy_patch[GRIDSIZE][GRIDSIZE]; - yBase=yid; - { - xBase=xid; - SetPatch(I, prevPt.x + xBase + 0.5f, prevPt.y + yBase + 0.5f, - &I_patch[0][0], &dIdx_patch[0][0], &dIdy_patch[0][0], - &A11, &A12, &A22); + yBase=yid; + { + xBase=xid; + SetPatch(I, prevPt.x + xBase + 0.5f, prevPt.y + yBase + 0.5f, + &I_patch[0][0], &dIdx_patch[0][0], &dIdy_patch[0][0], + &A11, &A12, &A22); - xBase+=xsize; - SetPatch(I, prevPt.x + xBase + 0.5f, prevPt.y + yBase + 0.5f, - &I_patch[0][1], &dIdx_patch[0][1], &dIdy_patch[0][1], - &A11, &A12, &A22); + xBase+=xsize; + SetPatch(I, prevPt.x + xBase + 0.5f, prevPt.y + yBase + 0.5f, + &I_patch[0][1], &dIdx_patch[0][1], &dIdy_patch[0][1], + &A11, &A12, &A22); - xBase+=xsize; - if(xBase>1, (c_winSize_y - 1)>>1); + float2 c_halfWin = (float2)((c_winSize_x - 1)>>1, (c_winSize_y - 1)>>1); const int tid = mad24(yid, xsize, xid); @@ -721,7 +615,7 @@ __kernel void lkSparse_C4_D5(image2d_t I, image2d_t J, return; } - nextPt -= c_halfWin; + nextPt -= c_halfWin; // extract the patch from the first image, compute covariation matrix of derivatives @@ -732,80 +626,74 @@ __kernel void lkSparse_C4_D5(image2d_t I, image2d_t J, float4 I_patch[8]; float4 dIdx_patch[8]; float4 dIdy_patch[8]; - float4 I_add,Dx_add,Dy_add; + float4 I_add,Dx_add,Dy_add; - yBase=yid; - { - xBase=xid; - SetPatch4(I, nextPt.x + xBase + 0.5f, nextPt.y + yBase + 0.5f, - &I_patch[0], &dIdx_patch[0], &dIdy_patch[0], - &A11, &A12, &A22); + yBase=yid; + { + xBase=xid; + SetPatch4(I, nextPt.x + xBase + 0.5f, nextPt.y + yBase + 0.5f, + &I_patch[0], &dIdx_patch[0], &dIdy_patch[0], + &A11, &A12, &A22); - xBase+=xsize; - SetPatch4(I, nextPt.x + xBase + 0.5f, nextPt.y + yBase + 0.5f, - &I_patch[1], &dIdx_patch[1], &dIdy_patch[1], - &A11, &A12, &A22); + xBase+=xsize; + SetPatch4(I, nextPt.x + xBase + 0.5f, nextPt.y + yBase + 0.5f, + &I_patch[1], &dIdx_patch[1], &dIdy_patch[1], + &A11, &A12, &A22); - xBase+=xsize; - if(xBase Date: Wed, 17 Jul 2013 15:21:23 +0200 Subject: [PATCH 21/64] Fixed bug #3101, problem on ellipse2poly function --- modules/core/src/drawing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index 9e3340897..fa0c5cf17 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -888,9 +888,10 @@ void ellipse2Poly( Point center, Size axes, int angle, pt.y = cvRound( cy + x * beta + y * alpha ); if( pt != prevPt ) pts.push_back(pt); + prevPt = pt; } - if( pts.size() < 2 ) + if( pts.size() == 1 ) pts.push_back(pts[0]); } From dd0481ef2df420bc8d3393ee6a57d07b46a3d691 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Thu, 18 Jul 2013 15:34:38 +0200 Subject: [PATCH 22/64] Added brackets around line 888-892 for correct code! --- modules/core/src/drawing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index fa0c5cf17..144fa964f 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -886,9 +886,10 @@ void ellipse2Poly( Point center, Size axes, int angle, Point pt; pt.x = cvRound( cx + x * alpha - y * beta ); pt.y = cvRound( cy + x * beta + y * alpha ); - if( pt != prevPt ) + if( pt != prevPt ){ pts.push_back(pt); prevPt = pt; + } } if( pts.size() == 1 ) From 9c04db554f753b7648f0a2a8e19eb9e93e085c0c Mon Sep 17 00:00:00 2001 From: Philippe FOUBERT Date: Sat, 20 Jul 2013 15:03:30 +0200 Subject: [PATCH 23/64] Rename PVAPI_DECLARATIONS to PVAPI_DEFINITIONS --- cmake/OpenCVFindLibsVideo.cmake | 2 +- modules/highgui/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index da61ad167..b7c838285 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -60,7 +60,7 @@ if(WITH_PVAPI) if(WIN32) if(MINGW) - set(PVAPI_DECLARATIONS "-DPVDECL=__stdcall") + set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall") endif(MINGW) set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/PvAPI.lib" CACHE PATH "The PvAPI library") else(WIN32) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 8e2909843..834eb821c 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -197,7 +197,7 @@ endif(HAVE_FFMPEG) if(HAVE_PVAPI) add_definitions(-DHAVE_PVAPI) - add_definitions(${PVAPI_DECLARATIONS}) + add_definitions(${PVAPI_DEFINITIONS}) ocv_include_directories(${PVAPI_INCLUDE_PATH}) set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs}) list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY}) From 7968789544f5c23fc6ed42ff24025dac6c4785b7 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Mon, 22 Jul 2013 15:16:22 +0200 Subject: [PATCH 24/64] Made change to install in windows guide, showing only difference between VS2010 and VS2012 --- .../introduction/windows_install/windows_install.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/tutorials/introduction/windows_install/windows_install.rst b/doc/tutorials/introduction/windows_install/windows_install.rst index cbfd0f66f..8ed84197d 100644 --- a/doc/tutorials/introduction/windows_install/windows_install.rst +++ b/doc/tutorials/introduction/windows_install/windows_install.rst @@ -312,9 +312,13 @@ First we set an enviroment variable to make easier our work. This will hold the :: - setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10 - -Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have folders like *bin* and *include*. The -m should be added if you wish to make the settings computer wise, instead of user wise. + setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10 (suggested for Visual Studio 2010 - 32 bit Windows) + setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc10 (suggested for Visual Studio 2010 - 64 bit Windows) + + setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc11 (suggested for Visual Studio 2012 - 32 bit Windows) + setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc11 (suggested for Visual Studio 2012 - 64 bit Windows) + +Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have two folders called *lib* and *bin*. The -m should be added if you wish to make the settings computer wise, instead of user wise. If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path. This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu): From a92feafc49e9d1db6929dd9e33fd15f12cf90267 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Tue, 23 Jul 2013 08:49:25 +0200 Subject: [PATCH 25/64] Fixed bug 3166 - added paper reference to stardetector code --- .../doc/common_interfaces_of_feature_detectors.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index 81c72d3a8..1358e6922 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -220,7 +220,7 @@ StarFeatureDetector ------------------- .. ocv:class:: StarFeatureDetector : public FeatureDetector -The class implements the keypoint detector introduced by K. Konolige, synonym of ``StarDetector``. :: +The class implements the keypoint detector introduced by [Agrawal08_], synonym of ``StarDetector``. :: class StarFeatureDetector : public FeatureDetector { @@ -234,6 +234,9 @@ The class implements the keypoint detector introduced by K. Konolige, synonym of ... }; +.. [Agrawal08] Agrawal, M., Konolige, K., & Blas, M. R. (2008). Censure: Center surround extremas for realtime feature detection and matching. In Computer Vision–ECCV 2008 (pp. 102-115). Springer Berlin Heidelberg. + + DenseFeatureDetector -------------------- .. ocv:class:: DenseFeatureDetector : public FeatureDetector From 194af062ff7c2195534db2ec66a34a974402a131 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Tue, 23 Jul 2013 09:49:09 +0200 Subject: [PATCH 26/64] Adapted the reference underscore to link properly --- .../features2d/doc/common_interfaces_of_feature_detectors.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index 1358e6922..84de8950a 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -220,7 +220,7 @@ StarFeatureDetector ------------------- .. ocv:class:: StarFeatureDetector : public FeatureDetector -The class implements the keypoint detector introduced by [Agrawal08_], synonym of ``StarDetector``. :: +The class implements the keypoint detector introduced by [Agrawal08]_, synonym of ``StarDetector``. :: class StarFeatureDetector : public FeatureDetector { From 908039c658f1001d3edac369bc9c0195ee645945 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 22 Jul 2013 07:02:04 -0700 Subject: [PATCH 27/64] Warning suppresion for TBB on WinRT added. --- 3rdparty/tbb/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/tbb/CMakeLists.txt b/3rdparty/tbb/CMakeLists.txt index be91b5b80..c728440f2 100644 --- a/3rdparty/tbb/CMakeLists.txt +++ b/3rdparty/tbb/CMakeLists.txt @@ -11,7 +11,7 @@ if (WIN32 AND ARM) set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz") set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a") set(tbb_version_file "version_string.ver") - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused-parameter) + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702) else() # 4.1 update 2 - works fine set(tbb_ver "tbb41_20130116oss") From 925e4eec983684e56124131accab30233777c8db Mon Sep 17 00:00:00 2001 From: Jan Starzynski Date: Wed, 24 Jul 2013 17:27:03 +0200 Subject: [PATCH 28/64] removed multiplied code for exception handling --- modules/java/generator/src/cpp/Mat.cpp | 1158 ++++++++++-------------- 1 file changed, 455 insertions(+), 703 deletions(-) diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index f2ad94e38..5aa939ec8 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -1,12 +1,71 @@ #define LOG_TAG "org.opencv.core.Mat" +#include + #include "common.h" #include "opencv2/core/core.hpp" using namespace cv; -extern "C" { +/// throw java exception from std::exception, no logging +static const char *throwJavaException(JNIEnv *env, const std::exception &e); +static const char *throwJavaException(JNIEnv *env, const std::exception &e) { + const char *exception_str = "std::exception"; + jclass je = 0; + + if(dynamic_cast(&e)) { + exception_str = "cv::Exception"; + je = env->FindClass("org/opencv/core/CvException"); + } + + if(!je) je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, e.what()); + return exception_str; +} +/// throw java exception from unknown exception, no logging +static void throwJavaException(JNIEnv *env); +static void throwJavaException(JNIEnv *env) { + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "unknown exception"); +} + +/// throw java exception from std::exception, use LOGD +static void throwJavaExceptionD(JNIEnv *env, const std::exception &e, const char *method); +static void throwJavaExceptionD(JNIEnv *env, const std::exception &e, const char *method) { + const char *exception_str = throwJavaException(env, e); + LOGD("%s caught %s: %s", method, exception_str, e.what()); + (void)method; // avoid "unused" warning + (void)exception_str; // avoid "unused" warning +} + +/// throw java exception from unknown exception, use LOGD +static void throwJavaExceptionD(JNIEnv *env, const char *method); +static void throwJavaExceptionD(JNIEnv *env, const char *method) { + throwJavaException(env); + LOGD("%s caught unknown exception (...)", method); + (void)method; // avoid "unused" warning +} + +/// throw java exception from std::exception, use LOGE +static void throwJavaExceptionE(JNIEnv *env, const std::exception &e, const char *method); +static void throwJavaExceptionE(JNIEnv *env, const std::exception &e, const char *method) { + const char *exception_str = throwJavaException(env, e); + LOGE("%s caught %s: %s", method, exception_str, e.what()); + (void)method; // avoid "unused" warning + (void)exception_str; // avoid "unused" warning +} + +/// throw java exception from unknown exception, use LOGE +static void throwJavaExceptionE(JNIEnv *env, const char *method); +static void throwJavaExceptionE(JNIEnv *env, const char *method) { + throwJavaException(env); + LOGE("%s caught unknown exception (...)", method); + (void)method; // avoid "unused" warning +} + +extern "C" { + // // MatXXX::MatXXX() @@ -35,22 +94,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III (JNIEnv* env, jclass, jint rows, jint cols, jint type) { + static const char method_name[] = "Mat::n_1Mat__III()"; try { - LOGD("Mat::n_1Mat__III()"); + LOGD(method_name); Mat* _retval_ = new Mat( rows, cols, type ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__III() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__III() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__III()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -67,22 +122,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type) { + static const char method_name[] = "Mat::n_1Mat__DDI()"; try { - LOGD("Mat::n_1Mat__DDI()"); + LOGD(method_name); Size size((int)size_width, (int)size_height); Mat* _retval_ = new Mat( size, type ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__DDI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__DDI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__DDI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -100,22 +151,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD (JNIEnv* env, jclass, jint rows, jint cols, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) { + static const char method_name[] = "Mat::n_1Mat__IIIDDDD()"; try { - LOGD("Mat::n_1Mat__IIIDDDD()"); + LOGD(method_name); Scalar s(s_val0, s_val1, s_val2, s_val3); Mat* _retval_ = new Mat( rows, cols, type, s ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__IIIDDDD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__IIIDDDD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__IIIDDDD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -132,23 +179,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) { + static const char method_name[] = "Mat::n_1Mat__DDIDDDD()"; try { - LOGD("Mat::n_1Mat__DDIDDDD()"); + LOGD(method_name); Size size((int)size_width, (int)size_height); Scalar s(s_val0, s_val1, s_val2, s_val3); Mat* _retval_ = new Mat( size, type, s ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__DDIDDDD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__DDIDDDD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__DDIDDDD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -165,23 +208,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end) { + static const char method_name[] = "Mat::n_1Mat__JIIII()"; try { - LOGD("Mat::n_1Mat__JIIII()"); + LOGD(method_name); Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange, colRange ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__JIIII() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__JIIII() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__JIIII()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -194,22 +233,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII (JNIEnv* env, jclass, jlong m_nativeObj, jint rowRange_start, jint rowRange_end) { + static const char method_name[] = "Mat::n_1Mat__JII()"; try { - LOGD("Mat::n_1Mat__JII()"); + LOGD(method_name); Range rowRange(rowRange_start, rowRange_end); Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange ); return (jlong) _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1Mat__JII() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1Mat__JII() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__JII()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -225,22 +260,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI (JNIEnv* env, jclass, jlong self, jint dtop, jint dbottom, jint dleft, jint dright) { + static const char method_name[] = "Mat::n_1adjustROI()"; try { - LOGD("Mat::n_1adjustROI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->adjustROI( dtop, dbottom, dleft, dright ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1adjustROI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1adjustROI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1adjustROI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -257,22 +288,18 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type) { + static const char method_name[] = "Mat::n_1assignTo__JJI()"; try { - LOGD("Mat::n_1assignTo__JJI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj), type ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1assignTo__JJI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1assignTo__JJI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1assignTo__JJI()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -284,22 +311,18 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1assignTo__JJ()"; try { - LOGD("Mat::n_1assignTo__JJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj) ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1assignTo__JJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1assignTo__JJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1assignTo__JJ()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -316,22 +339,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1channels()"; try { - LOGD("Mat::n_1channels()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->channels( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1channels() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1channels() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1channels()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -348,22 +367,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth, jboolean requireContinuous) { + static const char method_name[] = "Mat::n_1checkVector__JIIZ()"; try { - LOGD("Mat::n_1checkVector__JIIZ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->checkVector( elemChannels, depth, requireContinuous ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1checkVector__JIIZ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1checkVector__JIIZ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JIIZ()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -376,22 +391,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII (JNIEnv* env, jclass, jlong self, jint elemChannels, jint depth) { + static const char method_name[] = "Mat::n_1checkVector__JII()"; try { - LOGD("Mat::n_1checkVector__JII()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->checkVector( elemChannels, depth ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1checkVector__JII() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1checkVector__JII() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JII()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -404,22 +415,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI (JNIEnv* env, jclass, jlong self, jint elemChannels) { + static const char method_name[] = "Mat::n_1checkVector__JI()"; try { - LOGD("Mat::n_1checkVector__JI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->checkVector( elemChannels ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1checkVector__JI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1checkVector__JI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -437,22 +444,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1clone()"; try { - LOGD("Mat::n_1clone()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->clone( ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1clone() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1clone() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1clone()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -469,22 +472,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col (JNIEnv* env, jclass, jlong self, jint x) { + static const char method_name[] = "Mat::n_1col()"; try { - LOGD("Mat::n_1col()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->col( x ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1col() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1col() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1col()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -501,22 +500,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange (JNIEnv* env, jclass, jlong self, jint startcol, jint endcol) { + static const char method_name[] = "Mat::n_1colRange()"; try { - LOGD("Mat::n_1colRange()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->colRange( startcol, endcol ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1colRange() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1colRange() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1colRange()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -526,34 +521,31 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange // // int Mat::dims() // - + JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims (JNIEnv* env, jclass, jlong self); JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1dims()"; try { - LOGD("Mat::n_1dims()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->dims; return _retval_; } catch(cv::Exception e) { - LOGD("Mat::n_1dims() catched cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1dims() catched unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1dims()}"); + throwJavaExceptionD(env, method_name); return 0; } } + // // int Mat::cols() // @@ -564,22 +556,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1cols()"; try { - LOGD("Mat::n_1cols()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->cols; return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1cols() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1cols() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1cols()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -596,23 +584,19 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta) { + static const char method_name[] = "Mat::n_1convertTo__JJIDD()"; try { - LOGD("Mat::n_1convertTo__JJIDD()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha, beta ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1convertTo__JJIDD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1convertTo__JJIDD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJIDD()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -624,23 +608,19 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha) { + static const char method_name[] = "Mat::n_1convertTo__JJID()"; try { - LOGD("Mat::n_1convertTo__JJID()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1convertTo__JJID() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1convertTo__JJID() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJID()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -652,23 +632,19 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype) { + static const char method_name[] = "Mat::n_1convertTo__JJI()"; try { - LOGD("Mat::n_1convertTo__JJI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1convertTo__JJI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1convertTo__JJI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJI()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -685,23 +661,19 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1copyTo__JJ()"; try { - LOGD("Mat::n_1copyTo__JJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->copyTo( m ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1copyTo__JJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1copyTo__JJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1copyTo__JJ()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -718,24 +690,20 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jlong mask_nativeObj) { + static const char method_name[] = "Mat::n_1copyTo__JJJ()"; try { - LOGD("Mat::n_1copyTo__JJJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); me->copyTo( m, mask ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1copyTo__JJJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1copyTo__JJJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1copyTo__JJJ()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -752,22 +720,18 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII (JNIEnv* env, jclass, jlong self, jint rows, jint cols, jint type) { + static const char method_name[] = "Mat::n_1create__JIII()"; try { - LOGD("Mat::n_1create__JIII()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->create( rows, cols, type ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1create__JIII() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1create__JIII() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1create__JIII()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -784,23 +748,19 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI (JNIEnv* env, jclass, jlong self, jdouble size_width, jdouble size_height, jint type) { + static const char method_name[] = "Mat::n_1create__JDDI()"; try { - LOGD("Mat::n_1create__JDDI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size size((int)size_width, (int)size_height); me->create( size, type ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1create__JDDI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1create__JDDI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1create__JDDI()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -817,23 +777,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1cross()"; try { - LOGD("Mat::n_1cross()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->cross( m ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1cross() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1cross() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1cross()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -867,22 +823,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1depth()"; try { - LOGD("Mat::n_1depth()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->depth( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1depth() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1depth() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1depth()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -899,22 +851,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI (JNIEnv* env, jclass, jlong self, jint d) { + static const char method_name[] = "Mat::n_1diag__JI()"; try { - LOGD("Mat::n_1diag__JI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->diag( d ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1diag__JI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1diag__JI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1diag__JI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -932,22 +880,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J (JNIEnv* env, jclass, jlong d_nativeObj) { + static const char method_name[] = "Mat::n_1diag__J()"; try { - LOGD("Mat::n_1diag__J()"); + LOGD(method_name); Mat _retval_ = Mat::diag( (*(Mat*)d_nativeObj) ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1diag__J() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1diag__J() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1diag__J()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -964,23 +908,19 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1dot()"; try { - LOGD("Mat::n_1dot()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); double _retval_ = me->dot( m ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1dot() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1dot() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1dot()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -997,22 +937,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1elemSize()"; try { - LOGD("Mat::n_1elemSize()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL size_t _retval_ = me->elemSize( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1elemSize() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1elemSize() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1elemSize()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1029,22 +965,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1 JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1 (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1elemSize1()"; try { - LOGD("Mat::n_1elemSize1()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL size_t _retval_ = me->elemSize1( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1elemSize1() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1elemSize1() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1elemSize1()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1061,22 +993,18 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1empty()"; try { - LOGD("Mat::n_1empty()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL bool _retval_ = me->empty( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1empty() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1empty() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1empty()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1093,22 +1021,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III (JNIEnv* env, jclass, jint rows, jint cols, jint type) { + static const char method_name[] = "Mat::n_1eye__III()"; try { - LOGD("Mat::n_1eye__III()"); + LOGD(method_name); Mat _retval_ = Mat::eye( rows, cols, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1eye__III() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1eye__III() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1eye__III()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1125,22 +1049,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type) { + static const char method_name[] = "Mat::n_1eye__DDI()"; try { - LOGD("Mat::n_1eye__DDI()"); + LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::eye( size, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1eye__DDI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1eye__DDI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1eye__DDI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1157,22 +1077,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI (JNIEnv* env, jclass, jlong self, jint method) { + static const char method_name[] = "Mat::n_1inv__JI()"; try { - LOGD("Mat::n_1inv__JI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( method ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1inv__JI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1inv__JI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1inv__JI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1184,22 +1100,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1inv__J()"; try { - LOGD("Mat::n_1inv__J()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1inv__J() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1inv__J() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1inv__J()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1216,22 +1128,18 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1isContinuous()"; try { - LOGD("Mat::n_1isContinuous()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL bool _retval_ = me->isContinuous( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1isContinuous() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1isContinuous() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1isContinuous()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1248,22 +1156,18 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1isSubmatrix()"; try { - LOGD("Mat::n_1isSubmatrix()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL bool _retval_ = me->isSubmatrix( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1isSubmatrix() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1isSubmatrix() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1isSubmatrix()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1280,24 +1184,20 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10 JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10 (JNIEnv* env, jclass, jlong self, jdoubleArray wholeSize_out, jdoubleArray ofs_out) { + static const char method_name[] = "core::locateROI_10()"; try { - LOGD("core::locateROI_10()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size wholeSize; Point ofs; me->locateROI( wholeSize, ofs ); jdouble tmp_wholeSize[2] = {wholeSize.width, wholeSize.height}; env->SetDoubleArrayRegion(wholeSize_out, 0, 2, tmp_wholeSize); jdouble tmp_ofs[2] = {ofs.x, ofs.y}; env->SetDoubleArrayRegion(ofs_out, 0, 2, tmp_ofs); return; - } catch(cv::Exception e) { - LOGD("Mat::locateROI_10() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::locateROI_10() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::locateROI_10()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -1314,23 +1214,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jdouble scale) { + static const char method_name[] = "Mat::n_1mul__JJD()"; try { - LOGD("Mat::n_1mul__JJD()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m, scale ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1mul__JJD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1mul__JJD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1mul__JJD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1343,23 +1239,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1mul__JJ()"; try { - LOGD("Mat::n_1mul__JJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1mul__JJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1mul__JJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1mul__JJ()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1376,22 +1268,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III (JNIEnv* env, jclass, jint rows, jint cols, jint type) { + static const char method_name[] = "Mat::n_1ones__III()"; try { - LOGD("Mat::n_1ones__III()"); + LOGD(method_name); Mat _retval_ = Mat::ones( rows, cols, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1ones__III() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1ones__III() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1ones__III()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1408,22 +1296,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type) { + static const char method_name[] = "Mat::n_1ones__DDI()"; try { - LOGD("Mat::n_1ones__DDI()"); + LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::ones( size, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1ones__DDI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1ones__DDI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1ones__DDI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1440,22 +1324,18 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back (JNIEnv* env, jclass, jlong self, jlong m_nativeObj) { + static const char method_name[] = "Mat::n_1push_1back()"; try { - LOGD("Mat::n_1push_1back()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->push_back( (*(Mat*)m_nativeObj) ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1push_1back() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1push_1back() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1push_1back()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -1472,22 +1352,18 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1release()"; try { - LOGD("Mat::n_1release()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->release( ); return; - } catch(cv::Exception e) { - LOGD("Mat::n_1release() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return; } catch (...) { - LOGD("Mat::n_1release() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1release()}"); + throwJavaExceptionD(env, method_name); return; } } @@ -1504,22 +1380,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII (JNIEnv* env, jclass, jlong self, jint cn, jint rows) { + static const char method_name[] = "Mat::n_1reshape__JII()"; try { - LOGD("Mat::n_1reshape__JII()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn, rows ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1reshape__JII() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1reshape__JII() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1reshape__JII()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1532,22 +1404,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI (JNIEnv* env, jclass, jlong self, jint cn) { + static const char method_name[] = "Mat::n_1reshape__JI()"; try { - LOGD("Mat::n_1reshape__JI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1reshape__JI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1reshape__JI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1reshape__JI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1564,22 +1432,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row (JNIEnv* env, jclass, jlong self, jint y) { + static const char method_name[] = "Mat::n_1row()"; try { - LOGD("Mat::n_1row()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->row( y ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1row() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1row() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1row()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1596,22 +1460,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange (JNIEnv* env, jclass, jlong self, jint startrow, jint endrow) { + static const char method_name[] = "Mat::n_1rowRange()"; try { - LOGD("Mat::n_1rowRange()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->rowRange( startrow, endrow ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1rowRange() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1rowRange() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1rowRange()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1628,22 +1488,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1rows()"; try { - LOGD("Mat::n_1rows()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->rows; return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1rows() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1rows() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1rows()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1660,23 +1516,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) { + static const char method_name[] = "Mat::n_1setTo__JDDDD()"; try { - LOGD("Mat::n_1setTo__JDDDD()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Scalar s(s_val0, s_val1, s_val2, s_val3); Mat _retval_ = me->operator =( s ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1setTo__JDDDD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1setTo__JDDDD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JDDDD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1693,24 +1545,20 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ (JNIEnv* env, jclass, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3, jlong mask_nativeObj) { + static const char method_name[] = "Mat::n_1setTo__JDDDDJ()"; try { - LOGD("Mat::n_1setTo__JDDDDJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Scalar s(s_val0, s_val1, s_val2, s_val3); Mat& mask = *((Mat*)mask_nativeObj); Mat _retval_ = me->setTo( s, mask ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1setTo__JDDDDJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1setTo__JDDDDJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JDDDDJ()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1727,24 +1575,20 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ (JNIEnv* env, jclass, jlong self, jlong value_nativeObj, jlong mask_nativeObj) { + static const char method_name[] = "Mat::n_1setTo__JJJ()"; try { - LOGD("Mat::n_1setTo__JJJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& value = *((Mat*)value_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); Mat _retval_ = me->setTo( value, mask ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1setTo__JJJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1setTo__JJJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JJJ()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1757,23 +1601,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ (JNIEnv* env, jclass, jlong self, jlong value_nativeObj) { + static const char method_name[] = "Mat::n_1setTo__JJ()"; try { - LOGD("Mat::n_1setTo__JJ()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& value = *((Mat*)value_nativeObj); Mat _retval_ = me->setTo( value ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1setTo__JJ() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1setTo__JJ() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JJ()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1790,22 +1630,18 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1size()"; try { - LOGD("Mat::n_1size()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size _retval_ = me->size( ); jdoubleArray _da_retval_ = env->NewDoubleArray(2); jdouble _tmp_retval_[2] = {_retval_.width, _retval_.height}; env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_); return _da_retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1size() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1size() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1size()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1822,22 +1658,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI (JNIEnv* env, jclass, jlong self, jint i) { + static const char method_name[] = "Mat::n_1step1__JI()"; try { - LOGD("Mat::n_1step1__JI()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL size_t _retval_ = me->step1( i ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1step1__JI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1step1__JI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1step1__JI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1850,22 +1682,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1step1__J()"; try { - LOGD("Mat::n_1step1__J()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL size_t _retval_ = me->step1( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1step1__J() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1step1__J() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1step1__J()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1880,24 +1708,20 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr (JNIEnv* env, jclass, jlong self, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end) { + static const char method_name[] = "Mat::n_1submat_1rr()"; try { - LOGD("Mat::n_1submat_1rr()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); Mat _retval_ = me->operator()( rowRange, colRange ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1submat_1rr() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1submat_1rr() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1submat_1rr()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1914,23 +1738,19 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat (JNIEnv* env, jclass, jlong self, jint roi_x, jint roi_y, jint roi_width, jint roi_height) { + static const char method_name[] = "Mat::n_1submat()"; try { - LOGD("Mat::n_1submat()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Rect roi(roi_x, roi_y, roi_width, roi_height); Mat _retval_ = me->operator()( roi ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1submat() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1submat() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1submat()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1947,22 +1767,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1t()"; try { - LOGD("Mat::n_1t()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->t( ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1t() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1t() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1t()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -1979,22 +1795,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1total()"; try { - LOGD("Mat::n_1total()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL size_t _retval_ = me->total( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1total() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1total() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1total()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2011,22 +1823,18 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type (JNIEnv* env, jclass, jlong self) { + static const char method_name[] = "Mat::n_1type()"; try { - LOGD("Mat::n_1type()"); + LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL int _retval_ = me->type( ); return _retval_; - } catch(cv::Exception e) { - LOGD("Mat::n_1type() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1type() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1type()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2043,22 +1851,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III (JNIEnv* env, jclass, jint rows, jint cols, jint type) { + static const char method_name[] = "Mat::n_1zeros__III()"; try { - LOGD("Mat::n_1zeros__III()"); + LOGD(method_name); Mat _retval_ = Mat::zeros( rows, cols, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1zeros__III() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1zeros__III() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1zeros__III()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2075,22 +1879,18 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI (JNIEnv* env, jclass, jdouble size_width, jdouble size_height, jint type) { + static const char method_name[] = "Mat::n_1zeros__DDI()"; try { - LOGD("Mat::n_1zeros__DDI()"); + LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::zeros( size, type ); return (jlong) new Mat(_retval_); - } catch(cv::Exception e) { - LOGD("Mat::n_1zeros__DDI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::n_1zeros__DDI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1zeros__DDI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2120,8 +1920,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals) { + static const char method_name[] = "Mat::nPutD()"; try { - LOGD("Mat::nPutD()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(!me || !me->data) return 0; // no native object behind if(me->rows<=row || me->cols<=col) return 0; // indexes out of range @@ -2161,16 +1962,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nPutD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nPutD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2217,8 +2013,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals) { + static const char method_name[] = "Mat::nPutB()"; try { - LOGD("Mat::nPutB()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type @@ -2228,16 +2025,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB int res = mat_put(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nPutB() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nPutB() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutB()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2248,8 +2040,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals) { + static const char method_name[] = "Mat::nPutS()"; try { - LOGD("Mat::nPutS()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type @@ -2259,16 +2052,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS int res = mat_put(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nPutS() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nPutS() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutS()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2279,8 +2067,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals) { + static const char method_name[] = "Mat::nPutI()"; try { - LOGD("Mat::nPutI()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32S) return 0; // incompatible type @@ -2290,16 +2079,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI int res = mat_put(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nPutI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nPutI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2310,8 +2094,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals) { + static const char method_name[] = "Mat::nPutF()"; try { - LOGD("Mat::nPutF()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32F) return 0; // incompatible type @@ -2321,16 +2106,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF int res = mat_put(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nPutF() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nPutF() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutF()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2376,8 +2156,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jbyteArray vals) { + static const char method_name[] = "Mat::nGetB()"; try { - LOGD("Mat::nGetB()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type @@ -2387,16 +2168,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB int res = mat_get(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nGetB() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGetB() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetB()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2407,8 +2183,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jshortArray vals) { + static const char method_name[] = "Mat::nGetS()"; try { - LOGD("Mat::nGetS()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type @@ -2418,16 +2195,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS int res = mat_get(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nGetS() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGetS() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetS()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2438,8 +2210,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jintArray vals) { + static const char method_name[] = "Mat::nGetI()"; try { - LOGD("Mat::nGetI()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32S) return 0; // incompatible type @@ -2449,16 +2222,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI int res = mat_get(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nGetI() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGetI() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetI()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2469,8 +2237,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jfloatArray vals) { + static const char method_name[] = "Mat::nGetF()"; try { - LOGD("Mat::nGetF()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32F) return 0; // incompatible type @@ -2480,16 +2249,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF int res = mat_get(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nGetF() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGetF() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetF()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2500,8 +2264,9 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD (JNIEnv* env, jclass, jlong self, jint row, jint col, jint count, jdoubleArray vals) { + static const char method_name[] = "Mat::nGetD()"; try { - LOGD("Mat::nGetD()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_64F) return 0; // incompatible type @@ -2511,16 +2276,11 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD int res = mat_get(me, row, col, count, values); env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; - } catch(cv::Exception e) { - LOGD("Mat::nGetD() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGetD() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetD()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2531,8 +2291,9 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet (JNIEnv* env, jclass, jlong self, jint row, jint col) { + static const char method_name[] = "Mat::nGet()"; try { - LOGD("Mat::nGet()"); + LOGD(method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->rows<=row || me->cols<=col) return 0; // indexes out of range @@ -2553,16 +2314,11 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet env->SetDoubleArrayRegion(res, 0, me->channels(), buff); } return res; - } catch(cv::Exception e) { - LOGD("Mat::nGet() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); + } catch(const std::exception &e) { + throwJavaExceptionD(env, e, method_name); return 0; } catch (...) { - LOGD("Mat::nGet() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGet()}"); + throwJavaExceptionD(env, method_name); return 0; } } @@ -2573,25 +2329,21 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump (JNIEnv *env, jclass, jlong self) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - std::stringstream s; + static const char method_name[] = "Mat::nDump()"; try { - LOGD("Mat::nDump()"); - - s << *me; - return env->NewStringUTF(s.str().c_str()); - } catch(cv::Exception e) { - LOGE("Mat::nDump() caught cv::Exception: %s", e.what()); - jclass je = env->FindClass("org/opencv/core/CvException"); - if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); - return env->NewStringUTF("ERROR"); - } catch (...) { - LOGE("Mat::nDump() caught unknown exception (...)"); - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {Mat::nDump()}"); - return env->NewStringUTF("ERROR"); - } + LOGD(method_name); + cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL + std::stringstream s; + s << *me; + std::string str = s.str(); + return env->NewStringUTF(str.c_str()); + } catch(const std::exception &e) { + throwJavaExceptionE(env, e, method_name); + return 0; + } catch (...) { + throwJavaExceptionE(env, method_name); + return 0; + } } From 0b15cfd48c382c840b1fee55b1655cb22a252498 Mon Sep 17 00:00:00 2001 From: Alexander Pacha Date: Thu, 25 Jul 2013 16:40:09 +1200 Subject: [PATCH 29/64] Added FREAK-descriptor extractor to documentation. Previously it was missing. Ordered all descriptors by year of first publication. --- .../doc/common_interfaces_of_descriptor_extractors.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst index 63e56f678..6488969a3 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst @@ -78,9 +78,10 @@ The current implementation supports the following types of a descriptor extracto * ``"SIFT"`` -- :ocv:class:`SIFT` * ``"SURF"`` -- :ocv:class:`SURF` - * ``"ORB"`` -- :ocv:class:`ORB` - * ``"BRISK"`` -- :ocv:class:`BRISK` * ``"BRIEF"`` -- :ocv:class:`BriefDescriptorExtractor` + * ``"BRISK"`` -- :ocv:class:`BRISK` + * ``"ORB"`` -- :ocv:class:`ORB` + * ``"FREAK"`` -- :ocv:class:`FREAK` A combined format is also supported: descriptor extractor adapter name ( ``"Opponent"`` -- :ocv:class:`OpponentColorDescriptorExtractor` ) + descriptor extractor name (see above), From 70930a30a1e5d1d0f0745155c0198531c6c5e011 Mon Sep 17 00:00:00 2001 From: Jan Starzynski Date: Thu, 25 Jul 2013 13:36:27 +0200 Subject: [PATCH 30/64] refactored throwJavaException() and removed useless returns --- modules/java/generator/src/cpp/Mat.cpp | 813 ++++++++++--------------- 1 file changed, 327 insertions(+), 486 deletions(-) diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index 5aa939ec8..1d64d105b 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -7,61 +7,28 @@ using namespace cv; -/// throw java exception from std::exception, no logging -static const char *throwJavaException(JNIEnv *env, const std::exception &e); -static const char *throwJavaException(JNIEnv *env, const std::exception &e) { - const char *exception_str = "std::exception"; +/// throw java exception +static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method); +static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) { + std::string what = "unknown exception"; jclass je = 0; - if(dynamic_cast(&e)) { - exception_str = "cv::Exception"; - je = env->FindClass("org/opencv/core/CvException"); + if(e) { + std::string exception_type = "std::exception"; + + if(dynamic_cast(e)) { + exception_type = "cv::Exception"; + je = env->FindClass("org/opencv/core/CvException"); + } + + what = exception_type + ": " + e->what(); } if(!je) je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, e.what()); - return exception_str; -} - -/// throw java exception from unknown exception, no logging -static void throwJavaException(JNIEnv *env); -static void throwJavaException(JNIEnv *env) { - jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "unknown exception"); -} - -/// throw java exception from std::exception, use LOGD -static void throwJavaExceptionD(JNIEnv *env, const std::exception &e, const char *method); -static void throwJavaExceptionD(JNIEnv *env, const std::exception &e, const char *method) { - const char *exception_str = throwJavaException(env, e); - LOGD("%s caught %s: %s", method, exception_str, e.what()); + env->ThrowNew(je, what.c_str()); + + LOGE("%s caught %s", method, what.c_str()); (void)method; // avoid "unused" warning - (void)exception_str; // avoid "unused" warning -} - -/// throw java exception from unknown exception, use LOGD -static void throwJavaExceptionD(JNIEnv *env, const char *method); -static void throwJavaExceptionD(JNIEnv *env, const char *method) { - throwJavaException(env); - LOGD("%s caught unknown exception (...)", method); - (void)method; // avoid "unused" warning -} - -/// throw java exception from std::exception, use LOGE -static void throwJavaExceptionE(JNIEnv *env, const std::exception &e, const char *method); -static void throwJavaExceptionE(JNIEnv *env, const std::exception &e, const char *method) { - const char *exception_str = throwJavaException(env, e); - LOGE("%s caught %s: %s", method, exception_str, e.what()); - (void)method; // avoid "unused" warning - (void)exception_str; // avoid "unused" warning -} - -/// throw java exception from unknown exception, use LOGE -static void throwJavaExceptionE(JNIEnv *env, const char *method); -static void throwJavaExceptionE(JNIEnv *env, const char *method) { - throwJavaException(env); - LOGE("%s caught unknown exception (...)", method); - (void)method; // avoid "unused" warning } extern "C" { @@ -97,17 +64,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III static const char method_name[] = "Mat::n_1Mat__III()"; try { LOGD(method_name); - - Mat* _retval_ = new Mat( rows, cols, type ); - - return (jlong) _retval_; + return (jlong) new Mat( rows, cols, type ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -126,16 +90,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI try { LOGD(method_name); Size size((int)size_width, (int)size_height); - Mat* _retval_ = new Mat( size, type ); - - return (jlong) _retval_; + return (jlong) new Mat( size, type ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -155,16 +117,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD try { LOGD(method_name); Scalar s(s_val0, s_val1, s_val2, s_val3); - Mat* _retval_ = new Mat( rows, cols, type, s ); - - return (jlong) _retval_; + return (jlong) new Mat( rows, cols, type, s ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -184,16 +144,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD LOGD(method_name); Size size((int)size_width, (int)size_height); Scalar s(s_val0, s_val1, s_val2, s_val3); - Mat* _retval_ = new Mat( size, type, s ); - - return (jlong) _retval_; + return (jlong) new Mat( size, type, s ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -213,16 +171,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII LOGD(method_name); Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); - Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange, colRange ); - - return (jlong) _retval_; + return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange, colRange ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -237,16 +193,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII try { LOGD(method_name); Range rowRange(rowRange_start, rowRange_end); - Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange ); - - return (jlong) _retval_; + return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -265,15 +219,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->adjustROI( dtop, dbottom, dleft, dright ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -293,14 +246,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj), type ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -316,14 +265,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj) ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -343,16 +288,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->channels( ); - - return _retval_; + return me->channels( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -371,16 +314,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->checkVector( elemChannels, depth, requireContinuous ); - - return _retval_; + return me->checkVector( elemChannels, depth, requireContinuous ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -395,16 +336,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->checkVector( elemChannels, depth ); - - return _retval_; + return me->checkVector( elemChannels, depth ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -419,16 +358,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->checkVector( elemChannels ); - - return _retval_; + return me->checkVector( elemChannels ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -449,15 +386,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->clone( ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -477,15 +413,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->col( x ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -505,15 +440,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->colRange( startcol, endcol ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -532,16 +466,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->dims; - - return _retval_; + return me->dims; } catch(cv::Exception e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -560,16 +492,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->cols; - - return _retval_; + return me->cols; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -590,14 +520,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha, beta ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -614,14 +540,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -638,14 +560,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -667,14 +585,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->copyTo( m ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -697,14 +611,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ Mat& m = *((Mat*)m_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); me->copyTo( m, mask ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -725,14 +635,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->create( rows, cols, type ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -754,14 +660,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI Mat* me = (Mat*) self; //TODO: check for NULL Size size((int)size_width, (int)size_height); me->create( size, type ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -783,15 +685,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->cross( m ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -827,16 +728,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->depth( ); - - return _retval_; + return me->depth( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -856,15 +755,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->diag( d ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -883,17 +781,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J static const char method_name[] = "Mat::n_1diag__J()"; try { LOGD(method_name); - Mat _retval_ = Mat::diag( (*(Mat*)d_nativeObj) ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -913,16 +809,14 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - double _retval_ = me->dot( m ); - - return _retval_; + return me->dot( m ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -941,16 +835,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - size_t _retval_ = me->elemSize( ); - - return _retval_; + return me->elemSize( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -969,16 +861,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1 try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - size_t _retval_ = me->elemSize1( ); - - return _retval_; + return me->elemSize1( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -997,16 +887,14 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - bool _retval_ = me->empty( ); - - return _retval_; + return me->empty( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1024,17 +912,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III static const char method_name[] = "Mat::n_1eye__III()"; try { LOGD(method_name); - Mat _retval_ = Mat::eye( rows, cols, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1054,15 +940,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::eye( size, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1082,15 +967,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( method ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1105,15 +989,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1132,16 +1015,14 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - bool _retval_ = me->isContinuous( ); - - return _retval_; + return me->isContinuous( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1160,16 +1041,14 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - bool _retval_ = me->isSubmatrix( ); - - return _retval_; + return me->isSubmatrix( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1192,13 +1071,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10 Point ofs; me->locateROI( wholeSize, ofs ); jdouble tmp_wholeSize[2] = {wholeSize.width, wholeSize.height}; env->SetDoubleArrayRegion(wholeSize_out, 0, 2, tmp_wholeSize); jdouble tmp_ofs[2] = {ofs.x, ofs.y}; env->SetDoubleArrayRegion(ofs_out, 0, 2, tmp_ofs); - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -1220,15 +1096,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m, scale ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1245,15 +1120,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1271,17 +1145,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III static const char method_name[] = "Mat::n_1ones__III()"; try { LOGD(method_name); - Mat _retval_ = Mat::ones( rows, cols, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1301,15 +1173,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::ones( size, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1329,14 +1200,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->push_back( (*(Mat*)m_nativeObj) ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -1357,14 +1224,10 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->release( ); - - return; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return; + throwJavaException(env, 0, method_name); } } @@ -1385,15 +1248,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn, rows ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1409,15 +1271,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1437,15 +1298,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->row( y ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1465,15 +1325,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->rowRange( startrow, endrow ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1492,16 +1351,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->rows; - - return _retval_; + return me->rows; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1522,15 +1379,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD Mat* me = (Mat*) self; //TODO: check for NULL Scalar s(s_val0, s_val1, s_val2, s_val3); Mat _retval_ = me->operator =( s ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1552,15 +1408,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ Scalar s(s_val0, s_val1, s_val2, s_val3); Mat& mask = *((Mat*)mask_nativeObj); Mat _retval_ = me->setTo( s, mask ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1582,15 +1437,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ Mat& value = *((Mat*)value_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); Mat _retval_ = me->setTo( value, mask ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1607,15 +1461,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ Mat* me = (Mat*) self; //TODO: check for NULL Mat& value = *((Mat*)value_nativeObj); Mat _retval_ = me->setTo( value ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1635,15 +1488,17 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size _retval_ = me->size( ); - jdoubleArray _da_retval_ = env->NewDoubleArray(2); jdouble _tmp_retval_[2] = {_retval_.width, _retval_.height}; env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_); + jdoubleArray _da_retval_ = env->NewDoubleArray(2); + jdouble _tmp_retval_[2] = {_retval_.width, _retval_.height}; + env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_); return _da_retval_; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1662,16 +1517,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - size_t _retval_ = me->step1( i ); - - return _retval_; + return me->step1( i ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1686,16 +1539,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - size_t _retval_ = me->step1( ); - - return _retval_; + return me->step1( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } // @@ -1715,15 +1566,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); Mat _retval_ = me->operator()( rowRange, colRange ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1744,15 +1594,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat Mat* me = (Mat*) self; //TODO: check for NULL Rect roi(roi_x, roi_y, roi_width, roi_height); Mat _retval_ = me->operator()( roi ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1772,15 +1621,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->t( ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1799,16 +1647,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - size_t _retval_ = me->total( ); - - return _retval_; + return me->total( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1827,16 +1673,14 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type try { LOGD(method_name); Mat* me = (Mat*) self; //TODO: check for NULL - int _retval_ = me->type( ); - - return _retval_; + return me->type( ); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1854,17 +1698,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III static const char method_name[] = "Mat::n_1zeros__III()"; try { LOGD(method_name); - Mat _retval_ = Mat::zeros( rows, cols, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1884,15 +1726,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI LOGD(method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::zeros( size, type ); - return (jlong) new Mat(_retval_); } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -1963,12 +1804,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -2026,12 +1867,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS @@ -2053,12 +1894,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI @@ -2080,12 +1921,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF @@ -2107,12 +1948,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } @@ -2169,12 +2010,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS @@ -2196,12 +2037,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI @@ -2223,12 +2064,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF @@ -2250,12 +2091,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD @@ -2277,12 +2118,12 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD env->ReleasePrimitiveArrayCritical(vals, values, 0); return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet @@ -2315,12 +2156,12 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet } return res; } catch(const std::exception &e) { - throwJavaExceptionD(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionD(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump @@ -2338,12 +2179,12 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump std::string str = s.str(); return env->NewStringUTF(str.c_str()); } catch(const std::exception &e) { - throwJavaExceptionE(env, e, method_name); - return 0; + throwJavaException(env, &e, method_name); } catch (...) { - throwJavaExceptionE(env, method_name); - return 0; + throwJavaException(env, 0, method_name); } + + return 0; } From 57bd4851191c3dd30bf17bf4c340bafd28222092 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 25 Jul 2013 16:22:31 +0400 Subject: [PATCH 31/64] compute method for Feature2D --- .../features2d/include/opencv2/features2d/features2d.hpp | 2 ++ modules/features2d/src/descriptors.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index c1967f813..d4649baab 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -263,6 +263,8 @@ public: OutputArray descriptors, bool useProvidedKeypoints=false ) const = 0; + CV_WRAP void compute( const Mat& image, CV_OUT CV_IN_OUT std::vector& keypoints, CV_OUT Mat& descriptors ) const; + // Create feature detector and descriptor extractor by name. CV_WRAP static Ptr create( const string& name ); }; diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 06efe9791..c9e87c2ba 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -106,6 +106,12 @@ Ptr DescriptorExtractor::create(const string& descriptorExt return Algorithm::create("Feature2D." + descriptorExtractorType); } + +CV_WRAP void Feature2D::compute( const Mat& image, CV_OUT CV_IN_OUT std::vector& keypoints, CV_OUT Mat& descriptors ) const +{ + DescriptorExtractor::compute(image, keypoints, descriptors); +} + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /****************************************************************************************\ From d6b86d43c9373a626a87a24c6e104a985b2014d8 Mon Sep 17 00:00:00 2001 From: Jan Starzynski Date: Thu, 25 Jul 2013 14:53:22 +0200 Subject: [PATCH 32/64] removed declaration of throwJavaException --- modules/java/generator/src/cpp/Mat.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index 1d64d105b..9d1d9ec34 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -8,7 +8,6 @@ using namespace cv; /// throw java exception -static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method); static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) { std::string what = "unknown exception"; jclass je = 0; From 23c802b4cdde447f68afdef428443e81f0fa0b2f Mon Sep 17 00:00:00 2001 From: Daniil Osokin Date: Tue, 2 Jul 2013 00:53:18 +0400 Subject: [PATCH 33/64] Added camera calibration sample for android --- samples/android/camera-calibration/.classpath | 9 + samples/android/camera-calibration/.project | 33 +++ .../.settings/org.eclipse.jdt.core.prefs | 4 + .../camera-calibration/AndroidManifest.xml | 38 +++ .../android/camera-calibration/CMakeLists.txt | 6 + .../camera-calibration/res/drawable/icon.png | Bin 0 -> 2104 bytes .../camera_calibration_surface_view.xml | 12 + .../res/menu/calibration.xml | 22 ++ .../camera-calibration/res/values/strings.xml | 18 ++ .../cameracalibration/CalibrationResult.java | 69 ++++++ .../CameraCalibrationActivity.java | 216 ++++++++++++++++++ .../cameracalibration/CameraCalibrator.java | 169 ++++++++++++++ .../OnCameraFrameRender.java | 102 +++++++++ 13 files changed, 698 insertions(+) create mode 100644 samples/android/camera-calibration/.classpath create mode 100644 samples/android/camera-calibration/.project create mode 100644 samples/android/camera-calibration/.settings/org.eclipse.jdt.core.prefs create mode 100644 samples/android/camera-calibration/AndroidManifest.xml create mode 100644 samples/android/camera-calibration/CMakeLists.txt create mode 100644 samples/android/camera-calibration/res/drawable/icon.png create mode 100644 samples/android/camera-calibration/res/layout/camera_calibration_surface_view.xml create mode 100644 samples/android/camera-calibration/res/menu/calibration.xml create mode 100644 samples/android/camera-calibration/res/values/strings.xml create mode 100644 samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java create mode 100644 samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrationActivity.java create mode 100644 samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java create mode 100644 samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java diff --git a/samples/android/camera-calibration/.classpath b/samples/android/camera-calibration/.classpath new file mode 100644 index 000000000..46c3d4696 --- /dev/null +++ b/samples/android/camera-calibration/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/samples/android/camera-calibration/.project b/samples/android/camera-calibration/.project new file mode 100644 index 000000000..eae413e1a --- /dev/null +++ b/samples/android/camera-calibration/.project @@ -0,0 +1,33 @@ + + + OpenCV Sample - camera-calibration + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/samples/android/camera-calibration/.settings/org.eclipse.jdt.core.prefs b/samples/android/camera-calibration/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..48ab4c6b1 --- /dev/null +++ b/samples/android/camera-calibration/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/samples/android/camera-calibration/AndroidManifest.xml b/samples/android/camera-calibration/AndroidManifest.xml new file mode 100644 index 000000000..d47576abe --- /dev/null +++ b/samples/android/camera-calibration/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/android/camera-calibration/CMakeLists.txt b/samples/android/camera-calibration/CMakeLists.txt new file mode 100644 index 000000000..83b11b364 --- /dev/null +++ b/samples/android/camera-calibration/CMakeLists.txt @@ -0,0 +1,6 @@ +set(sample example-camera-calibration) + +add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11 ${ANDROID_SDK_TARGET}) +if(TARGET ${sample}) + add_dependencies(opencv_android_examples ${sample}) +endif() diff --git a/samples/android/camera-calibration/res/drawable/icon.png b/samples/android/camera-calibration/res/drawable/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..79ad94845212a05632f1ed5d247030e07c31addd GIT binary patch literal 2104 zcmV-82*>w{P)YbD1t&|5hxT0STX{vD|08m-q+5&+qvJId+s^s zy|JuBOSD8wv_wm^M03%kWmN;UL37X+yZ}A|-+}MJa*z!k0WCm%kaV|*(*Sf2TGj$# zS;ugE14tap^1bF3IE&Y=LO*~6t?J@*Bw^5>3?qh#D>!#G`ko-ADlVyEAlIcR70~DY z0bT*stBN>DU>rCOg3^OP8UfCOX`oJ35NJ5akC8a#xd2`VHT^737c7fB^nn|{odFX_P{Vlrz#)dk#+YOM%kQE_Z1C^IZs z@;?K8Q^i7%LybUf_8lwozb4qsoA`<0hGlZ%khkQl>`6!pw$=q_w z^(t5l?zgH!qv)EJ0z^8Yx9rc|Rsiw(L1Z;TSrR$+2dt{pbO8CZ{^Z+7dH#GIIHp@w zwNYm7B@y<^EUST3P#0u?Vc-og2h0S|gLeA)8ush&il&5V0(yfF!3hxgA?)WDf}WsZ z?1YlZ9?ngPmpEylA6VlkO87?*WP=!7PnR9QfaoSFu`$RopmVInX$_{pA}#`D8*bzg zRxy5Nf@F_xdEjpx4~pXap&$T$0Rus5EX2vc=f512ycUJ!gv4A0nt6O9qan-@ z6-EhUF=7k;=3-3Q1nkvuCeD`_OO6G#yol2ZECtbuL-L%&&;H*0j~od>^7X_*S;r+X z1u(}AF2s2ym9mxNU__M56&beLnXX1Hj`BV8?cFSTaXP7GWiO4&=~$k6-Z(}_a4^h0 zTSEW6do%*kr+&tRIP};7p7bD2eXtY)-HedT)8F3&4$fcJ1nV%ytq5a~Rjvgs+=$Z> zeCg6sN;iTr6WgSVg-gP&jrePhg)hg3F%vwcIu|u-C$n$Agv^AJwc{0 z1@JRlaYVjq0s2qS=Yf^LL#8boE9+t19I^<6iO^+pu-<$-r0w`O;kc!gQo_pt~9&x;M@QqP)Y4t59(EVVOL7?;S858&d1%}|9%Z4!za3<87 zkzXCK3t~KhXuRJIBi;f%ZZBJkN901YlMb#@(YEnTKzR8XETqg}K^u74yZS_(1iB78 z%CTc6=dqfBPr*%tK(y2zuUOQwGwpyuq@y|dT|7z8uH7GqL|Q*cP$vI zOC$AlEqV-|-Gu%UqqO!P7@e7Xy53{(_K}zI0j>vWY-8;A6i4m0ZJ?6F^L@CF1W>z1~qYNXjx9i=` zZzLO>j-NnwWim6`l53{DbY#r!h<3?6fa4TX;Y&V1e>D!`T*27yqfd`kAX;i;!LgW# zB=nvoY|%%!cq7RBf(x{tiIq6CLoNobyslwi&kZ z@)FV|qs{tyed8FsiDaFbPXv2(;hrPVZ|J9ihvRqoS&5WlN6%ylL2D8EUv;W*4YE+t z{)&AyL|D7g&juYpBkxyL!#QvJVqiCrqb>@HlPZZ7l(nBizaPG98IF7CY~EitdL~+; iC0e2-TB0RdJlp>;BGVN&W(79@0000 + + + + diff --git a/samples/android/camera-calibration/res/menu/calibration.xml b/samples/android/camera-calibration/res/menu/calibration.xml new file mode 100644 index 000000000..9c90f127c --- /dev/null +++ b/samples/android/camera-calibration/res/menu/calibration.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/samples/android/camera-calibration/res/values/strings.xml b/samples/android/camera-calibration/res/values/strings.xml new file mode 100644 index 000000000..e1ce932a1 --- /dev/null +++ b/samples/android/camera-calibration/res/values/strings.xml @@ -0,0 +1,18 @@ + + + + OCV Camera Calibration + Calibrate + Calibration + Undistortion + Comparison + Preview mode + Successfully calibrated!\nAvg. re-projection error: + Unsuccessful calibration.\nTry again + Please, capture more samples + Calibrating... + Please, wait + Original + Undistorted + + diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java new file mode 100644 index 000000000..4b03d5967 --- /dev/null +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java @@ -0,0 +1,69 @@ +package org.opencv.samples.cameracalibration; + +import org.opencv.core.Mat; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Log; + +public abstract class CalibrationResult { + private static final String TAG = "OCVSample::CalibrationResult"; + + private static final int CAMERA_MATRIX_ROWS = 3; + private static final int CAMERA_MATRIX_COLS = 3; + private static final int DISTORTION_COEFFICIENTS_SIZE = 5; + + public static void save(Activity activity, Mat cameraMatrix, Mat distortionCoefficients) { + SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPref.edit(); + + double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS]; + cameraMatrix.get(0, 0, cameraMatrixArray); + for (int i = 0; i < CAMERA_MATRIX_ROWS; i++) { + for (int j = 0; j < CAMERA_MATRIX_COLS; j++) { + Integer id = i * CAMERA_MATRIX_ROWS + j; + editor.putFloat(id.toString(), (float)cameraMatrixArray[id]); + } + } + + double[] distortionCoefficientsArray = new double[DISTORTION_COEFFICIENTS_SIZE]; + distortionCoefficients.get(0, 0, distortionCoefficientsArray); + int shift = CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS; + for (Integer i = shift; i < DISTORTION_COEFFICIENTS_SIZE + shift; i++) { + editor.putFloat(i.toString(), (float)distortionCoefficientsArray[i-shift]); + } + + editor.commit(); + Log.i(TAG, "Saved camera matrix: " + cameraMatrix.dump()); + Log.i(TAG, "Saved distortion coefficients: " + distortionCoefficients.dump()); + } + + public static boolean tryLoad(Activity activity, Mat cameraMatrix, Mat distortionCoefficients) { + SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE); + if (sharedPref.getFloat("0", -1) == -1) { + Log.i(TAG, "No previous calibration results found"); + return false; + } + + double[] cameraMatrixArray = new double[CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS]; + for (int i = 0; i < CAMERA_MATRIX_ROWS; i++) { + for (int j = 0; j < CAMERA_MATRIX_COLS; j++) { + Integer id = i * CAMERA_MATRIX_ROWS + j; + cameraMatrixArray[id] = sharedPref.getFloat(id.toString(), -1); + } + } + cameraMatrix.put(0, 0, cameraMatrixArray); + Log.i(TAG, "Loaded camera matrix: " + cameraMatrix.dump()); + + double[] distortionCoefficientsArray = new double[DISTORTION_COEFFICIENTS_SIZE]; + int shift = CAMERA_MATRIX_ROWS * CAMERA_MATRIX_COLS; + for (Integer i = shift; i < DISTORTION_COEFFICIENTS_SIZE + shift; i++) { + distortionCoefficientsArray[i - shift] = sharedPref.getFloat(i.toString(), -1); + } + distortionCoefficients.put(0, 0, distortionCoefficientsArray); + Log.i(TAG, "Loaded distortion coefficients: " + distortionCoefficients.dump()); + + return true; + } +} diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrationActivity.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrationActivity.java new file mode 100644 index 000000000..33c9bbbf4 --- /dev/null +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrationActivity.java @@ -0,0 +1,216 @@ +// This sample is based on "Camera calibration With OpenCV" tutorial: +// http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html +// +// It uses standard OpenCV asymmetric circles grid pattern 11x4: +// https://github.com/Itseez/opencv/blob/2.4/doc/acircles_pattern.png. +// The results are the camera matrix and 5 distortion coefficients. +// +// Tap on highlighted pattern to capture pattern corners for calibration. +// Move pattern along the whole screen and capture data. +// +// When you've captured necessary amount of pattern corners (usually ~20 are enough), +// press "Calibrate" button for performing camera calibration. + +package org.opencv.samples.cameracalibration; + +import org.opencv.android.BaseLoaderCallback; +import org.opencv.android.CameraBridgeViewBase; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; +import org.opencv.android.LoaderCallbackInterface; +import org.opencv.android.OpenCVLoader; +import org.opencv.core.Mat; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.res.Resources; +import android.os.AsyncTask; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.SurfaceView; +import android.view.View; +import android.view.View.OnTouchListener; +import android.view.WindowManager; +import android.widget.Toast; + +public class CameraCalibrationActivity extends Activity implements CvCameraViewListener2, OnTouchListener { + private static final String TAG = "OCVSample::Activity"; + + private CameraBridgeViewBase mOpenCvCameraView; + private CameraCalibrator mCalibrator; + private OnCameraFrameRender mOnCameraFrameRender; + private int mWidth; + private int mHeight; + + private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { + @Override + public void onManagerConnected(int status) { + switch (status) { + case LoaderCallbackInterface.SUCCESS: + { + Log.i(TAG, "OpenCV loaded successfully"); + mOpenCvCameraView.enableView(); + mOpenCvCameraView.setOnTouchListener(CameraCalibrationActivity.this); + } break; + default: + { + super.onManagerConnected(status); + } break; + } + } + }; + + public CameraCalibrationActivity() { + Log.i(TAG, "Instantiated new " + this.getClass()); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + Log.i(TAG, "called onCreate"); + super.onCreate(savedInstanceState); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + + setContentView(R.layout.camera_calibration_surface_view); + + mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_calibration_java_surface_view); + mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); + mOpenCvCameraView.setCvCameraViewListener(this); + } + + @Override + public void onPause() + { + super.onPause(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); + } + + @Override + public void onResume() + { + super.onResume(); + OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback); + } + + public void onDestroy() { + super.onDestroy(); + if (mOpenCvCameraView != null) + mOpenCvCameraView.disableView(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.calibration, menu); + + return true; + } + + @Override + public boolean onPrepareOptionsMenu (Menu menu) { + super.onPrepareOptionsMenu(menu); + menu.findItem(R.id.preview_mode).setEnabled(true); + if (!mCalibrator.isCalibrated()) + menu.findItem(R.id.preview_mode).setEnabled(false); + + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.calibration: + mOnCameraFrameRender = + new OnCameraFrameRender(new CalibrationFrameRender(mCalibrator)); + item.setChecked(true); + return true; + case R.id.undistortion: + mOnCameraFrameRender = + new OnCameraFrameRender(new UndistortionFrameRender(mCalibrator)); + item.setChecked(true); + return true; + case R.id.comparison: + mOnCameraFrameRender = + new OnCameraFrameRender(new ComparisonFrameRender(mCalibrator, mWidth, mHeight, getResources())); + item.setChecked(true); + return true; + case R.id.calibrate: + final Resources res = getResources(); + if (mCalibrator.getCornersBufferSize() < 2) { + (Toast.makeText(this, res.getString(R.string.more_samples), Toast.LENGTH_SHORT)).show(); + return true; + } + + mOnCameraFrameRender = new OnCameraFrameRender(new PreviewFrameRender()); + new AsyncTask() { + private ProgressDialog calibrationProgress; + + @Override + protected void onPreExecute() { + calibrationProgress = new ProgressDialog(CameraCalibrationActivity.this); + calibrationProgress.setTitle(res.getString(R.string.calibrating)); + calibrationProgress.setMessage(res.getString(R.string.please_wait)); + calibrationProgress.setCancelable(false); + calibrationProgress.setIndeterminate(true); + calibrationProgress.show(); + } + + @Override + protected Void doInBackground(Void... arg0) { + mCalibrator.calibrate(); + return null; + } + + @Override + protected void onPostExecute(Void result) { + calibrationProgress.dismiss(); + mCalibrator.clearCorners(); + mOnCameraFrameRender = new OnCameraFrameRender(new CalibrationFrameRender(mCalibrator)); + String resultMessage = (mCalibrator.isCalibrated()) ? + res.getString(R.string.calibration_successful) + " " + mCalibrator.getAvgReprojectionError() : + res.getString(R.string.calibration_unsuccessful); + (Toast.makeText(CameraCalibrationActivity.this, resultMessage, Toast.LENGTH_SHORT)).show(); + + if (mCalibrator.isCalibrated()) { + CalibrationResult.save(CameraCalibrationActivity.this, + mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); + } + } + }.execute(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + public void onCameraViewStarted(int width, int height) { + if (mWidth != width || mHeight != height) { + mWidth = width; + mHeight = height; + mCalibrator = new CameraCalibrator(mWidth, mHeight); + if (CalibrationResult.tryLoad(this, mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients())) { + mCalibrator.setCalibrated(); + } + + mOnCameraFrameRender = new OnCameraFrameRender(new CalibrationFrameRender(mCalibrator)); + } + } + + public void onCameraViewStopped() { + } + + public Mat onCameraFrame(CvCameraViewFrame inputFrame) { + return mOnCameraFrameRender.render(inputFrame); + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + Log.d(TAG, "onTouch invoked"); + + mCalibrator.addCorners(); + return false; + } +} diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java new file mode 100644 index 000000000..f0cd230a8 --- /dev/null +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java @@ -0,0 +1,169 @@ +package org.opencv.samples.cameracalibration; + +import java.util.ArrayList; +import java.util.List; + +import org.opencv.calib3d.Calib3d; +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; +import org.opencv.core.MatOfDouble; +import org.opencv.core.MatOfPoint2f; +import org.opencv.core.MatOfPoint3f; +import org.opencv.core.Point; +import org.opencv.core.Scalar; +import org.opencv.core.Size; + +import android.util.Log; + +public class CameraCalibrator { + private static final String TAG = "OCVSample::CameraCalibrator"; + + private final Size mPatternSize = new Size(4, 11); + private final int mCornersSize = (int)(mPatternSize.width * mPatternSize.height); + private boolean mPatternWasFound = false; + private MatOfPoint2f mCorners = new MatOfPoint2f(); + private List mCornersBuffer = new ArrayList(); + private boolean mIsCalibrated = false; + + private Mat mCameraMatrix = new Mat(); + private Mat mDistortionCoefficients = new Mat(); + private int mFlags; + private double mRms; + private double mSquareSize = 0.0181; + private Size mImageSize; + + public CameraCalibrator(int width, int height) { + mImageSize = new Size(width, height); + mFlags = Calib3d.CALIB_FIX_PRINCIPAL_POINT + + Calib3d.CALIB_ZERO_TANGENT_DIST + + Calib3d.CALIB_FIX_ASPECT_RATIO + + Calib3d.CALIB_FIX_K4 + + Calib3d.CALIB_FIX_K5; + Mat.eye(3, 3, CvType.CV_64FC1).copyTo(mCameraMatrix); + mCameraMatrix.put(0, 0, 1.0); + Mat.zeros(5, 1, CvType.CV_64FC1).copyTo(mDistortionCoefficients); + Log.i(TAG, "Instantiated new " + this.getClass()); + } + + public void processFrame(Mat grayFrame, Mat rgbaFrame) { + findPattern(grayFrame); + renderFrame(rgbaFrame); + } + + public void calibrate() { + ArrayList rvecs = new ArrayList(); + ArrayList tvecs = new ArrayList(); + Mat reprojectionErrors = new Mat(); + ArrayList objectPoints = new ArrayList(); + objectPoints.add(Mat.zeros(mCornersSize, 1, CvType.CV_32FC3)); + calcBoardCornerPositions(objectPoints.get(0)); + for (int i = 1; i < mCornersBuffer.size(); i++) { + objectPoints.add(objectPoints.get(0)); + } + + Calib3d.calibrateCamera(objectPoints, mCornersBuffer, mImageSize, + mCameraMatrix, mDistortionCoefficients, rvecs, tvecs, mFlags); + + mIsCalibrated = Core.checkRange(mCameraMatrix) + && Core.checkRange(mDistortionCoefficients); + + mRms = computeReprojectionErrors(objectPoints, rvecs, tvecs, reprojectionErrors); + Log.i(TAG, String.format("Average re-projection error: %f", mRms)); + Log.i(TAG, "Camera matrix: " + mCameraMatrix.dump()); + Log.i(TAG, "Distortion coefficients: " + mDistortionCoefficients.dump()); + } + + public void clearCorners() { + mCornersBuffer.clear(); + } + + private void calcBoardCornerPositions(Mat corners) { + final int cn = 3; + float positions[] = new float[mCornersSize * cn]; + + for (int i = 0; i < mPatternSize.height; i++) { + for (int j = 0; j < mPatternSize.width * cn; j += cn) { + positions[(int) (i * mPatternSize.width * cn + j + 0)] = + (2 * (j / cn) + i % 2) * (float) mSquareSize; + positions[(int) (i * mPatternSize.width * cn + j + 1)] = + i * (float) mSquareSize; + positions[(int) (i * mPatternSize.width * cn + j + 2)] = 0; + } + } + corners.create(mCornersSize, 1, CvType.CV_32FC3); + corners.put(0, 0, positions); + } + + private double computeReprojectionErrors(List objectPoints, + List rvecs, List tvecs, Mat perViewErrors) { + MatOfPoint2f cornersProjected = new MatOfPoint2f(); + double totalError = 0; + double error; + float viewErrors[] = new float[objectPoints.size()]; + + MatOfDouble distortionCoefficients = new MatOfDouble(mDistortionCoefficients); + int totalPoints = 0; + for (int i = 0; i < objectPoints.size(); i++) { + MatOfPoint3f points = new MatOfPoint3f(objectPoints.get(i)); + Calib3d.projectPoints(points, rvecs.get(i), tvecs.get(i), + mCameraMatrix, distortionCoefficients, cornersProjected); + error = Core.norm(mCornersBuffer.get(i), cornersProjected, Core.NORM_L2); + + int n = objectPoints.get(i).rows(); + viewErrors[i] = (float) Math.sqrt(error * error / n); + totalError += error * error; + totalPoints += n; + } + perViewErrors.create(objectPoints.size(), 1, CvType.CV_32FC1); + perViewErrors.put(0, 0, viewErrors); + + return Math.sqrt(totalError / totalPoints); + } + + private void findPattern(Mat grayFrame) { + mPatternWasFound = Calib3d.findCirclesGridDefault(grayFrame, mPatternSize, + mCorners, Calib3d.CALIB_CB_ASYMMETRIC_GRID); + } + + public void addCorners() { + if (mPatternWasFound) { + mCornersBuffer.add(mCorners.clone()); + } + } + + private void drawPoints(Mat rgbaFrame) { + Calib3d.drawChessboardCorners(rgbaFrame, mPatternSize, mCorners, mPatternWasFound); + } + + private void renderFrame(Mat rgbaFrame) { + drawPoints(rgbaFrame); + + Core.putText(rgbaFrame, "Captured: " + mCornersBuffer.size(), new Point(rgbaFrame.cols() / 3 * 2, rgbaFrame.rows() * 0.1), + Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); + } + + public Mat getCameraMatrix() { + return mCameraMatrix; + } + + public Mat getDistortionCoefficients() { + return mDistortionCoefficients; + } + + public int getCornersBufferSize() { + return mCornersBuffer.size(); + } + + public double getAvgReprojectionError() { + return mRms; + } + + public boolean isCalibrated() { + return mIsCalibrated; + } + + public void setCalibrated() { + mIsCalibrated = true; + } +} diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java new file mode 100644 index 000000000..3f155c2bf --- /dev/null +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java @@ -0,0 +1,102 @@ +package org.opencv.samples.cameracalibration; + +import java.util.ArrayList; +import java.util.List; + +import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; +import org.opencv.core.Core; +import org.opencv.core.Mat; +import org.opencv.core.MatOfPoint; +import org.opencv.core.Point; +import org.opencv.core.Range; +import org.opencv.core.Scalar; +import org.opencv.imgproc.Imgproc; + +import android.content.res.Resources; + +abstract class FrameRender { + protected CameraCalibrator mCalibrator; + + public abstract Mat render(CvCameraViewFrame inputFrame); +} + +class PreviewFrameRender extends FrameRender { + @Override + public Mat render(CvCameraViewFrame inputFrame) { + return inputFrame.rgba(); + } +} + +class CalibrationFrameRender extends FrameRender { + public CalibrationFrameRender(CameraCalibrator calibrator) { + mCalibrator = calibrator; + } + + @Override + public Mat render(CvCameraViewFrame inputFrame) { + Mat rgbaFrame = inputFrame.rgba(); + Mat grayFrame = inputFrame.gray(); + mCalibrator.processFrame(grayFrame, rgbaFrame); + + return rgbaFrame; + } +} + +class UndistortionFrameRender extends FrameRender { + public UndistortionFrameRender(CameraCalibrator calibrator) { + mCalibrator = calibrator; + } + + @Override + public Mat render(CvCameraViewFrame inputFrame) { + Mat renderedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type()); + Imgproc.undistort(inputFrame.rgba(), renderedFrame, + mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); + + return renderedFrame; + } +} + +class ComparisonFrameRender extends FrameRender { + private int mWidth; + private int mHeight; + private Resources mResources; + public ComparisonFrameRender(CameraCalibrator calibrator, int width, int height, Resources resources) { + mCalibrator = calibrator; + mWidth = width; + mHeight = height; + mResources = resources; + } + + @Override + public Mat render(CvCameraViewFrame inputFrame) { + Mat undistortedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type()); + Imgproc.undistort(inputFrame.rgba(), undistortedFrame, + mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); + + Mat comparisonFrame = inputFrame.rgba(); + undistortedFrame.colRange(new Range(0, mWidth / 2)).copyTo(comparisonFrame.colRange(new Range(mWidth / 2, mWidth))); + List border = new ArrayList(); + final int shift = (int)(mWidth * 0.005); + border.add(new MatOfPoint(new Point(mWidth / 2 - shift, 0), new Point(mWidth / 2 + shift, 0), + new Point(mWidth / 2 + shift, mHeight), new Point(mWidth / 2 - shift, mHeight))); + Core.fillPoly(comparisonFrame, border, new Scalar(255, 255, 255)); + + Core.putText(comparisonFrame, mResources.getString(R.string.original), new Point(mWidth * 0.1, mHeight * 0.1), + Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); + Core.putText(comparisonFrame, mResources.getString(R.string.undistorted), new Point(mWidth * 0.6, mHeight * 0.1), + Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); + + return comparisonFrame; + } +} + +class OnCameraFrameRender { + private FrameRender mFrameRender; + public OnCameraFrameRender(FrameRender frameRender) { + mFrameRender = frameRender; + } + public Mat render(CvCameraViewFrame inputFrame) { + return mFrameRender.render(inputFrame); + } +} From 270b2c7918466a9470748cf5002507ca723298fc Mon Sep 17 00:00:00 2001 From: yao Date: Fri, 26 Jul 2013 11:17:27 +0800 Subject: [PATCH 34/64] generating the lut table instead of hard coding one --- modules/ocl/src/hog.cpp | 126 ++++-------------------- modules/ocl/src/opencl/objdetect_hog.cl | 95 +----------------- 2 files changed, 18 insertions(+), 203 deletions(-) diff --git a/modules/ocl/src/hog.cpp b/modules/ocl/src/hog.cpp index 2e2b3a992..c7ac4098f 100644 --- a/modules/ocl/src/hog.cpp +++ b/modules/ocl/src/hog.cpp @@ -56,98 +56,6 @@ using namespace std; static oclMat gauss_w_lut; static bool hog_device_cpu; -/* pre-compute gaussian and interp_weight lookup tables if sigma is 4.0f */ -static const float gaussian_interp_lut[] = -{ - /* gaussian lut */ - 0.01831564f, 0.02926831f, 0.04393693f, 0.06196101f, 0.08208500f, 0.10215643f, - 0.11943297f, 0.13117145f, 0.13533528f, 0.13117145f, 0.11943297f, 0.10215643f, - 0.08208500f, 0.06196101f, 0.04393693f, 0.02926831f, 0.02926831f, 0.04677062f, - 0.07021102f, 0.09901341f, 0.13117145f, 0.16324551f, 0.19085334f, 0.20961139f, - 0.21626517f, 0.20961139f, 0.19085334f, 0.16324551f, 0.13117145f, 0.09901341f, - 0.07021102f, 0.04677062f, 0.04393693f, 0.07021102f, 0.10539922f, 0.14863673f, - 0.19691168f, 0.24506053f, 0.28650481f, 0.31466395f, 0.32465246f, 0.31466395f, - 0.28650481f, 0.24506053f, 0.19691168f, 0.14863673f, 0.10539922f, 0.07021102f, - 0.06196101f, 0.09901341f, 0.14863673f, 0.20961139f, 0.27768996f, 0.34559074f, - 0.40403652f, 0.44374731f, 0.45783335f, 0.44374731f, 0.40403652f, 0.34559074f, - 0.27768996f, 0.20961139f, 0.14863673f, 0.09901341f, 0.08208500f, 0.13117145f, - 0.19691168f, 0.27768996f, 0.36787945f, 0.45783335f, 0.53526145f, 0.58786964f, - 0.60653067f, 0.58786964f, 0.53526145f, 0.45783335f, 0.36787945f, 0.27768996f, - 0.19691168f, 0.13117145f, 0.10215643f, 0.16324551f, 0.24506053f, 0.34559074f, - 0.45783335f, 0.56978285f, 0.66614360f, 0.73161560f, 0.75483960f, 0.73161560f, - 0.66614360f, 0.56978285f, 0.45783335f, 0.34559074f, 0.24506053f, 0.16324551f, - 0.11943297f, 0.19085334f, 0.28650481f, 0.40403652f, 0.53526145f, 0.66614360f, - 0.77880079f, 0.85534531f, 0.88249689f, 0.85534531f, 0.77880079f, 0.66614360f, - 0.53526145f, 0.40403652f, 0.28650481f, 0.19085334f, 0.13117145f, 0.20961139f, - 0.31466395f, 0.44374731f, 0.58786964f, 0.73161560f, 0.85534531f, 0.93941307f, - 0.96923321f, 0.93941307f, 0.85534531f, 0.73161560f, 0.58786964f, 0.44374731f, - 0.31466395f, 0.20961139f, 0.13533528f, 0.21626517f, 0.32465246f, 0.45783335f, - 0.60653067f, 0.75483960f, 0.88249689f, 0.96923321f, 1.00000000f, 0.96923321f, - 0.88249689f, 0.75483960f, 0.60653067f, 0.45783335f, 0.32465246f, 0.21626517f, - 0.13117145f, 0.20961139f, 0.31466395f, 0.44374731f, 0.58786964f, 0.73161560f, - 0.85534531f, 0.93941307f, 0.96923321f, 0.93941307f, 0.85534531f, 0.73161560f, - 0.58786964f, 0.44374731f, 0.31466395f, 0.20961139f, 0.11943297f, 0.19085334f, - 0.28650481f, 0.40403652f, 0.53526145f, 0.66614360f, 0.77880079f, 0.85534531f, - 0.88249689f, 0.85534531f, 0.77880079f, 0.66614360f, 0.53526145f, 0.40403652f, - 0.28650481f, 0.19085334f, 0.10215643f, 0.16324551f, 0.24506053f, 0.34559074f, - 0.45783335f, 0.56978285f, 0.66614360f, 0.73161560f, 0.75483960f, 0.73161560f, - 0.66614360f, 0.56978285f, 0.45783335f, 0.34559074f, 0.24506053f, 0.16324551f, - 0.08208500f, 0.13117145f, 0.19691168f, 0.27768996f, 0.36787945f, 0.45783335f, - 0.53526145f, 0.58786964f, 0.60653067f, 0.58786964f, 0.53526145f, 0.45783335f, - 0.36787945f, 0.27768996f, 0.19691168f, 0.13117145f, 0.06196101f, 0.09901341f, - 0.14863673f, 0.20961139f, 0.27768996f, 0.34559074f, 0.40403652f, 0.44374731f, - 0.45783335f, 0.44374731f, 0.40403652f, 0.34559074f, 0.27768996f, 0.20961139f, - 0.14863673f, 0.09901341f, 0.04393693f, 0.07021102f, 0.10539922f, 0.14863673f, - 0.19691168f, 0.24506053f, 0.28650481f, 0.31466395f, 0.32465246f, 0.31466395f, - 0.28650481f, 0.24506053f, 0.19691168f, 0.14863673f, 0.10539922f, 0.07021102f, - 0.02926831f, 0.04677062f, 0.07021102f, 0.09901341f, 0.13117145f, 0.16324551f, - 0.19085334f, 0.20961139f, 0.21626517f, 0.20961139f, 0.19085334f, 0.16324551f, - 0.13117145f, 0.09901341f, 0.07021102f, 0.04677062f, - /* interp_weight lut */ - 0.00390625f, 0.01171875f, 0.01953125f, 0.02734375f, 0.03515625f, 0.04296875f, - 0.05078125f, 0.05859375f, 0.05859375f, 0.05078125f, 0.04296875f, 0.03515625f, - 0.02734375f, 0.01953125f, 0.01171875f, 0.00390625f, 0.01171875f, 0.03515625f, - 0.05859375f, 0.08203125f, 0.10546875f, 0.12890625f, 0.15234375f, 0.17578125f, - 0.17578125f, 0.15234375f, 0.12890625f, 0.10546875f, 0.08203125f, 0.05859375f, - 0.03515625f, 0.01171875f, 0.01953125f, 0.05859375f, 0.09765625f, 0.13671875f, - 0.17578125f, 0.21484375f, 0.25390625f, 0.29296875f, 0.29296875f, 0.25390625f, - 0.21484375f, 0.17578125f, 0.13671875f, 0.09765625f, 0.05859375f, 0.01953125f, - 0.02734375f, 0.08203125f, 0.13671875f, 0.19140625f, 0.24609375f, 0.30078125f, - 0.35546875f, 0.41015625f, 0.41015625f, 0.35546875f, 0.30078125f, 0.24609375f, - 0.19140625f, 0.13671875f, 0.08203125f, 0.02734375f, 0.03515625f, 0.10546875f, - 0.17578125f, 0.24609375f, 0.31640625f, 0.38671875f, 0.45703125f, 0.52734375f, - 0.52734375f, 0.45703125f, 0.38671875f, 0.31640625f, 0.24609375f, 0.17578125f, - 0.10546875f, 0.03515625f, 0.04296875f, 0.12890625f, 0.21484375f, 0.30078125f, - 0.38671875f, 0.47265625f, 0.55859375f, 0.64453125f, 0.64453125f, 0.55859375f, - 0.47265625f, 0.38671875f, 0.30078125f, 0.21484375f, 0.12890625f, 0.04296875f, - 0.05078125f, 0.15234375f, 0.25390625f, 0.35546875f, 0.45703125f, 0.55859375f, - 0.66015625f, 0.76171875f, 0.76171875f, 0.66015625f, 0.55859375f, 0.45703125f, - 0.35546875f, 0.25390625f, 0.15234375f, 0.05078125f, 0.05859375f, 0.17578125f, - 0.29296875f, 0.41015625f, 0.52734375f, 0.64453125f, 0.76171875f, 0.87890625f, - 0.87890625f, 0.76171875f, 0.64453125f, 0.52734375f, 0.41015625f, 0.29296875f, - 0.17578125f, 0.05859375f, 0.05859375f, 0.17578125f, 0.29296875f, 0.41015625f, - 0.52734375f, 0.64453125f, 0.76171875f, 0.87890625f, 0.87890625f, 0.76171875f, - 0.64453125f, 0.52734375f, 0.41015625f, 0.29296875f, 0.17578125f, 0.05859375f, - 0.05078125f, 0.15234375f, 0.25390625f, 0.35546875f, 0.45703125f, 0.55859375f, - 0.66015625f, 0.76171875f, 0.76171875f, 0.66015625f, 0.55859375f, 0.45703125f, - 0.35546875f, 0.25390625f, 0.15234375f, 0.05078125f, 0.04296875f, 0.12890625f, - 0.21484375f, 0.30078125f, 0.38671875f, 0.47265625f, 0.55859375f, 0.64453125f, - 0.64453125f, 0.55859375f, 0.47265625f, 0.38671875f, 0.30078125f, 0.21484375f, - 0.12890625f, 0.04296875f, 0.03515625f, 0.10546875f, 0.17578125f, 0.24609375f, - 0.31640625f, 0.38671875f, 0.45703125f, 0.52734375f, 0.52734375f, 0.45703125f, - 0.38671875f, 0.31640625f, 0.24609375f, 0.17578125f, 0.10546875f, 0.03515625f, - 0.02734375f, 0.08203125f, 0.13671875f, 0.19140625f, 0.24609375f, 0.30078125f, - 0.35546875f, 0.41015625f, 0.41015625f, 0.35546875f, 0.30078125f, 0.24609375f, - 0.19140625f, 0.13671875f, 0.08203125f, 0.02734375f, 0.01953125f, 0.05859375f, - 0.09765625f, 0.13671875f, 0.17578125f, 0.21484375f, 0.25390625f, 0.29296875f, - 0.29296875f, 0.25390625f, 0.21484375f, 0.17578125f, 0.13671875f, 0.09765625f, - 0.05859375f, 0.01953125f, 0.01171875f, 0.03515625f, 0.05859375f, 0.08203125f, - 0.10546875f, 0.12890625f, 0.15234375f, 0.17578125f, 0.17578125f, 0.15234375f, - 0.12890625f, 0.10546875f, 0.08203125f, 0.05859375f, 0.03515625f, 0.01171875f, - 0.00390625f, 0.01171875f, 0.01953125f, 0.02734375f, 0.03515625f, 0.04296875f, - 0.05078125f, 0.05859375f, 0.05859375f, 0.05078125f, 0.04296875f, 0.03515625f, - 0.02734375f, 0.01953125f, 0.01171875f, 0.00390625f -}; namespace cv { @@ -180,7 +88,7 @@ namespace cv int nblocks_win_x, int nblocks_win_y); void compute_hists(int nbins, int block_stride_x, int blovck_stride_y, - int height, int width, float sigma, const cv::ocl::oclMat &grad, + int height, int width, const cv::ocl::oclMat &grad, const cv::ocl::oclMat &qangle, const cv::ocl::oclMat &gauss_w_lut, cv::ocl::oclMat &block_hists); @@ -328,10 +236,18 @@ void cv::ocl::HOGDescriptor::init_buffer(const oclMat &img, Size win_stride) Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride); labels.create(1, wins_per_img.area(), CV_8U); - vector v_lut = vector(gaussian_interp_lut, gaussian_interp_lut + - sizeof(gaussian_interp_lut) / sizeof(gaussian_interp_lut[0])); - Mat m_lut(v_lut); - gauss_w_lut.upload(m_lut.reshape(1,1)); + float sigma = getWinSigma(); + float scale = 1.f / (2.f * sigma * sigma); + Mat gaussian_lut(1, 512, CV_32FC1); + int idx = 0; + for(int i=-8; i<8; i++) + for(int j=-8; j<8; j++) + gaussian_lut.at(idx++) = std::exp(-(j * j + i * i) * scale); + for(int i=-8; i<8; i++) + for(int j=-8; j<8; j++) + gaussian_lut.at(idx++) = (8.f - fabs(j + 0.5f)) * (8.f - fabs(i + 0.5f)) / 64.f; + + gauss_w_lut.upload(gaussian_lut); } void cv::ocl::HOGDescriptor::computeGradient(const oclMat &img, oclMat &grad, oclMat &qangle) @@ -358,7 +274,7 @@ void cv::ocl::HOGDescriptor::computeBlockHistograms(const oclMat &img) computeGradient(img, this->grad, this->qangle); hog::compute_hists(nbins, block_stride.width, block_stride.height, effect_size.height, - effect_size.width, (float)getWinSigma(), grad, qangle, gauss_w_lut, block_hists); + effect_size.width, grad, qangle, gauss_w_lut, block_hists); hog::normalize_hists(nbins, block_stride.width, block_stride.height, effect_size.height, effect_size.width, block_hists, (float)threshold_L2hys); @@ -1708,7 +1624,7 @@ void cv::ocl::device::hog::set_up_constants(int nbins, void cv::ocl::device::hog::compute_hists(int nbins, int block_stride_x, int block_stride_y, - int height, int width, float sigma, + int height, int width, const cv::ocl::oclMat &grad, const cv::ocl::oclMat &qangle, const cv::ocl::oclMat &gauss_w_lut, @@ -1716,8 +1632,7 @@ void cv::ocl::device::hog::compute_hists(int nbins, { Context *clCxt = Context::getContext(); vector< pair > args; - string kernelName = (sigma == 4.0f) ? "compute_hists_lut_kernel" : - "compute_hists_kernel"; + string kernelName = "compute_hists_lut_kernel"; int img_block_width = (width - CELLS_PER_BLOCK_X * CELL_WIDTH + block_stride_x) / block_stride_x; @@ -1728,9 +1643,6 @@ void cv::ocl::device::hog::compute_hists(int nbins, int grad_quadstep = grad.step >> 2; int qangle_step = qangle.step; - // Precompute gaussian spatial window parameter - float scale = 1.f / (2.f * sigma * sigma); - int blocks_in_group = 4; size_t localThreads[3] = { blocks_in_group * 24, 2, 1 }; size_t globalThreads[3] = { @@ -1751,14 +1663,10 @@ void cv::ocl::device::hog::compute_hists(int nbins, args.push_back( make_pair( sizeof(cl_int), (void *)&qangle_step)); args.push_back( make_pair( sizeof(cl_mem), (void *)&grad.data)); args.push_back( make_pair( sizeof(cl_mem), (void *)&qangle.data)); - if (kernelName.compare("compute_hists_lut_kernel") == 0) - args.push_back( make_pair( sizeof(cl_mem), (void *)&gauss_w_lut.data)); - else - args.push_back( make_pair( sizeof(cl_float), (void *)&scale)); + args.push_back( make_pair( sizeof(cl_mem), (void *)&gauss_w_lut.data)); args.push_back( make_pair( sizeof(cl_mem), (void *)&block_hists.data)); args.push_back( make_pair( smem, (void *)NULL)); - if(hog_device_cpu) { openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads, diff --git a/modules/ocl/src/opencl/objdetect_hog.cl b/modules/ocl/src/opencl/objdetect_hog.cl index 8ca12704e..036322760 100644 --- a/modules/ocl/src/opencl/objdetect_hog.cl +++ b/modules/ocl/src/opencl/objdetect_hog.cl @@ -53,7 +53,7 @@ //---------------------------------------------------------------------------- // Histogram computation // 12 threads for a cell, 12x4 threads per block -// Use pre-computed gaussian and interp_weight lookup tables if sigma is 4.0f +// Use pre-computed gaussian and interp_weight lookup tables __kernel void compute_hists_lut_kernel( const int cblock_stride_x, const int cblock_stride_y, const int cnbins, const int cblock_hist_size, const int img_block_width, @@ -146,99 +146,6 @@ __kernel void compute_hists_lut_kernel( } } -//---------------------------------------------------------------------------- -// Histogram computation -// 12 threads for a cell, 12x4 threads per block -__kernel void compute_hists_kernel( - const int cblock_stride_x, const int cblock_stride_y, - const int cnbins, const int cblock_hist_size, const int img_block_width, - const int blocks_in_group, const int blocks_total, - const int grad_quadstep, const int qangle_step, - __global const float* grad, __global const uchar* qangle, - const float scale, __global float* block_hists, __local float* smem) -{ - const int lx = get_local_id(0); - const int lp = lx / 24; /* local group id */ - const int gid = get_group_id(0) * blocks_in_group + lp;/* global group id */ - const int gidY = gid / img_block_width; - const int gidX = gid - gidY * img_block_width; - - const int lidX = lx - lp * 24; - const int lidY = get_local_id(1); - - const int cell_x = lidX / 12; - const int cell_y = lidY; - const int cell_thread_x = lidX - cell_x * 12; - - __local float* hists = smem + lp * cnbins * (CELLS_PER_BLOCK_X * - CELLS_PER_BLOCK_Y * 12 + CELLS_PER_BLOCK_X * CELLS_PER_BLOCK_Y); - __local float* final_hist = hists + cnbins * - (CELLS_PER_BLOCK_X * CELLS_PER_BLOCK_Y * 12); - - const int offset_x = gidX * cblock_stride_x + (cell_x << 2) + cell_thread_x; - const int offset_y = gidY * cblock_stride_y + (cell_y << 2); - - __global const float* grad_ptr = (gid < blocks_total) ? - grad + offset_y * grad_quadstep + (offset_x << 1) : grad; - __global const uchar* qangle_ptr = (gid < blocks_total) ? - qangle + offset_y * qangle_step + (offset_x << 1) : qangle; - - __local float* hist = hists + 12 * (cell_y * CELLS_PER_BLOCK_Y + cell_x) + - cell_thread_x; - for (int bin_id = 0; bin_id < cnbins; ++bin_id) - hist[bin_id * 48] = 0.f; - - const int dist_x = -4 + cell_thread_x - 4 * cell_x; - const int dist_center_x = dist_x - 4 * (1 - 2 * cell_x); - - const int dist_y_begin = -4 - 4 * lidY; - for (int dist_y = dist_y_begin; dist_y < dist_y_begin + 12; ++dist_y) - { - float2 vote = (float2) (grad_ptr[0], grad_ptr[1]); - uchar2 bin = (uchar2) (qangle_ptr[0], qangle_ptr[1]); - - grad_ptr += grad_quadstep; - qangle_ptr += qangle_step; - - int dist_center_y = dist_y - 4 * (1 - 2 * cell_y); - - float gaussian = exp(-(dist_center_y * dist_center_y + dist_center_x * - dist_center_x) * scale); - float interp_weight = (8.f - fabs(dist_y + 0.5f)) * - (8.f - fabs(dist_x + 0.5f)) / 64.f; - - hist[bin.x * 48] += gaussian * interp_weight * vote.x; - hist[bin.y * 48] += gaussian * interp_weight * vote.y; - } - barrier(CLK_LOCAL_MEM_FENCE); - - volatile __local float* hist_ = hist; - for (int bin_id = 0; bin_id < cnbins; ++bin_id, hist_ += 48) - { - if (cell_thread_x < 6) - hist_[0] += hist_[6]; - barrier(CLK_LOCAL_MEM_FENCE); - if (cell_thread_x < 3) - hist_[0] += hist_[3]; -#ifdef CPU - barrier(CLK_LOCAL_MEM_FENCE); -#endif - if (cell_thread_x == 0) - final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] = - hist_[0] + hist_[1] + hist_[2]; - } -#ifdef CPU - barrier(CLK_LOCAL_MEM_FENCE); -#endif - int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x; - if ((tid < cblock_hist_size) && (gid < blocks_total)) - { - __global float* block_hist = block_hists + - (gidY * img_block_width + gidX) * cblock_hist_size; - block_hist[tid] = final_hist[tid]; - } -} - //------------------------------------------------------------- // Normalization of histograms via L2Hys_norm // optimized for the case of 9 bins From 027b8021b1a44c8bac9acd08cc0d30abbdac10a1 Mon Sep 17 00:00:00 2001 From: Jin Ma Date: Fri, 26 Jul 2013 14:14:26 +0800 Subject: [PATCH 35/64] Added farneback to superres module. --- .../include/opencv2/superres/optical_flow.hpp | 1 + modules/superres/perf/perf_superres_ocl.cpp | 5 +- modules/superres/src/optical_flow.cpp | 74 +++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/modules/superres/include/opencv2/superres/optical_flow.hpp b/modules/superres/include/opencv2/superres/optical_flow.hpp index 13ea9905c..d51ce793e 100644 --- a/modules/superres/include/opencv2/superres/optical_flow.hpp +++ b/modules/superres/include/opencv2/superres/optical_flow.hpp @@ -58,6 +58,7 @@ namespace cv CV_EXPORTS Ptr createOptFlow_Farneback(); CV_EXPORTS Ptr createOptFlow_Farneback_GPU(); + CV_EXPORTS Ptr createOptFlow_Farneback_OCL(); CV_EXPORTS Ptr createOptFlow_Simple(); diff --git a/modules/superres/perf/perf_superres_ocl.cpp b/modules/superres/perf/perf_superres_ocl.cpp index 456ae5efb..0b9864cbd 100644 --- a/modules/superres/perf/perf_superres_ocl.cpp +++ b/modules/superres/perf/perf_superres_ocl.cpp @@ -46,7 +46,6 @@ #include "opencv2/ocl/ocl.hpp" using namespace std; -using namespace std::tr1; using namespace testing; using namespace perf; using namespace cv; @@ -113,8 +112,8 @@ PERF_TEST_P(Size_MatType, SuperResolution_BTVL1_OCL, declare.time(5 * 60); - const Size size = get<0>(GetParam()); - const int type = get<1>(GetParam()); + const Size size = std::tr1::get<0>(GetParam()); + const int type = std::tr1::get<1>(GetParam()); Mat frame(size, type); declare.in(frame, WARMUP_RNG); diff --git a/modules/superres/src/optical_flow.cpp b/modules/superres/src/optical_flow.cpp index 6947d1901..125969b3e 100644 --- a/modules/superres/src/optical_flow.cpp +++ b/modules/superres/src/optical_flow.cpp @@ -910,4 +910,78 @@ Ptr cv::superres::createOptFlow_DualTVL1_OCL() return new DualTVL1_OCL; } +/////////////////////////////////////////////////////////////////// +// FarneBack + +namespace +{ + class FarneBack_OCL : public oclOpticalFlow + { + public: + AlgorithmInfo* info() const; + + FarneBack_OCL(); + + void collectGarbage(); + + protected: + void impl(const cv::ocl::oclMat& input0, const cv::ocl::oclMat& input1, cv::ocl::oclMat& dst1, cv::ocl::oclMat& dst2); + + private: + double pyrScale_; + int numLevels_; + int winSize_; + int numIters_; + int polyN_; + double polySigma_; + int flags_; + + ocl::FarnebackOpticalFlow alg_; + }; + + CV_INIT_ALGORITHM(FarneBack_OCL, "DenseOpticalFlowExt.FarneBack_OCL", + obj.info()->addParam(obj, "pyrScale", obj.pyrScale_); + obj.info()->addParam(obj, "numLevels", obj.numLevels_); + obj.info()->addParam(obj, "winSize", obj.winSize_); + obj.info()->addParam(obj, "numIters", obj.numIters_); + obj.info()->addParam(obj, "polyN", obj.polyN_); + obj.info()->addParam(obj, "polySigma", obj.polySigma_); + obj.info()->addParam(obj, "flags", obj.flags_)); + + FarneBack_OCL::FarneBack_OCL() : oclOpticalFlow(CV_8UC1) + { + pyrScale_ = alg_.pyrScale; + numLevels_ = alg_.numLevels; + winSize_ = alg_.winSize; + numIters_ = alg_.numIters; + polyN_ = alg_.polyN; + polySigma_ = alg_.polySigma; + flags_ = alg_.flags; + } + + void FarneBack_OCL::impl(const cv::ocl::oclMat& input0, const cv::ocl::oclMat& input1, cv::ocl::oclMat& dst1, cv::ocl::oclMat& dst2) + { + alg_.pyrScale = pyrScale_; + alg_.numLevels = numLevels_; + alg_.winSize = winSize_; + alg_.numIters = numIters_; + alg_.polyN = polyN_; + alg_.polySigma = polySigma_; + alg_.flags = flags_; + + alg_(input0, input1, dst1, dst2); + } + + void FarneBack_OCL::collectGarbage() + { + alg_.releaseMemory(); + oclOpticalFlow::collectGarbage(); + } +} + +Ptr cv::superres::createOptFlow_Farneback_OCL() +{ + return new FarneBack_OCL; +} + #endif \ No newline at end of file From dfd29578415ff9928ec43bc36aae054e37d33006 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 26 Jul 2013 11:13:39 +0400 Subject: [PATCH 36/64] fixed gpu_perf4au perf test (added cuda impl) --- modules/gpu/perf4au/main.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/gpu/perf4au/main.cpp b/modules/gpu/perf4au/main.cpp index f6a65ad63..6d23a3db1 100644 --- a/modules/gpu/perf4au/main.cpp +++ b/modules/gpu/perf4au/main.cpp @@ -55,16 +55,12 @@ #include "opencv2/video/video.hpp" #include "opencv2/legacy/legacy.hpp" -int main(int argc, char* argv[]) -{ - perf::printCudaInfo(); +static const char * impls[] = { + "cuda", + "plain" +}; - perf::Regression::Init("gpu_perf4au"); - perf::TestBase::Init(argc, argv); - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} +CV_PERF_TEST_MAIN_WITH_IMPLS(gpu_perf4au, impls, perf::printCudaInfo()) ////////////////////////////////////////////////////////// // HoughLinesP From ee182eb086242326877d2e431404383b1a638397 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 26 Jul 2013 14:35:40 +0400 Subject: [PATCH 37/64] Fixed the setting of CVAPI_EXPORTS for modules that are always static/shared. Also, removed needless check of BUILD_SHARED_LIBS in core; in that case, only the current module's library type matters. --- cmake/OpenCVModule.cmake | 3 ++- modules/core/src/system.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 81340bd0e..0ac39e4c1 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -508,7 +508,8 @@ macro(ocv_create_module) ) endif() - if(BUILD_SHARED_LIBS) + if((NOT DEFINED OPENCV_MODULE_TYPE AND BUILD_SHARED_LIBS) + OR (DEFINED OPENCV_MODULE_TYPE AND OPENCV_MODULE_TYPE STREQUAL SHARED)) if(MSVC) set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS) else() diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index a891e94cc..062045de1 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -779,7 +779,7 @@ cvGetModuleInfo( const char* name, const char **version, const char **plugin_lis *plugin_list = plugin_list_buf; } -#if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE +#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ); BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ) From 1d571b1eaa2492cc06849a0d009609583ffbf0e1 Mon Sep 17 00:00:00 2001 From: Dmitry Retinskiy Date: Fri, 26 Jul 2013 16:13:07 +0400 Subject: [PATCH 38/64] bugfix #3121: corrected calculation of blue channel index --- modules/imgproc/src/color.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 41ca2db9c..fed7b7313 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -3457,7 +3457,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) case CV_BGR2YUV: case CV_RGB2YUV: { CV_Assert( scn == 3 || scn == 4 ); - bidx = code == CV_BGR2YCrCb || code == CV_RGB2YUV ? 0 : 2; + bidx = code == CV_BGR2YCrCb || code == CV_BGR2YUV ? 0 : 2; static const float yuv_f[] = { 0.114f, 0.587f, 0.299f, 0.492f, 0.877f }; static const int yuv_i[] = { B2Y, G2Y, R2Y, 8061, 14369 }; const float* coeffs_f = code == CV_BGR2YCrCb || code == CV_RGB2YCrCb ? 0 : yuv_f; @@ -3486,7 +3486,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( dcn <= 0 ) dcn = 3; CV_Assert( scn == 3 && (dcn == 3 || dcn == 4) ); - bidx = code == CV_YCrCb2BGR || code == CV_YUV2RGB ? 0 : 2; + bidx = code == CV_YCrCb2BGR || code == CV_YUV2BGR ? 0 : 2; static const float yuv_f[] = { 2.032f, -0.395f, -0.581f, 1.140f }; static const int yuv_i[] = { 33292, -6472, -9519, 18678 }; const float* coeffs_f = code == CV_YCrCb2BGR || code == CV_YCrCb2RGB ? 0 : yuv_f; From 3a0e26b89d391ef9c6a4c8b3c13fae7370ca0a56 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Fri, 26 Jul 2013 17:27:31 +0400 Subject: [PATCH 39/64] adding/tuning multiple run for perf tests failing due to big deviation (functions using TBB can work so) --- modules/imgproc/perf/perf_cvt_color.cpp | 2 +- modules/imgproc/perf/perf_histogram.cpp | 2 +- modules/imgproc/perf/perf_resize.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/imgproc/perf/perf_cvt_color.cpp b/modules/imgproc/perf/perf_cvt_color.cpp index 601beb899..966a442f3 100644 --- a/modules/imgproc/perf/perf_cvt_color.cpp +++ b/modules/imgproc/perf/perf_cvt_color.cpp @@ -258,7 +258,7 @@ PERF_TEST_P(Size_CvtMode, cvtColor8u, declare.time(100); declare.in(src, WARMUP_RNG).out(dst); - int runs = sz.width <= 320 ? 70 : 5; + int runs = sz.width <= 320 ? 100 : 5; TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn); SANITY_CHECK(dst, 1); diff --git a/modules/imgproc/perf/perf_histogram.cpp b/modules/imgproc/perf/perf_histogram.cpp index 92db3be34..fc6a5cc46 100644 --- a/modules/imgproc/perf/perf_histogram.cpp +++ b/modules/imgproc/perf/perf_histogram.cpp @@ -35,7 +35,7 @@ PERF_TEST_P(Size_Source, calcHist1d, declare.in(source); - TEST_CYCLE() + TEST_CYCLE_MULTIRUN(3) { calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges); } diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp index ea959a627..7634644ea 100644 --- a/modules/imgproc/perf/perf_resize.cpp +++ b/modules/imgproc/perf/perf_resize.cpp @@ -25,7 +25,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear, cvtest::fillGradient(src); declare.in(src).out(dst); - TEST_CYCLE() resize(src, dst, to); + TEST_CYCLE_MULTIRUN(10) resize(src, dst, to); #ifdef ANDROID SANITY_CHECK(dst, 5); @@ -52,7 +52,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear, cvtest::fillGradient(src); declare.in(src).out(dst); - TEST_CYCLE() resize(src, dst, to); + TEST_CYCLE_MULTIRUN(10) resize(src, dst, to); #ifdef ANDROID SANITY_CHECK(dst, 5); From 435d26391a434415dc329bf8adc900590f22db3a Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Sun, 28 Jul 2013 00:23:52 +0400 Subject: [PATCH 40/64] Added gittip button --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index 0799dff89..0ac9569b6 100644 --- a/README +++ b/README @@ -15,3 +15,5 @@ Summary of guidelines: * Include tests and documentation; * Clean up "oops" commits before submitting; * Follow the coding style guide. + +[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/gittip1.png)](https://www.gittip.com/OpenCV/) From 64f4957d328e3eee55530f1a18686100561af693 Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Sun, 28 Jul 2013 00:25:07 +0400 Subject: [PATCH 41/64] Rename README to README.md --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 4a36dfd123b38ad09d7e8331ce63d4a7849ca5de Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Sun, 28 Jul 2013 00:37:38 +0400 Subject: [PATCH 42/64] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0ac9569b6..66ee47f30 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,5 @@ Summary of guidelines: * Follow the coding style guide. [![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/gittip1.png)](https://www.gittip.com/OpenCV/) +[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/paypal-donate-button.png)](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org) + From 3ad22dbc4106bc5694bcf98dbba73e44c2cf539c Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Sun, 28 Jul 2013 01:01:46 +0400 Subject: [PATCH 43/64] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66ee47f30..681ce02b0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -OpenCV: open source computer vision library +OpenCV: Open Source Computer Vision Library Homepage: http://opencv.org Online docs: http://docs.opencv.org From cdc2ee9789d269141378f1a8a698d3debcf49257 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Sun, 28 Jul 2013 16:18:12 +0200 Subject: [PATCH 44/64] Documentation fix for cv::compare (issue 3149) Since commit d8417af0860 (July 2011) cv::compare produces an array with the same size and type as the input arrays. Signed-off-by: Michael Hanselmann --- modules/core/doc/operations_on_arrays.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/doc/operations_on_arrays.rst b/modules/core/doc/operations_on_arrays.rst index bd55993af..cef0e515b 100644 --- a/modules/core/doc/operations_on_arrays.rst +++ b/modules/core/doc/operations_on_arrays.rst @@ -532,7 +532,7 @@ Performs the per-element comparison of two arrays or an array and scalar value. :param value: scalar value. - :param dst: output array that has the same size as the input arrays and type= ``CV_8UC1`` . + :param dst: output array that has the same size and type as the input arrays. :param cmpop: a flag, that specifies correspondence between the arrays: From eb0d26b5be59605343310bcee109d85a6d36db78 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 30 Jul 2013 16:42:45 +0400 Subject: [PATCH 45/64] fixing warning on shadowing local var (TEST_CYCLE_MULTIRUN uses 'r') --- modules/imgproc/perf/perf_histogram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/perf/perf_histogram.cpp b/modules/imgproc/perf/perf_histogram.cpp index fc6a5cc46..1789470c2 100644 --- a/modules/imgproc/perf/perf_histogram.cpp +++ b/modules/imgproc/perf/perf_histogram.cpp @@ -28,8 +28,8 @@ PERF_TEST_P(Size_Source, calcHist1d, int dims = 1; int numberOfImages = 1; - const float r[] = {rangeLow, rangeHight}; - const float* ranges[] = {r}; + const float range[] = {rangeLow, rangeHight}; + const float* ranges[] = {range}; randu(source, rangeLow, rangeHight); From 11617e5d0b6f0a1495e36f7867f73e7fbd674f8f Mon Sep 17 00:00:00 2001 From: Kirill Kornyakov Date: Tue, 30 Jul 2013 18:48:20 +0400 Subject: [PATCH 46/64] Updated gitignore relative to new platforms dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0a19f3cee..4fd406edd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .DS_Store refman.rst OpenCV4Tegra/ +tegra/ *.user .sw[a-z] .*.swp From 252a11c437067c3f9852f75664b369f5af865de0 Mon Sep 17 00:00:00 2001 From: Kirill Kornyakov Date: Tue, 30 Jul 2013 18:51:53 +0400 Subject: [PATCH 47/64] Updated README.md --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 681ce02b0..403f118ee 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ -OpenCV: Open Source Computer Vision Library +### OpenCV: Open Source Computer Vision Library -Homepage: http://opencv.org -Online docs: http://docs.opencv.org -Q&A forum: http://answers.opencv.org -Dev zone: http://code.opencv.org +#### Resources -Please read before starting work on a pull request: - http://code.opencv.org/projects/opencv/wiki/How_to_contribute +* Homepage: +* Docs: +* Q&A forum: +* Issue tracking: + +#### Contributing + +Please read before starting work on a pull request: Summary of guidelines: @@ -16,6 +19,5 @@ Summary of guidelines: * Clean up "oops" commits before submitting; * Follow the coding style guide. -[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/gittip1.png)](https://www.gittip.com/OpenCV/) -[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/paypal-donate-button.png)](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org) - +[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/gittip1.png)](https://www.gittip.com/OpenCV/) +[![Donate OpenCV project](http://opencv.org/wp-content/uploads/2013/07/paypal-donate-button.png)](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org) \ No newline at end of file From 0c5244103f0b362bf99d0b6082f51da619eb54af Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Mon, 29 Jul 2013 15:51:16 +0200 Subject: [PATCH 48/64] Added all *.cpp samples reference to the 2.4.6 documentation as discussed in feature #3169 - Used lunix style slashes - works on most systems - Removed all trailing whitespaces --- ...camera_calibration_and_3d_reconstruction.rst | 10 ++++++++++ modules/contrib/doc/facerec/facerec_api.rst | 4 ++++ modules/contrib/doc/openfabmap.rst | 4 ++++ modules/contrib/doc/retina/index.rst | 5 +++++ modules/core/doc/basic_structures.rst | 3 +++ modules/core/doc/clustering.rst | 4 ++++ modules/core/doc/drawing_functions.rst | 4 ++++ modules/core/doc/operations_on_arrays.rst | 5 +++++ modules/core/doc/xml_yaml_persistence.rst | 4 ++++ ...mmon_interfaces_of_descriptor_extractors.rst | 5 +++++ ...common_interfaces_of_descriptor_matchers.rst | 6 ++++++ .../common_interfaces_of_feature_detectors.rst | 5 +++++ ...nterfaces_of_generic_descriptor_matchers.rst | 4 ++++ .../doc/feature_detection_and_description.rst | 8 ++++++++ .../features2d/doc/object_categorization.rst | 2 ++ modules/gpu/doc/object_detection.rst | 2 ++ .../reading_and_writing_images_and_video.rst | 4 ++++ modules/highgui/doc/user_interface.rst | 4 ++++ modules/imgproc/doc/feature_detection.rst | 9 +++++++++ modules/imgproc/doc/filtering.rst | 13 +++++++++++++ .../imgproc/doc/geometric_transformations.rst | 3 +++ modules/imgproc/doc/histograms.rst | 2 ++ .../doc/miscellaneous_transformations.rst | 16 +++++++++++++++- ...tructural_analysis_and_shape_descriptors.rst | 17 +++++++++++++++++ modules/legacy/doc/expectation_maximization.rst | 4 ++++ .../doc/feature_detection_and_description.rst | 2 ++ modules/nonfree/doc/feature_detection.rst | 4 ++++ modules/photo/doc/inpainting.rst | 4 ++++ modules/stitching/doc/high_level.rst | 5 +++++ .../doc/motion_analysis_and_object_tracking.rst | 13 +++++++++++++ 30 files changed, 174 insertions(+), 1 deletion(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index b90fba7e1..886ac6f1d 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -105,7 +105,14 @@ The functions below use the above model to do the following: * Estimate the relative position and orientation of the stereo camera "heads" and compute the *rectification* transformation that makes the camera optical axes parallel. +.. Sample code:: + * : A calibration sample for 3 cameras in horizontal position can be found at opencv_source_code/samples/cpp/3calibration.cpp + * : A calibration sample based on a sequence of images can be found at opencv_source_code/samples/cpp/calibration.cpp + * : A calibration sample in order to do 3D reconstruction can be found at opencv_source_code/samples/cpp/build3dmodel.cpp + * : A calibration sample of an artificially generated camera and chessboard patterns can be found at opencv_source_code/samples/cpp/calibration_artificial.cpp + * : A calibration example on stereo calibration can be found at opencv_source_code/samples/cpp/stereo_calib.cpp + * : A calibration example on stereo matching can be found at opencv_source_code/samples/cpp/stereo_match.cpp calibrateCamera --------------- @@ -766,6 +773,9 @@ Homography matrix is determined up to a scale. Thus, it is normalized so that :ocv:func:`warpPerspective`, :ocv:func:`perspectiveTransform` +.. Sample code:: + + * : A example on calculating a homography for image matching can be found at opencv_source_code/samples/cpp/video_homography.cpp estimateAffine3D -------------------- diff --git a/modules/contrib/doc/facerec/facerec_api.rst b/modules/contrib/doc/facerec/facerec_api.rst index 8bea7070a..af3901f72 100644 --- a/modules/contrib/doc/facerec/facerec_api.rst +++ b/modules/contrib/doc/facerec/facerec_api.rst @@ -3,6 +3,10 @@ FaceRecognizer .. highlight:: cpp +.. Sample code:: + + * : An example using the FaceRecognizer class can be found at opencv_source_code/samples/cpp/facerec_demo.cpp + FaceRecognizer -------------- diff --git a/modules/contrib/doc/openfabmap.rst b/modules/contrib/doc/openfabmap.rst index 2f2ad4074..bfcd9bcf0 100644 --- a/modules/contrib/doc/openfabmap.rst +++ b/modules/contrib/doc/openfabmap.rst @@ -9,6 +9,10 @@ FAB-MAP is an approach to appearance-based place recognition. FAB-MAP compares i openFABMAP requires training data (e.g. a collection of images from a similar but not identical environment) to construct a visual vocabulary for the visual bag-of-words model, along with a Chow-Liu tree representation of feature likelihood and for use in the Sampled new place method (see below). +.. Sample code:: + + * : An example using the openFABMAP package can be found at opencv_source_code/samples/cpp/fabmap_sample.cpp + of2::FabMap -------------------- diff --git a/modules/contrib/doc/retina/index.rst b/modules/contrib/doc/retina/index.rst index a3a5bc82f..6decb3955 100644 --- a/modules/contrib/doc/retina/index.rst +++ b/modules/contrib/doc/retina/index.rst @@ -63,6 +63,11 @@ The retina can be settled up with various parameters, by default, the retina can void activateContoursProcessing (const bool activate); }; +.. Sample code:: + + * : An example on retina tone mapping can be found at opencv_source_code/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp + * : An example on retina tone mapping on video input can be found at opencv_source_code/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp + * : A complete example illustrating the retina interface can be found at opencv_source_code/samples/cpp/retinaDemo.cpp Description +++++++++++ diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 370587922..44c36a4b1 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -803,6 +803,9 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including ``std::sort()`` . +.. Sample code:: + + * : An example demonstrating the serial out capabilities of cv::Mat can be found at opencv_source_code/samples/cpp/cout_mat.cpp .. _MatrixExpressions: diff --git a/modules/core/doc/clustering.rst b/modules/core/doc/clustering.rst index f58e99ce2..d770043f0 100644 --- a/modules/core/doc/clustering.rst +++ b/modules/core/doc/clustering.rst @@ -66,6 +66,10 @@ Basically, you can use only the core of the function, set the number of attempts to 1, initialize labels each time using a custom algorithm, pass them with the ( ``flags`` = ``KMEANS_USE_INITIAL_LABELS`` ) flag, and then choose the best (most-compact) clustering. +.. Sample code:: + + * : An example on K-means clustering can be found at opencv_source_code/samples/cpp/kmeans.cpp + partition ------------- Splits an element set into equivalency classes. diff --git a/modules/core/doc/drawing_functions.rst b/modules/core/doc/drawing_functions.rst index 342301db9..f4df7eef7 100644 --- a/modules/core/doc/drawing_functions.rst +++ b/modules/core/doc/drawing_functions.rst @@ -26,6 +26,10 @@ If a drawn figure is partially or completely outside the image, the drawing func .. note:: The functions do not support alpha-transparency when the target image is 4-channel. In this case, the ``color[3]`` is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image. +.. Sample code:: + + * : An example on using variate drawing functions like line, rectangle, ... can be found at opencv_source_code/samples/cpp/drawing.cpp + circle ---------- Draws a circle. diff --git a/modules/core/doc/operations_on_arrays.rst b/modules/core/doc/operations_on_arrays.rst index bd55993af..bc9de713b 100644 --- a/modules/core/doc/operations_on_arrays.rst +++ b/modules/core/doc/operations_on_arrays.rst @@ -997,6 +997,9 @@ All of the above improvements have been implemented in :ocv:func:`matchTemplate` .. seealso:: :ocv:func:`dct` , :ocv:func:`getOptimalDFTSize` , :ocv:func:`mulSpectrums`, :ocv:func:`filter2D` , :ocv:func:`matchTemplate` , :ocv:func:`flip` , :ocv:func:`cartToPolar` , :ocv:func:`magnitude` , :ocv:func:`phase` +.. Sample code:: + + * : An example using the discrete fourier transform can be found at opencv_source_code/samples/cpp/dft.cpp divide @@ -2262,7 +2265,9 @@ The sample below is the function that takes two matrices. The first function sto :ocv:func:`dft`, :ocv:func:`dct` +.. Sample code:: + * : An example using PCA for dimensionality reduction while maintaining an amount of variance can be found at opencv_source_code/samples/cpp/pca.cpp PCA::PCA -------- diff --git a/modules/core/doc/xml_yaml_persistence.rst b/modules/core/doc/xml_yaml_persistence.rst index 42fa40161..0628e8b0e 100644 --- a/modules/core/doc/xml_yaml_persistence.rst +++ b/modules/core/doc/xml_yaml_persistence.rst @@ -91,6 +91,10 @@ Several things can be noted by looking at the sample code and the output: * In YAML (but not XML), mappings and sequences can be written in a compact Python-like inline form. In the sample above matrix elements, as well as each feature, including its lbp value, is stored in such inline form. To store a mapping/sequence in a compact form, put ":" after the opening character, e.g. use **"{:"** instead of **"{"** and **"[:"** instead of **"["**. When the data is written to XML, those extra ":" are ignored. +.. Sample code:: + + * : A complete example using the FileStorage interface can be found at opencv_source_code/samples/cpp/filestorage.cpp + Reading data from a file storage. --------------------------------- diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst index 63e56f678..51870731d 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst @@ -9,7 +9,10 @@ represented as vectors in a multidimensional space. All objects that implement t descriptor extractors inherit the :ocv:class:`DescriptorExtractor` interface. +.. Sample code:: + * : An example explaining keypoint extraction can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp + * : An example on descriptor evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_evaluation.cpp DescriptorExtractor ------------------- @@ -137,4 +140,6 @@ Strecha C., Fua P. *BRIEF: Binary Robust Independent Elementary Features* , ... }; +.. Sample code:: + * : A complete BRIEF extractor sample can be found at opencv_source_code/samples/cpp/brief_match_test.cpp diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst index d7e5eb4c2..6272e8818 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst @@ -9,6 +9,12 @@ that are represented as vectors in a multidimensional space. All objects that im descriptor matchers inherit the :ocv:class:`DescriptorMatcher` interface. +.. Sample code:: + + * : An example explaining keypoint matching can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp + * : An example on descriptor matching evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_matcher_evaluation.cpp + * : An example on one to many image matching can be found at opencv_source_code/samples/cpp/matching_to_many_images.cpp + DMatch ------ .. ocv:struct:: DMatch diff --git a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst index 81c72d3a8..bd0bce5c1 100644 --- a/modules/features2d/doc/common_interfaces_of_feature_detectors.rst +++ b/modules/features2d/doc/common_interfaces_of_feature_detectors.rst @@ -8,6 +8,11 @@ between different algorithms solving the same problem. All objects that implemen inherit the :ocv:class:`FeatureDetector` interface. +.. Sample code:: + + * : An example explaining keypoint detection can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp + + KeyPoint -------- .. ocv:class:: KeyPoint diff --git a/modules/features2d/doc/common_interfaces_of_generic_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_generic_descriptor_matchers.rst index a306c6606..b5e60dc59 100644 --- a/modules/features2d/doc/common_interfaces_of_generic_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_generic_descriptor_matchers.rst @@ -11,7 +11,11 @@ Every descriptor with the :ocv:class:`VectorDescriptorMatcher` ). There are descriptors such as the One-way descriptor and Ferns that have the ``GenericDescriptorMatcher`` interface implemented but do not support ``DescriptorExtractor``. +.. Sample code:: + * : An example explaining keypoint description can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp + * : An example on descriptor matching evaluation can be found at opencv_source_code/samples/cpp/detector_descriptor_matcher_evaluation.cpp + * : An example on one to many image matching can be found at opencv_source_code/samples/cpp/matching_to_many_images.cpp GenericDescriptorMatcher ------------------------ diff --git a/modules/features2d/doc/feature_detection_and_description.rst b/modules/features2d/doc/feature_detection_and_description.rst index 80a1de04a..9690f883a 100644 --- a/modules/features2d/doc/feature_detection_and_description.rst +++ b/modules/features2d/doc/feature_detection_and_description.rst @@ -3,6 +3,10 @@ Feature Detection and Description .. highlight:: cpp +.. Sample code:: + + * : An example explaining keypoint detection and description can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp + FAST ---- Detects corners using the FAST algorithm @@ -158,6 +162,10 @@ Class implementing the FREAK (*Fast Retina Keypoint*) keypoint descriptor, descr .. [AOV12] A. Alahi, R. Ortiz, and P. Vandergheynst. FREAK: Fast Retina Keypoint. In IEEE Conference on Computer Vision and Pattern Recognition, 2012. CVPR 2012 Open Source Award Winner. +.. Sample code:: + + * : An example on how to use the FREAK descriptor can be found at opencv_source_code/samples/cpp/freak_demo.cpp + FREAK::FREAK ------------ The FREAK constructor diff --git a/modules/features2d/doc/object_categorization.rst b/modules/features2d/doc/object_categorization.rst index d7b34aff5..3212b6abd 100644 --- a/modules/features2d/doc/object_categorization.rst +++ b/modules/features2d/doc/object_categorization.rst @@ -5,6 +5,8 @@ Object Categorization This section describes approaches based on local 2D features and used to categorize objects. +.. Sample code:: A complete Bag-Of-Words sample can be found at opencv_source_code/samples/cpp/bagofwords_classification.cpp + BOWTrainer ---------- .. ocv:class:: BOWTrainer diff --git a/modules/gpu/doc/object_detection.rst b/modules/gpu/doc/object_detection.rst index 133660236..c7986fa7a 100644 --- a/modules/gpu/doc/object_detection.rst +++ b/modules/gpu/doc/object_detection.rst @@ -62,7 +62,9 @@ The class implements Histogram of Oriented Gradients ([Dalal2005]_) object detec Interfaces of all methods are kept similar to the ``CPU HOG`` descriptor and detector analogues as much as possible. +.. Sample code:: + * : An example applying the HOG descriptor for people detection can be found at opencv_source_code/samples/cpp/peopledetect.cpp gpu::HOGDescriptor::HOGDescriptor ------------------------------------- diff --git a/modules/highgui/doc/reading_and_writing_images_and_video.rst b/modules/highgui/doc/reading_and_writing_images_and_video.rst index d473bb492..3b96124b9 100644 --- a/modules/highgui/doc/reading_and_writing_images_and_video.rst +++ b/modules/highgui/doc/reading_and_writing_images_and_video.rst @@ -224,6 +224,10 @@ The class provides C++ API for capturing video from cameras or for reading video .. note:: In C API the black-box structure ``CvCapture`` is used instead of ``VideoCapture``. +.. Sample code:: + + * : A basic sample on using the VideoCapture interface can be found at opencv_source_code/samples/cpp/starter_video.cpp + * : Another basic video processing sample can be found at opencv_source_code/samples/cpp/video_dmtx.cpp VideoCapture::VideoCapture ------------------------------ diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index def8451a2..cadb16492 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -33,6 +33,10 @@ The function ``createTrackbar`` creates a trackbar (a slider or range control) w Clicking the label of each trackbar enables editing the trackbar values manually. +.. Sample code:: + + * : An example of using the trackbar functionality can be found at opencv_source_code/samples/cpp/connected_components.cpp + getTrackbarPos ------------------ Returns the trackbar position. diff --git a/modules/imgproc/doc/feature_detection.rst b/modules/imgproc/doc/feature_detection.rst index df1a19307..1122cefc7 100644 --- a/modules/imgproc/doc/feature_detection.rst +++ b/modules/imgproc/doc/feature_detection.rst @@ -32,7 +32,9 @@ Finds edges in an image using the [Canny86]_ algorithm. The function finds edges in the input image ``image`` and marks them in the output map ``edges`` using the Canny algorithm. The smallest value between ``threshold1`` and ``threshold2`` is used for edge linking. The largest value is used to find initial segments of strong edges. See http://en.wikipedia.org/wiki/Canny_edge_detector +.. Sample code:: + * : An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.cpp cornerEigenValsAndVecs ---------------------- @@ -356,6 +358,9 @@ Example: :: :ocv:func:`fitEllipse`, :ocv:func:`minEnclosingCircle` +.. Sample code:: + + * : An example using the Hough circle detector can be found at opencv_source_code/samples/cpp/houghcircles.cpp HoughLines ---------- @@ -412,6 +417,10 @@ Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform. See also the example in :ocv:func:`HoughLinesP` description. +.. Sample code:: + + * : An example using the Hough line detector can be found at opencv_source_code/samples/cpp/houghlines.cpp + HoughLinesP ----------- Finds line segments in a binary image using the probabilistic Hough transform. diff --git a/modules/imgproc/doc/filtering.rst b/modules/imgproc/doc/filtering.rst index 0b1f9a34e..4265d9461 100755 --- a/modules/imgproc/doc/filtering.rst +++ b/modules/imgproc/doc/filtering.rst @@ -868,6 +868,9 @@ The function supports the in-place mode. Dilation can be applied several ( ``ite :ocv:func:`morphologyEx`, :ocv:func:`createMorphologyFilter` +.. Sample code:: + + * : An example using the morphological dilate operation can be found at opencv_source_code/samples/cpp/morphology2.cpp erode ----- @@ -908,7 +911,9 @@ The function supports the in-place mode. Erosion can be applied several ( ``iter :ocv:func:`morphologyEx`, :ocv:func:`createMorphologyFilter` +.. Sample code:: + * : An example using the morphological erode operation can be found at opencv_source_code/samples/cpp/morphology2.cpp filter2D -------- @@ -1245,6 +1250,9 @@ Any of the operations can be done in-place. In case of multi-channel images, eac :ocv:func:`erode`, :ocv:func:`createMorphologyFilter` +.. Sample code:: + + * : An example using the morphologyEx function for the morphological opening and closing operations can be found at opencv_source_code/samples/cpp/morphology2.cpp Laplacian --------- @@ -1290,7 +1298,9 @@ This is done when ``ksize > 1`` . When ``ksize == 1`` , the Laplacian is compute :ocv:func:`Sobel`, :ocv:func:`Scharr` +.. Sample code:: + * : An example using the Laplace transformation for edge detection can be found at opencv_source_code/samples/cpp/laplace.cpp pyrDown ------- @@ -1400,6 +1410,9 @@ After the iterations over, the color components of the initial pixel (that is, t When ``maxLevel > 0``, the gaussian pyramid of ``maxLevel+1`` levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than ``sr`` from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when ``maxLevel==0``). +.. Sample code:: + + * : An example using mean-shift image segmentation can be found at opencv_source_code/samples/cpp/meanshift_segmentation.cpp sepFilter2D ----------- diff --git a/modules/imgproc/doc/geometric_transformations.rst b/modules/imgproc/doc/geometric_transformations.rst index c48da01d7..28f84294e 100644 --- a/modules/imgproc/doc/geometric_transformations.rst +++ b/modules/imgproc/doc/geometric_transformations.rst @@ -307,6 +307,9 @@ where The function emulates the human "foveal" vision and can be used for fast scale and rotation-invariant template matching, for object tracking and so forth. The function can not operate in-place. +.. Sample code:: + + * : An example using the geometric logpolar operation in 4 applications can be found at opencv_source_code/samples/cpp/logpolar_bsm.cpp remap ----- diff --git a/modules/imgproc/doc/histograms.rst b/modules/imgproc/doc/histograms.rst index f576d5d75..7ac4d47f8 100644 --- a/modules/imgproc/doc/histograms.rst +++ b/modules/imgproc/doc/histograms.rst @@ -99,7 +99,9 @@ input arrays at the same location. The sample below shows how to compute a 2D Hu waitKey(); } +.. Sample code:: + * : An example for creating histograms of an image can be found at opencv_source_code/samples/cpp/demhist.cpp calcBackProject diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index 9fd8df517..c84a53d23 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -481,6 +481,10 @@ In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. ``maskSize=CV_DIST_MASK_PRECISE`` is not supported yet. +.. Sample code:: + + * : An example on using the distance transform can be found at opencv_source_code/samples/cpp/distrans.cpp + floodFill --------- Fills a connected component with the given color. @@ -580,11 +584,13 @@ where * Color/brightness of the seed point in case of a fixed range. -Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the ``floodfill.cpp`` sample. +Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. .. seealso:: :ocv:func:`findContours` +.. Sample code:: + * : An example using the FloodFill technique can be found at opencv_source_code/samples/cpp/ffilldemo.cpp integral -------- @@ -748,6 +754,10 @@ Visual demonstration and usage example of the function can be found in the OpenC .. seealso:: :ocv:func:`findContours` +.. Sample code:: + + * : An example using the watershed algorithm can be found at opencv_source_code/samples/cpp/watershed.cpp + grabCut ------- Runs the GrabCut algorithm. @@ -794,3 +804,7 @@ See the sample ``grabcut.cpp`` to learn how to use the function. .. [Meyer92] Meyer, F. *Color Image Segmentation*, ICIP92, 1992 .. [Telea04] Alexandru Telea, *An Image Inpainting Technique Based on the Fast Marching Method*. Journal of Graphics, GPU, and Game Tools 9 1, pp 23-34 (2004) + +.. Sample code:: + + * : An example using the GrabCut algorithm can be found at opencv_source_code/samples/cpp/grabcut.cpp \ No newline at end of file diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 37b23510d..3912abe81 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -166,6 +166,12 @@ The function retrieves contours from the binary image using the algorithm .. note:: If you use the new Python interface then the ``CV_`` prefix has to be omitted in contour retrieval mode and contour approximation method parameters (for example, use ``cv2.RETR_LIST`` and ``cv2.CHAIN_APPROX_NONE`` parameters). If you use the old Python interface then these parameters have the ``CV_`` prefix (for example, use ``cv.CV_RETR_LIST`` and ``cv.CV_CHAIN_APPROX_NONE``). +.. Sample code:: + + * : An example using the findContour functionality can be found at opencv_source_code/samples/cpp/contours2.cpp + * : An example using findContours to clean up a background segmentation result at opencv_source_code/samples/cpp/segment_objects.cpp + + drawContours ---------------- Draws contours outlines or filled contours. @@ -246,7 +252,10 @@ The function draws contour outlines in the image if waitKey(0); } +.. Sample code:: + * : An example using the drawContour functionality can be found at opencv_source_code/samples/cpp/contours2.cpp + * : An example using drawContours to clean up a background segmentation result at opencv_source_code/samples/cpp/segment_objects.cpp approxPolyDP ---------------- @@ -417,6 +426,10 @@ The functions find the convex hull of a 2D point set using the Sklansky's algori that has *O(N logN)* complexity in the current implementation. See the OpenCV sample ``convexhull.cpp`` that demonstrates the usage of different function variants. +.. Sample code:: + + * : An example using the convexHull functionality can be found at opencv_source_code/samples/cpp/convexhull.cpp + convexityDefects ---------------- @@ -473,6 +486,10 @@ Fits an ellipse around a set of 2D points. The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed. The algorithm [Fitzgibbon95]_ is used. +.. Sample code:: + + * : An example using the fitEllipse technique can be found at opencv_source_code/samples/cpp/fitellipse.cpp + fitLine ----------- Fits a line to a 2D or 3D point set. diff --git a/modules/legacy/doc/expectation_maximization.rst b/modules/legacy/doc/expectation_maximization.rst index d97d152e7..aac622ace 100644 --- a/modules/legacy/doc/expectation_maximization.rst +++ b/modules/legacy/doc/expectation_maximization.rst @@ -5,6 +5,10 @@ This section describes obsolete ``C`` interface of EM algorithm. Details of the .. highlight:: cpp +.. Sample code:: + + * : An example on using the Expectation Maximalization algorithm can be found at opencv_source_code/samples/cpp/em.cpp + CvEMParams ---------- diff --git a/modules/legacy/doc/feature_detection_and_description.rst b/modules/legacy/doc/feature_detection_and_description.rst index 222d7a03a..4dfabfb1e 100644 --- a/modules/legacy/doc/feature_detection_and_description.rst +++ b/modules/legacy/doc/feature_detection_and_description.rst @@ -99,7 +99,9 @@ Trains a randomized tree using an input set of keypoints. :param num_quant_bits: Number of bits used for quantization. +.. Sample code:: + * : An example on training a Random Tree Classifier for letter recognition can be found at opencv_source_code\samples\cpp\letter_recog.cpp RandomizedTree::read ------------------------ diff --git a/modules/nonfree/doc/feature_detection.rst b/modules/nonfree/doc/feature_detection.rst index c7ccb7493..526aba513 100644 --- a/modules/nonfree/doc/feature_detection.rst +++ b/modules/nonfree/doc/feature_detection.rst @@ -75,6 +75,10 @@ SURF .. [Bay06] Bay, H. and Tuytelaars, T. and Van Gool, L. "SURF: Speeded Up Robust Features", 9th European Conference on Computer Vision, 2006 +.. Sample code:: + + * : An example using the SURF feature detector can be found at opencv_source_code/samples/cpp/generic_descriptor_match.cpp + * : Another example using the SURF feature detector, extractor and matcher can be found at opencv_source_code/samples/cpp/matcher_simple.cpp SURF::SURF ---------- diff --git a/modules/photo/doc/inpainting.rst b/modules/photo/doc/inpainting.rst index ef69ebc70..2f7a89944 100644 --- a/modules/photo/doc/inpainting.rst +++ b/modules/photo/doc/inpainting.rst @@ -31,3 +31,7 @@ Restores the selected region in an image using the region neighborhood. The function reconstructs the selected image area from the pixel near the area boundary. The function may be used to remove dust and scratches from a scanned photo, or to remove undesirable objects from still images or video. See http://en.wikipedia.org/wiki/Inpainting for more details. + +.. Sample code:: + + * : An example using the inpainting technique can be found at opencv_source_code/samples/cpp/inpaint.cpp \ No newline at end of file diff --git a/modules/stitching/doc/high_level.rst b/modules/stitching/doc/high_level.rst index 583407208..bc0819519 100644 --- a/modules/stitching/doc/high_level.rst +++ b/modules/stitching/doc/high_level.rst @@ -88,6 +88,11 @@ High level image stitcher. It's possible to use this class without being aware o /* hidden */ }; +.. Sample code:: + + * : A basic example on image stitching can be found at opencv_source_code/samples/cpp/stitching.cpp + * : A detailed example on image stitching can be found at opencv_source_code/samples/cpp/stitching_detailed.cpp + Stitcher::createDefault ----------------------- Creates a stitcher with the default parameters. diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 5653e21bd..4b3232175 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -42,6 +42,10 @@ Calculates an optical flow for a sparse feature set using the iterative Lucas-Ka The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See [Bouguet00]_. The function is parallelized with the TBB library. +.. Sample code:: + + * : An example using the Lucas-Kanade optical flow algorithm can be found at opencv_source_code/samples/cpp/lkdemo.cpp + buildOpticalFlowPyramid ----------------------- Constructs the image pyramid which can be passed to :ocv:func:`calcOpticalFlowPyrLK`. @@ -109,6 +113,9 @@ The function finds an optical flow for each ``prev`` pixel using the [Farneback2 \texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0]) +.. Sample code:: + + * : An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/cpp/fback.cpp estimateRigidTransform -------------------------- @@ -342,7 +349,9 @@ The function implements the iterative object search algorithm. It takes the inpu :ocv:func:`contourArea` ), and rendering the remaining contours with :ocv:func:`drawContours` . +.. Sample code:: + * : A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp KalmanFilter ------------ @@ -353,7 +362,9 @@ KalmanFilter The class implements a standard Kalman filter http://en.wikipedia.org/wiki/Kalman_filter, [Welch95]_. However, you can modify ``transitionMatrix``, ``controlMatrix``, and ``measurementMatrix`` to get an extended Kalman filter functionality. See the OpenCV sample ``kalman.cpp`` . +.. Sample code:: + * : An example using the standard Kalman filter can be found at opencv_source_code/samples/cpp/kalman.cpp KalmanFilter::KalmanFilter @@ -641,7 +652,9 @@ Calculate an optical flow using "SimpleFlow" algorithm. See [Tao2012]_. And site of project - http://graphics.berkeley.edu/papers/Tao-SAN-2012-05/. +.. Sample code:: + * : An example using the simpleFlow algorithm can be found at opencv_source_code/samples/cpp/simpleflow_demo.cpp createOptFlow_DualTVL1 ---------------------- From 6257df1c4b5d62661312461b9cb9d72ec2fe423c Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 19 Jul 2013 02:43:05 -0700 Subject: [PATCH 49/64] API restricted on WinRT partially removed from core. Additional CMAKE flag WITH_WINRT added. --- CMakeLists.txt | 1 + cmake/OpenCVCRTLinkage.cmake | 15 +++++++ cmake/templates/cvconfig.h.cmake | 6 +++ modules/core/CMakeLists.txt | 4 ++ modules/core/src/alloc.cpp | 13 +++++- modules/core/src/glob.cpp | 56 ++++++++++++++++++++++++-- modules/core/src/parallel.cpp | 4 ++ modules/core/src/system.cpp | 69 +++++++++++++++++++++++++++++++- 8 files changed, 163 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4a6a5f01..419cc68e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,7 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 ) +OCV_OPTION(WITH_WINRT "Build with Windows Runtime support" OFF IF WIN32 ) OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) ) OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 ) diff --git a/cmake/OpenCVCRTLinkage.cmake b/cmake/OpenCVCRTLinkage.cmake index 7514285d9..d5e4f27e9 100644 --- a/cmake/OpenCVCRTLinkage.cmake +++ b/cmake/OpenCVCRTLinkage.cmake @@ -2,6 +2,21 @@ if(NOT MSVC) message(FATAL_ERROR "CRT options are available only for MSVC") endif() +#INCLUDE (CheckIncludeFiles) + +if (WITH_WINRT) + #CHECK_INCLUDE_FILES("wrl/client.h" HAVE_WINRT) + TRY_COMPILE(HAVE_WINRT + "${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp" + "${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp" + CMAKE_FLAGS "\"kernel.lib\" \"user32.lib\"" + OUTPUT_VARIABLE OUTPUT) + if (HAVE_WINRT) + add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602) + endif() + message(STATUS "Windows RT: ${HAVE_WINRT}") +endif(WITH_WINRT) + if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index f5950b64f..7587eef6b 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -76,6 +76,12 @@ /* GTK+ 2.0 Thread support */ #cmakedefine HAVE_GTHREAD +/* Windows Runtime support */ +#cmakedefine HAVE_WINRT + +/* Win32 UI */ +#cmakedefine HAVE_WIN32UI + /* GTK+ 2.x toolkit */ #cmakedefine HAVE_GTK diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index dc62a884f..8b6123204 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -2,6 +2,10 @@ set(the_description "The Core Functionality") ocv_add_module(core ${ZLIB_LIBRARIES}) ocv_module_include_directories(${ZLIB_INCLUDE_DIR}) +if (HAVE_WINRT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"C:/Program Files/Windows Kits/8.0/References/CommonConfiguration/Neutral\" /AI\"C:/Program Files/Microsoft Visual Studio 11.0/VC/vcpackages\"") +endif() + if(HAVE_CUDA) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) diff --git a/modules/core/src/alloc.cpp b/modules/core/src/alloc.cpp index 1944ed17d..da89673f0 100644 --- a/modules/core/src/alloc.cpp +++ b/modules/core/src/alloc.cpp @@ -42,6 +42,10 @@ #include "precomp.hpp" +#if (_WIN32_WINNT >= 0x0602) +#include +#endif + #define CV_USE_SYSTEM_MALLOC 1 namespace cv @@ -96,7 +100,14 @@ void fastFree(void* ptr) #ifdef WIN32 struct CriticalSection { - CriticalSection() { InitializeCriticalSection(&cs); } + CriticalSection() + { +#if (_WIN32_WINNT >= 0x0600) + InitializeCriticalSectionEx(&cs, 1000, 0); +#else + InitializeCriticalSection(&cs); +#endif + } ~CriticalSection() { DeleteCriticalSection(&cs); } void lock() { EnterCriticalSection(&cs); } void unlock() { LeaveCriticalSection(&cs); } diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index 368f304ef..b531832a4 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -56,16 +56,40 @@ namespace struct DIR { +#ifdef HAVE_WINRT + WIN32_FIND_DATAW data; +#else WIN32_FIND_DATA data; +#endif HANDLE handle; dirent ent; +#ifdef HAVE_WINRT + DIR() {}; + ~DIR() + { + if (ent.d_name) + free((void*)ent.d_name); + } +#endif }; DIR* opendir(const char* path) { DIR* dir = new DIR; dir->ent.d_name = 0; - dir->handle = ::FindFirstFileA((cv::String(path) + "\\*").c_str(), &dir->data); +#ifdef HAVE_WINRT + cv::String full_path = cv::String(path) + "\\*"; + size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size()); + wchar_t* wfull_path = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + wfull_path[size] = 0; + mbstowcs(wfull_path, full_path.c_str(), full_path.size()); + dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard, + &dir->data, FindExSearchNameMatch, NULL, 0); + free(wfull_path); +#else + dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(), + FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0); +#endif if(dir->handle == INVALID_HANDLE_VALUE) { /*closedir will do all cleanup*/ @@ -76,12 +100,25 @@ namespace dirent* readdir(DIR* dir) { +#ifdef HAVE_WINRT if (dir->ent.d_name != 0) { - if (::FindNextFile(dir->handle, &dir->data) != TRUE) + if (::FindNextFileW(dir->handle, &dir->data) != TRUE) + return 0; + } + size_t asize = wcstombs(NULL, dir->data.cFileName, 0); + char* aname = (char*)malloc((asize+1)*sizeof(char)); + aname[asize] = 0; + wcstombs(aname, dir->data.cFileName, asize); + dir->ent.d_name = aname; +#else + if (dir->ent.d_name != 0) + { + if (::FindNextFileA(dir->handle, &dir->data) != TRUE) return 0; } dir->ent.d_name = dir->data.cFileName; +#endif return &dir->ent; } @@ -107,7 +144,20 @@ static bool isDir(const cv::String& path, DIR* dir) if (dir) attributes = dir->data.dwFileAttributes; else - attributes = ::GetFileAttributes(path.c_str()); + { + WIN32_FILE_ATTRIBUTE_DATA all_attrs; +#ifdef HAVE_WINRT + size_t size = mbstowcs(NULL, path.c_str(), path.size()); + wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + wpath[size] = 0; + mbstowcs(wpath, path.c_str(), path.size()); + ::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs); + free(wpath); +#else + ::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs); +#endif + attributes = all_attrs.dwFileAttributes; + } return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); #else diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 0a9ed0987..1ae8c9631 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -453,7 +453,11 @@ int cv::getNumberOfCPUs(void) { #if defined WIN32 || defined _WIN32 SYSTEM_INFO sysinfo; +#if defined(_M_ARM) || defined(_M_X64) || defined(HAVE_WINRT) + GetNativeSystemInfo( &sysinfo ); +#else GetSystemInfo( &sysinfo ); +#endif return (int)sysinfo.dwNumberOfProcessors; #elif defined ANDROID diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 6da32637c..da697af2e 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -47,6 +47,9 @@ #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx #endif #include +#if (_WIN32_WINNT >= 0x0602) +#include +#endif #undef small #undef min #undef max @@ -75,6 +78,32 @@ } #endif #endif + +#ifdef HAVE_WINRT +#pragma comment(lib, "MinCore_Downlevel") +#include + +std::wstring GetTempPathWinRT() +{ + return std::wstring(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data()); +} + +std::wstring GetTempFileNameWinRT(std::wstring prefix) +{ + wchar_t guidStr[120]; + GUID* g = 0x00; + g = new GUID; + CoCreateGuid(g); + wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x"; + swprintf(&guidStr[0],mask, 120, g->Data1,g->Data2,g->Data3,UINT(g->Data4[0]), + UINT(g->Data4[1]),UINT(g->Data4[2]),UINT(g->Data4[3]),UINT(g->Data4[4]), + UINT(g->Data4[5]),UINT(g->Data4[6]),UINT(g->Data4[7])); + delete g; + + return prefix + std::wstring(guidStr); +} + +#endif #else #include #include @@ -359,10 +388,39 @@ string format( const char* fmt, ... ) string tempfile( const char* suffix ) { +#ifdef HAVE_WINRT + std::wstring temp_dir = L""; + wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH"); + if (opencv_temp_dir) + temp_dir = std::wstring(opencv_temp_dir); +#else const char *temp_dir = getenv("OPENCV_TEMP_PATH"); +#endif string fname; #if defined WIN32 || defined _WIN32 +#ifdef HAVE_WINRT + RoInitialize(RO_INIT_MULTITHREADED); + std::wstring temp_dir2; + if (temp_dir.empty()) + temp_dir = GetTempPathWinRT(); + + std::wstring temp_file; + temp_file = GetTempFileNameWinRT(L"ocv"); + if (temp_file.empty()) + return std::string(); + + temp_file = temp_dir + std::wstring(L"\\") + temp_file; + DeleteFileW(temp_file.c_str()); + + size_t asize = wcstombs(NULL, temp_file.c_str(), 0); + char* aname = (char*)malloc((asize+1)*sizeof(char)); + aname[asize] = 0; + wcstombs(aname, temp_file.c_str(), asize); + fname = std::string(aname); + free(aname); + RoUninitialize(); +#else char temp_dir2[MAX_PATH + 1] = { 0 }; char temp_file[MAX_PATH + 1] = { 0 }; @@ -377,6 +435,7 @@ string tempfile( const char* suffix ) DeleteFileA(temp_file); fname = temp_file; +#endif # else # ifdef ANDROID //char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX"; @@ -766,7 +825,15 @@ namespace cv struct Mutex::Impl { - Impl() { InitializeCriticalSection(&cs); refcount = 1; } + Impl() + { +#if (_WIN32_WINNT >= 0x0600) + ::InitializeCriticalSectionEx(&cs, 1000, 0); +#else + ::InitializeCriticalSection(&cs); +#endif + refcount = 1; + } ~Impl() { DeleteCriticalSection(&cs); } void lock() { EnterCriticalSection(&cs); } From 62b85a41da3a346f887e9486639ef81bf2a89395 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 23 Jul 2013 06:44:57 -0700 Subject: [PATCH 50/64] TLS calls on WinRT replaced on variables with C++11 "thread" attribute. --- modules/contrib/src/inputoutput.cpp | 74 +++++++++++++++++++++++++---- modules/core/src/alloc.cpp | 8 ++-- modules/core/src/rand.cpp | 39 +++++++++++---- modules/core/src/system.cpp | 4 +- 4 files changed, 101 insertions(+), 24 deletions(-) diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index a711f242a..0c8175352 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -16,10 +16,23 @@ namespace cv list.clear(); std::string path_f = path + "/" + exten; #ifdef WIN32 + #if HAVE_WINRT + WIN32_FIND_DATAW FindFileData; + #else WIN32_FIND_DATA FindFileData; - HANDLE hFind; + #endif + HANDLE hFind; - hFind = FindFirstFile((LPCSTR)path_f.c_str(), &FindFileData); + #ifdef HAVE_WINRT + size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); + wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + wpath[size] = 0; + mbstowcs(wpath, path_f.c_str(), path_f.size()); + hFind = FindFirstFileW(wpath, &FindFileData); + free(wpath); + #else + hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); + #endif if (hFind == INVALID_HANDLE_VALUE) { return list; @@ -34,13 +47,29 @@ namespace cv FindFileData.dwFileAttributes == FILE_ATTRIBUTE_SYSTEM || FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY) { + char* fname; + #ifdef HAVE_WINRT + size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); + char* fname = (char*)malloc((asize+1)*sizeof(char)); + fname[asize] = 0; + wcstombs(fname, FindFileData.cFileName, asize); + #else + fname = FindFileData.cFileName; + #endif if (addPath) - list.push_back(path + "/" + FindFileData.cFileName); + list.push_back(path + "/" + fname); else - list.push_back(FindFileData.cFileName); + list.push_back(fname); + #ifdef HAVE_WINRT + free(fname); + #endif } } - while(FindNextFile(hFind, &FindFileData)); + #ifdef HAVE_WINRT + while(FindNextFileW(hFind, &FindFileData)); + #else + while(FindNextFileA(hFind, &FindFileData)); + #endif FindClose(hFind); } #else @@ -75,10 +104,23 @@ namespace cv std::string path_f = path + "/" + exten; list.clear(); #ifdef WIN32 + #if HAVE_WINRT + WIN32_FIND_DATAW FindFileData; + #else WIN32_FIND_DATA FindFileData; + #endif HANDLE hFind; - hFind = FindFirstFile((LPCSTR)path_f.c_str(), &FindFileData); + #ifdef HAVE_WINRT + size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); + wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + wpath[size] = 0; + mbstowcs(wpath, path_f.c_str(), path_f.size()); + hFind = FindFirstFileW(wpath, &FindFileData); + free(wpath); + #else + hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); + #endif if (hFind == INVALID_HANDLE_VALUE) { return list; @@ -91,13 +133,27 @@ namespace cv strcmp(FindFileData.cFileName, ".") != 0 && strcmp(FindFileData.cFileName, "..") != 0) { + char* fname; + #ifdef HAVE_WINRT + size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); + char* fname = (char*)malloc((asize+1)*sizeof(char)); + fname[asize] = 0; + wcstombs(fname, FindFileData.cFileName, asize); + #else + fname = FindFileData.cFileName; + #endif + if (addPath) - list.push_back(path + "/" + FindFileData.cFileName); + list.push_back(path + "/" + fname); else - list.push_back(FindFileData.cFileName); + list.push_back(fname); } } - while(FindNextFile(hFind, &FindFileData)); + #ifdef HAVE_WINRT + while(FindNextFileW(hFind, &FindFileData)); + #else + while(FindNextFileA(hFind, &FindFileData)); + #endif FindClose(hFind); } diff --git a/modules/core/src/alloc.cpp b/modules/core/src/alloc.cpp index da89673f0..37b1e0db9 100644 --- a/modules/core/src/alloc.cpp +++ b/modules/core/src/alloc.cpp @@ -42,10 +42,6 @@ #include "precomp.hpp" -#if (_WIN32_WINNT >= 0x0602) -#include -#endif - #define CV_USE_SYSTEM_MALLOC 1 namespace cv @@ -98,6 +94,10 @@ void fastFree(void* ptr) #define STAT(stmt) #ifdef WIN32 +#if (_WIN32_WINNT >= 0x0602) +#include +#endif + struct CriticalSection { CriticalSection() diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 2cdbe3916..54bb753a1 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -726,33 +726,54 @@ void RNG::fill( InputOutputArray _mat, int disttype, } #ifdef WIN32 + + +#ifdef HAVE_WINRT +// using C++11 thread attribute for local thread data +__declspec( thread ) RNG* rng = NULL; + + void deleteThreadRNGData() + { + if (rng) + delete rng; +} + +RNG& theRNG() +{ + if (!rng) + { + rng = new RNG; + } + return *rng; +} +#else #ifdef WINCE # define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) #endif static DWORD tlsRNGKey = TLS_OUT_OF_INDEXES; -void deleteThreadRNGData() -{ - if( tlsRNGKey != TLS_OUT_OF_INDEXES ) - delete (RNG*)TlsGetValue( tlsRNGKey ); + void deleteThreadRNGData() + { + if( tlsRNGKey != TLS_OUT_OF_INDEXES ) + delete (RNG*)TlsGetValue( tlsRNGKey ); } RNG& theRNG() { if( tlsRNGKey == TLS_OUT_OF_INDEXES ) { - tlsRNGKey = TlsAlloc(); - CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES); + tlsRNGKey = TlsAlloc(); + CV_Assert(tlsRNGKey != TLS_OUT_OF_INDEXES); } RNG* rng = (RNG*)TlsGetValue( tlsRNGKey ); if( !rng ) { - rng = new RNG; - TlsSetValue( tlsRNGKey, rng ); + rng = new RNG; + TlsSetValue( tlsRNGKey, rng ); } return *rng; } - +#endif //HAVE_WINRT #else static pthread_key_t tlsRNGKey = 0; diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index da697af2e..a90fb8b58 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -48,7 +48,7 @@ #endif #include #if (_WIN32_WINNT >= 0x0602) -#include + #include #endif #undef small #undef min @@ -80,8 +80,8 @@ #endif #ifdef HAVE_WINRT -#pragma comment(lib, "MinCore_Downlevel") #include +#pragma comment(lib, "MinCore_Downlevel") std::wstring GetTempPathWinRT() { From e03ffde346206a4b73de176a167d42015585ecd6 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 25 Jul 2013 07:22:14 -0700 Subject: [PATCH 51/64] WinRT API Certification fixes for core and contrib. --- modules/contrib/src/inputoutput.cpp | 17 +++++++++-------- modules/core/src/system.cpp | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index 0c8175352..f545d15f7 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -1,5 +1,6 @@ #include "opencv2/contrib/contrib.hpp" +#include #if defined(WIN32) || defined(_WIN32) #include @@ -16,7 +17,7 @@ namespace cv list.clear(); std::string path_f = path + "/" + exten; #ifdef WIN32 - #if HAVE_WINRT + #ifdef HAVE_WINRT WIN32_FIND_DATAW FindFileData; #else WIN32_FIND_DATA FindFileData; @@ -28,7 +29,7 @@ namespace cv wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); wpath[size] = 0; mbstowcs(wpath, path_f.c_str(), path_f.size()); - hFind = FindFirstFileW(wpath, &FindFileData); + hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); free(wpath); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); @@ -50,7 +51,7 @@ namespace cv char* fname; #ifdef HAVE_WINRT size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - char* fname = (char*)malloc((asize+1)*sizeof(char)); + fname = (char*)malloc((asize+1)*sizeof(char)); fname[asize] = 0; wcstombs(fname, FindFileData.cFileName, asize); #else @@ -104,7 +105,7 @@ namespace cv std::string path_f = path + "/" + exten; list.clear(); #ifdef WIN32 - #if HAVE_WINRT + #ifdef HAVE_WINRT WIN32_FIND_DATAW FindFileData; #else WIN32_FIND_DATA FindFileData; @@ -116,7 +117,7 @@ namespace cv wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); wpath[size] = 0; mbstowcs(wpath, path_f.c_str(), path_f.size()); - hFind = FindFirstFileW(wpath, &FindFileData); + hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); free(wpath); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); @@ -130,13 +131,13 @@ namespace cv do { if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && - strcmp(FindFileData.cFileName, ".") != 0 && - strcmp(FindFileData.cFileName, "..") != 0) + wcscmp(FindFileData.cFileName, L".") != 0 && + wcscmp(FindFileData.cFileName, L"..") != 0) { char* fname; #ifdef HAVE_WINRT size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - char* fname = (char*)malloc((asize+1)*sizeof(char)); + fname = (char*)malloc((asize+1)*sizeof(char)); fname[asize] = 0; wcstombs(fname, FindFileData.cFileName, asize); #else diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index a90fb8b58..9279f4a22 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -81,7 +81,6 @@ #ifdef HAVE_WINRT #include -#pragma comment(lib, "MinCore_Downlevel") std::wstring GetTempPathWinRT() { From c8d1fccdac2f674016501329b8210bd2fadd9702 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 1 Aug 2013 13:58:46 +0400 Subject: [PATCH 52/64] compare cv::gpu::calcHist with cv::calcHist --- modules/gpu/perf/perf_imgproc.cpp | 12 +++++++++++- modules/gpu/test/test_imgproc.cpp | 29 ++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index ee4601277..c7fb2a17c 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -562,7 +562,17 @@ PERF_TEST_P(Sz, ImgProc_CalcHist, } else { - FAIL_NO_CPU(); + cv::Mat dst; + + const int hbins = 256; + const float hranges[] = {0.0f, 256.0f}; + const int histSize[] = {hbins}; + const float* ranges[] = {hranges}; + const int channels[] = {0}; + + TEST_CYCLE() cv::calcHist(&src, 1, channels, cv::Mat(), dst, 1, histSize, ranges); + + CPU_SANITY_CHECK(dst); } } diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp index e424763bf..03d2b9cae 100644 --- a/modules/gpu/test/test_imgproc.cpp +++ b/modules/gpu/test/test_imgproc.cpp @@ -133,24 +133,6 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, ALL_DEVICES); /////////////////////////////////////////////////////////////////////////////////////////////////////// // CalcHist -namespace -{ - void calcHistGold(const cv::Mat& src, cv::Mat& hist) - { - hist.create(1, 256, CV_32SC1); - hist.setTo(cv::Scalar::all(0)); - - int* hist_row = hist.ptr(); - for (int y = 0; y < src.rows; ++y) - { - const uchar* src_row = src.ptr(y); - - for (int x = 0; x < src.cols; ++x) - ++hist_row[src_row[x]]; - } - } -} - PARAM_TEST_CASE(CalcHist, cv::gpu::DeviceInfo, cv::Size) { cv::gpu::DeviceInfo devInfo; @@ -174,7 +156,16 @@ GPU_TEST_P(CalcHist, Accuracy) cv::gpu::calcHist(loadMat(src), hist); cv::Mat hist_gold; - calcHistGold(src, hist_gold); + + const int hbins = 256; + const float hranges[] = {0.0f, 256.0f}; + const int histSize[] = {hbins}; + const float* ranges[] = {hranges}; + const int channels[] = {0}; + + cv::calcHist(&src, 1, channels, cv::Mat(), hist_gold, 1, histSize, ranges); + hist_gold = hist_gold.reshape(1, 1); + hist_gold.convertTo(hist_gold, CV_32S); EXPECT_MAT_NEAR(hist_gold, hist, 0.0); } From bfca1afd9e81a526fd35b40b174b22d2e040f866 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 1 Aug 2013 16:25:16 +0400 Subject: [PATCH 53/64] rewrite histEven test --- modules/gpu/test/test_imgproc.cpp | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp index 03d2b9cae..a67760ea5 100644 --- a/modules/gpu/test/test_imgproc.cpp +++ b/modules/gpu/test/test_imgproc.cpp @@ -86,13 +86,16 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Integral, testing::Combine( /////////////////////////////////////////////////////////////////////////////////////////////////////// // HistEven -struct HistEven : testing::TestWithParam +PARAM_TEST_CASE(HistEven, cv::gpu::DeviceInfo, cv::Size) { cv::gpu::DeviceInfo devInfo; + cv::Size size; + virtual void SetUp() { - devInfo = GetParam(); + devInfo = GET_PARAM(0); + size = GET_PARAM(1); cv::gpu::setDevice(devInfo.deviceID()); } @@ -100,35 +103,30 @@ struct HistEven : testing::TestWithParam GPU_TEST_P(HistEven, Accuracy) { - cv::Mat img = readImage("stereobm/aloe-L.png"); - ASSERT_FALSE(img.empty()); + cv::Mat src = randomMat(size, CV_8UC1); - cv::Mat hsv; - cv::cvtColor(img, hsv, CV_BGR2HSV); - - int hbins = 30; - float hranges[] = {0.0f, 180.0f}; - - std::vector srcs; - cv::gpu::split(loadMat(hsv), srcs); + int hbins = 256; + float hranges[] = {0.0f, 256.0f}; cv::gpu::GpuMat hist; - cv::gpu::histEven(srcs[0], hist, hbins, (int)hranges[0], (int)hranges[1]); + cv::gpu::histEven(loadMat(src), hist, hbins, (int) hranges[0], (int) hranges[1]); + + cv::Mat hist_gold; - cv::MatND histnd; int histSize[] = {hbins}; const float* ranges[] = {hranges}; int channels[] = {0}; - cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges); + cv::calcHist(&src, 1, channels, cv::Mat(), hist_gold, 1, histSize, ranges); - cv::Mat hist_gold = histnd; hist_gold = hist_gold.t(); hist_gold.convertTo(hist_gold, CV_32S); EXPECT_MAT_NEAR(hist_gold, hist, 0.0); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, ALL_DEVICES); +INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, testing::Combine( + ALL_DEVICES, + DIFFERENT_SIZES)); /////////////////////////////////////////////////////////////////////////////////////////////////////// // CalcHist From a28cb99e885aa71503c35e2f26427832c2ead121 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 1 Aug 2013 16:51:52 +0400 Subject: [PATCH 54/64] optimized version of histEven for CV_8UC1 --- modules/gpu/src/cuda/hist.cu | 80 +++++++++++++++++++++++++++++++ modules/gpu/src/imgproc.cpp | 17 ++++++- modules/gpu/test/test_imgproc.cpp | 4 +- 3 files changed, 98 insertions(+), 3 deletions(-) diff --git a/modules/gpu/src/cuda/hist.cu b/modules/gpu/src/cuda/hist.cu index 8b8a1e8c6..d9ba559f9 100644 --- a/modules/gpu/src/cuda/hist.cu +++ b/modules/gpu/src/cuda/hist.cu @@ -109,6 +109,86 @@ namespace hist ///////////////////////////////////////////////////////////////////////// +namespace hist +{ + __device__ __forceinline__ void histEvenInc(int* shist, uint data, int binSize, int lowerLevel, int upperLevel) + { + if (data >= lowerLevel && data <= upperLevel) + { + const uint ind = (data - lowerLevel) / binSize; + Emulation::smem::atomicAdd(shist + ind, 1); + } + } + + __global__ void histEven8u(const uchar* src, const size_t step, const int rows, const int cols, + int* hist, const int binCount, const int binSize, const int lowerLevel, const int upperLevel) + { + extern __shared__ int shist[]; + + const int y = blockIdx.x * blockDim.y + threadIdx.y; + const int tid = threadIdx.y * blockDim.x + threadIdx.x; + + if (tid < binCount) + shist[tid] = 0; + + __syncthreads(); + + if (y < rows) + { + const uchar* rowPtr = src + y * step; + const uint* rowPtr4 = (uint*) rowPtr; + + const int cols_4 = cols / 4; + for (int x = threadIdx.x; x < cols_4; x += blockDim.x) + { + const uint data = rowPtr4[x]; + + histEvenInc(shist, (data >> 0) & 0xFFU, binSize, lowerLevel, upperLevel); + histEvenInc(shist, (data >> 8) & 0xFFU, binSize, lowerLevel, upperLevel); + histEvenInc(shist, (data >> 16) & 0xFFU, binSize, lowerLevel, upperLevel); + histEvenInc(shist, (data >> 24) & 0xFFU, binSize, lowerLevel, upperLevel); + } + + if (cols % 4 != 0 && threadIdx.x == 0) + { + for (int x = cols_4 * 4; x < cols; ++x) + { + const uchar data = rowPtr[x]; + histEvenInc(shist, data, binSize, lowerLevel, upperLevel); + } + } + } + + __syncthreads(); + + if (tid < binCount) + { + const int histVal = shist[tid]; + + if (histVal > 0) + ::atomicAdd(hist + tid, histVal); + } + } + + void histEven8u(PtrStepSzb src, int* hist, int binCount, int lowerLevel, int upperLevel, cudaStream_t stream) + { + const dim3 block(32, 8); + const dim3 grid(divUp(src.rows, block.y)); + + const int binSize = divUp(upperLevel - lowerLevel, binCount); + + const size_t smem_size = binCount * sizeof(int); + + histEven8u<<>>(src.data, src.step, src.rows, src.cols, hist, binCount, binSize, lowerLevel, upperLevel); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } +} + +///////////////////////////////////////////////////////////////////////// + namespace hist { __constant__ int c_lut[256]; diff --git a/modules/gpu/src/imgproc.cpp b/modules/gpu/src/imgproc.cpp index 8e452b4a1..23523630b 100644 --- a/modules/gpu/src/imgproc.cpp +++ b/modules/gpu/src/imgproc.cpp @@ -889,6 +889,21 @@ void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerL histEven(src, hist, buf, histSize, lowerLevel, upperLevel, stream); } +namespace hist +{ + void histEven8u(PtrStepSzb src, int* hist, int binCount, int lowerLevel, int upperLevel, cudaStream_t stream); +} + +namespace +{ + void histEven8u(const GpuMat& src, GpuMat& hist, GpuMat&, int histSize, int lowerLevel, int upperLevel, cudaStream_t stream) + { + hist.create(1, histSize, CV_32S); + cudaSafeCall( cudaMemsetAsync(hist.data, 0, histSize * sizeof(int), stream) ); + hist::histEven8u(src, hist.ptr(), histSize, lowerLevel, upperLevel, stream); + } +} + void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream) { CV_Assert(src.type() == CV_8UC1 || src.type() == CV_16UC1 || src.type() == CV_16SC1 ); @@ -896,7 +911,7 @@ void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSiz typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, GpuMat& buf, int levels, int lowerLevel, int upperLevel, cudaStream_t stream); static const hist_t hist_callers[] = { - NppHistogramEvenC1::hist, + histEven8u, 0, NppHistogramEvenC1::hist, NppHistogramEvenC1::hist diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp index a67760ea5..811d1294c 100644 --- a/modules/gpu/test/test_imgproc.cpp +++ b/modules/gpu/test/test_imgproc.cpp @@ -105,8 +105,8 @@ GPU_TEST_P(HistEven, Accuracy) { cv::Mat src = randomMat(size, CV_8UC1); - int hbins = 256; - float hranges[] = {0.0f, 256.0f}; + int hbins = 30; + float hranges[] = {50.0f, 200.0f}; cv::gpu::GpuMat hist; cv::gpu::histEven(loadMat(src), hist, hbins, (int) hranges[0], (int) hranges[1]); From 55cb26551fa66f5562ee1f91b8097fd74dedbf2f Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 2 Aug 2013 09:05:21 +0400 Subject: [PATCH 55/64] use NPP version for Fermi --- modules/gpu/src/cuda/hist.cu | 2 +- modules/gpu/src/imgproc.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/gpu/src/cuda/hist.cu b/modules/gpu/src/cuda/hist.cu index d9ba559f9..d0ec257c4 100644 --- a/modules/gpu/src/cuda/hist.cu +++ b/modules/gpu/src/cuda/hist.cu @@ -120,7 +120,7 @@ namespace hist } } - __global__ void histEven8u(const uchar* src, const size_t step, const int rows, const int cols, + __global__ void histEven8u(const uchar* src, const size_t step, const int rows, const int cols, int* hist, const int binCount, const int binSize, const int lowerLevel, const int upperLevel) { extern __shared__ int shist[]; diff --git a/modules/gpu/src/imgproc.cpp b/modules/gpu/src/imgproc.cpp index 23523630b..1904b6aad 100644 --- a/modules/gpu/src/imgproc.cpp +++ b/modules/gpu/src/imgproc.cpp @@ -896,7 +896,7 @@ namespace hist namespace { - void histEven8u(const GpuMat& src, GpuMat& hist, GpuMat&, int histSize, int lowerLevel, int upperLevel, cudaStream_t stream) + void histEven8u(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, cudaStream_t stream) { hist.create(1, histSize, CV_32S); cudaSafeCall( cudaMemsetAsync(hist.data, 0, histSize * sizeof(int), stream) ); @@ -911,12 +911,18 @@ void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSiz typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, GpuMat& buf, int levels, int lowerLevel, int upperLevel, cudaStream_t stream); static const hist_t hist_callers[] = { - histEven8u, + NppHistogramEvenC1::hist, 0, NppHistogramEvenC1::hist, NppHistogramEvenC1::hist }; + if (src.depth() == CV_8U && deviceSupports(FEATURE_SET_COMPUTE_30)) + { + histEven8u(src, hist, histSize, lowerLevel, upperLevel, StreamAccessor::getStream(stream)); + return; + } + hist_callers[src.depth()](src, hist, buf, histSize, lowerLevel, upperLevel, StreamAccessor::getStream(stream)); } From 63786c389fe9462141005e55ae4837ff6fed9d5c Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 29 Jul 2013 04:38:18 -0700 Subject: [PATCH 56/64] Warning and review notes fixes. WITH_WINRT -> ENABLE_WINRT_MODE; Some temporary char* replaced with Ptr; Build fix for regular WIN32; Windows Platform SDK and MSVC search added to cmake; Warinig fixes. --- CMakeLists.txt | 13 ++++++++-- cmake/OpenCVCRTLinkage.cmake | 37 +++++++++++++++++++++------- cmake/checks/winrttest.cpp | 6 +++++ modules/contrib/src/inputoutput.cpp | 35 +++++++++++++------------- modules/core/CMakeLists.txt | 2 +- modules/core/src/glob.cpp | 10 +++----- modules/core/src/system.cpp | 24 +++++++++--------- modules/core/test/test_main.cpp | 4 +++ modules/ts/include/opencv2/ts/ts.hpp | 4 +++ 9 files changed, 89 insertions(+), 46 deletions(-) create mode 100644 cmake/checks/winrttest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 419cc68e2..46881c453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 ) -OCV_OPTION(WITH_WINRT "Build with Windows Runtime support" OFF IF WIN32 ) OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) ) OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 ) @@ -213,7 +212,7 @@ OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) ) OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF ) OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF ) - +OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 ) # uncategorized options # =================================================== @@ -604,6 +603,16 @@ if(ANDROID) status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO) endif() +# ================== Windows RT features ================== +if(WIN32) +status("") + status(" Windows RT support:" HAVE_WINRT THEN YES ELSE NO) + if (ENABLE_WINRT_MODE) + status(" Windows SDK v8.0:" ${WINDOWS_SDK_PATH}) + status(" Visual Studio 2012:" ${VISUAL_STUDIO_PATH}) + endif() +endif(WIN32) + # ========================== GUI ========================== status("") status(" GUI: ") diff --git a/cmake/OpenCVCRTLinkage.cmake b/cmake/OpenCVCRTLinkage.cmake index d5e4f27e9..295b914b6 100644 --- a/cmake/OpenCVCRTLinkage.cmake +++ b/cmake/OpenCVCRTLinkage.cmake @@ -4,18 +4,37 @@ endif() #INCLUDE (CheckIncludeFiles) -if (WITH_WINRT) - #CHECK_INCLUDE_FILES("wrl/client.h" HAVE_WINRT) - TRY_COMPILE(HAVE_WINRT - "${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp" - "${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp" - CMAKE_FLAGS "\"kernel.lib\" \"user32.lib\"" - OUTPUT_VARIABLE OUTPUT) +if (ENABLE_WINRT_MODE) + set(HAVE_WINRT True) + + # search Windows Platform SDK + message(STATUS "Checking for Windows Platfrom SDK") + GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE) + if (WINDOWS_SDK_PATH STREQUAL "") + message(ERROR "Windows Platform SDK 8.0 was not found!") + set(HAVE_WINRT False) + endif() + + #search for Visual Studio 11.0 install directory + message(STATUS "Checking for Visual Studio 2012") + GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE) + if (VISUAL_STUDIO_PATH STREQUAL "") + message(ERROR "Visual Studio 2012 was not found!") + set(HAVE_WINRT False) + endif() + + if (HAVE_WINRT) + TRY_COMPILE(HAVE_WINRT + "${OPENCV_BINARY_DIR}/CMakeFiles/CMakeTmp" + "${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp" + CMAKE_FLAGS "\"kernel.lib\" \"user32.lib\"" + OUTPUT_VARIABLE OUTPUT) + endif() + if (HAVE_WINRT) add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602) endif() - message(STATUS "Windows RT: ${HAVE_WINRT}") -endif(WITH_WINRT) +endif(ENABLE_WINRT_MODE) if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) foreach(flag_var diff --git a/cmake/checks/winrttest.cpp b/cmake/checks/winrttest.cpp new file mode 100644 index 000000000..4172afe55 --- /dev/null +++ b/cmake/checks/winrttest.cpp @@ -0,0 +1,6 @@ +#include + +int main(int, char**) +{ + return 0; +} \ No newline at end of file diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index f545d15f7..e04740fae 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -20,17 +20,16 @@ namespace cv #ifdef HAVE_WINRT WIN32_FIND_DATAW FindFileData; #else - WIN32_FIND_DATA FindFileData; + WIN32_FIND_DATAA FindFileData; #endif HANDLE hFind; #ifdef HAVE_WINRT size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); - wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + Ptr wpath = new wchar_t[size+1]; wpath[size] = 0; mbstowcs(wpath, path_f.c_str(), path_f.size()); hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); - free(wpath); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); #endif @@ -48,22 +47,19 @@ namespace cv FindFileData.dwFileAttributes == FILE_ATTRIBUTE_SYSTEM || FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY) { - char* fname; + cv::Ptr fname; #ifdef HAVE_WINRT size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - fname = (char*)malloc((asize+1)*sizeof(char)); + fname = new char[asize+1]; fname[asize] = 0; wcstombs(fname, FindFileData.cFileName, asize); #else fname = FindFileData.cFileName; #endif if (addPath) - list.push_back(path + "/" + fname); + list.push_back(path + "/" + std::string(fname)); else - list.push_back(fname); - #ifdef HAVE_WINRT - free(fname); - #endif + list.push_back(std::string(fname)); } } #ifdef HAVE_WINRT @@ -108,17 +104,16 @@ namespace cv #ifdef HAVE_WINRT WIN32_FIND_DATAW FindFileData; #else - WIN32_FIND_DATA FindFileData; + WIN32_FIND_DATAA FindFileData; #endif HANDLE hFind; #ifdef HAVE_WINRT size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); - wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + Ptr wpath = new wchar_t[size+1]; wpath[size] = 0; mbstowcs(wpath, path_f.c_str(), path_f.size()); hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); - free(wpath); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); #endif @@ -130,14 +125,20 @@ namespace cv { do { +#ifdef HAVE_WINRT if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && wcscmp(FindFileData.cFileName, L".") != 0 && wcscmp(FindFileData.cFileName, L"..") != 0) +#else + if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && + strcmp(FindFileData.cFileName, ".") != 0 && + strcmp(FindFileData.cFileName, "..") != 0) +#endif { - char* fname; + cv::Ptr fname; #ifdef HAVE_WINRT size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - fname = (char*)malloc((asize+1)*sizeof(char)); + fname = new char[asize+1]; fname[asize] = 0; wcstombs(fname, FindFileData.cFileName, asize); #else @@ -145,9 +146,9 @@ namespace cv #endif if (addPath) - list.push_back(path + "/" + fname); + list.push_back(path + "/" + std::string(fname)); else - list.push_back(fname); + list.push_back(std::string(fname)); } } #ifdef HAVE_WINRT diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 8b6123204..fe13daabb 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -3,7 +3,7 @@ ocv_add_module(core ${ZLIB_LIBRARIES}) ocv_module_include_directories(${ZLIB_INCLUDE_DIR}) if (HAVE_WINRT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"C:/Program Files/Windows Kits/8.0/References/CommonConfiguration/Neutral\" /AI\"C:/Program Files/Microsoft Visual Studio 11.0/VC/vcpackages\"") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"") endif() if(HAVE_CUDA) diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index b531832a4..e39cba016 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -68,7 +68,7 @@ namespace ~DIR() { if (ent.d_name) - free((void*)ent.d_name); + delete[] ent.d_name; } #endif }; @@ -80,12 +80,11 @@ namespace #ifdef HAVE_WINRT cv::String full_path = cv::String(path) + "\\*"; size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size()); - wchar_t* wfull_path = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + cv::Ptr wfull_path = new wchar_t[size+1]; wfull_path[size] = 0; mbstowcs(wfull_path, full_path.c_str(), full_path.size()); dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0); - free(wfull_path); #else dir->handle = ::FindFirstFileExA((cv::String(path) + "\\*").c_str(), FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0); @@ -107,7 +106,7 @@ namespace return 0; } size_t asize = wcstombs(NULL, dir->data.cFileName, 0); - char* aname = (char*)malloc((asize+1)*sizeof(char)); + char* aname = new char[asize+1]; aname[asize] = 0; wcstombs(aname, dir->data.cFileName, asize); dir->ent.d_name = aname; @@ -148,11 +147,10 @@ static bool isDir(const cv::String& path, DIR* dir) WIN32_FILE_ATTRIBUTE_DATA all_attrs; #ifdef HAVE_WINRT size_t size = mbstowcs(NULL, path.c_str(), path.size()); - wchar_t* wpath = (wchar_t*)malloc((size+1)*sizeof(wchar_t)); + cv::Ptr wpath = new wchar_t[size+1]; wpath[size] = 0; mbstowcs(wpath, path.c_str(), path.size()); ::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs); - free(wpath); #else ::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs); #endif diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 9279f4a22..7e01ca5ea 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -89,15 +89,14 @@ std::wstring GetTempPathWinRT() std::wstring GetTempFileNameWinRT(std::wstring prefix) { - wchar_t guidStr[120]; - GUID* g = 0x00; - g = new GUID; - CoCreateGuid(g); + wchar_t guidStr[40]; + GUID g; + CoCreateGuid(&g); wchar_t* mask = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x"; - swprintf(&guidStr[0],mask, 120, g->Data1,g->Data2,g->Data3,UINT(g->Data4[0]), - UINT(g->Data4[1]),UINT(g->Data4[2]),UINT(g->Data4[3]),UINT(g->Data4[4]), - UINT(g->Data4[5]),UINT(g->Data4[6]),UINT(g->Data4[7])); - delete g; + swprintf(&guidStr[0], sizeof(guidStr)/sizeof(wchar_t), mask, + g.Data1, g.Data2, g.Data3, UINT(g.Data4[0]), UINT(g.Data4[1]), + UINT(g.Data4[2]), UINT(g.Data4[3]), UINT(g.Data4[4]), + UINT(g.Data4[5]), UINT(g.Data4[6]), UINT(g.Data4[7])); return prefix + std::wstring(guidStr); } @@ -389,7 +388,7 @@ string tempfile( const char* suffix ) { #ifdef HAVE_WINRT std::wstring temp_dir = L""; - wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH"); + const wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH"); if (opencv_temp_dir) temp_dir = std::wstring(opencv_temp_dir); #else @@ -413,11 +412,10 @@ string tempfile( const char* suffix ) DeleteFileW(temp_file.c_str()); size_t asize = wcstombs(NULL, temp_file.c_str(), 0); - char* aname = (char*)malloc((asize+1)*sizeof(char)); + Ptr aname = new char[asize+1]; aname[asize] = 0; wcstombs(aname, temp_file.c_str(), asize); fname = std::string(aname); - free(aname); RoUninitialize(); #else char temp_dir2[MAX_PATH + 1] = { 0 }; @@ -804,6 +802,10 @@ cvGetModuleInfo( const char* name, const char **version, const char **plugin_lis } #if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE +#ifdef HAVE_WINRT + #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +#endif + BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ); BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ) diff --git a/modules/core/test/test_main.cpp b/modules/core/test/test_main.cpp index 6b2499344..3294fab2b 100644 --- a/modules/core/test/test_main.cpp +++ b/modules/core/test/test_main.cpp @@ -1,3 +1,7 @@ +#ifdef HAVE_WINRT + #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +#endif + #include "test_precomp.hpp" CV_TEST_MAIN("cv") diff --git a/modules/ts/include/opencv2/ts/ts.hpp b/modules/ts/include/opencv2/ts/ts.hpp index eafcb8902..384046fd7 100644 --- a/modules/ts/include/opencv2/ts/ts.hpp +++ b/modules/ts/include/opencv2/ts/ts.hpp @@ -10,6 +10,10 @@ #include // for va_list +#ifdef HAVE_WINRT + #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +#endif + #ifdef _MSC_VER #pragma warning( disable: 4127 ) #endif From f28496c62832eb2e73bfe45caf4fd21caedc9029 Mon Sep 17 00:00:00 2001 From: StevenPuttemans Date: Fri, 2 Aug 2013 14:05:08 +0200 Subject: [PATCH 57/64] Added sample links in documentation for python2, ocl and gpu --- .../camera_calibration_and_3d_reconstruction.rst | 9 +++++++++ modules/contrib/doc/facerec/facerec_api.rst | 2 ++ modules/core/doc/clustering.rst | 2 ++ modules/core/doc/operations_on_arrays.rst | 3 +++ .../doc/feature_detection_and_description.rst | 4 ++++ modules/features2d/doc/object_categorization.rst | 6 +++++- .../camera_calibration_and_3d_reconstruction.rst | 6 +++++- modules/gpu/doc/image_filtering.rst | 2 ++ modules/gpu/doc/image_processing.rst | 4 ++++ modules/gpu/doc/object_detection.rst | 6 ++++++ modules/gpu/doc/video.rst | 15 ++++++++++++++- .../doc/reading_and_writing_images_and_video.rst | 5 +++++ modules/imgproc/doc/feature_detection.rst | 4 ++++ modules/imgproc/doc/filtering.rst | 8 ++++++++ modules/imgproc/doc/histograms.rst | 3 +++ .../imgproc/doc/miscellaneous_transformations.rst | 10 +++++++++- modules/imgproc/doc/object_detection.rst | 3 +++ .../structural_analysis_and_shape_descriptors.rst | 6 ++++++ modules/legacy/doc/expectation_maximization.rst | 2 ++ .../doc/feature_detection_and_description.rst | 2 ++ modules/ml/doc/k_nearest_neighbors.rst | 8 +++++++- modules/ml/doc/support_vector_machines.rst | 6 ++++++ modules/nonfree/doc/feature_detection.rst | 9 ++++++++- modules/objdetect/doc/cascade_classification.rst | 4 ++++ .../ocl/doc/feature_detection_and_description.rst | 2 ++ modules/ocl/doc/image_processing.rst | 3 +++ modules/ocl/doc/object_detection.rst | 4 ++++ modules/photo/doc/inpainting.rst | 4 +++- .../doc/motion_analysis_and_object_tracking.rst | 9 +++++++++ 29 files changed, 144 insertions(+), 7 deletions(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 886ac6f1d..b4c4563ef 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -114,6 +114,8 @@ The functions below use the above model to do the following: * : A calibration example on stereo calibration can be found at opencv_source_code/samples/cpp/stereo_calib.cpp * : A calibration example on stereo matching can be found at opencv_source_code/samples/cpp/stereo_match.cpp + * : PYTHON : A camera calibration sample can be found at opencv_source_code/samples/python2/calibrate.py + calibrateCamera --------------- Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. @@ -586,7 +588,9 @@ Finds an object pose from 3D-2D point correspondences. The function estimates the object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients. +.. Sample code:: + * : An example of how to use solvePNP for planar augmented reality can be found at opencv_source_code/samples/python2/plane_ar.py solvePnPRansac ------------------ @@ -1082,6 +1086,9 @@ Class for computing stereo correspondence using the block matching algorithm. :: The class is a C++ wrapper for the associated functions. In particular, :ocv:funcx:`StereoBM::operator()` is the wrapper for :ocv:cfunc:`cvFindStereoCorrespondenceBM`. +.. Sample code: + + * : OCL : An example for using the stereoBM matching algorithm can be found at opencv_source_code/samples/ocl/stereo_match.cpp StereoBM::StereoBM ------------------ @@ -1181,7 +1188,9 @@ The class implements the modified H. Hirschmuller algorithm [HH08]_ that differs * Some pre- and post- processing steps from K. Konolige algorithm :ocv:funcx:`StereoBM::operator()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering). +.. Sample code:: + * : PYTHON : An example illustrating the use of the StereoSGBM matching algorithm can be found at opencv_source_code/samples/python2/stereo_match.py StereoSGBM::StereoSGBM -------------------------- diff --git a/modules/contrib/doc/facerec/facerec_api.rst b/modules/contrib/doc/facerec/facerec_api.rst index af3901f72..74bb01472 100644 --- a/modules/contrib/doc/facerec/facerec_api.rst +++ b/modules/contrib/doc/facerec/facerec_api.rst @@ -7,6 +7,8 @@ FaceRecognizer * : An example using the FaceRecognizer class can be found at opencv_source_code/samples/cpp/facerec_demo.cpp + * : PYTHON : An example using the FaceRecognizer class can be found at opencv_source_code/samples/python2/facerec_demo.py + FaceRecognizer -------------- diff --git a/modules/core/doc/clustering.rst b/modules/core/doc/clustering.rst index d770043f0..ae1245174 100644 --- a/modules/core/doc/clustering.rst +++ b/modules/core/doc/clustering.rst @@ -70,6 +70,8 @@ attempts to 1, initialize labels each time using a custom algorithm, pass them w * : An example on K-means clustering can be found at opencv_source_code/samples/cpp/kmeans.cpp + * : PYTHON : An example on K-means clustering can be found at opencv_source_code/samples/python2/kmeans.py + partition ------------- Splits an element set into equivalency classes. diff --git a/modules/core/doc/operations_on_arrays.rst b/modules/core/doc/operations_on_arrays.rst index f4815bd69..b33637dc6 100644 --- a/modules/core/doc/operations_on_arrays.rst +++ b/modules/core/doc/operations_on_arrays.rst @@ -1001,6 +1001,9 @@ All of the above improvements have been implemented in :ocv:func:`matchTemplate` * : An example using the discrete fourier transform can be found at opencv_source_code/samples/cpp/dft.cpp + * : PYTHON : An example using the dft functionality to perform Wiener deconvolution can be found at opencv_source/samples/python2/deconvolution.py + * : PYTHON : An example rearranging the quadrants of a Fourier image can be found at opencv_source/samples/python2/dft.py + divide ------ diff --git a/modules/features2d/doc/feature_detection_and_description.rst b/modules/features2d/doc/feature_detection_and_description.rst index 9690f883a..286c0cced 100644 --- a/modules/features2d/doc/feature_detection_and_description.rst +++ b/modules/features2d/doc/feature_detection_and_description.rst @@ -55,6 +55,10 @@ Maximally stable extremal region extractor. :: The class encapsulates all the parameters of the MSER extraction algorithm (see http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions). Also see http://code.opencv.org/projects/opencv/wiki/MSER for useful comments and parameters description. +.. Sample code:: + + * : PYTHON : A complete example showing the use of the MSER detector can be found at opencv_source_code/samples/python2/mser.py + ORB --- diff --git a/modules/features2d/doc/object_categorization.rst b/modules/features2d/doc/object_categorization.rst index 3212b6abd..a7db53e76 100644 --- a/modules/features2d/doc/object_categorization.rst +++ b/modules/features2d/doc/object_categorization.rst @@ -5,7 +5,11 @@ Object Categorization This section describes approaches based on local 2D features and used to categorize objects. -.. Sample code:: A complete Bag-Of-Words sample can be found at opencv_source_code/samples/cpp/bagofwords_classification.cpp +.. Sample code:: + + * : A complete Bag-Of-Words sample can be found at opencv_source_code/samples/cpp/bagofwords_classification.cpp + + * : PYTHON : An example using the features2D framework to perform object categorization can be found at opencv_source_code/samples/python2/find_obj.py BOWTrainer ---------- diff --git a/modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst b/modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst index 587c253d2..c0ad590cf 100644 --- a/modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst @@ -44,8 +44,12 @@ The class also performs pre- and post-filtering steps: Sobel pre-filtering (if ` This means that the input left image is low textured. +.. Sample code:: - + * : A basic stereo matching example can be found at opencv_source_code/samples/gpu/stereo_match.cpp + * : A stereo matching example using several GPU's can be found at opencv_source_code/samples/gpu/stereo_multi.cpp + * : A stereo matching example using several GPU's and driver API can be found at opencv_source_code/samples/gpu/driver_api_stereo_multi.cpp + gpu::StereoBM_GPU::StereoBM_GPU ----------------------------------- Enables :ocv:class:`gpu::StereoBM_GPU` constructors. diff --git a/modules/gpu/doc/image_filtering.rst b/modules/gpu/doc/image_filtering.rst index 348a42510..82de72a24 100644 --- a/modules/gpu/doc/image_filtering.rst +++ b/modules/gpu/doc/image_filtering.rst @@ -5,7 +5,9 @@ Image Filtering Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images. +.. Sample code:: + * : An example containing all basic morphology operators like erode and dilate can be found at opencv_source_code/samples/gpu/morphology.cpp gpu::BaseRowFilter_GPU ---------------------- diff --git a/modules/gpu/doc/image_processing.rst b/modules/gpu/doc/image_processing.rst index 0b3254033..ba702baef 100644 --- a/modules/gpu/doc/image_processing.rst +++ b/modules/gpu/doc/image_processing.rst @@ -966,7 +966,9 @@ Composites two images using alpha opacity values contained in each image. :param stream: Stream for the asynchronous version. +.. Sample code:: + * : An example demonstrating the use of alphaComp can be found at opencv_source_code/samples/gpu/alpha_comp.cpp gpu::Canny ------------------- @@ -1028,7 +1030,9 @@ Finds lines in a binary image using the classical Hough transform. .. seealso:: :ocv:func:`HoughLines` +.. Sample code:: + * : An example using the Hough lines detector can be found at opencv_source_code/samples/gpu/houghlines.cpp gpu::HoughLinesDownload ----------------------- diff --git a/modules/gpu/doc/object_detection.rst b/modules/gpu/doc/object_detection.rst index c7986fa7a..56cbd96da 100644 --- a/modules/gpu/doc/object_detection.rst +++ b/modules/gpu/doc/object_detection.rst @@ -65,6 +65,9 @@ Interfaces of all methods are kept similar to the ``CPU HOG`` descriptor and det .. Sample code:: * : An example applying the HOG descriptor for people detection can be found at opencv_source_code/samples/cpp/peopledetect.cpp + * : A GPU example applying the HOG descriptor for people detection can be found at opencv_source_code/samples/gpu/hog.cpp + + * : PYTHON : An example applying the HOG descriptor for people detection can be found at opencv_source_code/samples/python2/peopledetect.py gpu::HOGDescriptor::HOGDescriptor ------------------------------------- @@ -232,7 +235,10 @@ Cascade classifier class used for object detection. Supports HAAR and LBP cascad Size getClassifierSize() const; }; +.. Sample code:: + * : A cascade classifier example can be found at opencv_source_code/samples/gpu/cascadeclassifier.cpp + * : A Nvidea API specific cascade classifier example can be found at opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp gpu::CascadeClassifier_GPU::CascadeClassifier_GPU ----------------------------------------------------- diff --git a/modules/gpu/doc/video.rst b/modules/gpu/doc/video.rst index 284bb17fa..31cfff2f1 100644 --- a/modules/gpu/doc/video.rst +++ b/modules/gpu/doc/video.rst @@ -3,8 +3,11 @@ Video Analysis .. highlight:: cpp +.. Sample code:: - + * : A general optical flow example can be found at opencv_source_code/samples/gpu/optical_flow.cpp + * : A feneral optical flow example using the nvidia API can be found at opencv_source_code/samples/gpu/opticalflow_nvidia_api.cpp + gpu::BroxOpticalFlow -------------------- .. ocv:class:: gpu::BroxOpticalFlow @@ -44,7 +47,9 @@ Class computing the optical flow for two images using Brox et al Optical Flow al GpuMat buf; }; +.. Sample code:: + * : An example illustrating the Brox et al optical flow algorithm can be found at opencv_source_code/samples/gpu/brox_optical_flow.cpp gpu::GoodFeaturesToTrackDetector_GPU ------------------------------------ @@ -213,7 +218,9 @@ The class can calculate an optical flow for a sparse feature set or dense optica .. seealso:: :ocv:func:`calcOpticalFlowPyrLK` +.. Sample code:: + * : An example of the Lucas Kanade optical flow algorithm can be found at opencv_source_code/samples/gpu/pyrlk_optical_flow.cpp gpu::PyrLKOpticalFlow::sparse ----------------------------- @@ -418,7 +425,9 @@ The class discriminates between foreground and background pixels by building and .. seealso:: :ocv:class:`BackgroundSubtractorMOG` +.. Sample code:: + * : An example on gaussian mixture based background/foreground segmantation can be found at opencv_source_code/samples/gpu/bgfg_segm.cpp gpu::MOG_GPU::MOG_GPU --------------------- @@ -697,7 +706,9 @@ The class uses H264 video codec. .. note:: Currently only Windows platform is supported. +.. Sample code:: + * : An example on how to use the videoWriter class can be found at opencv_source_code/samples/gpu/video_writer.cpp gpu::VideoWriter_GPU::VideoWriter_GPU ------------------------------------- @@ -910,7 +921,9 @@ Class for reading video from files. .. note:: Currently only Windows and Linux platforms are supported. +.. Sample code:: + * : An example on how to use the videoReader class can be found at opencv_source_code/samples/gpu/video_reader.cpp gpu::VideoReader_GPU::Codec --------------------------- diff --git a/modules/highgui/doc/reading_and_writing_images_and_video.rst b/modules/highgui/doc/reading_and_writing_images_and_video.rst index 3b96124b9..789838600 100644 --- a/modules/highgui/doc/reading_and_writing_images_and_video.rst +++ b/modules/highgui/doc/reading_and_writing_images_and_video.rst @@ -229,6 +229,11 @@ The class provides C++ API for capturing video from cameras or for reading video * : A basic sample on using the VideoCapture interface can be found at opencv_source_code/samples/cpp/starter_video.cpp * : Another basic video processing sample can be found at opencv_source_code/samples/cpp/video_dmtx.cpp + * : PYTHON : A basic sample on using the VideoCapture interface can be found at opencv_source_code/samples/python2/video.py + * : PYTHON : basic video processing sample can be found at opencv_source_code/samples/python2/video_dmtx.py + * : PYTHON : A multi threaded video processing sample can be found at opencv_source_code/samples/python2/video_threaded.py + + VideoCapture::VideoCapture ------------------------------ VideoCapture constructors. diff --git a/modules/imgproc/doc/feature_detection.rst b/modules/imgproc/doc/feature_detection.rst index 1122cefc7..254e7908a 100644 --- a/modules/imgproc/doc/feature_detection.rst +++ b/modules/imgproc/doc/feature_detection.rst @@ -36,6 +36,8 @@ http://en.wikipedia.org/wiki/Canny_edge_detector * : An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.cpp + * : PYTHON : An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.py + cornerEigenValsAndVecs ---------------------- Calculates eigenvalues and eigenvectors of image blocks for corner detection. @@ -87,7 +89,9 @@ The output of the function can be used for robust edge or corner detection. :ocv:func:`cornerHarris`, :ocv:func:`preCornerDetect` +.. Sample code:: + * : PYTHON : An example on how to use eigenvectors and eigenvalues to estimate image texture flow direction can be found at opencv_source_code/samples/python2/texture_flow.py cornerHarris ------------ diff --git a/modules/imgproc/doc/filtering.rst b/modules/imgproc/doc/filtering.rst index 4265d9461..d23af607f 100755 --- a/modules/imgproc/doc/filtering.rst +++ b/modules/imgproc/doc/filtering.rst @@ -22,6 +22,10 @@ OpenCV enables you to specify the extrapolation method. For details, see the fun * BORDER_CONSTANT: iiiiii|abcdefgh|iiiiiii with some specified 'i' */ +.. Sample code:: + + * : PYTHON : A complete example illustrating different morphological operations like erode/dilate, open/close, blackhat/tophat ... can be found at opencv_source_code/samples/python2/morphology.py + BaseColumnFilter ---------------- .. ocv:class:: BaseColumnFilter @@ -1361,6 +1365,10 @@ Upsamples an image and then blurs it. The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in :ocv:func:`pyrDown` multiplied by 4. +.. Sample code:: + + * : PYTHON : An example of Laplacian Pyramid construction and merging can be found at opencv_source_code/samples/python2/lappyr.py + pyrMeanShiftFiltering --------------------- diff --git a/modules/imgproc/doc/histograms.rst b/modules/imgproc/doc/histograms.rst index 7ac4d47f8..d436b3c2a 100644 --- a/modules/imgproc/doc/histograms.rst +++ b/modules/imgproc/doc/histograms.rst @@ -103,6 +103,9 @@ input arrays at the same location. The sample below shows how to compute a 2D Hu * : An example for creating histograms of an image can be found at opencv_source_code/samples/cpp/demhist.cpp + * : PYTHON : An example for creating color histograms can be found at opencv_source/samples/python2/color_histogram.py + * : PYTHON : An example illustrating RGB and grayscale histogram plotting can be found at opencv_source/samples/python2/hist.py + calcBackProject ------------------- diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index c84a53d23..305706a42 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -485,6 +485,8 @@ Currently, the second variant can use only the approximate distance transform al * : An example on using the distance transform can be found at opencv_source_code/samples/cpp/distrans.cpp + * : PYTHON : An example on using the distance transform can be found at opencv_source/samples/python2/distrans.py + floodFill --------- Fills a connected component with the given color. @@ -592,6 +594,8 @@ Use these functions to either mark a connected component with the specified colo * : An example using the FloodFill technique can be found at opencv_source_code/samples/cpp/ffilldemo.cpp + * : PYTHON : An example using the FloodFill technique can be found at opencv_source_code/samples/python2/floodfill.cpp + integral -------- Calculates the integral of an image. @@ -758,6 +762,8 @@ Visual demonstration and usage example of the function can be found in the OpenC * : An example using the watershed algorithm can be found at opencv_source_code/samples/cpp/watershed.cpp + * : PYTHON : An example using the watershed algorithm can be found at opencv_source_code/samples/python2/watershed.py + grabCut ------- Runs the GrabCut algorithm. @@ -807,4 +813,6 @@ See the sample ``grabcut.cpp`` to learn how to use the function. .. Sample code:: - * : An example using the GrabCut algorithm can be found at opencv_source_code/samples/cpp/grabcut.cpp \ No newline at end of file + * : An example using the GrabCut algorithm can be found at opencv_source_code/samples/cpp/grabcut.cpp + + * : PYTHON : An example using the GrabCut algorithm can be found at opencv_source_code/samples/python2/grabcut.py \ No newline at end of file diff --git a/modules/imgproc/doc/object_detection.rst b/modules/imgproc/doc/object_detection.rst index c6231a05e..d9c43d3fc 100644 --- a/modules/imgproc/doc/object_detection.rst +++ b/modules/imgproc/doc/object_detection.rst @@ -74,3 +74,6 @@ image patch: After the function finishes the comparison, the best matches can be found as global minimums (when ``CV_TM_SQDIFF`` was used) or maximums (when ``CV_TM_CCORR`` or ``CV_TM_CCOEFF`` was used) using the :ocv:func:`minMaxLoc` function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze. +.. Sample code:: + + * : PYTHON : An example on how to match mouse selected regions in an image can be found at opencv_source_code/samples/python2/mouse_and_match.py \ No newline at end of file diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 3912abe81..0f4eaf8cd 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -171,6 +171,8 @@ The function retrieves contours from the binary image using the algorithm * : An example using the findContour functionality can be found at opencv_source_code/samples/cpp/contours2.cpp * : An example using findContours to clean up a background segmentation result at opencv_source_code/samples/cpp/segment_objects.cpp + * : PYTHON : An example using the findContour functionality can be found at opencv_source/samples/python2/contours.py + * : PYTHON : An example of detecting squares in an image can be found at opencv_source/samples/python2/squares.py drawContours ---------------- @@ -257,6 +259,8 @@ The function draws contour outlines in the image if * : An example using the drawContour functionality can be found at opencv_source_code/samples/cpp/contours2.cpp * : An example using drawContours to clean up a background segmentation result at opencv_source_code/samples/cpp/segment_objects.cpp + * : PYTHON : An example using the drawContour functionality can be found at opencv_source/samples/python2/contours.py + approxPolyDP ---------------- Approximates a polygonal curve(s) with the specified precision. @@ -562,7 +566,9 @@ http://en.wikipedia.org/wiki/M-estimator :math:`w_i` are adjusted to be inversely proportional to :math:`\rho(r_i)` . +.. Sample code: + * : PYTHON : An example of robust line fitting can be found at opencv_source_code/samples/python2/fitline.py isContourConvex ------------------- diff --git a/modules/legacy/doc/expectation_maximization.rst b/modules/legacy/doc/expectation_maximization.rst index aac622ace..5aff6c2c0 100644 --- a/modules/legacy/doc/expectation_maximization.rst +++ b/modules/legacy/doc/expectation_maximization.rst @@ -9,6 +9,8 @@ This section describes obsolete ``C`` interface of EM algorithm. Details of the * : An example on using the Expectation Maximalization algorithm can be found at opencv_source_code/samples/cpp/em.cpp + * : PYTHON : An example using Expectation Maximalization for Gaussian Mixing can be found at opencv_source_code/samples/python2/gaussian_mix.py + CvEMParams ---------- diff --git a/modules/legacy/doc/feature_detection_and_description.rst b/modules/legacy/doc/feature_detection_and_description.rst index 4dfabfb1e..a12ccc9ba 100644 --- a/modules/legacy/doc/feature_detection_and_description.rst +++ b/modules/legacy/doc/feature_detection_and_description.rst @@ -75,7 +75,9 @@ Class containing a base structure for ``RTreeClassifier``. :: void estimateQuantPercForPosteriors(float perc[2]); }; +.. Sample code:: + * : PYTHON : An example using Randomized Tree training for letter recognition can be found at opencv_source_code/samples/python2/letter_recog.py RandomizedTree::train ------------------------- diff --git a/modules/ml/doc/k_nearest_neighbors.rst b/modules/ml/doc/k_nearest_neighbors.rst index 739f52dad..11f19178c 100644 --- a/modules/ml/doc/k_nearest_neighbors.rst +++ b/modules/ml/doc/k_nearest_neighbors.rst @@ -9,7 +9,13 @@ CvKNearest ---------- .. ocv:class:: CvKNearest : public CvStatModel -The class implements K-Nearest Neighbors model as described in the beginning of this section. +The class implements K-Nearest Neighbors model as described in the beginning of this section. + +.. Sample code:: + + * : PYTHON : An example of digit recognition using KNearest can be found at opencv_source/samples/python2/digits.py + * : PYTHON : An example of grid search digit recognition using KNearest can be found at opencv_source/samples/python2/digits_adjust.py + * : PYTHON : An example of video digit recognition using KNearest can be found at opencv_source/samples/python2/digits_video.py CvKNearest::CvKNearest ---------------------- diff --git a/modules/ml/doc/support_vector_machines.rst b/modules/ml/doc/support_vector_machines.rst index b0d23ae86..e1196e912 100644 --- a/modules/ml/doc/support_vector_machines.rst +++ b/modules/ml/doc/support_vector_machines.rst @@ -150,6 +150,12 @@ CvSVM Support Vector Machines. +.. Sample code:: + + * : PYTHON : An example of digit recognition using SVM can be found at opencv_source/samples/python2/digits.py + * : PYTHON : An example of grid search digit recognition using SVM can be found at opencv_source/samples/python2/digits_adjust.py + * : PYTHON : An example of video digit recognition using SVM can be found at opencv_source/samples/python2/digits_video.py + CvSVM::CvSVM ------------ Default and training constructors. diff --git a/modules/nonfree/doc/feature_detection.rst b/modules/nonfree/doc/feature_detection.rst index 526aba513..ed513f3fb 100644 --- a/modules/nonfree/doc/feature_detection.rst +++ b/modules/nonfree/doc/feature_detection.rst @@ -234,6 +234,9 @@ The class ``SURF_GPU`` uses some buffers and provides access to it. All buffers .. seealso:: :ocv:class:`SURF` +.. Sample code:: + + * : An example for using the SURF keypoint matcher on GPU can be found at opencv_source_code/samples/gpu/surf_keypoint_matcher.cpp ocl::SURF_OCL ------------- @@ -331,4 +334,8 @@ The ``descriptors`` matrix is :math:`\texttt{nFeatures} \times \texttt{descripto The class ``SURF_OCL`` uses some buffers and provides access to it. All buffers can be safely released between function calls. -.. seealso:: :ocv:class:`SURF` \ No newline at end of file +.. seealso:: :ocv:class:`SURF` + +.. Sample code:: + + * : OCL : An example of the SURF detector can be found at opencv_source_code/samples/ocl/surf_matcher.cpp \ No newline at end of file diff --git a/modules/objdetect/doc/cascade_classification.rst b/modules/objdetect/doc/cascade_classification.rst index eb07a6c8f..d8147873b 100644 --- a/modules/objdetect/doc/cascade_classification.rst +++ b/modules/objdetect/doc/cascade_classification.rst @@ -215,6 +215,10 @@ Detects objects of different sizes in the input image. The detected objects are The function is parallelized with the TBB library. +.. Sample code:: + + * : PYTHON : A face detection example using cascade classifiers can be found at opencv_source_code/samples/python2/facedetect.py + CascadeClassifier::setImage ------------------------------- diff --git a/modules/ocl/doc/feature_detection_and_description.rst b/modules/ocl/doc/feature_detection_and_description.rst index d4fd6e65f..bd40c3696 100644 --- a/modules/ocl/doc/feature_detection_and_description.rst +++ b/modules/ocl/doc/feature_detection_and_description.rst @@ -363,7 +363,9 @@ The class implements Histogram of Oriented Gradients ([Dalal2005]_) object detec Interfaces of all methods are kept similar to the ``CPU HOG`` descriptor and detector analogues as much as possible. +.. Sample code:: + * : OCL : An example using the HOG descriptor can be found at opencv_source_code/samples/ocl/hog.cpp ocl::HOGDescriptor::HOGDescriptor ------------------------------------- diff --git a/modules/ocl/doc/image_processing.rst b/modules/ocl/doc/image_processing.rst index 94712e091..9cb1ebe76 100644 --- a/modules/ocl/doc/image_processing.rst +++ b/modules/ocl/doc/image_processing.rst @@ -257,7 +257,10 @@ The class can calculate an optical flow for a sparse feature set or dense optica .. seealso:: :ocv:func:`calcOpticalFlowPyrLK` +.. Sample code:: + * : OCL : An example the Lucas Kanade optical flow pyramid method can be found at opencv_source_code/samples/ocl/pyrlk_optical_flow.cpp + * : OCL : An example for square detection can be found at opencv_source_code/samples/ocl/squares.cpp ocl::PyrLKOpticalFlow::sparse ----------------------------- diff --git a/modules/ocl/doc/object_detection.rst b/modules/ocl/doc/object_detection.rst index 17eb62d0e..247a21b14 100644 --- a/modules/ocl/doc/object_detection.rst +++ b/modules/ocl/doc/object_detection.rst @@ -20,6 +20,10 @@ Cascade classifier class used for object detection. Supports HAAR cascade classi CvSize maxSize = cvSize(0, 0)); }; +.. Sample code:: + + * : OCL : A face detection example using cascade classifiers can be found at opencv_source_code/samples/ocl/facedetect.cpp + ocl::OclCascadeClassifier::oclHaarDetectObjects ------------------------------------------------------ Returns the detected objects by a list of rectangles diff --git a/modules/photo/doc/inpainting.rst b/modules/photo/doc/inpainting.rst index 2f7a89944..07c665a76 100644 --- a/modules/photo/doc/inpainting.rst +++ b/modules/photo/doc/inpainting.rst @@ -34,4 +34,6 @@ for more details. .. Sample code:: - * : An example using the inpainting technique can be found at opencv_source_code/samples/cpp/inpaint.cpp \ No newline at end of file + * : An example using the inpainting technique can be found at opencv_source_code/samples/cpp/inpaint.cpp + + * : PYTHON : An example using the inpainting technique can be found at opencv_source_code/samples/python2/inpaint.py \ No newline at end of file diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 4b3232175..db9349403 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -46,6 +46,9 @@ The function implements a sparse iterative version of the Lucas-Kanade optical f * : An example using the Lucas-Kanade optical flow algorithm can be found at opencv_source_code/samples/cpp/lkdemo.cpp + * : PYTHON : An example using the Lucas-Kanade optical flow algorithm can be found at opencv_source_code/samples/python2/lk_track.py + * : PYTHON : An example using the Lucas-Kanade tracker for homography matching can be found at opencv_source_code/samples/python2/lk_homography.py + buildOpticalFlowPyramid ----------------------- Constructs the image pyramid which can be passed to :ocv:func:`calcOpticalFlowPyrLK`. @@ -117,6 +120,8 @@ The function finds an optical flow for each ``prev`` pixel using the [Farneback2 * : An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/cpp/fback.cpp + * : PYTHON : An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/python2/opt_flow.py + estimateRigidTransform -------------------------- Computes an optimal affine transformation between two 2D point sets. @@ -234,7 +239,9 @@ In fact, :ocv:func:`fastAtan2` and :ocv:func:`phase` are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the ``mask`` is filled to indicate pixels where the computed angle is valid. +.. Sample code:: + * : PYTHON : An example on how to perform a motion template technique can be found at opencv_source_code/samples/python2/motempl.py calcGlobalOrientation ------------------------- @@ -320,7 +327,9 @@ First, it finds an object center using See the OpenCV sample ``camshiftdemo.c`` that tracks colored objects. +.. Sample code:: + * : PYTHON : A sample explaining the camshift tracking algorithm can be found at opencv_source_code/samples/python2/camshift.py meanShift --------- From 2243118fc039288a2a4aaa6972b63c84b6b29ae1 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Sun, 4 Aug 2013 08:47:42 -0700 Subject: [PATCH 58/64] NEON instruction set enabled for WIN32 on ARM by default. --- modules/core/include/opencv2/core/internal.hpp | 8 +++++++- modules/flann/include/opencv2/flann/dist.h | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index 5e8a03b66..2f26e7cb6 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -136,7 +136,13 @@ CV_INLINE IppiSize ippiSize(int width, int height) # endif #endif -#ifdef __ARM_NEON__ + +#if (defined WIN32 || defined _WIN32) && defined(_M_ARM) +# include +# include "arm_neon.h" +# define CV_NEON 1 +# define CPU_HAS_NEON_FEATURE (true) +#elif defined(__ARM_NEON__) # include # define CV_NEON 1 # define CPU_HAS_NEON_FEATURE (true) diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h index 7380d0c5d..80ae2dc91 100644 --- a/modules/flann/include/opencv2/flann/dist.h +++ b/modules/flann/include/opencv2/flann/dist.h @@ -43,8 +43,12 @@ typedef unsigned __int64 uint64_t; #include "defines.h" +#if (defined WIN32 || defined _WIN32) && defined(_M_ARM) +# include +#endif + #ifdef __ARM_NEON__ -#include "arm_neon.h" +# include "arm_neon.h" #endif namespace cvflann From aada5f78443d1879e8ea5a0087cf3c288deecd07 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Sun, 4 Aug 2013 22:34:36 +0400 Subject: [PATCH 59/64] Difference in method definition and declaration fixed (Bug #3189). --- modules/highgui/src/cap_msmf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_msmf.cpp b/modules/highgui/src/cap_msmf.cpp index 09f65b7e8..76b9a215c 100644 --- a/modules/highgui/src/cap_msmf.cpp +++ b/modules/highgui/src/cap_msmf.cpp @@ -2124,7 +2124,7 @@ long videoDevices::initDevices(IMFAttributes *pAttributes) return hr; } -size_t videoDevices::getCount() +unsigned int videoDevices::getCount() { return vds_Devices.size(); } From a06891851d8e99d0bbf3dfef602b94b5e24b474d Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Mon, 5 Aug 2013 11:11:54 +0400 Subject: [PATCH 60/64] fixing compilation with `-Werror=format-security` enabled --- modules/java/generator/src/cpp/Mat.cpp | 154 ++++++++++++------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index 9d1d9ec34..b651b4d70 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -62,7 +62,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III { static const char method_name[] = "Mat::n_1Mat__III()"; try { - LOGD(method_name); + LOGD("%s", method_name); return (jlong) new Mat( rows, cols, type ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -87,7 +87,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI { static const char method_name[] = "Mat::n_1Mat__DDI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Size size((int)size_width, (int)size_height); return (jlong) new Mat( size, type ); } catch(const std::exception &e) { @@ -114,7 +114,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD { static const char method_name[] = "Mat::n_1Mat__IIIDDDD()"; try { - LOGD(method_name); + LOGD("%s", method_name); Scalar s(s_val0, s_val1, s_val2, s_val3); return (jlong) new Mat( rows, cols, type, s ); } catch(const std::exception &e) { @@ -140,7 +140,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD { static const char method_name[] = "Mat::n_1Mat__DDIDDDD()"; try { - LOGD(method_name); + LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Scalar s(s_val0, s_val1, s_val2, s_val3); return (jlong) new Mat( size, type, s ); @@ -167,7 +167,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII { static const char method_name[] = "Mat::n_1Mat__JIIII()"; try { - LOGD(method_name); + LOGD("%s", method_name); Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange, colRange ); @@ -190,7 +190,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII { static const char method_name[] = "Mat::n_1Mat__JII()"; try { - LOGD(method_name); + LOGD("%s", method_name); Range rowRange(rowRange_start, rowRange_end); return (jlong) new Mat( (*(Mat*)m_nativeObj), rowRange ); } catch(const std::exception &e) { @@ -215,7 +215,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI { static const char method_name[] = "Mat::n_1adjustROI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->adjustROI( dtop, dbottom, dleft, dright ); return (jlong) new Mat(_retval_); @@ -242,7 +242,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI { static const char method_name[] = "Mat::n_1assignTo__JJI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj), type ); } catch(const std::exception &e) { @@ -261,7 +261,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ { static const char method_name[] = "Mat::n_1assignTo__JJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->assignTo( (*(Mat*)m_nativeObj) ); } catch(const std::exception &e) { @@ -285,7 +285,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels { static const char method_name[] = "Mat::n_1channels()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->channels( ); } catch(const std::exception &e) { @@ -311,7 +311,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ { static const char method_name[] = "Mat::n_1checkVector__JIIZ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->checkVector( elemChannels, depth, requireContinuous ); } catch(const std::exception &e) { @@ -333,7 +333,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII { static const char method_name[] = "Mat::n_1checkVector__JII()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->checkVector( elemChannels, depth ); } catch(const std::exception &e) { @@ -355,7 +355,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI { static const char method_name[] = "Mat::n_1checkVector__JI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->checkVector( elemChannels ); } catch(const std::exception &e) { @@ -382,7 +382,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone { static const char method_name[] = "Mat::n_1clone()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->clone( ); return (jlong) new Mat(_retval_); @@ -409,7 +409,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col { static const char method_name[] = "Mat::n_1col()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->col( x ); return (jlong) new Mat(_retval_); @@ -436,7 +436,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange { static const char method_name[] = "Mat::n_1colRange()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->colRange( startcol, endcol ); return (jlong) new Mat(_retval_); @@ -463,7 +463,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims { static const char method_name[] = "Mat::n_1dims()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->dims; } catch(cv::Exception e) { @@ -489,7 +489,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols { static const char method_name[] = "Mat::n_1cols()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->cols; } catch(const std::exception &e) { @@ -515,7 +515,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD { static const char method_name[] = "Mat::n_1convertTo__JJIDD()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha, beta ); @@ -535,7 +535,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID { static const char method_name[] = "Mat::n_1convertTo__JJID()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype, alpha ); @@ -555,7 +555,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI { static const char method_name[] = "Mat::n_1convertTo__JJI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->convertTo( m, rtype ); @@ -580,7 +580,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ { static const char method_name[] = "Mat::n_1copyTo__JJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); me->copyTo( m ); @@ -605,7 +605,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ { static const char method_name[] = "Mat::n_1copyTo__JJJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); @@ -631,7 +631,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII { static const char method_name[] = "Mat::n_1create__JIII()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->create( rows, cols, type ); } catch(const std::exception &e) { @@ -655,7 +655,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI { static const char method_name[] = "Mat::n_1create__JDDI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size size((int)size_width, (int)size_height); me->create( size, type ); @@ -680,7 +680,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross { static const char method_name[] = "Mat::n_1cross()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->cross( m ); @@ -725,7 +725,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth { static const char method_name[] = "Mat::n_1depth()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->depth( ); } catch(const std::exception &e) { @@ -751,7 +751,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI { static const char method_name[] = "Mat::n_1diag__JI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->diag( d ); return (jlong) new Mat(_retval_); @@ -779,7 +779,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J { static const char method_name[] = "Mat::n_1diag__J()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat _retval_ = Mat::diag( (*(Mat*)d_nativeObj) ); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { @@ -805,7 +805,7 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot { static const char method_name[] = "Mat::n_1dot()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); return me->dot( m ); @@ -832,7 +832,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize { static const char method_name[] = "Mat::n_1elemSize()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->elemSize( ); } catch(const std::exception &e) { @@ -858,7 +858,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1 { static const char method_name[] = "Mat::n_1elemSize1()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->elemSize1( ); } catch(const std::exception &e) { @@ -884,7 +884,7 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty { static const char method_name[] = "Mat::n_1empty()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->empty( ); } catch(const std::exception &e) { @@ -910,7 +910,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III { static const char method_name[] = "Mat::n_1eye__III()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat _retval_ = Mat::eye( rows, cols, type ); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { @@ -936,7 +936,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI { static const char method_name[] = "Mat::n_1eye__DDI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::eye( size, type ); return (jlong) new Mat(_retval_); @@ -963,7 +963,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI { static const char method_name[] = "Mat::n_1inv__JI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( method ); return (jlong) new Mat(_retval_); @@ -985,7 +985,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J { static const char method_name[] = "Mat::n_1inv__J()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->inv( ); return (jlong) new Mat(_retval_); @@ -1012,7 +1012,7 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous { static const char method_name[] = "Mat::n_1isContinuous()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->isContinuous( ); } catch(const std::exception &e) { @@ -1038,7 +1038,7 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix { static const char method_name[] = "Mat::n_1isSubmatrix()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->isSubmatrix( ); } catch(const std::exception &e) { @@ -1064,7 +1064,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_locateROI_10 { static const char method_name[] = "core::locateROI_10()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size wholeSize; Point ofs; @@ -1091,7 +1091,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD { static const char method_name[] = "Mat::n_1mul__JJD()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m, scale ); @@ -1115,7 +1115,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ { static const char method_name[] = "Mat::n_1mul__JJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); Mat _retval_ = me->mul( m ); @@ -1143,7 +1143,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III { static const char method_name[] = "Mat::n_1ones__III()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat _retval_ = Mat::ones( rows, cols, type ); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { @@ -1169,7 +1169,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI { static const char method_name[] = "Mat::n_1ones__DDI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::ones( size, type ); return (jlong) new Mat(_retval_); @@ -1196,7 +1196,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back { static const char method_name[] = "Mat::n_1push_1back()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->push_back( (*(Mat*)m_nativeObj) ); } catch(const std::exception &e) { @@ -1220,7 +1220,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release { static const char method_name[] = "Mat::n_1release()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL me->release( ); } catch(const std::exception &e) { @@ -1244,7 +1244,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII { static const char method_name[] = "Mat::n_1reshape__JII()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn, rows ); return (jlong) new Mat(_retval_); @@ -1267,7 +1267,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI { static const char method_name[] = "Mat::n_1reshape__JI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->reshape( cn ); return (jlong) new Mat(_retval_); @@ -1294,7 +1294,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row { static const char method_name[] = "Mat::n_1row()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->row( y ); return (jlong) new Mat(_retval_); @@ -1321,7 +1321,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange { static const char method_name[] = "Mat::n_1rowRange()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->rowRange( startrow, endrow ); return (jlong) new Mat(_retval_); @@ -1348,7 +1348,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows { static const char method_name[] = "Mat::n_1rows()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->rows; } catch(const std::exception &e) { @@ -1374,7 +1374,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD { static const char method_name[] = "Mat::n_1setTo__JDDDD()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Scalar s(s_val0, s_val1, s_val2, s_val3); Mat _retval_ = me->operator =( s ); @@ -1402,7 +1402,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ { static const char method_name[] = "Mat::n_1setTo__JDDDDJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Scalar s(s_val0, s_val1, s_val2, s_val3); Mat& mask = *((Mat*)mask_nativeObj); @@ -1431,7 +1431,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ { static const char method_name[] = "Mat::n_1setTo__JJJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& value = *((Mat*)value_nativeObj); Mat& mask = *((Mat*)mask_nativeObj); @@ -1456,7 +1456,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ { static const char method_name[] = "Mat::n_1setTo__JJ()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& value = *((Mat*)value_nativeObj); Mat _retval_ = me->setTo( value ); @@ -1484,7 +1484,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size { static const char method_name[] = "Mat::n_1size()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size _retval_ = me->size( ); jdoubleArray _da_retval_ = env->NewDoubleArray(2); @@ -1514,7 +1514,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI { static const char method_name[] = "Mat::n_1step1__JI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->step1( i ); } catch(const std::exception &e) { @@ -1536,7 +1536,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J { static const char method_name[] = "Mat::n_1step1__J()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->step1( ); } catch(const std::exception &e) { @@ -1560,7 +1560,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr { static const char method_name[] = "Mat::n_1submat_1rr()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Range rowRange(rowRange_start, rowRange_end); Range colRange(colRange_start, colRange_end); @@ -1589,7 +1589,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat { static const char method_name[] = "Mat::n_1submat()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Rect roi(roi_x, roi_y, roi_width, roi_height); Mat _retval_ = me->operator()( roi ); @@ -1617,7 +1617,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t { static const char method_name[] = "Mat::n_1t()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat _retval_ = me->t( ); return (jlong) new Mat(_retval_); @@ -1644,7 +1644,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total { static const char method_name[] = "Mat::n_1total()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->total( ); } catch(const std::exception &e) { @@ -1670,7 +1670,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type { static const char method_name[] = "Mat::n_1type()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL return me->type( ); } catch(const std::exception &e) { @@ -1696,7 +1696,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III { static const char method_name[] = "Mat::n_1zeros__III()"; try { - LOGD(method_name); + LOGD("%s", method_name); Mat _retval_ = Mat::zeros( rows, cols, type ); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { @@ -1722,7 +1722,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI { static const char method_name[] = "Mat::n_1zeros__DDI()"; try { - LOGD(method_name); + LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Mat _retval_ = Mat::zeros( size, type ); return (jlong) new Mat(_retval_); @@ -1762,7 +1762,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD { static const char method_name[] = "Mat::nPutD()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(!me || !me->data) return 0; // no native object behind if(me->rows<=row || me->cols<=col) return 0; // indexes out of range @@ -1855,7 +1855,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB { static const char method_name[] = "Mat::nPutB()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type @@ -1882,7 +1882,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS { static const char method_name[] = "Mat::nPutS()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type @@ -1909,7 +1909,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI { static const char method_name[] = "Mat::nPutI()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32S) return 0; // incompatible type @@ -1936,7 +1936,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF { static const char method_name[] = "Mat::nPutF()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32F) return 0; // incompatible type @@ -1998,7 +1998,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB { static const char method_name[] = "Mat::nGetB()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type @@ -2025,7 +2025,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS { static const char method_name[] = "Mat::nGetS()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type @@ -2052,7 +2052,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI { static const char method_name[] = "Mat::nGetI()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32S) return 0; // incompatible type @@ -2079,7 +2079,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF { static const char method_name[] = "Mat::nGetF()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_32F) return 0; // incompatible type @@ -2106,7 +2106,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD { static const char method_name[] = "Mat::nGetD()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->depth() != CV_64F) return 0; // incompatible type @@ -2133,7 +2133,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet { static const char method_name[] = "Mat::nGet()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind if(me->rows<=row || me->cols<=col) return 0; // indexes out of range @@ -2171,7 +2171,7 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump { static const char method_name[] = "Mat::nDump()"; try { - LOGD(method_name); + LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL std::stringstream s; s << *me; From 7b0734caf94b0af4c56250903014ce20aa7552e0 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Mon, 5 Aug 2013 11:45:17 +0400 Subject: [PATCH 61/64] fixing java test after fix in OpenCV library --- .../src/org/opencv/test/core/CoreTest.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/core/CoreTest.java b/modules/java/android_test/src/org/opencv/test/core/CoreTest.java index a6023c7cc..45e435330 100644 --- a/modules/java/android_test/src/org/opencv/test/core/CoreTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/CoreTest.java @@ -491,20 +491,6 @@ public class CoreTest extends OpenCVTestCase { Point truth[] = { new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(5, 6), - new Point(4, 6), - new Point(4, 6), - new Point(4, 6), - new Point(4, 6), - new Point(4, 6), - new Point(4, 6), - new Point(4, 6), new Point(4, 6) }; assertArrayPointsEquals(truth, pts.toArray(), EPS); From 2f780ed994b958db70d6ef46ac9dbbe2e7bf3005 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 6 Aug 2013 15:22:46 +0400 Subject: [PATCH 62/64] Fix whitespace errors. --- cmake/checks/winrttest.cpp | 2 +- cmake/templates/cvconfig.h.cmake | 1 - .../windows_install/windows_install.rst | 4 +- ...mera_calibration_and_3d_reconstruction.rst | 2 +- ...on_interfaces_of_descriptor_extractors.rst | 2 +- .../features2d/doc/object_categorization.rst | 2 +- modules/highgui/src/cap_ximea.cpp | 14 +++---- modules/ml/doc/k_nearest_neighbors.rst | 2 +- modules/ocl/perf/perf_gftt.cpp | 4 +- .../camera-calibration/AndroidManifest.xml | 40 +++++++++---------- 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/cmake/checks/winrttest.cpp b/cmake/checks/winrttest.cpp index 4172afe55..2b1d5fa2a 100644 --- a/cmake/checks/winrttest.cpp +++ b/cmake/checks/winrttest.cpp @@ -2,5 +2,5 @@ int main(int, char**) { - return 0; + return 0; } \ No newline at end of file diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index f4b07d053..72cf58b5f 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -160,4 +160,3 @@ /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN - diff --git a/doc/tutorials/introduction/windows_install/windows_install.rst b/doc/tutorials/introduction/windows_install/windows_install.rst index d9ec05f78..c29c13aed 100644 --- a/doc/tutorials/introduction/windows_install/windows_install.rst +++ b/doc/tutorials/introduction/windows_install/windows_install.rst @@ -314,10 +314,10 @@ First we set an enviroment variable to make easier our work. This will hold the setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10 (suggested for Visual Studio 2010 - 32 bit Windows) setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc10 (suggested for Visual Studio 2010 - 64 bit Windows) - + setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc11 (suggested for Visual Studio 2012 - 32 bit Windows) setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc11 (suggested for Visual Studio 2012 - 64 bit Windows) - + Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have two folders called *lib* and *bin*. The -m should be added if you wish to make the settings computer wise, instead of user wise. If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path. This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu): diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 83bec3cf2..60eeebb4d 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -1184,7 +1184,7 @@ Class for computing stereo correspondence using the block matching algorithm, in .. Sample code: - * : OCL : An example for using the stereoBM matching algorithm can be found at opencv_source_code/samples/ocl/stereo_match.cpp + * : OCL : An example for using the stereoBM matching algorithm can be found at opencv_source_code/samples/ocl/stereo_match.cpp createStereoBM ------------------ diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst index 39706b72d..3ab2e870b 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_extractors.rst @@ -145,6 +145,6 @@ Strecha C., Fua P. *BRIEF: Binary Robust Independent Elementary Features* , ... }; -.. Sample code:: +.. Sample code:: * : A complete BRIEF extractor sample can be found at opencv_source_code/samples/cpp/brief_match_test.cpp diff --git a/modules/features2d/doc/object_categorization.rst b/modules/features2d/doc/object_categorization.rst index ec7b6d879..ca2d3a90c 100644 --- a/modules/features2d/doc/object_categorization.rst +++ b/modules/features2d/doc/object_categorization.rst @@ -5,7 +5,7 @@ Object Categorization This section describes approaches based on local 2D features and used to categorize objects. -.. Sample code:: +.. Sample code:: * : A complete Bag-Of-Words sample can be found at opencv_source_code/samples/cpp/bagofwords_classification.cpp diff --git a/modules/highgui/src/cap_ximea.cpp b/modules/highgui/src/cap_ximea.cpp index 98279e05b..b14c113e8 100644 --- a/modules/highgui/src/cap_ximea.cpp +++ b/modules/highgui/src/cap_ximea.cpp @@ -138,7 +138,7 @@ void CvCaptureCAM_XIMEA::close() { if(frame) cvReleaseImage(&frame); - + if(hmv) { xiStopAcquisition(hmv); @@ -176,11 +176,11 @@ IplImage* CvCaptureCAM_XIMEA::retrieveFrame(int) { // update cvImage after format has changed resetCvImage(); - + // copy pixel data switch( image.frm) { - case XI_MONO8 : + case XI_MONO8 : case XI_RAW8 : memcpy( frame->imageData, image.bp, image.width*image.height); break; case XI_MONO16 : case XI_RAW16 : memcpy( frame->imageData, image.bp, image.width*image.height*sizeof(WORD)); break; @@ -210,9 +210,9 @@ void CvCaptureCAM_XIMEA::resetCvImage() { case XI_MONO8 : case XI_RAW8 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 1); break; - case XI_MONO16 : + case XI_MONO16 : case XI_RAW16 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_16U, 1); break; - case XI_RGB24 : + case XI_RGB24 : case XI_RGB_PLANAR : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 3); break; case XI_RGB32 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 4); break; default : @@ -338,9 +338,9 @@ int CvCaptureCAM_XIMEA::getBpp() { case XI_MONO8 : case XI_RAW8 : return 1; - case XI_MONO16 : + case XI_MONO16 : case XI_RAW16 : return 2; - case XI_RGB24 : + case XI_RGB24 : case XI_RGB_PLANAR : return 3; case XI_RGB32 : return 4; default : diff --git a/modules/ml/doc/k_nearest_neighbors.rst b/modules/ml/doc/k_nearest_neighbors.rst index 8f5f45c12..9a3fca455 100644 --- a/modules/ml/doc/k_nearest_neighbors.rst +++ b/modules/ml/doc/k_nearest_neighbors.rst @@ -15,7 +15,7 @@ The class implements K-Nearest Neighbors model as described in the beginning of * : PYTHON : An example of digit recognition using KNearest can be found at opencv_source/samples/python2/digits.py * : PYTHON : An example of grid search digit recognition using KNearest can be found at opencv_source/samples/python2/digits_adjust.py - * : PYTHON : An example of video digit recognition using KNearest can be found at opencv_source/samples/python2/digits_video.py + * : PYTHON : An example of video digit recognition using KNearest can be found at opencv_source/samples/python2/digits_video.py CvKNearest::CvKNearest ---------------------- diff --git a/modules/ocl/perf/perf_gftt.cpp b/modules/ocl/perf/perf_gftt.cpp index bca6f398a..bdc62b622 100644 --- a/modules/ocl/perf/perf_gftt.cpp +++ b/modules/ocl/perf/perf_gftt.cpp @@ -55,14 +55,14 @@ PERFTEST(GoodFeaturesToTrack) double qualityLevel = 0.01; std::string images[] = { "rubberwhale1.png", "aloeL.jpg" }; - + std::vector pts_gold, pts_ocl; for(size_t imgIdx = 0; imgIdx < (sizeof(images)/sizeof(std::string)); ++imgIdx) { Mat frame = imread(abspath(images[imgIdx]), IMREAD_GRAYSCALE); CV_Assert(!frame.empty()); - + for(float minDistance = 0; minDistance < 4; minDistance += 3.0) { SUBTEST << "image = " << images[imgIdx] << "; "; diff --git a/samples/android/camera-calibration/AndroidManifest.xml b/samples/android/camera-calibration/AndroidManifest.xml index d47576abe..c8885db03 100644 --- a/samples/android/camera-calibration/AndroidManifest.xml +++ b/samples/android/camera-calibration/AndroidManifest.xml @@ -1,25 +1,25 @@ - - + + - - - - - - - + android:configChanges="keyboardHidden|orientation" > + + + + + - + - - - + + + From 8bed7bb5f9215eca621aed05cbf1dfa48743a50f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 6 Aug 2013 15:38:19 +0400 Subject: [PATCH 63/64] Fixed documentation errors. --- .../doc/camera_calibration_and_3d_reconstruction.rst | 2 +- modules/core/doc/opengl_interop.rst | 6 +----- modules/highgui/doc/user_interface.rst | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 60eeebb4d..d486bc8ca 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -1214,7 +1214,7 @@ The class implements the modified H. Hirschmuller algorithm [HH08]_ that differs * Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi sub-pixel metric from [BT98]_ is used. Though, the color images are supported as well. - * Some pre- and post- processing steps from K. Konolige algorithm :ocv:funcx:`StereoBM::operator()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering). + * Some pre- and post- processing steps from K. Konolige algorithm ``StereoBM`` are included, for example: pre-filtering (``StereoBM::PREFILTER_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering). .. Sample code:: diff --git a/modules/core/doc/opengl_interop.rst b/modules/core/doc/opengl_interop.rst index e0db36aec..53c58fcdf 100644 --- a/modules/core/doc/opengl_interop.rst +++ b/modules/core/doc/opengl_interop.rst @@ -158,14 +158,10 @@ ogl::Buffer::copyTo ------------------- Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. -.. ocv:function:: void ogl::Buffer::copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const +.. ocv:function:: void ogl::Buffer::copyTo(OutputArray arr) const :param arr: Destination array (host or device memory, can be :ocv:class:`Mat` , :ocv:class:`gpu::GpuMat` , ``std::vector`` or ``ogl::Buffer`` ). - :param target: Buffer usage for destination buffer (if ``arr`` is OpenGL buffer). - - :param autoRelease: Auto release mode for destination buffer (if ``arr`` is OpenGL buffer). - ogl::Buffer::clone diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index 09967ba2c..3b822e488 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -266,7 +266,7 @@ setOpenGlContext ---------------- Sets the specified window as current OpenGL context. -.. ocv:function:: void setOpenGlContext(const string& winname) +.. ocv:function:: void setOpenGlContext(const String& winname) :param winname: Window name @@ -274,6 +274,6 @@ updateWindow ------------ Force window to redraw its context and call draw callback ( :ocv:func:`setOpenGlDrawCallback` ). -.. ocv:function:: void updateWindow(const string& winname) +.. ocv:function:: void updateWindow(const String& winname) :param winname: Window name From 48a6edbdfe48fb5fcf0431aaa0c1dbed34d71993 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 6 Aug 2013 17:06:13 +0400 Subject: [PATCH 64/64] Fixed compilation errors. --- modules/contrib/src/inputoutput.cpp | 8 ++++---- modules/java/generator/src/cpp/Mat.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index 9edf6a056..d0e947b33 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -56,9 +56,9 @@ namespace cv fname = FindFileData.cFileName; #endif if (addPath) - list.push_back(path + "/" + std::string(fname)); + list.push_back(path + "/" + String(fname)); else - list.push_back(std::string(fname)); + list.push_back(String(fname)); } } #ifdef HAVE_WINRT @@ -145,9 +145,9 @@ namespace cv #endif if (addPath) - list.push_back(path + "/" + std::string(fname)); + list.push_back(path + "/" + String(fname)); else - list.push_back(std::string(fname)); + list.push_back(String(fname)); } } #ifdef HAVE_WINRT diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index bc5b87f4e..b3b0f66e7 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -1,6 +1,7 @@ #define LOG_TAG "org.opencv.core.Mat" #include +#include #include "common.h" #include "opencv2/core.hpp"