From 634c3a37c766aaa38aa21d80fd78779bd859cfb3 Mon Sep 17 00:00:00 2001 From: Str3iber Date: Mon, 5 Jan 2015 00:38:03 +0100 Subject: [PATCH 01/21] initial LUCID inclusion --- modules/xfeatures2d/doc/extra_features.rst | 25 ++ modules/xfeatures2d/doc/xfeatures2d.bib | 9 + .../include/opencv2/xfeatures2d.hpp | 21 +- modules/xfeatures2d/src/lucid.cpp | 226 ++++++++++++++++++ modules/xfeatures2d/test/test_features2d.cpp | 8 + 5 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 modules/xfeatures2d/src/lucid.cpp diff --git a/modules/xfeatures2d/doc/extra_features.rst b/modules/xfeatures2d/doc/extra_features.rst index ca3296f7b..cb5693c1f 100644 --- a/modules/xfeatures2d/doc/extra_features.rst +++ b/modules/xfeatures2d/doc/extra_features.rst @@ -91,3 +91,28 @@ We notice that for keypoint matching applications, image content has little effe :param keypoints: Set of detected keypoints :param corrThresh: Correlation threshold. :param verbose: Prints pair selection informations. + + + +LUCID +------------------------ +.. ocv:class:: LUCID : public DescriptorExtractor + +Class for computing LUCID descriptors described in a paper by Ziegler, Andrew, +Eric Christiansen, David Kriegman, and Serge J. Belongie. +*Locally uniform comparison image descriptor.* In Advances in Neural Information Processing Systems, pp. 1-9. 2012. :: + + class LUCID : public DescriptorExtractor + { + public: + LUCID(const int lucid_kernel = 1, const int blur_kernel = 2); + + virtual int descriptorSize() const; + virtual int descriptorType() const; + virtual int defaultNorm() const; + + virtual void compute(InputArray _src, std::vector &keypoints, OutputArray _desc); + + protected: + int l_kernel, b_kernel; + }; diff --git a/modules/xfeatures2d/doc/xfeatures2d.bib b/modules/xfeatures2d/doc/xfeatures2d.bib index 0fa73c8cd..f23c529ab 100644 --- a/modules/xfeatures2d/doc/xfeatures2d.bib +++ b/modules/xfeatures2d/doc/xfeatures2d.bib @@ -44,3 +44,12 @@ year={2012}, organization={Ieee} } + +@incollection{LUCID, + title={Locally uniform comparison image descriptor}, + author={Ziegler, Andrew, Eric Christiansen, David Kriegman, and Serge J. Belongie} + booktitle={Advances in Neural Information Processing Systems} + pages={1--9} + year={2012} + publisher={NIPS} +} diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index b6f2909fc..4c5584257 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -128,7 +128,26 @@ class CV_EXPORTS BriefDescriptorExtractor : public DescriptorExtractor public: static Ptr create( int bytes = 32 ); }; - + + +// Locally Uniform Comparison Image Descriptor + +// @brief This class implements the Locally Uniform Comparison Image Descriptor @cite LUCID +class CV_EXPORTS LUCID : public DescriptorExtractor +{ +public: + static Ptr create(const int lucid_kernel, const int blur_kernel); +}; + +/** @brief Separable box filter blur, needed by LUCID, also exposed for the user + +@param _src Image on which blur should be applied +@param _dst Image resulting from _src having blur applied, the output image +@param kernel Blur kernel size where 1 equates a 3x3 matrix, 2 = 5x5, 3 = 7x7, and so on +*/ +CV_EXPORTS void separable_blur(const InputArray _src, CV_OUT OutputArray _dst, const int kernel); + + //! @} } diff --git a/modules/xfeatures2d/src/lucid.cpp b/modules/xfeatures2d/src/lucid.cpp new file mode 100644 index 000000000..1a1d4fafa --- /dev/null +++ b/modules/xfeatures2d/src/lucid.cpp @@ -0,0 +1,226 @@ +// This implementation of, and any deviation from, the original algorithm as +// proposed by Ziegler et al. is not endorsed by Ziegler et al. nor does it +// claim to represent their definition of locally uniform comparison image +// descriptor. The original LUCID algorithm as proposed by Ziegler et al. remains +// the property of its respective authors. This implementation is an adaptation of +// said algorithm and contributed to OpenCV by Str3iber. + +// References: +// Ziegler, Andrew, Eric Christiansen, David Kriegman, and Serge J. Belongie. +// "Locally uniform comparison image descriptor." In Advances in Neural Information +// Processing Systems, pp. 1-9. 2012. + +/* +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 + (3-clause BSD License) + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the names of the copyright holders nor the names of the contributors + may 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 copyright holders 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. +*/ + +#include "precomp.hpp" + +namespace cv { + namespace xfeatures2d { + void separable_blur(const InputArray _src, OutputArray _dst, const int kernel) { + int z, p, r = 0, g = 0, b = 0, m = kernel*2+1, width, height; + + Point3_ *pnt; + + Mat_ src = _src.getMat(); + if (src.empty()) { + CV_Error(Error::StsBadArg, "empty source image supplied"); + + return; + } + + _dst.create(src.size(), src.type()); + Mat_ dst = _dst.getMat(); + + width = dst.cols, height = dst.rows; + + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + z = kernel*-1; + + if (!x) { + r = 0, g = 0, b = 0; + + for (p = x+z; z <= kernel; ++z, p=x+z) { + pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); + r += pnt->z; + g += pnt->y; + b += pnt->x; + } + } + else { + p = x+z-1; + + pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); + r -= pnt->z; + g -= pnt->y; + b -= pnt->x; + + p = x+kernel; + + pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); + r += pnt->z; + g += pnt->y; + b += pnt->x; + } + + pnt = dst.ptr >(y, x); + pnt->z = static_cast(r/m); + pnt->y = static_cast(g/m); + pnt->x = static_cast(b/m); + } + } + + for (int x = 0, rl = 0, gl = 0, bl = 0, rn = 0, gn = 0, bn = 0; x < width; ++x) { + for (int y = 0; y < height; ++y) { + z = kernel*-1; + + if (!y) { + r = 0, g = 0, b = 0; + + for (p = y+z; z <= kernel; ++z, p=y+z) { + pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); + r += pnt->z; + g += pnt->y; + b += pnt->x; + } + } + else { + p = y+z-1; + + pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); + r -= pnt->z, r -= rl; + g -= pnt->y, g -= gl; + b -= pnt->x, b -= bl; + + p = y+kernel; + + pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); + r += pnt->z, r += rn; + g += pnt->y, g += gn; + b += pnt->x, b += bn; + } + + pnt = dst.ptr >(y, x); + rl = pnt->z; + gl = pnt->y; + bl = pnt->x; + rn = r/m; + gn = g/m; + bn = b/m; + pnt->z = static_cast(rn); + pnt->y = static_cast(gn); + pnt->x = static_cast(bn); + } + } + } + + class LUCIDImpl : public LUCID { + public: + LUCIDImpl(const int lucid_kernel = 1, const int blur_kernel = 2); + + virtual int descriptorSize() const; + virtual int descriptorType() const; + virtual int defaultNorm() const; + + virtual void compute(InputArray _src, std::vector &keypoints, OutputArray _desc); + + protected: + int l_kernel, b_kernel; + }; + + Ptr LUCID::create(const int lucid_kernel, const int blur_kernel) { + return makePtr(lucid_kernel, blur_kernel); + } + + LUCIDImpl::LUCIDImpl(const int lucid_kernel, const int blur_kernel) { + l_kernel = lucid_kernel; + b_kernel = blur_kernel; + } + + int LUCIDImpl::descriptorSize() const { + return (l_kernel*2+1)*(l_kernel*2+1)*3; + } + + int LUCIDImpl::descriptorType() const { + return CV_8UC1; + } + + int LUCIDImpl::defaultNorm() const { + return NORM_HAMMING; + } + + // gliese581h suggested filling a cv::Mat with descriptors to enable BFmatcher compatibility + // speed-ups and enhancements by gliese581h + void LUCIDImpl::compute(InputArray _src, std::vector &keypoints, OutputArray _desc) { + if (_src.getMat().empty()) + return; + + Mat_ src; + + separable_blur(_src.getMat(), src, b_kernel); + + int x, y, j, d, p, m = (l_kernel*2+1)*(l_kernel*2+1)*3, width = src.cols, height = src.rows, r, c; + + Mat_ desc(keypoints.size(), m); + + for (std::size_t i = 0; i < keypoints.size(); ++i) { + x = static_cast(keypoints[i].pt.x)-l_kernel, y = static_cast(keypoints[i].pt.y)-l_kernel, d = x+2*l_kernel, p = y+2*l_kernel, j = x, r = static_cast(i), c = 0; + + while (x <= d) { + Vec3b &pix = src((y < 0 ? height+y : y >= height ? y-height : y), (x < 0 ? width+x : x >= width ? x-width : x)); + + desc(r, c++) = pix[0]; + desc(r, c++) = pix[1]; + desc(r, c++) = pix[2]; + + ++x; + if (x > d) { + if (y < p) { + ++y; + x = j; + } + else + break; + } + } + } + + if (_desc.needed()) + sort(desc, _desc, SORT_EVERY_ROW | SORT_ASCENDING); + } + } +} diff --git a/modules/xfeatures2d/test/test_features2d.cpp b/modules/xfeatures2d/test/test_features2d.cpp index d5f001ce1..303274efa 100644 --- a/modules/xfeatures2d/test/test_features2d.cpp +++ b/modules/xfeatures2d/test/test_features2d.cpp @@ -1025,6 +1025,14 @@ TEST( Features2d_DescriptorExtractor_BRIEF, regression ) test.safe_run(); } +TEST( Features2d_DescriptorExtractor_LUCID, regression ) +{ + CV_DescriptorExtractorTest test( "descriptor-lucid", 1, + LUCID::create(1, 2) ); + test.safe_run(); +} + + /*#if CV_SSE2 TEST( Features2d_DescriptorExtractor_Calonder_uchar, regression ) From 84c598f39e1b5cd090cc3ed150c7aeab84dbb66f Mon Sep 17 00:00:00 2001 From: Str3iber Date: Fri, 16 Jan 2015 15:28:11 +0100 Subject: [PATCH 02/21] avoid msvc warning --- modules/xfeatures2d/src/lucid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/xfeatures2d/src/lucid.cpp b/modules/xfeatures2d/src/lucid.cpp index 1a1d4fafa..dfaf14125 100644 --- a/modules/xfeatures2d/src/lucid.cpp +++ b/modules/xfeatures2d/src/lucid.cpp @@ -195,7 +195,7 @@ namespace cv { int x, y, j, d, p, m = (l_kernel*2+1)*(l_kernel*2+1)*3, width = src.cols, height = src.rows, r, c; - Mat_ desc(keypoints.size(), m); + Mat_ desc(static_cast(keypoints.size()), m); for (std::size_t i = 0; i < keypoints.size(); ++i) { x = static_cast(keypoints[i].pt.x)-l_kernel, y = static_cast(keypoints[i].pt.y)-l_kernel, d = x+2*l_kernel, p = y+2*l_kernel, j = x, r = static_cast(i), c = 0; From 7c703bc52d13ccfb07b4fcba319549509ca9c4d2 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Tue, 20 Jan 2015 17:23:46 +0200 Subject: [PATCH 03/21] Add AGAST detector --- modules/xfeatures2d/doc/extra_features.rst | 22 + modules/xfeatures2d/doc/xfeatures2d.bib | 9 + .../include/opencv2/xfeatures2d.hpp | 32 +- modules/xfeatures2d/perf/perf_agast.cpp | 41 + modules/xfeatures2d/src/agast.cpp | 7670 ++++++++++++++ modules/xfeatures2d/src/agast_score.cpp | 9378 +++++++++++++++++ modules/xfeatures2d/src/agast_score.hpp | 65 + modules/xfeatures2d/test/test_agast.cpp | 138 + 8 files changed, 17354 insertions(+), 1 deletion(-) create mode 100644 modules/xfeatures2d/perf/perf_agast.cpp create mode 100644 modules/xfeatures2d/src/agast.cpp create mode 100644 modules/xfeatures2d/src/agast_score.cpp create mode 100644 modules/xfeatures2d/src/agast_score.hpp create mode 100644 modules/xfeatures2d/test/test_agast.cpp diff --git a/modules/xfeatures2d/doc/extra_features.rst b/modules/xfeatures2d/doc/extra_features.rst index ca3296f7b..742dd3a0f 100644 --- a/modules/xfeatures2d/doc/extra_features.rst +++ b/modules/xfeatures2d/doc/extra_features.rst @@ -91,3 +91,25 @@ We notice that for keypoint matching applications, image content has little effe :param keypoints: Set of detected keypoints :param corrThresh: Correlation threshold. :param verbose: Prints pair selection informations. + +AGAST +----- +Detects corners using the AGAST algorithm + +.. ocv:function:: void AGAST( InputArray image, vector& keypoints, int threshold, bool nonmaxSuppression=true ) +.. ocv:function:: void AGAST( InputArray image, vector& keypoints, int threshold, bool nonmaxSuppression, int type ) + + :param image: grayscale image where keypoints (corners) are detected. + + :param keypoints: keypoints detected on the image. + + :param threshold: threshold on difference between intensity of the central pixel and pixels of a circle around this pixel. + + :param nonmaxSuppression: if true, non-maximum suppression is applied to detected corners (keypoints). + + :param type: one of the three neighborhoods as defined in the paper: ``AgastFeatureDetector::OAST_9_16``, ``AgastFeatureDetector::AGAST_7_12d``, ``AgastFeatureDetector::AGAST_7_12s``, ``AgastFeatureDetector::AGAST_5_8`` + +Detects corners using the AGAST algorithm by [Mair2010]_. + + +.. [Mair2010] Elmar Mair and Gregory D. Hager and Darius Burschka and Michael Suppa and Gerhard Hirzinger, Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, ECCV2010 diff --git a/modules/xfeatures2d/doc/xfeatures2d.bib b/modules/xfeatures2d/doc/xfeatures2d.bib index 0fa73c8cd..202ff76f5 100644 --- a/modules/xfeatures2d/doc/xfeatures2d.bib +++ b/modules/xfeatures2d/doc/xfeatures2d.bib @@ -44,3 +44,12 @@ year={2012}, organization={Ieee} } + +@inproceedings{mair2010_agast, + title={Adaptive and Generic Corner Detection Based on the Accelerated Segment Test"}, + author={"Elmar Mair and Gregory D. Hager and Darius Burschka and Michael Suppa and Gerhard Hirzinger"}, + year={"2010"}, + month={"September"}, + booktitle={"European Conference on Computer Vision (ECCV'10)"}, + url={"http://www6.in.tum.de/Main/ResearchAgast"} +} diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index b6f2909fc..6d4f24677 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -128,7 +128,37 @@ class CV_EXPORTS BriefDescriptorExtractor : public DescriptorExtractor public: static Ptr create( int bytes = 32 ); }; - + +//! detects corners using AGAST algorithm by Elmar Mair +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, int type ); + +class CV_EXPORTS_W AgastFeatureDetector : public Feature2D +{ +public: + enum + { + AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, + THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, + }; + + CV_WRAP static Ptr create( int threshold=10, + bool nonmaxSuppression=true, + int type=AgastFeatureDetector::OAST_9_16 ); + + CV_WRAP virtual void setThreshold(int threshold) = 0; + CV_WRAP virtual int getThreshold() const = 0; + + CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; + CV_WRAP virtual bool getNonmaxSuppression() const = 0; + + CV_WRAP virtual void setType(int type) = 0; + CV_WRAP virtual int getType() const = 0; +}; + //! @} } diff --git a/modules/xfeatures2d/perf/perf_agast.cpp b/modules/xfeatures2d/perf/perf_agast.cpp new file mode 100644 index 000000000..4dc9e1566 --- /dev/null +++ b/modules/xfeatures2d/perf/perf_agast.cpp @@ -0,0 +1,41 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace cv::xfeatures2d; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +CV_ENUM(AgastType, AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, + AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16) + +typedef std::tr1::tuple File_Type_t; +typedef perf::TestBaseWithParam agast; + +#define AGAST_IMAGES \ + "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ + "stitching/a3.png" + +PERF_TEST_P(agast, detect, testing::Combine( + testing::Values(AGAST_IMAGES), + AgastType::all() + )) +{ + string filename = getDataPath(get<0>(GetParam())); + int type = get<1>(GetParam()); + Mat frame = imread(filename, IMREAD_GRAYSCALE); + + if (frame.empty()) + FAIL() << "Unable to load source image " << filename; + + declare.in(frame); + + Ptr fd = AgastFeatureDetector::create(20, true, type); + ASSERT_FALSE( fd.empty() ); + vector points; + + TEST_CYCLE() fd->detect(frame, points); + + SANITY_CHECK_KEYPOINTS(points); +} diff --git a/modules/xfeatures2d/src/agast.cpp b/modules/xfeatures2d/src/agast.cpp new file mode 100644 index 000000000..a995e2a9d --- /dev/null +++ b/modules/xfeatures2d/src/agast.cpp @@ -0,0 +1,7670 @@ +/* This is AGAST and OAST, an optimal and accelerated corner detector + based on the accelerated segment tests + Below is the original copyright and the references */ + +/* +Copyright (C) 2010 Elmar Mair +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + *Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + *Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + *Neither the name of the University of Cambridge nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +The references are: + * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, + Elmar Mair and Gregory D. Hager and Darius Burschka + and Michael Suppa and Gerhard Hirzinger ECCV 2010 + URL: http://www6.in.tum.de/Main/ResearchAgast +*/ + +#include "precomp.hpp" +#include "agast_score.hpp" + +#ifdef _WIN32 +#pragma warning( disable : 4127 ) +#endif + +namespace cv +{ +namespace xfeatures2d +{ + +static void AGAST_5_8(InputArray _img, std::vector& keypoints, int threshold) +{ + + cv::Mat img; + if(!_img.getMat().isContinuous()) + img = _img.getMat().clone(); + else + img = _img.getMat(); + + size_t total = 0; + int xsize = img.cols; + int ysize = img.rows; + size_t nExpectedCorners = keypoints.capacity(); + register int x, y; + register int xsizeB = xsize - 2; + register int ysizeB = ysize - 1; + register int width; + + keypoints.resize(0); + + int pixel_5_8_[16]; + makeAgastOffsets(pixel_5_8_, (int)img.step, AgastFeatureDetector::AGAST_5_8); + + register short offset0 = (short) pixel_5_8_[0]; + register short offset1 = (short) pixel_5_8_[1]; + register short offset2 = (short) pixel_5_8_[2]; + register short offset3 = (short) pixel_5_8_[3]; + register short offset4 = (short) pixel_5_8_[4]; + register short offset5 = (short) pixel_5_8_[5]; + register short offset6 = (short) pixel_5_8_[6]; + register short offset7 = (short) pixel_5_8_[7]; + + width = xsize; + + for(y = 1; y < ysizeB; y++) + { + x = 0; + while(true) + { + homogeneous: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + if(ptr[offset7] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset1] > cb) + goto success_homogeneous; + else + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else if(ptr[offset0] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + } + } + structured: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset1] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto structured; + else + goto homogeneous; + else if(ptr[offset0] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto structured; + else + if(ptr[offset7] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + } + } + success_homogeneous: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto homogeneous; + success_structured: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto structured; + } + } +} + +static void AGAST_7_12d(InputArray _img, std::vector& keypoints, int threshold) +{ + cv::Mat img; + if(!_img.getMat().isContinuous()) + img = _img.getMat().clone(); + else + img = _img.getMat(); + + size_t total = 0; + int xsize = img.cols; + int ysize = img.rows; + size_t nExpectedCorners = keypoints.capacity(); + register int x, y; + register int xsizeB = xsize - 4; + register int ysizeB = ysize - 3; + register int width; + + keypoints.resize(0); + + int pixel_7_12d_[16]; + makeAgastOffsets(pixel_7_12d_, (int)img.step, AgastFeatureDetector::AGAST_7_12d); + + register short offset0 = (short) pixel_7_12d_[0]; + register short offset1 = (short) pixel_7_12d_[1]; + register short offset2 = (short) pixel_7_12d_[2]; + register short offset3 = (short) pixel_7_12d_[3]; + register short offset4 = (short) pixel_7_12d_[4]; + register short offset5 = (short) pixel_7_12d_[5]; + register short offset6 = (short) pixel_7_12d_[6]; + register short offset7 = (short) pixel_7_12d_[7]; + register short offset8 = (short) pixel_7_12d_[8]; + register short offset9 = (short) pixel_7_12d_[9]; + register short offset10 = (short) pixel_7_12d_[10]; + register short offset11 = (short) pixel_7_12d_[11]; + + width = xsize; + + for(y = 3; y < ysizeB; y++) + { + x = 2; + while(true) + { + homogeneous: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_homogeneous; + else + if(ptr[offset7] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + goto success_homogeneous; + else + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else if(ptr[offset0] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto success_homogeneous; + else + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset2] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + } + } + structured: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset2] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else if(ptr[offset0] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset2] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + } + } + success_homogeneous: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto homogeneous; + success_structured: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto structured; + } + } +} + +static void AGAST_7_12s(InputArray _img, std::vector& keypoints, int threshold) +{ + cv::Mat img; + if(!_img.getMat().isContinuous()) + img = _img.getMat().clone(); + else + img = _img.getMat(); + + size_t total = 0; + int xsize = img.cols; + int ysize = img.rows; + size_t nExpectedCorners = keypoints.capacity(); + register int x, y; + register int xsizeB=xsize - 3; //2, +1 due to faster test x>xsizeB + register int ysizeB=ysize - 2; + register int width; + + keypoints.resize(0); + + int pixel_7_12s_[16]; + makeAgastOffsets(pixel_7_12s_, (int)img.step, AgastFeatureDetector::AGAST_7_12s); + + register short offset0 = (short) pixel_7_12s_[0]; + register short offset1 = (short) pixel_7_12s_[1]; + register short offset2 = (short) pixel_7_12s_[2]; + register short offset3 = (short) pixel_7_12s_[3]; + register short offset4 = (short) pixel_7_12s_[4]; + register short offset5 = (short) pixel_7_12s_[5]; + register short offset6 = (short) pixel_7_12s_[6]; + register short offset7 = (short) pixel_7_12s_[7]; + register short offset8 = (short) pixel_7_12s_[8]; + register short offset9 = (short) pixel_7_12s_[9]; + register short offset10 = (short) pixel_7_12s_[10]; + register short offset11 = (short) pixel_7_12s_[11]; + + width = xsize; + + for(y = 2; y < ysizeB; y++) + { + x = 1; + while(true) + { + homogeneous: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + goto success_homogeneous; + else + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else if(ptr[offset0] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto success_homogeneous; + else + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_homogeneous; + else + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_homogeneous; + else + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_homogeneous; + else + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + if(ptr[offset1] < c_b) + if(ptr[offset2] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + else + goto homogeneous; + } + } + structured: + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset7] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else if(ptr[offset0] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + if(ptr[offset11] > cb) + goto success_structured; + else + goto homogeneous; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto success_structured; + else + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto success_structured; + else + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto success_structured; + else + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto success_structured; + else + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + if(ptr[offset1] < c_b) + if(ptr[offset2] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto success_structured; + else + goto structured; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto success_structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto structured; + else + goto homogeneous; + } + } + success_homogeneous: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto homogeneous; + success_structured: + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + goto structured; + } + } +} + +static void OAST_9_16(InputArray _img, std::vector& keypoints, int threshold) +{ + cv::Mat img; + if(!_img.getMat().isContinuous()) + img = _img.getMat().clone(); + else + img = _img.getMat(); + + size_t total = 0; + int xsize = img.cols; + int ysize = img.rows; + size_t nExpectedCorners = keypoints.capacity(); + register int x, y; + register int xsizeB=xsize - 4; + register int ysizeB=ysize - 3; + register int width; + + keypoints.resize(0); + + int pixel_9_16_[16]; + makeAgastOffsets(pixel_9_16_, (int)img.step, AgastFeatureDetector::OAST_9_16); + + register short offset0 = (short) pixel_9_16_[0]; + register short offset1 = (short) pixel_9_16_[1]; + register short offset2 = (short) pixel_9_16_[2]; + register short offset3 = (short) pixel_9_16_[3]; + register short offset4 = (short) pixel_9_16_[4]; + register short offset5 = (short) pixel_9_16_[5]; + register short offset6 = (short) pixel_9_16_[6]; + register short offset7 = (short) pixel_9_16_[7]; + register short offset8 = (short) pixel_9_16_[8]; + register short offset9 = (short) pixel_9_16_[9]; + register short offset10 = (short) pixel_9_16_[10]; + register short offset11 = (short) pixel_9_16_[11]; + register short offset12 = (short) pixel_9_16_[12]; + register short offset13 = (short) pixel_9_16_[13]; + register short offset14 = (short) pixel_9_16_[14]; + register short offset15 = (short) pixel_9_16_[15]; + + width = xsize; + + for(y = 3; y < ysizeB; y++) + { + x = 2; + while(true) + { + x++; + if(x > xsizeB) + break; + else + { + register const unsigned char* const ptr = img.ptr() + y*width + x; + register const int cb = *ptr + threshold; + register const int c_b = *ptr - threshold; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + {} + else + if(ptr[offset15] > cb) + {} + else + continue; + else + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset7] < c_b) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset13] > cb) + {} + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset14] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset13] > cb) + {} + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset5] < c_b) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + {} + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset12] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + {} + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset12] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset4] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset10] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + {} + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + {} + else + if(ptr[offset12] < c_b) + {} + else + continue; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset10] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + {} + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + {} + else + if(ptr[offset14] < c_b) + {} + else + continue; + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + {} + else + if(ptr[offset10] < c_b) + {} + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + {} + else + if(ptr[offset12] < c_b) + {} + else + continue; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset0] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + {} + else + if(ptr[offset10] > cb) + {} + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset2] < c_b) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + {} + else + if(ptr[offset12] > cb) + {} + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + {} + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset4] < c_b) + if(ptr[offset5] > cb) + if(ptr[offset12] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + {} + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset5] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset14] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset13] < c_b) + {} + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset7] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + {} + else + if(ptr[offset15] < c_b) + {} + else + continue; + else + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset6] < c_b) + {} + else + if(ptr[offset13] < c_b) + {} + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset6] > cb) + {} + else + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + {} + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset11] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + {} + else + if(ptr[offset14] > cb) + {} + else + continue; + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + {} + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + {} + else + if(ptr[offset12] > cb) + {} + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset1] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + {} + else + if(ptr[offset10] > cb) + {} + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + {} + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + {} + else + if(ptr[offset10] < c_b) + {} + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + {} + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + {} + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + else + continue; + } + if(total == nExpectedCorners) + { + if(nExpectedCorners == 0) + { + nExpectedCorners = 512; + keypoints.reserve(nExpectedCorners); + } + else + { + nExpectedCorners *= 2; + keypoints.reserve(nExpectedCorners); + } + } + keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); + total++; + } + } +} + + +void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression) +{ + AGAST(_img, keypoints, threshold, nonmax_suppression, AgastFeatureDetector::OAST_9_16); +} + + +class AgastFeatureDetector_Impl : public AgastFeatureDetector +{ +public: + AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, int _type ) + : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) + {} + + void detect( InputArray _image, std::vector& keypoints, InputArray _mask ) + { + Mat mask = _mask.getMat(), grayImage; + UMat ugrayImage; + _InputArray gray = _image; + if( _image.type() != CV_8U ) + { + _OutputArray ogray = _image.isUMat() ? _OutputArray(ugrayImage) : _OutputArray(grayImage); + cvtColor( _image, ogray, COLOR_BGR2GRAY ); + gray = ogray; + } + AGAST( gray, keypoints, threshold, nonmaxSuppression, type ); + KeyPointsFilter::runByPixelsMask( keypoints, mask ); + } + + void set(int prop, double value) + { + if(prop == THRESHOLD) + threshold = cvRound(value); + else if(prop == NONMAX_SUPPRESSION) + nonmaxSuppression = value != 0; + else + CV_Error(Error::StsBadArg, ""); + } + + double get(int prop) const + { + if(prop == THRESHOLD) + return threshold; + if(prop == NONMAX_SUPPRESSION) + return nonmaxSuppression; + CV_Error(Error::StsBadArg, ""); + return 0; + } + + void setThreshold(int threshold_) { threshold = threshold_; } + int getThreshold() const { return threshold; } + + void setNonmaxSuppression(bool f) { nonmaxSuppression = f; } + bool getNonmaxSuppression() const { return nonmaxSuppression; } + + void setType(int type_) { type = type_; } + int getType() const { return type; } + + int threshold; + bool nonmaxSuppression; + int type; +}; + +Ptr AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type ) +{ + return makePtr(threshold, nonmaxSuppression, type); +} + +void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression, int type) +{ + // detect + switch(type) { + case AgastFeatureDetector::AGAST_5_8: + AGAST_5_8(_img, keypoints, threshold); + break; + case AgastFeatureDetector::AGAST_7_12d: + AGAST_7_12d(_img, keypoints, threshold); + break; + case AgastFeatureDetector::AGAST_7_12s: + AGAST_7_12s(_img, keypoints, threshold); + break; + case AgastFeatureDetector::OAST_9_16: + OAST_9_16(_img, keypoints, threshold); + break; + } + + cv::Mat img = _img.getMat(); + + // score + int pixel_[16]; + makeAgastOffsets(pixel_, (int)img.step, type); + + std::vector::iterator kpt; + for(kpt = keypoints.begin(); kpt != keypoints.end(); kpt++) + { + switch(type) { + case AgastFeatureDetector::AGAST_5_8: + kpt->response = (float)agast_cornerScore + (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); + break; + case AgastFeatureDetector::AGAST_7_12d: + kpt->response = (float)agast_cornerScore + (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); + break; + case AgastFeatureDetector::AGAST_7_12s: + kpt->response = (float)agast_cornerScore + (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); + break; + case AgastFeatureDetector::OAST_9_16: + kpt->response = (float)agast_cornerScore + (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); + break; + } + } + // suppression + if(nonmax_suppression) + { + size_t j; + size_t curr_idx; + size_t lastRow = 0, next_lastRow = 0; + size_t num_Corners = keypoints.size(); + size_t lastRowCorner_ind = 0, next_lastRowCorner_ind = 0; + + std::vector nmsFlags; + std::vector::iterator nmsFlags_p; + std::vector::iterator currCorner_nms; + std::vector::const_iterator currCorner; + + currCorner = keypoints.begin(); + + nmsFlags.resize((int)num_Corners); + nmsFlags_p = nmsFlags.begin(); + + // set all flags to MAXIMUM + for(j = num_Corners; j > 0; j--) + *nmsFlags_p++ = -1; + nmsFlags_p = nmsFlags.begin(); + + for(curr_idx = 0; curr_idx < num_Corners; curr_idx++) + { + int t; + // check above + if(lastRow + 1 < currCorner->pt.y) + { + lastRow = next_lastRow; + lastRowCorner_ind = next_lastRowCorner_ind; + } + if(next_lastRow != currCorner->pt.y) + { + next_lastRow = (size_t) currCorner->pt.y; + next_lastRowCorner_ind = curr_idx; + } + if(lastRow + 1 == currCorner->pt.y) + { + // find the corner above the current one + while( (keypoints[lastRowCorner_ind].pt.x < currCorner->pt.x) + && (keypoints[lastRowCorner_ind].pt.y == lastRow) ) + lastRowCorner_ind++; + + if( (keypoints[lastRowCorner_ind].pt.x == currCorner->pt.x) + && (lastRowCorner_ind != curr_idx) ) + { + size_t w = lastRowCorner_ind; + // find the maximum in this block + while(nmsFlags[w] != -1) + w = nmsFlags[w]; + + if(keypoints[curr_idx].response < keypoints[w].response) + nmsFlags[curr_idx] = (int)w; + else + nmsFlags[w] = (int)curr_idx; + } + } + + // check left + t = (int)curr_idx - 1; + if( (curr_idx != 0) && (keypoints[t].pt.y == currCorner->pt.y) + && (keypoints[t].pt.x + 1 == currCorner->pt.x) ) + { + int currCornerMaxAbove_ind = nmsFlags[curr_idx]; + // find the maximum in that area + while(nmsFlags[t] != -1) + t = nmsFlags[t]; + // no maximum above + if(currCornerMaxAbove_ind == -1) + { + if((size_t)t != curr_idx) + { + if ( keypoints[curr_idx].response < keypoints[t].response ) + nmsFlags[curr_idx] = t; + else + nmsFlags[t] = (int)curr_idx; + } + } + else // maximum above + { + if(t != currCornerMaxAbove_ind) + { + if(keypoints[currCornerMaxAbove_ind].response < keypoints[t].response) + { + nmsFlags[currCornerMaxAbove_ind] = t; + nmsFlags[curr_idx] = t; + } + else + { + nmsFlags[t] = currCornerMaxAbove_ind; + nmsFlags[curr_idx] = currCornerMaxAbove_ind; + } + } + } + } + currCorner++; + } + + // removing non-maximum corners + for(curr_idx = 0; curr_idx < num_Corners; curr_idx++) + { + if(*nmsFlags_p++ != -1) + keypoints.erase(keypoints.begin() + curr_idx); + } + } +} + +} +} // END NAMESPACE CV diff --git a/modules/xfeatures2d/src/agast_score.cpp b/modules/xfeatures2d/src/agast_score.cpp new file mode 100644 index 000000000..521af8c67 --- /dev/null +++ b/modules/xfeatures2d/src/agast_score.cpp @@ -0,0 +1,9378 @@ +/* This is AGAST and OAST, an optimal and accelerated corner detector + based on the accelerated segment tests + Below is the original copyright and the references */ + +/* +Copyright (C) 2010 Elmar Mair +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + *Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + *Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + *Neither the name of the University of Cambridge nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +The references are: + * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, + Elmar Mair and Gregory D. Hager and Darius Burschka + and Michael Suppa and Gerhard Hirzinger ECCV 2010 + URL: http://www6.in.tum.de/Main/ResearchAgast +*/ + +#include "agast_score.hpp" + +#ifdef _WIN32 +#pragma warning( disable : 4127 ) +#endif + +namespace cv +{ +namespace xfeatures2d +{ + +void makeAgastOffsets(int pixel[16], int rowStride, int type) +{ + static const int offsets16[][2] = + { + {-3, 0}, {-3, -1}, {-2, -2}, {-1, -3}, {0, -3}, { 1, -3}, { 2, -2}, { 3, -1}, + { 3, 0}, { 3, 1}, { 2, 2}, { 1, 3}, {0, 3}, {-1, 3}, {-2, 2}, {-3, 1} + }; + + static const int offsets12d[][2] = + { + {-3, 0}, {-2, -1}, {-1, -2}, {0, -3}, { 1, -2}, { 2, -1}, + { 3, 0}, { 2, 1}, { 1, 2}, {0, 3}, {-1, 2}, {-2, 1} + }; + + static const int offsets12s[][2] = + { + {-2, 0}, {-2, -1}, {-1, -2}, {0, -2}, { 1, -2}, { 2, -1}, + { 2, 0}, { 2, 1}, { 1, 2}, {0, 2}, {-1, 2}, {-2, 1} + }; + + static const int offsets8[][2] = + { + {-1, 0}, {-1, -1}, {0, -1}, { 1, -1}, + { 1, 0}, { 1, 1}, {0, 1}, {-1, 1} + }; + + const int (*offsets)[2] = type == AgastFeatureDetector::OAST_9_16 ? offsets16 : + type == AgastFeatureDetector::AGAST_7_12d ? offsets12d : + type == AgastFeatureDetector::AGAST_7_12s ? offsets12s : + type == AgastFeatureDetector::AGAST_5_8 ? offsets8 : 0; + + CV_Assert(pixel && offsets); + + int k = 0; + for( ; k < 16; k++ ) + pixel[k] = offsets[k][0] + offsets[k][1] * rowStride; +} + +// 16 pixel mask +template<> +int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) +{ + int bmin = threshold; + int bmax = 255; + int b_test = (bmax + bmin) / 2; + + register short offset0 = (short) pixel[0]; + register short offset1 = (short) pixel[1]; + register short offset2 = (short) pixel[2]; + register short offset3 = (short) pixel[3]; + register short offset4 = (short) pixel[4]; + register short offset5 = (short) pixel[5]; + register short offset6 = (short) pixel[6]; + register short offset7 = (short) pixel[7]; + register short offset8 = (short) pixel[8]; + register short offset9 = (short) pixel[9]; + register short offset10 = (short) pixel[10]; + register short offset11 = (short) pixel[11]; + register short offset12 = (short) pixel[12]; + register short offset13 = (short) pixel[13]; + register short offset14 = (short) pixel[14]; + register short offset15 = (short) pixel[15]; + + while(true) + { + register const int cb = *pixel + b_test; + register const int c_b = *pixel - b_test; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset7] < c_b) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset14] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset5] < c_b) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset12] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset12] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset4] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset10] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset12] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset10] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + goto is_a_corner; + else + if(ptr[offset14] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset5] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset12] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset0] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset2] < c_b) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset12] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset4] < c_b) + if(ptr[offset5] > cb) + if(ptr[offset12] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset5] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset14] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset7] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset10] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + goto is_a_corner; + else + if(ptr[offset14] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset12] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset9] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset12] > cb) + if(ptr[offset13] > cb) + if(ptr[offset14] > cb) + if(ptr[offset15] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset12] < c_b) + if(ptr[offset13] < c_b) + if(ptr[offset14] < c_b) + if(ptr[offset15] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + + is_a_corner: + bmin = b_test; + goto end; + + is_not_a_corner: + bmax = b_test; + goto end; + + end: + + if(bmin == bmax - 1 || bmin == bmax) + return bmin; + b_test = (bmin + bmax) / 2; + } +} + +// 12 pixel mask in diamond format +template<> +int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) +{ + int bmin = threshold; + int bmax = 255; + int b_test = (bmax + bmin)/2; + + register short offset0 = (short) pixel[0]; + register short offset1 = (short) pixel[1]; + register short offset2 = (short) pixel[2]; + register short offset3 = (short) pixel[3]; + register short offset4 = (short) pixel[4]; + register short offset5 = (short) pixel[5]; + register short offset6 = (short) pixel[6]; + register short offset7 = (short) pixel[7]; + register short offset8 = (short) pixel[8]; + register short offset9 = (short) pixel[9]; + register short offset10 = (short) pixel[10]; + register short offset11 = (short) pixel[11]; + + while(true) + { + register const int cb = *pixel + b_test; + register const int c_b = *pixel - b_test; + if(ptr[offset0] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset2] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset0] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset11] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset9] > cb) + if(ptr[offset6] > cb) + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset2] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset2] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + + is_a_corner: + bmin = b_test; + goto end; + + is_not_a_corner: + bmax = b_test; + goto end; + + end: + + if(bmin == bmax - 1 || bmin == bmax) + return bmin; + b_test = (bmin + bmax) / 2; + } +} + +//12 pixel mask in square format +template<> +int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) +{ + int bmin = threshold; + int bmax = 255; + int b_test = (bmax + bmin)/2; + + register short offset0 = (short) pixel[0]; + register short offset1 = (short) pixel[1]; + register short offset2 = (short) pixel[2]; + register short offset3 = (short) pixel[3]; + register short offset4 = (short) pixel[4]; + register short offset5 = (short) pixel[5]; + register short offset6 = (short) pixel[6]; + register short offset7 = (short) pixel[7]; + register short offset8 = (short) pixel[8]; + register short offset9 = (short) pixel[9]; + register short offset10 = (short) pixel[10]; + register short offset11 = (short) pixel[11]; + + while(true) + { + register const int cb = *pixel + b_test; + register const int c_b = *pixel - b_test; + if(ptr[offset0] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset2] < c_b) + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset3] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset7] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset0] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset2] > cb) + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset2] > cb) + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset9] > cb) + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset4] < c_b) + if(ptr[offset10] > cb) + if(ptr[offset8] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset9] > cb) + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset7] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset9] > cb) + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] > cb) + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset2] > cb) + if(ptr[offset9] > cb) + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] < c_b) + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] < c_b) + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset8] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset8] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset3] < c_b) + goto is_a_corner; + else + if(ptr[offset10] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] < c_b) + if(ptr[offset11] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset2] < c_b) + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset2] > cb) + if(ptr[offset9] < c_b) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset8] > cb) + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset8] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset9] < c_b) + goto is_not_a_corner; + else + if(ptr[offset9] > cb) + if(ptr[offset1] > cb) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + goto is_not_a_corner; + else + if(ptr[offset6] > cb) + if(ptr[offset8] > cb) + if(ptr[offset4] > cb) + if(ptr[offset3] > cb) + goto is_a_corner; + else + if(ptr[offset10] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset10] > cb) + if(ptr[offset11] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + + is_a_corner: + bmin = b_test; + goto end; + + is_not_a_corner: + bmax = b_test; + goto end; + + end: + + if(bmin == bmax - 1 || bmin == bmax) + return bmin; + b_test = (bmin + bmax) / 2; + } +} + +// 8 pixel mask +template<> +int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) +{ + int bmin = threshold; + int bmax = 255; + int b_test = (bmax + bmin)/2; + + register short offset0 = (short) pixel[0]; + register short offset1 = (short) pixel[1]; + register short offset2 = (short) pixel[2]; + register short offset3 = (short) pixel[3]; + register short offset4 = (short) pixel[4]; + register short offset5 = (short) pixel[5]; + register short offset6 = (short) pixel[6]; + register short offset7 = (short) pixel[7]; + + while(true) + { + register const int cb = *pixel + b_test; + register const int c_b = *pixel - b_test; + if(ptr[offset0] > cb) + if(ptr[offset2] > cb) + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + if(ptr[offset7] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset5] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset7] > cb) + if(ptr[offset6] > cb) + if(ptr[offset1] > cb) + goto is_a_corner; + else + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else if(ptr[offset0] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset7] > cb) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset6] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] > cb) + if(ptr[offset3] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset5] < c_b) + if(ptr[offset7] < c_b) + if(ptr[offset6] < c_b) + if(ptr[offset1] < c_b) + goto is_a_corner; + else + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] > cb) + if(ptr[offset5] > cb) + if(ptr[offset2] > cb) + if(ptr[offset1] > cb) + if(ptr[offset4] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] > cb) + if(ptr[offset4] > cb) + if(ptr[offset6] > cb) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset3] < c_b) + if(ptr[offset5] < c_b) + if(ptr[offset2] < c_b) + if(ptr[offset1] < c_b) + if(ptr[offset4] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + if(ptr[offset7] < c_b) + if(ptr[offset4] < c_b) + if(ptr[offset6] < c_b) + goto is_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + else + goto is_not_a_corner; + + is_a_corner: + bmin=b_test; + goto end; + + is_not_a_corner: + bmax=b_test; + goto end; + + end: + + if(bmin == bmax - 1 || bmin == bmax) + return bmin; + b_test = (bmin + bmax) / 2; + } +} + +} +} // namespace cv diff --git a/modules/xfeatures2d/src/agast_score.hpp b/modules/xfeatures2d/src/agast_score.hpp new file mode 100644 index 000000000..f00abbe53 --- /dev/null +++ b/modules/xfeatures2d/src/agast_score.hpp @@ -0,0 +1,65 @@ +/* This is AGAST and OAST, an optimal and accelerated corner detector + based on the accelerated segment tests + Below is the original copyright and the references */ + +/* +Copyright (C) 2010 Elmar Mair +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + *Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + *Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + *Neither the name of the University of Cambridge nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +The references are: + * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, + Elmar Mair and Gregory D. Hager and Darius Burschka + and Michael Suppa and Gerhard Hirzinger ECCV 2010 + URL: http://www6.in.tum.de/Main/ResearchAgast +*/ + + +#ifndef __OPENCV_FEATURES_2D_AGAST_HPP__ +#define __OPENCV_FEATURES_2D_AGAST_HPP__ + +#ifdef __cplusplus + +#include "precomp.hpp" +namespace cv +{ +namespace xfeatures2d +{ + +void makeAgastOffsets(int pixel[16], int row_stride, int type); + +template +int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold); + +} +} +#endif +#endif diff --git a/modules/xfeatures2d/test/test_agast.cpp b/modules/xfeatures2d/test/test_agast.cpp new file mode 100644 index 000000000..db6dbdc57 --- /dev/null +++ b/modules/xfeatures2d/test/test_agast.cpp @@ -0,0 +1,138 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "test_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace cv::xfeatures2d; + +class CV_AgastTest : public cvtest::BaseTest +{ +public: + CV_AgastTest(); + ~CV_AgastTest(); +protected: + void run(int); +}; + +CV_AgastTest::CV_AgastTest() {} +CV_AgastTest::~CV_AgastTest() {} + +void CV_AgastTest::run( int ) +{ + for(int type=0; type <= 2; ++type) { + Mat image1 = imread(string(ts->get_data_path()) + "inpaint/orig.png"); + Mat image2 = imread(string(ts->get_data_path()) + "cameracalibration/chess9.png"); + string xml = string(ts->get_data_path()) + format("agast/result%d.xml", type); + + if (image1.empty() || image2.empty()) + { + ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); + return; + } + + Mat gray1, gray2; + cvtColor(image1, gray1, COLOR_BGR2GRAY); + cvtColor(image2, gray2, COLOR_BGR2GRAY); + + vector keypoints1; + vector keypoints2; + AGAST(gray1, keypoints1, 30, true, type); + AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type); + + for(size_t i = 0; i < keypoints1.size(); ++i) + { + const KeyPoint& kp = keypoints1[i]; + cv::circle(image1, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); + } + + for(size_t i = 0; i < keypoints2.size(); ++i) + { + const KeyPoint& kp = keypoints2[i]; + cv::circle(image2, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); + } + + Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8U, &keypoints1[0]); + Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8U, &keypoints2[0]); + + FileStorage fs(xml, FileStorage::READ); + if (!fs.isOpened()) + { + fs.open(xml, FileStorage::WRITE); + if (!fs.isOpened()) + { + ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + return; + } + fs << "exp_kps1" << kps1; + fs << "exp_kps2" << kps2; + fs.release(); + fs.open(xml, FileStorage::READ); + if (!fs.isOpened()) + { + ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + return; + } + } + + Mat exp_kps1, exp_kps2; + read( fs["exp_kps1"], exp_kps1, Mat() ); + read( fs["exp_kps2"], exp_kps2, Mat() ); + fs.release(); + + if ( exp_kps1.size != kps1.size || 0 != cvtest::norm(exp_kps1, kps1, NORM_L2) || + exp_kps2.size != kps2.size || 0 != cvtest::norm(exp_kps2, kps2, NORM_L2)) + { + ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); + return; + } + + /*cv::namedWindow("Img1"); cv::imshow("Img1", image1); + cv::namedWindow("Img2"); cv::imshow("Img2", image2); + cv::waitKey(0);*/ + } + + ts->set_failed_test_info(cvtest::TS::OK); +} + +TEST(Features2d_AGAST, regression) { CV_AgastTest test; test.safe_run(); } From 25aad108acf6f9c7567cffb20a44d39c0f96ba22 Mon Sep 17 00:00:00 2001 From: Str3iber Date: Tue, 20 Jan 2015 16:37:56 +0100 Subject: [PATCH 04/21] make suggested changes --- modules/xfeatures2d/doc/extra_features.rst | 25 ---- .../include/opencv2/xfeatures2d.hpp | 17 ++- modules/xfeatures2d/src/lucid.cpp | 116 +++--------------- 3 files changed, 23 insertions(+), 135 deletions(-) diff --git a/modules/xfeatures2d/doc/extra_features.rst b/modules/xfeatures2d/doc/extra_features.rst index cb5693c1f..ca3296f7b 100644 --- a/modules/xfeatures2d/doc/extra_features.rst +++ b/modules/xfeatures2d/doc/extra_features.rst @@ -91,28 +91,3 @@ We notice that for keypoint matching applications, image content has little effe :param keypoints: Set of detected keypoints :param corrThresh: Correlation threshold. :param verbose: Prints pair selection informations. - - - -LUCID ------------------------- -.. ocv:class:: LUCID : public DescriptorExtractor - -Class for computing LUCID descriptors described in a paper by Ziegler, Andrew, -Eric Christiansen, David Kriegman, and Serge J. Belongie. -*Locally uniform comparison image descriptor.* In Advances in Neural Information Processing Systems, pp. 1-9. 2012. :: - - class LUCID : public DescriptorExtractor - { - public: - LUCID(const int lucid_kernel = 1, const int blur_kernel = 2); - - virtual int descriptorSize() const; - virtual int descriptorType() const; - virtual int defaultNorm() const; - - virtual void compute(InputArray _src, std::vector &keypoints, OutputArray _desc); - - protected: - int l_kernel, b_kernel; - }; diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 4c5584257..6df6f526d 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -130,22 +130,21 @@ public: }; -// Locally Uniform Comparison Image Descriptor +/** @brief Class implementing the locally uniform comparison image descriptor, described in @cite LUCID -// @brief This class implements the Locally Uniform Comparison Image Descriptor @cite LUCID +An image descriptor that can be computed very fast, while being +about as robust as, for example, SURF or BRIEF. + */ class CV_EXPORTS LUCID : public DescriptorExtractor { public: + /** + * @param lucid_kernel kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + * @param blur_kernel kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + */ static Ptr create(const int lucid_kernel, const int blur_kernel); }; -/** @brief Separable box filter blur, needed by LUCID, also exposed for the user - -@param _src Image on which blur should be applied -@param _dst Image resulting from _src having blur applied, the output image -@param kernel Blur kernel size where 1 equates a 3x3 matrix, 2 = 5x5, 3 = 7x7, and so on -*/ -CV_EXPORTS void separable_blur(const InputArray _src, CV_OUT OutputArray _dst, const int kernel); //! @} diff --git a/modules/xfeatures2d/src/lucid.cpp b/modules/xfeatures2d/src/lucid.cpp index dfaf14125..22c5fcd4c 100644 --- a/modules/xfeatures2d/src/lucid.cpp +++ b/modules/xfeatures2d/src/lucid.cpp @@ -50,110 +50,24 @@ the use of this software, even if advised of the possibility of such damage. namespace cv { namespace xfeatures2d { - void separable_blur(const InputArray _src, OutputArray _dst, const int kernel) { - int z, p, r = 0, g = 0, b = 0, m = kernel*2+1, width, height; - - Point3_ *pnt; - - Mat_ src = _src.getMat(); - if (src.empty()) { - CV_Error(Error::StsBadArg, "empty source image supplied"); - - return; - } - - _dst.create(src.size(), src.type()); - Mat_ dst = _dst.getMat(); - - width = dst.cols, height = dst.rows; - - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; ++x) { - z = kernel*-1; - - if (!x) { - r = 0, g = 0, b = 0; - - for (p = x+z; z <= kernel; ++z, p=x+z) { - pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); - r += pnt->z; - g += pnt->y; - b += pnt->x; - } - } - else { - p = x+z-1; - - pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); - r -= pnt->z; - g -= pnt->y; - b -= pnt->x; - - p = x+kernel; - - pnt = src.ptr >(y, (p < 0 ? width+p : p >= width ? p-width : p)); - r += pnt->z; - g += pnt->y; - b += pnt->x; - } - - pnt = dst.ptr >(y, x); - pnt->z = static_cast(r/m); - pnt->y = static_cast(g/m); - pnt->x = static_cast(b/m); - } - } - - for (int x = 0, rl = 0, gl = 0, bl = 0, rn = 0, gn = 0, bn = 0; x < width; ++x) { - for (int y = 0; y < height; ++y) { - z = kernel*-1; - - if (!y) { - r = 0, g = 0, b = 0; - - for (p = y+z; z <= kernel; ++z, p=y+z) { - pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); - r += pnt->z; - g += pnt->y; - b += pnt->x; - } - } - else { - p = y+z-1; - - pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); - r -= pnt->z, r -= rl; - g -= pnt->y, g -= gl; - b -= pnt->x, b -= bl; - - p = y+kernel; - - pnt = dst.ptr >((p < 0 ? height+p : p >= height ? p-height : p), x); - r += pnt->z, r += rn; - g += pnt->y, g += gn; - b += pnt->x, b += bn; - } - - pnt = dst.ptr >(y, x); - rl = pnt->z; - gl = pnt->y; - bl = pnt->x; - rn = r/m; - gn = g/m; - bn = b/m; - pnt->z = static_cast(rn); - pnt->y = static_cast(gn); - pnt->x = static_cast(bn); - } - } - } - + /*! + LUCID implementation + */ class LUCIDImpl : public LUCID { public: + /** Constructor + * @param lucid_kernel kernel for descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + * @param blur_kernel kernel for blurring image prior to descriptor construction, where 1=3x3, 2=5x5, 3=7x7 and so forth + */ LUCIDImpl(const int lucid_kernel = 1, const int blur_kernel = 2); + /** returns the descriptor length */ virtual int descriptorSize() const; + + /** returns the descriptor type */ virtual int descriptorType() const; + + /** returns the default norm type */ virtual int defaultNorm() const; virtual void compute(InputArray _src, std::vector &keypoints, OutputArray _desc); @@ -168,7 +82,7 @@ namespace cv { LUCIDImpl::LUCIDImpl(const int lucid_kernel, const int blur_kernel) { l_kernel = lucid_kernel; - b_kernel = blur_kernel; + b_kernel = blur_kernel*2+1; } int LUCIDImpl::descriptorSize() const { @@ -191,7 +105,7 @@ namespace cv { Mat_ src; - separable_blur(_src.getMat(), src, b_kernel); + blur(_src.getMat(), src, cv::Size(b_kernel, b_kernel)); int x, y, j, d, p, m = (l_kernel*2+1)*(l_kernel*2+1)*3, width = src.cols, height = src.rows, r, c; @@ -223,4 +137,4 @@ namespace cv { sort(desc, _desc, SORT_EVERY_ROW | SORT_ASCENDING); } } -} +} // END NAMESPACE CV From 361dff4ee43c99a51ccdc915fbdcb29e01bc25cf Mon Sep 17 00:00:00 2001 From: Dikay900 Date: Fri, 28 Nov 2014 19:49:58 +0100 Subject: [PATCH 05/21] fix already defined macro variable --- modules/line_descriptor/src/binary_descriptor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/line_descriptor/src/binary_descriptor.cpp b/modules/line_descriptor/src/binary_descriptor.cpp index 2d2929f9c..f5739b661 100644 --- a/modules/line_descriptor/src/binary_descriptor.cpp +++ b/modules/line_descriptor/src/binary_descriptor.cpp @@ -756,7 +756,7 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines ) /* some variables' declarations */ float rho1, rho2, tempValue; - float direction, near, length; + float direction, diffNear, length; unsigned int octaveID, lineIDInOctave; /*more than one octave image, organize lines in scale space. @@ -784,8 +784,8 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines ) /*nearThreshold depends on the distance of the image coordinate origin to current line. *so nearThreshold = rho1 * nearThresholdRatio, where nearThresholdRatio = 1-cos(10*pi/180) = 0.0152*/ tempValue = (float) ( rho1 * 0.0152 ); - float nearThreshold = ( tempValue > 6 ) ? ( tempValue ) : 6; - nearThreshold = ( nearThreshold < 12 ) ? nearThreshold : 12; + float diffNearThreshold = ( tempValue > 6 ) ? ( tempValue ) : 6; + diffNearThreshold = ( diffNearThreshold < 12 ) ? diffNearThreshold : 12; /* compute scaled lenght of current line */ dx = fabs( edLineVec_[octaveCount]->lineEndpoints_[lineCurId][0] - edLineVec_[octaveCount]->lineEndpoints_[lineCurId][2] ); //x1-x2 @@ -831,10 +831,10 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines ) /* get known term from equation to be compared */ rho2 = (float) ( scale[octaveID] * fabs( edLineVec_[octaveID]->lineEquations_[lineIDInOctave][2] ) ); /* compute difference between known ters */ - near = fabs( rho1 - rho2 ); + diffNear = fabs( rho1 - rho2 ); /* two lines are not close in the image */ - if( near > nearThreshold ) + if( diffNear > diffNearThreshold ) { continue; } From 9d93d045890f7e7b784e38224b45a935795a3cbc Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Fri, 3 Apr 2015 16:56:42 +0300 Subject: [PATCH 06/21] Remove deprecated RST doc. --- modules/xfeatures2d/doc/xfeatures2d.rst | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 modules/xfeatures2d/doc/xfeatures2d.rst diff --git a/modules/xfeatures2d/doc/xfeatures2d.rst b/modules/xfeatures2d/doc/xfeatures2d.rst deleted file mode 100644 index a690f0922..000000000 --- a/modules/xfeatures2d/doc/xfeatures2d.rst +++ /dev/null @@ -1,11 +0,0 @@ -***************************************** -xfeatures2d. Extra 2D Features Framework -***************************************** - -.. highlight:: cpp - -.. toctree:: - :maxdepth: 2 - - extra_features - nonfree_features From a68027a408ace7ac1f9155ed2e79cac6bcea4049 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Fri, 3 Apr 2015 18:01:29 +0300 Subject: [PATCH 07/21] Fix AGAST function and documentation. --- modules/xfeatures2d/include/opencv2/xfeatures2d.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 0716f4742..1bff133a1 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -129,6 +129,11 @@ public: static Ptr create( int bytes = 32 ); }; +/** @brief The class implements the keypoint detector using AGAST algorithm by Elmar Mair. : + */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, int threshold, bool nonmaxSuppression, int type ); @@ -138,7 +143,7 @@ public: enum { AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, - THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, + THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001, }; CV_WRAP static Ptr create( int threshold=10, From eeb00c887a3db6ac533dd3bd28cb2abee89aea17 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Sat, 4 Apr 2015 09:57:24 +0300 Subject: [PATCH 08/21] More detailed documentation and proper cite. --- .../include/opencv2/xfeatures2d.hpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 1bff133a1..7ac50d9ee 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -129,14 +129,30 @@ public: static Ptr create( int bytes = 32 ); }; -/** @brief The class implements the keypoint detector using AGAST algorithm by Elmar Mair. : - */ +/** @overload */ CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, int threshold, bool nonmaxSuppression=true ); +/** @brief Detects corners using the AGAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the four neighborhoods as defined in the paper: +AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, +AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 + +Detects corners using the AGAST algorithm by @cite mair2010_agast . + + */ CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, int threshold, bool nonmaxSuppression, int type ); +/** @brief Wrapping class for feature detection using the AGAST method. : + */ class CV_EXPORTS_W AgastFeatureDetector : public Feature2D { public: From c3be5a0c117cd7977d400ba48abcd1d908661ca3 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 6 Apr 2015 22:35:59 +0300 Subject: [PATCH 09/21] Fix (typo) bug in soring routines. --- modules/xfeatures2d/src/agast_score.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/xfeatures2d/src/agast_score.cpp b/modules/xfeatures2d/src/agast_score.cpp index 521af8c67..fc4d26b70 100644 --- a/modules/xfeatures2d/src/agast_score.cpp +++ b/modules/xfeatures2d/src/agast_score.cpp @@ -118,8 +118,8 @@ int agast_cornerScore(const uchar* ptr, const i while(true) { - register const int cb = *pixel + b_test; - register const int c_b = *pixel - b_test; + register const int cb = *ptr + b_test; + register const int c_b = *ptr - b_test; if(ptr[offset0] > cb) if(ptr[offset2] > cb) if(ptr[offset4] > cb) @@ -2189,8 +2189,8 @@ int agast_cornerScore(const uchar* ptr, const while(true) { - register const int cb = *pixel + b_test; - register const int c_b = *pixel - b_test; + register const int cb = *ptr + b_test; + register const int c_b = *ptr - b_test; if(ptr[offset0] > cb) if(ptr[offset5] > cb) if(ptr[offset2] > cb) @@ -3401,8 +3401,8 @@ int agast_cornerScore(const uchar* ptr, const while(true) { - register const int cb = *pixel + b_test; - register const int c_b = *pixel - b_test; + register const int cb = *ptr + b_test; + register const int c_b = *ptr - b_test; if(ptr[offset0] > cb) if(ptr[offset5] > cb) if(ptr[offset2] < c_b) @@ -9031,8 +9031,8 @@ int agast_cornerScore(const uchar* ptr, const i while(true) { - register const int cb = *pixel + b_test; - register const int c_b = *pixel - b_test; + register const int cb = *ptr + b_test; + register const int c_b = *ptr - b_test; if(ptr[offset0] > cb) if(ptr[offset2] > cb) if(ptr[offset3] > cb) From c6ea6d126df18db691845b05971fd0e7b5906191 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Thu, 26 Mar 2015 15:44:23 +0300 Subject: [PATCH 10/21] Fix build of tools with hal module --- modules/adas/tools/fcw_detect/CMakeLists.txt | 2 +- modules/adas/tools/fcw_train/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/adas/tools/fcw_detect/CMakeLists.txt b/modules/adas/tools/fcw_detect/CMakeLists.txt index 604aec718..d2f2a2e11 100644 --- a/modules/adas/tools/fcw_detect/CMakeLists.txt +++ b/modules/adas/tools/fcw_detect/CMakeLists.txt @@ -13,7 +13,7 @@ endif() project(${the_target}) ocv_include_directories("${OpenCV_SOURCE_DIR}/include/opencv") -ocv_include_modules(${OPENCV_${the_target}_DEPS}) +ocv_include_modules_recurse(${OPENCV_${the_target}_DEPS}) file(GLOB ${the_target}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) diff --git a/modules/adas/tools/fcw_train/CMakeLists.txt b/modules/adas/tools/fcw_train/CMakeLists.txt index f1cbecf7b..5b1d78303 100644 --- a/modules/adas/tools/fcw_train/CMakeLists.txt +++ b/modules/adas/tools/fcw_train/CMakeLists.txt @@ -13,7 +13,7 @@ endif() project(${the_target}) ocv_include_directories("${OpenCV_SOURCE_DIR}/include/opencv") -ocv_include_modules(${OPENCV_${the_target}_DEPS}) +ocv_include_modules_recurse(${OPENCV_${the_target}_DEPS}) file(GLOB ${the_target}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) From cdddcc8237627f667d66daffb3fcb3af39a3e673 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 16 Apr 2015 22:52:05 +0300 Subject: [PATCH 11/21] fixed contrib code to match the HAL --- modules/optflow/src/motempl.cpp | 2 +- modules/rgbd/src/depth_to_3d.h | 4 ++-- modules/xfeatures2d/src/sift.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/optflow/src/motempl.cpp b/modules/optflow/src/motempl.cpp index 5d2ce76d4..738c87964 100644 --- a/modules/optflow/src/motempl.cpp +++ b/modules/optflow/src/motempl.cpp @@ -212,7 +212,7 @@ void calcMotionGradient( InputArray _mhi, OutputArray _mask, float* orient_row = orient.ptr(y); uchar* mask_row = mask.ptr(y); - fastAtan2(dY_max_row, dX_min_row, orient_row, size.width, true); + hal::fastAtan2(dY_max_row, dX_min_row, orient_row, size.width, true); // make orientation zero where the gradient is very small for( x = 0; x < size.width; x++ ) diff --git a/modules/rgbd/src/depth_to_3d.h b/modules/rgbd/src/depth_to_3d.h index a92cb32a2..97e786730 100644 --- a/modules/rgbd/src/depth_to_3d.h +++ b/modules/rgbd/src/depth_to_3d.h @@ -81,7 +81,7 @@ convertDepthToFloat(const cv::Mat& depth, const cv::Mat& mask, float scale, cv:: v_mat((int)n_points, 0) = (float)v; T depth_i = depth.at(v, u); - if (cvIsNaN(depth_i) || (depth_i == std::numeric_limits::min()) || (depth_i == std::numeric_limits::max())) + if (cvIsNaN((float)depth_i) || (depth_i == std::numeric_limits::min()) || (depth_i == std::numeric_limits::max())) z_mat((int)n_points, 0) = std::numeric_limits::quiet_NaN(); else z_mat((int)n_points, 0) = depth_i * scale; @@ -111,7 +111,7 @@ convertDepthToFloat(const cv::Mat& depth, float scale, const cv::Mat &uv_mat, cv { T depth_i = depth.at < T > ((int)(*uv_iter)[1], (int)(*uv_iter)[0]); - if (cvIsNaN(depth_i) || (depth_i == std::numeric_limits < T > ::min()) + if (cvIsNaN((float)depth_i) || (depth_i == std::numeric_limits < T > ::min()) || (depth_i == std::numeric_limits < T > ::max())) *z_mat_iter = std::numeric_limits::quiet_NaN(); else diff --git a/modules/xfeatures2d/src/sift.cpp b/modules/xfeatures2d/src/sift.cpp index 4ed1e4142..fc67c4d6e 100644 --- a/modules/xfeatures2d/src/sift.cpp +++ b/modules/xfeatures2d/src/sift.cpp @@ -337,9 +337,9 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius, len = k; // compute gradient values, orientations and the weights over the pixel neighborhood - exp(W, W, len); - fastAtan2(Y, X, Ori, len, true); - magnitude(X, Y, Mag, len); + hal::exp(W, W, len); + hal::fastAtan2(Y, X, Ori, len, true); + hal::magnitude(X, Y, Mag, len); for( k = 0; k < len; k++ ) { @@ -620,9 +620,9 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc } len = k; - fastAtan2(Y, X, Ori, len, true); - magnitude(X, Y, Mag, len); - exp(W, W, len); + hal::fastAtan2(Y, X, Ori, len, true); + hal::magnitude(X, Y, Mag, len); + hal::exp(W, W, len); for( k = 0; k < len; k++ ) { From a275cedd83d24e7e2c08425c65ac59fe7be9f6a4 Mon Sep 17 00:00:00 2001 From: yifita Date: Sat, 18 Apr 2015 14:12:44 +0200 Subject: [PATCH 12/21] added missing typePtr_DualTVL1OpticalFlow --- modules/matlab/include/opencv2/matlab/bridge.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/matlab/include/opencv2/matlab/bridge.hpp b/modules/matlab/include/opencv2/matlab/bridge.hpp index 64592ca4e..34faeae8e 100644 --- a/modules/matlab/include/opencv2/matlab/bridge.hpp +++ b/modules/matlab/include/opencv2/matlab/bridge.hpp @@ -85,6 +85,7 @@ typedef cv::Ptr Ptr_AlignMTB; typedef cv::Ptr Ptr_CalibrateDebevec; typedef cv::Ptr Ptr_CalibrateRobertson; typedef cv::Ptr Ptr_DenseOpticalFlow; +typedef cv::Ptr Ptr_DualTVL1OpticalFlow; typedef cv::Ptr Ptr_MergeDebevec; typedef cv::Ptr Ptr_MergeMertens; typedef cv::Ptr Ptr_MergeRobertson; @@ -468,6 +469,11 @@ public: Ptr_DenseOpticalFlow toPtrDenseOpticalFlow() { return Ptr_DenseOpticalFlow(); } operator Ptr_DenseOpticalFlow() { return toPtrDenseOpticalFlow(); } + // --------------------------- Ptr_DualTVL1OpticalFlow ------------------- + Bridge& operator=(const Ptr_DualTVL1OpticalFlow& ) { return *this; } + Ptr_DualTVL1OpticalFlow toPtrDualTVL1OpticalFlow() { return Ptr_DualTVL1OpticalFlow(); } + operator Ptr_DualTVL1OpticalFlow() { return toPtrDualTVL1OpticalFlow(); } + // --------------------------- Ptr_MergeDebevec ----------------------- Bridge& operator=(const Ptr_MergeDebevec& ) { return *this; } Ptr_MergeDebevec toPtrMergeDebevec() { return Ptr_MergeDebevec(); } From 459c05b732469f59d5bbf440fc9125ca25a57746 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Tue, 28 Apr 2015 18:12:57 +0300 Subject: [PATCH 13/21] Remove AGAST (for merger to upstream opencv) --- modules/xfeatures2d/doc/xfeatures2d.bib | 9 - .../include/opencv2/xfeatures2d.hpp | 47 - modules/xfeatures2d/perf/perf_agast.cpp | 41 - modules/xfeatures2d/src/agast.cpp | 7670 -------------- modules/xfeatures2d/src/agast_score.cpp | 9378 ----------------- modules/xfeatures2d/src/agast_score.hpp | 65 - modules/xfeatures2d/test/test_agast.cpp | 138 - 7 files changed, 17348 deletions(-) delete mode 100644 modules/xfeatures2d/perf/perf_agast.cpp delete mode 100644 modules/xfeatures2d/src/agast.cpp delete mode 100644 modules/xfeatures2d/src/agast_score.cpp delete mode 100644 modules/xfeatures2d/src/agast_score.hpp delete mode 100644 modules/xfeatures2d/test/test_agast.cpp diff --git a/modules/xfeatures2d/doc/xfeatures2d.bib b/modules/xfeatures2d/doc/xfeatures2d.bib index 0d3918923..f23c529ab 100644 --- a/modules/xfeatures2d/doc/xfeatures2d.bib +++ b/modules/xfeatures2d/doc/xfeatures2d.bib @@ -45,15 +45,6 @@ organization={Ieee} } -@inproceedings{mair2010_agast, - title={Adaptive and Generic Corner Detection Based on the Accelerated Segment Test"}, - author={"Elmar Mair and Gregory D. Hager and Darius Burschka and Michael Suppa and Gerhard Hirzinger"}, - year={"2010"}, - month={"September"}, - booktitle={"European Conference on Computer Vision (ECCV'10)"}, - url={"http://www6.in.tum.de/Main/ResearchAgast" -} - @incollection{LUCID, title={Locally uniform comparison image descriptor}, author={Ziegler, Andrew, Eric Christiansen, David Kriegman, and Serge J. Belongie} diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 7ac50d9ee..31afe7a12 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -129,53 +129,6 @@ public: static Ptr create( int bytes = 32 ); }; -/** @overload */ -CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, - int threshold, bool nonmaxSuppression=true ); - -/** @brief Detects corners using the AGAST algorithm - -@param image grayscale image where keypoints (corners) are detected. -@param keypoints keypoints detected on the image. -@param threshold threshold on difference between intensity of the central pixel and pixels of a -circle around this pixel. -@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners -(keypoints). -@param type one of the four neighborhoods as defined in the paper: -AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, -AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 - -Detects corners using the AGAST algorithm by @cite mair2010_agast . - - */ -CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, - int threshold, bool nonmaxSuppression, int type ); - -/** @brief Wrapping class for feature detection using the AGAST method. : - */ -class CV_EXPORTS_W AgastFeatureDetector : public Feature2D -{ -public: - enum - { - AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, - THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001, - }; - - CV_WRAP static Ptr create( int threshold=10, - bool nonmaxSuppression=true, - int type=AgastFeatureDetector::OAST_9_16 ); - - CV_WRAP virtual void setThreshold(int threshold) = 0; - CV_WRAP virtual int getThreshold() const = 0; - - CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; - CV_WRAP virtual bool getNonmaxSuppression() const = 0; - - CV_WRAP virtual void setType(int type) = 0; - CV_WRAP virtual int getType() const = 0; -}; - /** @brief Class implementing the locally uniform comparison image descriptor, described in @cite LUCID An image descriptor that can be computed very fast, while being diff --git a/modules/xfeatures2d/perf/perf_agast.cpp b/modules/xfeatures2d/perf/perf_agast.cpp deleted file mode 100644 index 4dc9e1566..000000000 --- a/modules/xfeatures2d/perf/perf_agast.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "perf_precomp.hpp" - -using namespace std; -using namespace cv; -using namespace cv::xfeatures2d; -using namespace perf; -using std::tr1::make_tuple; -using std::tr1::get; - -CV_ENUM(AgastType, AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, - AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16) - -typedef std::tr1::tuple File_Type_t; -typedef perf::TestBaseWithParam agast; - -#define AGAST_IMAGES \ - "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ - "stitching/a3.png" - -PERF_TEST_P(agast, detect, testing::Combine( - testing::Values(AGAST_IMAGES), - AgastType::all() - )) -{ - string filename = getDataPath(get<0>(GetParam())); - int type = get<1>(GetParam()); - Mat frame = imread(filename, IMREAD_GRAYSCALE); - - if (frame.empty()) - FAIL() << "Unable to load source image " << filename; - - declare.in(frame); - - Ptr fd = AgastFeatureDetector::create(20, true, type); - ASSERT_FALSE( fd.empty() ); - vector points; - - TEST_CYCLE() fd->detect(frame, points); - - SANITY_CHECK_KEYPOINTS(points); -} diff --git a/modules/xfeatures2d/src/agast.cpp b/modules/xfeatures2d/src/agast.cpp deleted file mode 100644 index a995e2a9d..000000000 --- a/modules/xfeatures2d/src/agast.cpp +++ /dev/null @@ -1,7670 +0,0 @@ -/* This is AGAST and OAST, an optimal and accelerated corner detector - based on the accelerated segment tests - Below is the original copyright and the references */ - -/* -Copyright (C) 2010 Elmar Mair -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - *Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - *Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - *Neither the name of the University of Cambridge nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -The references are: - * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, - Elmar Mair and Gregory D. Hager and Darius Burschka - and Michael Suppa and Gerhard Hirzinger ECCV 2010 - URL: http://www6.in.tum.de/Main/ResearchAgast -*/ - -#include "precomp.hpp" -#include "agast_score.hpp" - -#ifdef _WIN32 -#pragma warning( disable : 4127 ) -#endif - -namespace cv -{ -namespace xfeatures2d -{ - -static void AGAST_5_8(InputArray _img, std::vector& keypoints, int threshold) -{ - - cv::Mat img; - if(!_img.getMat().isContinuous()) - img = _img.getMat().clone(); - else - img = _img.getMat(); - - size_t total = 0; - int xsize = img.cols; - int ysize = img.rows; - size_t nExpectedCorners = keypoints.capacity(); - register int x, y; - register int xsizeB = xsize - 2; - register int ysizeB = ysize - 1; - register int width; - - keypoints.resize(0); - - int pixel_5_8_[16]; - makeAgastOffsets(pixel_5_8_, (int)img.step, AgastFeatureDetector::AGAST_5_8); - - register short offset0 = (short) pixel_5_8_[0]; - register short offset1 = (short) pixel_5_8_[1]; - register short offset2 = (short) pixel_5_8_[2]; - register short offset3 = (short) pixel_5_8_[3]; - register short offset4 = (short) pixel_5_8_[4]; - register short offset5 = (short) pixel_5_8_[5]; - register short offset6 = (short) pixel_5_8_[6]; - register short offset7 = (short) pixel_5_8_[7]; - - width = xsize; - - for(y = 1; y < ysizeB; y++) - { - x = 0; - while(true) - { - homogeneous: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - if(ptr[offset7] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset1] > cb) - goto success_homogeneous; - else - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else if(ptr[offset0] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - } - } - structured: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset1] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto structured; - else - goto homogeneous; - else if(ptr[offset0] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto structured; - else - if(ptr[offset7] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - } - } - success_homogeneous: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto homogeneous; - success_structured: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto structured; - } - } -} - -static void AGAST_7_12d(InputArray _img, std::vector& keypoints, int threshold) -{ - cv::Mat img; - if(!_img.getMat().isContinuous()) - img = _img.getMat().clone(); - else - img = _img.getMat(); - - size_t total = 0; - int xsize = img.cols; - int ysize = img.rows; - size_t nExpectedCorners = keypoints.capacity(); - register int x, y; - register int xsizeB = xsize - 4; - register int ysizeB = ysize - 3; - register int width; - - keypoints.resize(0); - - int pixel_7_12d_[16]; - makeAgastOffsets(pixel_7_12d_, (int)img.step, AgastFeatureDetector::AGAST_7_12d); - - register short offset0 = (short) pixel_7_12d_[0]; - register short offset1 = (short) pixel_7_12d_[1]; - register short offset2 = (short) pixel_7_12d_[2]; - register short offset3 = (short) pixel_7_12d_[3]; - register short offset4 = (short) pixel_7_12d_[4]; - register short offset5 = (short) pixel_7_12d_[5]; - register short offset6 = (short) pixel_7_12d_[6]; - register short offset7 = (short) pixel_7_12d_[7]; - register short offset8 = (short) pixel_7_12d_[8]; - register short offset9 = (short) pixel_7_12d_[9]; - register short offset10 = (short) pixel_7_12d_[10]; - register short offset11 = (short) pixel_7_12d_[11]; - - width = xsize; - - for(y = 3; y < ysizeB; y++) - { - x = 2; - while(true) - { - homogeneous: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_homogeneous; - else - if(ptr[offset7] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - goto success_homogeneous; - else - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else if(ptr[offset0] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto success_homogeneous; - else - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset2] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - } - } - structured: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset2] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else if(ptr[offset0] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset2] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - } - } - success_homogeneous: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto homogeneous; - success_structured: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto structured; - } - } -} - -static void AGAST_7_12s(InputArray _img, std::vector& keypoints, int threshold) -{ - cv::Mat img; - if(!_img.getMat().isContinuous()) - img = _img.getMat().clone(); - else - img = _img.getMat(); - - size_t total = 0; - int xsize = img.cols; - int ysize = img.rows; - size_t nExpectedCorners = keypoints.capacity(); - register int x, y; - register int xsizeB=xsize - 3; //2, +1 due to faster test x>xsizeB - register int ysizeB=ysize - 2; - register int width; - - keypoints.resize(0); - - int pixel_7_12s_[16]; - makeAgastOffsets(pixel_7_12s_, (int)img.step, AgastFeatureDetector::AGAST_7_12s); - - register short offset0 = (short) pixel_7_12s_[0]; - register short offset1 = (short) pixel_7_12s_[1]; - register short offset2 = (short) pixel_7_12s_[2]; - register short offset3 = (short) pixel_7_12s_[3]; - register short offset4 = (short) pixel_7_12s_[4]; - register short offset5 = (short) pixel_7_12s_[5]; - register short offset6 = (short) pixel_7_12s_[6]; - register short offset7 = (short) pixel_7_12s_[7]; - register short offset8 = (short) pixel_7_12s_[8]; - register short offset9 = (short) pixel_7_12s_[9]; - register short offset10 = (short) pixel_7_12s_[10]; - register short offset11 = (short) pixel_7_12s_[11]; - - width = xsize; - - for(y = 2; y < ysizeB; y++) - { - x = 1; - while(true) - { - homogeneous: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - goto success_homogeneous; - else - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else if(ptr[offset0] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto success_homogeneous; - else - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_homogeneous; - else - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_homogeneous; - else - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_homogeneous; - else - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - if(ptr[offset1] < c_b) - if(ptr[offset2] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - else - goto homogeneous; - } - } - structured: - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset7] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else if(ptr[offset0] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - if(ptr[offset11] > cb) - goto success_structured; - else - goto homogeneous; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto success_structured; - else - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto success_structured; - else - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto success_structured; - else - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto success_structured; - else - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - if(ptr[offset1] < c_b) - if(ptr[offset2] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto success_structured; - else - goto structured; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto success_structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto structured; - else - goto homogeneous; - } - } - success_homogeneous: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto homogeneous; - success_structured: - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - goto structured; - } - } -} - -static void OAST_9_16(InputArray _img, std::vector& keypoints, int threshold) -{ - cv::Mat img; - if(!_img.getMat().isContinuous()) - img = _img.getMat().clone(); - else - img = _img.getMat(); - - size_t total = 0; - int xsize = img.cols; - int ysize = img.rows; - size_t nExpectedCorners = keypoints.capacity(); - register int x, y; - register int xsizeB=xsize - 4; - register int ysizeB=ysize - 3; - register int width; - - keypoints.resize(0); - - int pixel_9_16_[16]; - makeAgastOffsets(pixel_9_16_, (int)img.step, AgastFeatureDetector::OAST_9_16); - - register short offset0 = (short) pixel_9_16_[0]; - register short offset1 = (short) pixel_9_16_[1]; - register short offset2 = (short) pixel_9_16_[2]; - register short offset3 = (short) pixel_9_16_[3]; - register short offset4 = (short) pixel_9_16_[4]; - register short offset5 = (short) pixel_9_16_[5]; - register short offset6 = (short) pixel_9_16_[6]; - register short offset7 = (short) pixel_9_16_[7]; - register short offset8 = (short) pixel_9_16_[8]; - register short offset9 = (short) pixel_9_16_[9]; - register short offset10 = (short) pixel_9_16_[10]; - register short offset11 = (short) pixel_9_16_[11]; - register short offset12 = (short) pixel_9_16_[12]; - register short offset13 = (short) pixel_9_16_[13]; - register short offset14 = (short) pixel_9_16_[14]; - register short offset15 = (short) pixel_9_16_[15]; - - width = xsize; - - for(y = 3; y < ysizeB; y++) - { - x = 2; - while(true) - { - x++; - if(x > xsizeB) - break; - else - { - register const unsigned char* const ptr = img.ptr() + y*width + x; - register const int cb = *ptr + threshold; - register const int c_b = *ptr - threshold; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - {} - else - if(ptr[offset15] > cb) - {} - else - continue; - else - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset7] < c_b) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset13] > cb) - {} - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset14] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset13] > cb) - {} - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset5] < c_b) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - {} - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset12] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - {} - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset12] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset4] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset10] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - {} - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - {} - else - if(ptr[offset12] < c_b) - {} - else - continue; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset10] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - {} - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - {} - else - if(ptr[offset14] < c_b) - {} - else - continue; - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - {} - else - if(ptr[offset10] < c_b) - {} - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - {} - else - if(ptr[offset12] < c_b) - {} - else - continue; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset0] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - {} - else - if(ptr[offset10] > cb) - {} - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset2] < c_b) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - {} - else - if(ptr[offset12] > cb) - {} - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - {} - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset4] < c_b) - if(ptr[offset5] > cb) - if(ptr[offset12] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - {} - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset5] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset14] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset13] < c_b) - {} - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset7] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - {} - else - if(ptr[offset15] < c_b) - {} - else - continue; - else - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset6] < c_b) - {} - else - if(ptr[offset13] < c_b) - {} - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset6] > cb) - {} - else - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - {} - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset11] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - {} - else - if(ptr[offset14] > cb) - {} - else - continue; - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - {} - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - {} - else - if(ptr[offset12] > cb) - {} - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset1] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - {} - else - if(ptr[offset10] > cb) - {} - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - {} - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - {} - else - if(ptr[offset10] < c_b) - {} - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - {} - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - {} - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - else - continue; - } - if(total == nExpectedCorners) - { - if(nExpectedCorners == 0) - { - nExpectedCorners = 512; - keypoints.reserve(nExpectedCorners); - } - else - { - nExpectedCorners *= 2; - keypoints.reserve(nExpectedCorners); - } - } - keypoints.push_back(KeyPoint(Point2f((float)x, (float)y), 1.0f)); - total++; - } - } -} - - -void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression) -{ - AGAST(_img, keypoints, threshold, nonmax_suppression, AgastFeatureDetector::OAST_9_16); -} - - -class AgastFeatureDetector_Impl : public AgastFeatureDetector -{ -public: - AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, int _type ) - : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) - {} - - void detect( InputArray _image, std::vector& keypoints, InputArray _mask ) - { - Mat mask = _mask.getMat(), grayImage; - UMat ugrayImage; - _InputArray gray = _image; - if( _image.type() != CV_8U ) - { - _OutputArray ogray = _image.isUMat() ? _OutputArray(ugrayImage) : _OutputArray(grayImage); - cvtColor( _image, ogray, COLOR_BGR2GRAY ); - gray = ogray; - } - AGAST( gray, keypoints, threshold, nonmaxSuppression, type ); - KeyPointsFilter::runByPixelsMask( keypoints, mask ); - } - - void set(int prop, double value) - { - if(prop == THRESHOLD) - threshold = cvRound(value); - else if(prop == NONMAX_SUPPRESSION) - nonmaxSuppression = value != 0; - else - CV_Error(Error::StsBadArg, ""); - } - - double get(int prop) const - { - if(prop == THRESHOLD) - return threshold; - if(prop == NONMAX_SUPPRESSION) - return nonmaxSuppression; - CV_Error(Error::StsBadArg, ""); - return 0; - } - - void setThreshold(int threshold_) { threshold = threshold_; } - int getThreshold() const { return threshold; } - - void setNonmaxSuppression(bool f) { nonmaxSuppression = f; } - bool getNonmaxSuppression() const { return nonmaxSuppression; } - - void setType(int type_) { type = type_; } - int getType() const { return type; } - - int threshold; - bool nonmaxSuppression; - int type; -}; - -Ptr AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type ) -{ - return makePtr(threshold, nonmaxSuppression, type); -} - -void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression, int type) -{ - // detect - switch(type) { - case AgastFeatureDetector::AGAST_5_8: - AGAST_5_8(_img, keypoints, threshold); - break; - case AgastFeatureDetector::AGAST_7_12d: - AGAST_7_12d(_img, keypoints, threshold); - break; - case AgastFeatureDetector::AGAST_7_12s: - AGAST_7_12s(_img, keypoints, threshold); - break; - case AgastFeatureDetector::OAST_9_16: - OAST_9_16(_img, keypoints, threshold); - break; - } - - cv::Mat img = _img.getMat(); - - // score - int pixel_[16]; - makeAgastOffsets(pixel_, (int)img.step, type); - - std::vector::iterator kpt; - for(kpt = keypoints.begin(); kpt != keypoints.end(); kpt++) - { - switch(type) { - case AgastFeatureDetector::AGAST_5_8: - kpt->response = (float)agast_cornerScore - (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); - break; - case AgastFeatureDetector::AGAST_7_12d: - kpt->response = (float)agast_cornerScore - (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); - break; - case AgastFeatureDetector::AGAST_7_12s: - kpt->response = (float)agast_cornerScore - (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); - break; - case AgastFeatureDetector::OAST_9_16: - kpt->response = (float)agast_cornerScore - (&img.at((int)kpt->pt.y, (int)kpt->pt.x), pixel_, threshold); - break; - } - } - // suppression - if(nonmax_suppression) - { - size_t j; - size_t curr_idx; - size_t lastRow = 0, next_lastRow = 0; - size_t num_Corners = keypoints.size(); - size_t lastRowCorner_ind = 0, next_lastRowCorner_ind = 0; - - std::vector nmsFlags; - std::vector::iterator nmsFlags_p; - std::vector::iterator currCorner_nms; - std::vector::const_iterator currCorner; - - currCorner = keypoints.begin(); - - nmsFlags.resize((int)num_Corners); - nmsFlags_p = nmsFlags.begin(); - - // set all flags to MAXIMUM - for(j = num_Corners; j > 0; j--) - *nmsFlags_p++ = -1; - nmsFlags_p = nmsFlags.begin(); - - for(curr_idx = 0; curr_idx < num_Corners; curr_idx++) - { - int t; - // check above - if(lastRow + 1 < currCorner->pt.y) - { - lastRow = next_lastRow; - lastRowCorner_ind = next_lastRowCorner_ind; - } - if(next_lastRow != currCorner->pt.y) - { - next_lastRow = (size_t) currCorner->pt.y; - next_lastRowCorner_ind = curr_idx; - } - if(lastRow + 1 == currCorner->pt.y) - { - // find the corner above the current one - while( (keypoints[lastRowCorner_ind].pt.x < currCorner->pt.x) - && (keypoints[lastRowCorner_ind].pt.y == lastRow) ) - lastRowCorner_ind++; - - if( (keypoints[lastRowCorner_ind].pt.x == currCorner->pt.x) - && (lastRowCorner_ind != curr_idx) ) - { - size_t w = lastRowCorner_ind; - // find the maximum in this block - while(nmsFlags[w] != -1) - w = nmsFlags[w]; - - if(keypoints[curr_idx].response < keypoints[w].response) - nmsFlags[curr_idx] = (int)w; - else - nmsFlags[w] = (int)curr_idx; - } - } - - // check left - t = (int)curr_idx - 1; - if( (curr_idx != 0) && (keypoints[t].pt.y == currCorner->pt.y) - && (keypoints[t].pt.x + 1 == currCorner->pt.x) ) - { - int currCornerMaxAbove_ind = nmsFlags[curr_idx]; - // find the maximum in that area - while(nmsFlags[t] != -1) - t = nmsFlags[t]; - // no maximum above - if(currCornerMaxAbove_ind == -1) - { - if((size_t)t != curr_idx) - { - if ( keypoints[curr_idx].response < keypoints[t].response ) - nmsFlags[curr_idx] = t; - else - nmsFlags[t] = (int)curr_idx; - } - } - else // maximum above - { - if(t != currCornerMaxAbove_ind) - { - if(keypoints[currCornerMaxAbove_ind].response < keypoints[t].response) - { - nmsFlags[currCornerMaxAbove_ind] = t; - nmsFlags[curr_idx] = t; - } - else - { - nmsFlags[t] = currCornerMaxAbove_ind; - nmsFlags[curr_idx] = currCornerMaxAbove_ind; - } - } - } - } - currCorner++; - } - - // removing non-maximum corners - for(curr_idx = 0; curr_idx < num_Corners; curr_idx++) - { - if(*nmsFlags_p++ != -1) - keypoints.erase(keypoints.begin() + curr_idx); - } - } -} - -} -} // END NAMESPACE CV diff --git a/modules/xfeatures2d/src/agast_score.cpp b/modules/xfeatures2d/src/agast_score.cpp deleted file mode 100644 index fc4d26b70..000000000 --- a/modules/xfeatures2d/src/agast_score.cpp +++ /dev/null @@ -1,9378 +0,0 @@ -/* This is AGAST and OAST, an optimal and accelerated corner detector - based on the accelerated segment tests - Below is the original copyright and the references */ - -/* -Copyright (C) 2010 Elmar Mair -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - *Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - *Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - *Neither the name of the University of Cambridge nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -The references are: - * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, - Elmar Mair and Gregory D. Hager and Darius Burschka - and Michael Suppa and Gerhard Hirzinger ECCV 2010 - URL: http://www6.in.tum.de/Main/ResearchAgast -*/ - -#include "agast_score.hpp" - -#ifdef _WIN32 -#pragma warning( disable : 4127 ) -#endif - -namespace cv -{ -namespace xfeatures2d -{ - -void makeAgastOffsets(int pixel[16], int rowStride, int type) -{ - static const int offsets16[][2] = - { - {-3, 0}, {-3, -1}, {-2, -2}, {-1, -3}, {0, -3}, { 1, -3}, { 2, -2}, { 3, -1}, - { 3, 0}, { 3, 1}, { 2, 2}, { 1, 3}, {0, 3}, {-1, 3}, {-2, 2}, {-3, 1} - }; - - static const int offsets12d[][2] = - { - {-3, 0}, {-2, -1}, {-1, -2}, {0, -3}, { 1, -2}, { 2, -1}, - { 3, 0}, { 2, 1}, { 1, 2}, {0, 3}, {-1, 2}, {-2, 1} - }; - - static const int offsets12s[][2] = - { - {-2, 0}, {-2, -1}, {-1, -2}, {0, -2}, { 1, -2}, { 2, -1}, - { 2, 0}, { 2, 1}, { 1, 2}, {0, 2}, {-1, 2}, {-2, 1} - }; - - static const int offsets8[][2] = - { - {-1, 0}, {-1, -1}, {0, -1}, { 1, -1}, - { 1, 0}, { 1, 1}, {0, 1}, {-1, 1} - }; - - const int (*offsets)[2] = type == AgastFeatureDetector::OAST_9_16 ? offsets16 : - type == AgastFeatureDetector::AGAST_7_12d ? offsets12d : - type == AgastFeatureDetector::AGAST_7_12s ? offsets12s : - type == AgastFeatureDetector::AGAST_5_8 ? offsets8 : 0; - - CV_Assert(pixel && offsets); - - int k = 0; - for( ; k < 16; k++ ) - pixel[k] = offsets[k][0] + offsets[k][1] * rowStride; -} - -// 16 pixel mask -template<> -int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) -{ - int bmin = threshold; - int bmax = 255; - int b_test = (bmax + bmin) / 2; - - register short offset0 = (short) pixel[0]; - register short offset1 = (short) pixel[1]; - register short offset2 = (short) pixel[2]; - register short offset3 = (short) pixel[3]; - register short offset4 = (short) pixel[4]; - register short offset5 = (short) pixel[5]; - register short offset6 = (short) pixel[6]; - register short offset7 = (short) pixel[7]; - register short offset8 = (short) pixel[8]; - register short offset9 = (short) pixel[9]; - register short offset10 = (short) pixel[10]; - register short offset11 = (short) pixel[11]; - register short offset12 = (short) pixel[12]; - register short offset13 = (short) pixel[13]; - register short offset14 = (short) pixel[14]; - register short offset15 = (short) pixel[15]; - - while(true) - { - register const int cb = *ptr + b_test; - register const int c_b = *ptr - b_test; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset7] < c_b) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset14] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset5] < c_b) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset12] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset12] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset4] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset10] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset12] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset10] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - goto is_a_corner; - else - if(ptr[offset14] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset5] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset12] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset0] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset2] < c_b) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset12] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset4] < c_b) - if(ptr[offset5] > cb) - if(ptr[offset12] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset5] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset14] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset7] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset10] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - goto is_a_corner; - else - if(ptr[offset14] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset12] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset9] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset12] > cb) - if(ptr[offset13] > cb) - if(ptr[offset14] > cb) - if(ptr[offset15] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset12] < c_b) - if(ptr[offset13] < c_b) - if(ptr[offset14] < c_b) - if(ptr[offset15] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - - is_a_corner: - bmin = b_test; - goto end; - - is_not_a_corner: - bmax = b_test; - goto end; - - end: - - if(bmin == bmax - 1 || bmin == bmax) - return bmin; - b_test = (bmin + bmax) / 2; - } -} - -// 12 pixel mask in diamond format -template<> -int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) -{ - int bmin = threshold; - int bmax = 255; - int b_test = (bmax + bmin)/2; - - register short offset0 = (short) pixel[0]; - register short offset1 = (short) pixel[1]; - register short offset2 = (short) pixel[2]; - register short offset3 = (short) pixel[3]; - register short offset4 = (short) pixel[4]; - register short offset5 = (short) pixel[5]; - register short offset6 = (short) pixel[6]; - register short offset7 = (short) pixel[7]; - register short offset8 = (short) pixel[8]; - register short offset9 = (short) pixel[9]; - register short offset10 = (short) pixel[10]; - register short offset11 = (short) pixel[11]; - - while(true) - { - register const int cb = *ptr + b_test; - register const int c_b = *ptr - b_test; - if(ptr[offset0] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset2] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset0] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset11] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset9] > cb) - if(ptr[offset6] > cb) - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset2] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset2] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - - is_a_corner: - bmin = b_test; - goto end; - - is_not_a_corner: - bmax = b_test; - goto end; - - end: - - if(bmin == bmax - 1 || bmin == bmax) - return bmin; - b_test = (bmin + bmax) / 2; - } -} - -//12 pixel mask in square format -template<> -int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) -{ - int bmin = threshold; - int bmax = 255; - int b_test = (bmax + bmin)/2; - - register short offset0 = (short) pixel[0]; - register short offset1 = (short) pixel[1]; - register short offset2 = (short) pixel[2]; - register short offset3 = (short) pixel[3]; - register short offset4 = (short) pixel[4]; - register short offset5 = (short) pixel[5]; - register short offset6 = (short) pixel[6]; - register short offset7 = (short) pixel[7]; - register short offset8 = (short) pixel[8]; - register short offset9 = (short) pixel[9]; - register short offset10 = (short) pixel[10]; - register short offset11 = (short) pixel[11]; - - while(true) - { - register const int cb = *ptr + b_test; - register const int c_b = *ptr - b_test; - if(ptr[offset0] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset2] < c_b) - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset3] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset7] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset0] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset2] > cb) - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset2] > cb) - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset9] > cb) - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset4] < c_b) - if(ptr[offset10] > cb) - if(ptr[offset8] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset9] > cb) - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset7] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset9] > cb) - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] > cb) - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset2] > cb) - if(ptr[offset9] > cb) - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] < c_b) - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] < c_b) - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset8] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset8] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset3] < c_b) - goto is_a_corner; - else - if(ptr[offset10] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] < c_b) - if(ptr[offset11] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset2] < c_b) - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset2] > cb) - if(ptr[offset9] < c_b) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset8] > cb) - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset8] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset9] < c_b) - goto is_not_a_corner; - else - if(ptr[offset9] > cb) - if(ptr[offset1] > cb) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - goto is_not_a_corner; - else - if(ptr[offset6] > cb) - if(ptr[offset8] > cb) - if(ptr[offset4] > cb) - if(ptr[offset3] > cb) - goto is_a_corner; - else - if(ptr[offset10] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset10] > cb) - if(ptr[offset11] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - - is_a_corner: - bmin = b_test; - goto end; - - is_not_a_corner: - bmax = b_test; - goto end; - - end: - - if(bmin == bmax - 1 || bmin == bmax) - return bmin; - b_test = (bmin + bmax) / 2; - } -} - -// 8 pixel mask -template<> -int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold) -{ - int bmin = threshold; - int bmax = 255; - int b_test = (bmax + bmin)/2; - - register short offset0 = (short) pixel[0]; - register short offset1 = (short) pixel[1]; - register short offset2 = (short) pixel[2]; - register short offset3 = (short) pixel[3]; - register short offset4 = (short) pixel[4]; - register short offset5 = (short) pixel[5]; - register short offset6 = (short) pixel[6]; - register short offset7 = (short) pixel[7]; - - while(true) - { - register const int cb = *ptr + b_test; - register const int c_b = *ptr - b_test; - if(ptr[offset0] > cb) - if(ptr[offset2] > cb) - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - if(ptr[offset7] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset5] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset7] > cb) - if(ptr[offset6] > cb) - if(ptr[offset1] > cb) - goto is_a_corner; - else - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else if(ptr[offset0] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset7] > cb) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset6] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] > cb) - if(ptr[offset3] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset5] < c_b) - if(ptr[offset7] < c_b) - if(ptr[offset6] < c_b) - if(ptr[offset1] < c_b) - goto is_a_corner; - else - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] > cb) - if(ptr[offset5] > cb) - if(ptr[offset2] > cb) - if(ptr[offset1] > cb) - if(ptr[offset4] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] > cb) - if(ptr[offset4] > cb) - if(ptr[offset6] > cb) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset3] < c_b) - if(ptr[offset5] < c_b) - if(ptr[offset2] < c_b) - if(ptr[offset1] < c_b) - if(ptr[offset4] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - if(ptr[offset7] < c_b) - if(ptr[offset4] < c_b) - if(ptr[offset6] < c_b) - goto is_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - else - goto is_not_a_corner; - - is_a_corner: - bmin=b_test; - goto end; - - is_not_a_corner: - bmax=b_test; - goto end; - - end: - - if(bmin == bmax - 1 || bmin == bmax) - return bmin; - b_test = (bmin + bmax) / 2; - } -} - -} -} // namespace cv diff --git a/modules/xfeatures2d/src/agast_score.hpp b/modules/xfeatures2d/src/agast_score.hpp deleted file mode 100644 index f00abbe53..000000000 --- a/modules/xfeatures2d/src/agast_score.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* This is AGAST and OAST, an optimal and accelerated corner detector - based on the accelerated segment tests - Below is the original copyright and the references */ - -/* -Copyright (C) 2010 Elmar Mair -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - *Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - *Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - *Neither the name of the University of Cambridge nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -The references are: - * Adaptive and Generic Corner Detection Based on the Accelerated Segment Test, - Elmar Mair and Gregory D. Hager and Darius Burschka - and Michael Suppa and Gerhard Hirzinger ECCV 2010 - URL: http://www6.in.tum.de/Main/ResearchAgast -*/ - - -#ifndef __OPENCV_FEATURES_2D_AGAST_HPP__ -#define __OPENCV_FEATURES_2D_AGAST_HPP__ - -#ifdef __cplusplus - -#include "precomp.hpp" -namespace cv -{ -namespace xfeatures2d -{ - -void makeAgastOffsets(int pixel[16], int row_stride, int type); - -template -int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold); - -} -} -#endif -#endif diff --git a/modules/xfeatures2d/test/test_agast.cpp b/modules/xfeatures2d/test/test_agast.cpp deleted file mode 100644 index db6dbdc57..000000000 --- a/modules/xfeatures2d/test/test_agast.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "test_precomp.hpp" - -using namespace std; -using namespace cv; -using namespace cv::xfeatures2d; - -class CV_AgastTest : public cvtest::BaseTest -{ -public: - CV_AgastTest(); - ~CV_AgastTest(); -protected: - void run(int); -}; - -CV_AgastTest::CV_AgastTest() {} -CV_AgastTest::~CV_AgastTest() {} - -void CV_AgastTest::run( int ) -{ - for(int type=0; type <= 2; ++type) { - Mat image1 = imread(string(ts->get_data_path()) + "inpaint/orig.png"); - Mat image2 = imread(string(ts->get_data_path()) + "cameracalibration/chess9.png"); - string xml = string(ts->get_data_path()) + format("agast/result%d.xml", type); - - if (image1.empty() || image2.empty()) - { - ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); - return; - } - - Mat gray1, gray2; - cvtColor(image1, gray1, COLOR_BGR2GRAY); - cvtColor(image2, gray2, COLOR_BGR2GRAY); - - vector keypoints1; - vector keypoints2; - AGAST(gray1, keypoints1, 30, true, type); - AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type); - - for(size_t i = 0; i < keypoints1.size(); ++i) - { - const KeyPoint& kp = keypoints1[i]; - cv::circle(image1, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); - } - - for(size_t i = 0; i < keypoints2.size(); ++i) - { - const KeyPoint& kp = keypoints2[i]; - cv::circle(image2, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); - } - - Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8U, &keypoints1[0]); - Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8U, &keypoints2[0]); - - FileStorage fs(xml, FileStorage::READ); - if (!fs.isOpened()) - { - fs.open(xml, FileStorage::WRITE); - if (!fs.isOpened()) - { - ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); - return; - } - fs << "exp_kps1" << kps1; - fs << "exp_kps2" << kps2; - fs.release(); - fs.open(xml, FileStorage::READ); - if (!fs.isOpened()) - { - ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); - return; - } - } - - Mat exp_kps1, exp_kps2; - read( fs["exp_kps1"], exp_kps1, Mat() ); - read( fs["exp_kps2"], exp_kps2, Mat() ); - fs.release(); - - if ( exp_kps1.size != kps1.size || 0 != cvtest::norm(exp_kps1, kps1, NORM_L2) || - exp_kps2.size != kps2.size || 0 != cvtest::norm(exp_kps2, kps2, NORM_L2)) - { - ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); - return; - } - - /*cv::namedWindow("Img1"); cv::imshow("Img1", image1); - cv::namedWindow("Img2"); cv::imshow("Img2", image2); - cv::waitKey(0);*/ - } - - ts->set_failed_test_info(cvtest::TS::OK); -} - -TEST(Features2d_AGAST, regression) { CV_AgastTest test; test.safe_run(); } From 9d38de38b2d26734cfc948108c33c3c2cdc22dd5 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Tue, 5 May 2015 18:56:45 +0300 Subject: [PATCH 14/21] fixed compile error and warning --- modules/tracking/src/TrackingFunctionPF.hpp | 1 + modules/xphoto/src/gcgraph.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/tracking/src/TrackingFunctionPF.hpp b/modules/tracking/src/TrackingFunctionPF.hpp index 5b5461ae7..0f7b66e56 100644 --- a/modules/tracking/src/TrackingFunctionPF.hpp +++ b/modules/tracking/src/TrackingFunctionPF.hpp @@ -9,6 +9,7 @@ namespace cv{ public: TrackingFunctionPF(const Mat& chosenRect); void update(const Mat& image); + int getDims() const { return 4; } double calc(const double* x) const; void correctParams(double* pt)const; private: diff --git a/modules/xphoto/src/gcgraph.hpp b/modules/xphoto/src/gcgraph.hpp index 639373085..513e9c2d1 100644 --- a/modules/xphoto/src/gcgraph.hpp +++ b/modules/xphoto/src/gcgraph.hpp @@ -254,7 +254,7 @@ TWeight GCGraph::maxFlow() minWeight = MIN(minWeight, weight); CV_Assert( minWeight > 0 ); } - weight = abs( TWeight(v->weight) ); + weight = std::abs( TWeight(v->weight) ); minWeight = MIN(minWeight, weight); CV_Assert( minWeight > 0 ); } From 5785a6a58a869b5bac44586e15c67ae1bfcee33f Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 11 May 2015 15:17:29 +0300 Subject: [PATCH 15/21] Add DAISY descriptor for wide-baseline / keypoints. --- modules/xfeatures2d/doc/xfeatures2d.bib | 11 + .../include/opencv2/xfeatures2d.hpp | 31 + modules/xfeatures2d/perf/perf_daisy.cpp | 33 + modules/xfeatures2d/src/daisy.cpp | 2054 +++++++++++++++++ modules/xfeatures2d/test/test_features2d.cpp | 7 + .../test_rotation_and_scale_invariance.cpp | 18 + 6 files changed, 2154 insertions(+) create mode 100644 modules/xfeatures2d/perf/perf_daisy.cpp create mode 100644 modules/xfeatures2d/src/daisy.cpp diff --git a/modules/xfeatures2d/doc/xfeatures2d.bib b/modules/xfeatures2d/doc/xfeatures2d.bib index f23c529ab..bbfaadde5 100644 --- a/modules/xfeatures2d/doc/xfeatures2d.bib +++ b/modules/xfeatures2d/doc/xfeatures2d.bib @@ -53,3 +53,14 @@ year={2012} publisher={NIPS} } + +@article{Tola10, + author = "E. Tola and V. Lepetit and P. Fua", + title = {{DAISY: An Efficient Dense Descriptor Applied to Wide Baseline Stereo}}, + journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence", + year = 2010, + month = "May", + pages = "815--830", + volume = "32", + number = "5" +} diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 31afe7a12..4241a1f7b 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -144,6 +144,37 @@ public: static Ptr create(const int lucid_kernel, const int blur_kernel); }; +/** @brief Class implementing DAISY descriptor, described in @cite Tola10 + +@param radius radius of the descriptor at the initial scale +@param q_radius amount of radial range division quantity +@param q_theta amount of angular range division quantity +@param q_hist amount of gradient orientations range division quantity +@param mode choose computation mode of descriptors where +DAISY::ONLY_KEYS means to compute descriptors only for keypoints in the list (default) and +DAISY::COMP_FULL will compute descriptors for all pixels in the given image +@param norm choose descriptors normalization type, where +DAISY::NRM_NONE will not do any normalization (default), +DAISY::NRM_PARTIAL mean that histograms are normalized independently for L2 norm equal to 1.0, +DAISY::NRM_FULL mean that descriptors are normalized for L2 norm equal to 1.0, +DAISY::NRM_SIFT mean that descriptors are normalized for L2 norm equal to 1.0 but no individual one is bigger than 0.154 as in SIFT +@param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image +@param interpolation switch to disable interpolation for speed improvement at minor quality loss +@param use_orientation sample patterns using keypoints orientation, disabled by default. + + */ +class CV_EXPORTS DAISY : public DescriptorExtractor +{ +public: + enum + { + ONLY_KEYS = 0, COMP_FULL = 1, + NRM_NONE = 100, NRM_PARTIAL = 101, NRM_FULL = 102, NRM_SIFT = 103, + }; + static Ptr create( float radius = 15, int q_radius = 3, int q_theta = 8, + int q_hist = 8, int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, + InputArray H = noArray() , bool interpolation = true, bool use_orientation = false ); +}; //! @} diff --git a/modules/xfeatures2d/perf/perf_daisy.cpp b/modules/xfeatures2d/perf/perf_daisy.cpp new file mode 100644 index 000000000..bb60b8e78 --- /dev/null +++ b/modules/xfeatures2d/perf/perf_daisy.cpp @@ -0,0 +1,33 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace cv::xfeatures2d; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +typedef perf::TestBaseWithParam daisy; + +#define DAISY_IMAGES \ + "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ + "stitching/a3.png" + +PERF_TEST_P(daisy, extract, testing::Values(DAISY_IMAGES)) +{ + string filename = getDataPath(GetParam()); + Mat frame = imread(filename, IMREAD_GRAYSCALE); + ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename; + + Mat mask; + declare.in(frame).time(90); + + // use DAISY in COMP_FULL mode (every pixel, dense baseline mode) + Ptr descriptor = DAISY::create(15, 3, 8, 8, DAISY::COMP_FULL, DAISY::NRM_NONE, noArray(), true, false); + + vector points; + vector descriptors; + TEST_CYCLE() descriptor->compute(frame, points, descriptors); + + SANITY_CHECK(descriptors, 1e-4); +} diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp new file mode 100644 index 000000000..7a71856b6 --- /dev/null +++ b/modules/xfeatures2d/src/daisy.cpp @@ -0,0 +1,2054 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2009 + * Engin Tola + * web : http://www.engintola.com + * email : engin.tola+libdaisy@gmail.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the Willow Garage nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *********************************************************************/ + +/* + "DAISY: An Efficient Dense Descriptor Applied to Wide Baseline Stereo" + by Engin Tola, Vincent Lepetit and Pascal Fua. IEEE Transactions on + Pattern Analysis and achine Intelligence, 31 Mar. 2009. + IEEE computer Society Digital Library. IEEE Computer Society, + http:doi.ieeecomputersociety.org/10.1109/TPAMI.2009.77 + + "A fast local descriptor for dense matching" by Engin Tola, Vincent + Lepetit, and Pascal Fua. Intl. Conf. on Computer Vision and Pattern + Recognition, Alaska, USA, June 2008 + + OpenCV port by: Cristian Balint + */ + +#include "precomp.hpp" +#include "opencv2/imgproc/imgproc_c.h" + +#include +#include + +namespace cv +{ +namespace xfeatures2d +{ + +// constants +const double g_sigma_0 = 1; +const double g_sigma_1 = sqrt(2.0); +const double g_sigma_2 = 8; +const double g_sigma_step = std::pow(2,1.0/2); +const int g_scale_st = int( (log(g_sigma_1/g_sigma_0)) / log(g_sigma_step) ); +static int g_scale_en = 1; + +const double g_sigma_init = 1.6; +const static int g_grid_orientation_resolution = 360; + +static const int MAX_CUBE_NO = 64; +static const int MAX_NORMALIZATION_ITER = 5; + +int g_cube_number; +int g_selected_cubes[MAX_CUBE_NO]; // m_rad_q_no < MAX_CUBE_NO + +/* + !DAISY implementation + */ +class DAISY_Impl : public DAISY +{ + +public: + /** Constructor + @param radius radius of the descriptor at the initial scale + @param q_radius amount of radial range divisions + @param q_theta amount of angular range divisions + @param q_hist amount of gradient orientations range divisions + @param mode computation of descriptors + @param norm normalization type + @param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image + @param interpolation switch to disable interpolation at minor costs of quality (default is true) + */ + explicit DAISY_Impl(float radius=15, int q_radius=3, int q_theta=8, int q_hist=8, + int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, InputArray H = noArray(), + bool interpolation = true, bool use_orientation = false); + + virtual ~DAISY_Impl(); + + /** returns the descriptor length in bytes */ + virtual int descriptorSize() const { + // +1 is for center pixel + return ( (m_rad_q_no * m_th_q_no + 1) * m_hist_th_q_no ); + }; + /** returns the descriptor type */ + virtual int descriptorType() const { return CV_32F; } + /** returns the default norm type */ + virtual int defaultNorm() const { return NORM_L2; } + + // main compute routine + virtual void compute( InputArray image, std::vector& keypoints, OutputArray descriptors ); + +protected: + + /* + * DAISY parameters + */ + + // operation mode + int m_mode; + + // maximum radius of the descriptor region. + float m_rad; + + // the number of quantizations of the radius. + int m_rad_q_no; + + // the number of quantizations of the angle. + int m_th_q_no; + + // the number of quantizations of the gradient orientations. + int m_hist_th_q_no; + + // holds the type of the normalization to apply; equals to NRM_PARTIAL by + // default. change the value using set_normalization() function. + int m_nrm_type; + + // holds optional H matrix + InputArray m_h_matrix; + + // input image. + float* m_image; + + // image height + int m_h; + + // image width + int m_w; + + // stores the descriptors : its size is [ m_w * m_h * m_descriptor_size ]. + float* m_dense_descriptors; + + // stores the layered gradients in successively smoothed form: layer[n] = + // m_gradient_layers * gaussian( sigma_n ); n>= 1; layer[0] is the layered_gradient + float* m_smoothed_gradient_layers; + + // if set to true, descriptors are scale invariant + bool m_scale_invariant; + + // if set to true, descriptors are rotation invariant + bool m_rotation_invariant; + + // number of bins in the histograms while computing orientation + int m_orientation_resolution; + + // hold the scales of the pixels + float* m_scale_map; + + // holds the orientaitons of the pixels + int* m_orientation_map; + + // Holds the oriented coordinates (y,x) of the grid points of the region. + double** m_oriented_grid_points; + + // holds the gaussian sigmas for radius quantizations for an incremental + // application + double* m_cube_sigmas; + + bool m_descriptor_memory; + bool m_workspace_memory; + + // the number of grid locations + int m_grid_point_number; + + // the size of the descriptor vector + int m_descriptor_size; + + // holds the amount of shift that's required for histogram computation + double m_orientation_shift_table[360]; + + // if enabled, descriptors are computed with casting non-integer locations + // to integer positions otherwise we use interpolation. + bool m_disable_interpolation; + + // switch to enable sample by keypoints orientation + bool m_use_orientation; + + // size of m_hsz layers at a single sigma: m_hsz * m_layer_size + int m_cube_size; + + // size of the layer : m_h*m_w + int m_layer_size; + + /* + * DAISY functions + */ + + // computes the histogram at yx; the size of histogram is m_hist_th_q_no + void compute_histogram( float* hcube, int y, int x, float* histogram ); + + // reorganizes the cube data so that histograms are sequential in memory. + void compute_histograms(); + + // emulates the way sift is normalized. + void normalize_sift_way( float* desc ); + + // normalizes the descriptor histogram by histogram + void normalize_partial( float* desc ); + + // normalizes the full descriptor. + void normalize_full( float* desc ); + + // initializes the class: computes gradient and structure-points + void initialize(); + + void update_selected_cubes(); + + int quantize_radius( float rad ); + + int filter_size( double sigma ); + + // computes scales for every pixel and scales the structure grid so that the + // resulting descriptors are scale invariant. you must set + // m_scale_invariant flag to 1 for the program to call this function + void compute_scales(); + + // Return a number in the range [-0.5, 0.5] that represents the location of + // the peak of a parabola passing through the 3 evenly spaced samples. The + // center value is assumed to be greater than or equal to the other values + // if positive, or less than if negative. + float interpolate_peak( float left, float center, float right ); + + // Smooth a histogram by using a [1/3 1/3 1/3] kernel. Assume the histogram + // is connected in a circular buffer. + void smooth_histogram( float *hist, int bins ); + + // computes pixel orientations and rotates the structure grid so that + // resulting descriptors are rotation invariant. If the scales is also + // detected, then orientations are computed at the computed scales. you must + // set m_rotation_invariant flag to 1 for the program to call this function + void compute_orientations(); + + // the clipping threshold to use in normalization: values above this value + // are clipped to this value for normalize_sift_way() function + float m_descriptor_normalization_threshold; + + // computes the sigma's of layers from descriptor parameters if the user did + // not sets it. these define the size of the petals of the descriptor. + void compute_cube_sigmas(); + + // Computes the locations of the unscaled unrotated points where the + // histograms are going to be computed according to the given parameters. + void compute_grid_points(); + + // Computes the locations of the unscaled rotated points where the + // histograms are going to be computed according to the given parameters. + void compute_oriented_grid_points(); + + // smooths each of the layers by a Gaussian having "sigma" standart + // deviation. + void smooth_layers( float*layers, int h, int w, int layer_number, float sigma ); + + // Holds the coordinates (y,x) of the grid points of the region. + double** m_grid_points; + + int get_hq() { return m_hist_th_q_no; } + int get_thq() { return m_th_q_no; } + int get_rq() { return m_rad_q_no; } + float get_rad() { return m_rad; } + + // sets the type of the normalization to apply out of {NRM_PARTIAL, + // NRM_FULL, NRM_SIFT}. Call before using get_descriptor() if you want to + // change the default normalization type. + void set_normalization( int nrm_type ) { m_nrm_type = nrm_type; } + + // applies one of the normalizations (partial,full,sift) to the desciptors. + void normalize_descriptors(int nrm_type = DAISY::NRM_NONE); + + // normalizes histograms individually + void normalize_histograms(); + + // gets the histogram at y,x with 'orientation' from the r'th cube + float* get_histogram( int y, int x, int r ); + + // if called, I don't use interpolation in the computation of + // descriptors. + void disable_interpolation() { m_disable_interpolation = true; } + + // returns the region number. + int grid_point_number() { return m_grid_point_number; } + + // releases all the used memory; call this if you want to process + // multiple images within a loop. + void reset(); + + // releases unused memory after descriptor computation is completed. + void release_auxilary(); + + // computes the descriptors for every pixel in the image. + void compute_descriptors(); + + // returns all the descriptors. + float* get_dense_descriptors(); + + // returns oriented grid points. default is 0 orientation. + double* get_grid(int o=0); + + // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the + // scales for every pixel so that the resulting descriptors are scale + // invariant. + void scale_invariant( bool state=true ) + { + g_scale_en = (int)( (log(g_sigma_2/g_sigma_0)) / log(g_sigma_step) ) - g_scale_st; + m_scale_invariant = state; + } + + // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the + // orientations for every pixel so that the resulting descriptors are + // rotation invariant. orientation steps are 360/ori_resolution + void rotation_invariant(int ori_resolution=36, bool state=true) + { + m_rotation_invariant = state; + m_orientation_resolution = ori_resolution; + } + + // sets the gaussian variances manually. must be called before + // initialize() to be considered. must be exact sigma values -> f + // converts to incremental format. + void set_cube_gaussians( double* sigma_array, int sz ); + + int* get_orientation_map() { return m_orientation_map; } + + // call compute_descriptor_memory to find the amount of memory to allocate + void set_descriptor_memory( float* descriptor, long int d_size ); + + // call compute_workspace_memory to find the amount of memory to allocate + void set_workspace_memory( float* workspace, long int w_size ); + + // returns the amount of memory needed for the compute_descriptors() + // function. it is basically equal to imagesize x descriptor_size + int compute_descriptor_memory() { + if( m_h == 0 || m_descriptor_size == 0 ) { + CV_Error( Error::StsInternal, "Image and descriptor size is zero" ); + } + return m_w * m_h * m_descriptor_size; + } + + // returns the amount of memory needed for workspace. call before initialize() + int compute_workspace_memory() { + if( m_cube_size == 0 ) { + CV_Error( Error::StsInternal, "Cube size is zero" ); + } + return (g_cube_number+1)* m_cube_size; + } + + void normalize_descriptor(float* desc, int nrm_type = DAISY::NRM_NONE) + { + if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; + else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); + else if( nrm_type == DAISY::NRM_FULL ) normalize_full(desc); + else if( nrm_type == DAISY::NRM_SIFT ) normalize_sift_way(desc); + else + CV_Error( Error::StsInternal, "No such normalization" ); + } + + // transform a point via the homography + void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) + { + double kxp = H[0]*x + H[1]*y + H[2]; + double kyp = H[3]*x + H[4]*y + H[5]; + double kp = H[6]*x + H[7]*y + H[8]; + u = kxp / kp; + v = kyp / kp; + } + +private: + + // returns the descriptor vector for the point (y, x) !!! use this for + // precomputed operations meaning that you must call compute_descriptors() + // before calling this function. if you want normalized descriptors, call + // normalize_descriptors() before calling compute_descriptors() + inline void get_descriptor(int y, int x, float* &descriptor); + + // computes the descriptor and returns the result in 'descriptor' ( allocate + // 'descriptor' memory first ie: float descriptor = new + // float[m_descriptor_size]; -> the descriptor is normalized. + inline void get_descriptor(double y, double x, int orientation, float* descriptor ); + + // computes the descriptor and returns the result in 'descriptor' ( allocate + // 'descriptor' memory first ie: float descriptor = new + // float[m_descriptor_size]; -> the descriptor is NOT normalized. + inline void get_unnormalized_descriptor(double y, double x, int orientation, float* descriptor ); + + // computes the descriptor at homography-warped grid. (y,x) is not the + // coordinates of this image but the coordinates of the original grid where + // the homography will be applied. Meaning that the grid is somewhere else + // and we warp this grid with H and compute the descriptor on this warped + // grid; returns null/false if centers falls outside the image; allocate + // 'descriptor' memory first. descriptor is normalized. + inline bool get_descriptor(double y, double x, int orientation, double* H, float* descriptor ); + + // computes the descriptor at homography-warped grid. (y,x) is not the + // coordinates of this image but the coordinates of the original grid where + // the homography will be applied. Meaning that the grid is somewhere else + // and we warp this grid with H and compute the descriptor on this warped + // grid; returns null/false if centers falls outside the image; allocate + // 'descriptor' memory first. descriptor is NOT normalized. + inline bool get_unnormalized_descriptor(double y, double x, int orientation, double* H, float* descriptor ); + + // compute the smoothed gradient layers. + inline void compute_smoothed_gradient_layers(); + + // does not use interpolation while computing the histogram. + inline void ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ); + + // returns the interpolated histogram: picks either bi_get_histogram or + // ti_get_histogram depending on 'shift' + inline void i_get_histogram( float* histogram, double y, double x, double shift, float* cube ); + + // records the histogram that is computed by bilinear interpolation + // regarding the shift in the spatial coordinates. hcube is the + // histogram cube for a constant smoothness level. + inline void bi_get_histogram( float* descriptor, double y, double x, int shift, float* hcube ); + + // records the histogram that is computed by trilinear interpolation + // regarding the shift in layers and spatial coordinates. hcube is the + // histogram cube for a constant smoothness level. + inline void ti_get_histogram( float* descriptor, double y, double x, double shift, float* hcube ); + + // uses interpolation, for no interpolation call ni_get_descriptor. see also get_descriptor + inline void i_get_descriptor( double y, double x, int orientation, float* descriptor ); + + // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor + inline void ni_get_descriptor( double y, double x, int orientation, float* descriptor ); + + // uses interpolation for no interpolation call ni_get_descriptor. see also get_descriptor + inline bool i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + + // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor + inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + + // creates a 1D gaussian filter with N(mean,sigma). + inline void gaussian_1d(float* fltr, int fsz, float sigma, float mean ) + { + CV_Assert(fltr != NULL); + int sz = (fsz-1)/2; + int counter=-1; + float sum = 0.0; + float v = 2*sigma*sigma; + for( int x=-sz; x<=sz; x++ ) + { + counter++; + fltr[counter] = exp((-(x-mean)*(x-mean))/v); + sum += fltr[counter]; + } + + if( sum != 0 ) + { + for( int x=0; x + class rectangle + { + public: + T lx, ux, ly, uy; + T dx, dy; + rectangle(T xl, T xu, T yl, T yu) { lx=xl; ux=xu; ly=yl; uy=yu; dx=ux-lx; dy=uy-ly; }; + rectangle() { lx = ux = ly = uy = dx = dy = 0; }; + }; + + // checks if the number x is between lx - ux interval. + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + { + if( ( ((lx lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='&') + { + switch( oper ) + { + case '|': + if( is_inside(x,lx,ux,le,ue) || is_inside(y,ly,uy,le,ue) ) + return true; + return false; + + default: + if( is_inside(x,lx,ux,le,ue) && is_inside(y,ly,uy,le,ue) ) + return true; + return false; + } + } + + // checks if the number x is between lx - ux and/or y is between ly - uy interval. + // If the number is inside, then function returns true, else it returns false. + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='&') + { + switch( oper ) + { + case '|': + if( is_inside(x,roi.lx,roi.ux,le,ue) || is_inside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + + default: + if( is_inside(x,roi.lx,roi.ux,le,ue) && is_inside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + } + } + + // checks if the number x is outside lx - ux interval + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx>x is checked else lx>=x is checked + // if ue=1 => x>ux is checked else x>=ux is checked + // by default is x is searched outside of [lx,ux) + template inline + bool is_outside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + { + return !(is_inside(x,lx,ux,le,ue)); + } + + // checks if the numbers x and y is outside their intervals. + // The equality is checked depending on the value of le and ue parameters. + // If le=1 => lx>x is checked else lx>=x is checked + // If ue=1 => x>ux is checked else x>=ux is checked + // By default is x is searched outside of [lx,ux) (Similarly for y) + // By default, 'oper' is set to OR. If one of them is outside it returns + // true otherwise false. + template inline + bool is_outside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='|') + { + switch( oper ) + { + case '&': + if( is_outside(x,lx,ux,le,ue) && is_outside(y,ly,uy,le,ue) ) + return true; + return false; + default: + if( is_outside(x,lx,ux,le,ue) || is_outside(y,ly,uy,le,ue) ) + return true; + return false; + } + } + + // checks if the numbers x and y is outside their intervals. + // The equality is checked depending on the value of le and ue parameters. + // If le=1 => lx>x is checked else lx>=x is checked + // If ue=1 => x>ux is checked else x>=ux is checked + // By default is x is searched outside of [lx,ux) (Similarly for y) + // By default, 'oper' is set to OR. If one of them is outside it returns + // true otherwise false. + template inline + bool is_outside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='|') + { + switch( oper ) + { + case '&': + if( is_outside(x,roi.lx,roi.ux,le,ue) && is_outside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + default: + if( is_outside(x,roi.lx,roi.ux,le,ue) || is_outside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + } + } + + // computes the square of a number and returns it. + template inline + T square(T a) + { + return a*a; + } + + // computes the square of an array. if in_place is enabled, the + // result is returned in the array arr. + template inline + T* square(T* arr, int sz, bool in_place=false) + { + T* out; + if( in_place ) out = arr; + else out = allocate(sz); + + for( int i=0; i inline + float l2norm( T* a, int sz) + { + float norm=0; + for( int k=0; k inline + float l2norm( T1* a, T2* b, int sz) + { + float norm=0; + for( int i=0; i inline + float l2norm( T y0, T x0, T y1, T x1 ) + { + float d0 = x0 - x1; + float d1 = y0 - y1; + + return sqrt( d0*d0 + d1*d1 ); + } + + // allocates a memory of size sz and returns a pointer to the array + template inline + T* allocate(const int sz) + { + T* array = new T[sz]; + return array; + } + + // allocates a memory of size ysz x xsz and returns a double pointer to it + template inline + T** allocate(const int ysz, const int xsz) + { + T** mat = new T*[ysz]; + int i; + + for(i=0; i(xsz); + + return mat; + } + + // deallocates the memory and sets the pointer to null. + template inline + void deallocate(T* &array) + { + delete[] array; + array = NULL; + } + + // deallocates the memory and sets the pointer to null. + template inline + void deallocate(T** &mat, int ysz) + { + if( mat == NULL ) return; + + for(int i=0; i inline + void polar2cartesian(T1 r, T1 t, T2 &y, T2 &x) + { + x = (T2)( r * cos( t ) ); + y = (T2)( r * sin( t ) ); + } + + + template inline + void convolve_sym_( T* image, int h, int w, T* kernel, int ksize ) + { + conv_horizontal( image, h, w, kernel, ksize ); + conv_vertical ( image, h, w, kernel, ksize ); + } + + template + inline void convolve_sym( T* image, int h, int w, T* kernel, int ksize, T* out=NULL ) + { + if( out == NULL ) out = image; + else memcpy( out, image, sizeof(T)*h*w ); + convolve_sym_(out, h, w, kernel, ksize); + } + + // divides the elements of the array with num + template inline + void divide(T1* arr, int sz, T2 num ) + { + float inv_num = 1.0 / num; + + for( int i=0; i inline + T* zeros(int r) + { + T* data = allocate(r); + memset( data, 0, sizeof(T)*r ); + return data; + } + + template inline + T* layered_gradient( T* data, int h, int w, int layer_no=8 ) + { + int data_size = h * w; + T* layers = zeros(layer_no * data_size); + + // smooth the data matrix + T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); + + T *dx = new T[data_size]; + T *dy = new T[data_size]; + gradient(bdata, h, w, dy, dx); + deallocate( bdata ); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int l=0; l 0 ) layer_l[index] = value; + else layer_l[index] = 0; + } + } + deallocate(dy); + deallocate(dx); + + return layers; + } + + // computes the gradient of an image and returns the result in + // pointers to REAL. + template inline + void gradient(T* im, int h, int w, T* dy, T* dx) + { + CV_Assert( dx != NULL ); + CV_Assert( dy != NULL ); + + for( int y=0; y0 && x0 && y inline + // original T* workspace=0 was removed + void layered_gradient( T* data, int h, int w, int layer_no, T* layers, int lwork=0 ) + { + int data_size = h * w; + CV_Assert(layers!=NULL); + memset(layers,0,sizeof(T)*data_size*layer_no); + + bool empty=false; + T* work=NULL; + if( lwork < 3*data_size ) { + work = new T[3*data_size]; + empty=true; + } + + // // smooth the data matrix + // T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); + float kernel[5]; gaussian_1d(kernel, 5, 0.5, 0); + memcpy( work, data, sizeof(T)*data_size); + convolve_sym( work, h, w, kernel, 5 ); + + T *dx = work+data_size; + T *dy = work+2*data_size; + gradient( work, h, w, dy, dx ); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int l=0; l 0 ) layer_l[index] = value; + else layer_l[index] = 0; + } + } + if( empty ) delete []work; + } + + // casts a type T2 array into a type T1 array. + template inline + T1* type_cast(T2* data, int sz) + { + T1* out = new T1[sz]; + + for( int i=0; i inline + T1* blur_gaussian_2d( T2* array, int rn, int cn, float sigma, int kernel_size=0, bool in_place=false ) + { + T1* out = NULL; + + if( in_place ) + out = (T1*)array; + else + out = type_cast(array,rn*cn); + + if( kernel_size == 0 ) + kernel_size = (int)(3*sigma); + + if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd + if( kernel_size < 3 ) kernel_size= 3; // kernel size cannot be smaller than 3 + + float* kernel = new float[kernel_size]; + gaussian_1d(kernel, kernel_size, sigma, 0); + + // !! apply the filter separately + convolve_sym( out, rn, cn, kernel, kernel_size ); + // conv_horizontal( out, rn, cn, kernel, kernel_size); + // conv_vertical ( out, rn, cn, kernel, kernel_size); + + deallocate(kernel); + return out; + } + +}; // END DAISY_Impl CLASS + + +// ------------------------------------------------- +/* DAISY computation routines */ + +float* DAISY_Impl::get_histogram( int y, int x, int r ) +{ + CV_Assert( y >= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + return m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size + (y*m_w+x)*m_hist_th_q_no; + // i_get_histogram( histogram, y, x, 0, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); +} + + +float* DAISY_Impl::get_dense_descriptors() +{ + return m_dense_descriptors; +} + +double* DAISY_Impl::get_grid(int o) +{ + CV_Assert( o >= 0 && o < 360 ); + return m_oriented_grid_points[o]; +} + +void DAISY_Impl::reset() +{ + deallocate( m_image ); + // deallocate( m_grid_points, m_grid_point_number ); + // deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + // deallocate( m_cube_sigmas ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + if( !m_descriptor_memory ) deallocate( m_dense_descriptors ); + if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); +} + +void DAISY_Impl::release_auxilary() +{ + deallocate( m_image ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + + if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); + + deallocate( m_grid_points, m_grid_point_number ); + deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + deallocate( m_cube_sigmas ); +} + +void DAISY_Impl::compute_grid_points() +{ + double r_step = m_rad / m_rad_q_no; + double t_step = 2*CV_PI/ m_th_q_no; + + if( m_grid_points ) + deallocate( m_grid_points, m_grid_point_number ); + + m_grid_points = allocate(m_grid_point_number, 2); + for( int y=0; y(m_h*m_w*m_descriptor_size); + + memset(m_dense_descriptors, 0, sizeof(float)*m_h*m_w*m_descriptor_size); + + int y, x, index, orientation; +#if defined _OPENMP +#pragma omp parallel for private(y,x,index,orientation) +#endif + for( y=0; y= 0 && orientation < g_grid_orientation_resolution ) ) orientation = 0; + get_unnormalized_descriptor( y, x, orientation, &(m_dense_descriptors[index*m_descriptor_size]) ); + } + } +} + +void DAISY_Impl::smooth_layers( float* layers, int h, int w, int layer_number, float sigma ) +{ + int fsz = filter_size(sigma); + float* filter = new float[fsz]; + gaussian_1d(filter, fsz, sigma, 0); + int i; + float* layer=0; +#if defined _OPENMP +#pragma omp parallel for private(i, layer) +#endif + for( i=0; i 1e-5 ) + divide( desc, m_descriptor_size, norm); + + for( h=0; h m_descriptor_normalization_threshold ) + { + desc[ h ] = m_descriptor_normalization_threshold; + changed = true; + } + } + } +} + +void DAISY_Impl::normalize_descriptors( int nrm_type ) +{ + int number_of_descriptors = m_h * m_w; + int d; + +#if defined _OPENMP +#pragma omp parallel for private(d) +#endif + for( d=0; d(g_cube_number); + + double r_step = double(m_rad)/m_rad_q_no; + for( int r=0; r< m_rad_q_no; r++ ) + { + m_cube_sigmas[r] = (r+1)*r_step/2; + } + } + update_selected_cubes(); +} + +void DAISY_Impl::set_cube_gaussians( double* sigma_array, int sz ) +{ + g_cube_number = sz; + + if( m_cube_sigmas ) deallocate( m_cube_sigmas ); + m_cube_sigmas = allocate(g_cube_number); + + for( int r=0; r= m_cube_sigmas[g_cube_number-1] ) return g_cube_number-1; + + float dist; + float mindist=FLT_MAX; + int mini=0; + for( int c=0; c(g_grid_orientation_resolution, m_grid_point_number*2 ); + + for( int i=0; i= left && center >= right); + + float den = (left - 2.0 * center + right); + + if( den == 0 ) return 0; + else return 0.5*(left -right)/den; +} + +int DAISY_Impl::filter_size( double sigma ) +{ + int fsz = (int)(5*sigma); + + // kernel size must be odd + if( fsz%2 == 0 ) fsz++; + + // kernel size cannot be smaller than 3 + if( fsz < 3 ) fsz = 3; + + return fsz; +} + +void DAISY_Impl::compute_scales() +{ + //############################################################################### + //# scale detection is work-in-progress! do not use it if you're not Engin Tola # + //############################################################################### + + int imsz = m_w * m_h; + + float sigma = pow( g_sigma_step, g_scale_st)*g_sigma_0; + + float* sim = blur_gaussian_2d( m_image, m_h, m_w, sigma, filter_size(sigma), false); + + float* next_sim = NULL; + + float* max_dog = allocate(imsz); + + m_scale_map = allocate(imsz); + + memset( max_dog, 0, imsz*sizeof(float) ); + memset( m_scale_map, 0, imsz*sizeof(float) ); + + int i; + float sigma_prev; + float sigma_new; + float sigma_inc; + + sigma_prev = g_sigma_0; + for( i=0; i( sim, m_h, m_w, sigma_inc, filter_size( sigma_inc ) , false); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int p=0; p max_dog[p] ) + { + max_dog[p] = dog; + m_scale_map[p] = i; + } + } + deallocate( sim ); + + sim = next_sim; + } + + blur_gaussian_2d( m_scale_map, m_h, m_w, 10.0, filter_size(10), true); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int q=0; q(m_orientation_resolution); + + for( x=0; x max_val ) + { + max_val = hist[ori]; + max_ind = ori; + } + } + + prev = max_ind-1; + if( prev < 0 ) + prev += m_orientation_resolution; + + next = max_ind+1; + if( next >= m_orientation_resolution ) + next -= m_orientation_resolution; + + peak = interpolate_peak(hist[prev], hist[max_ind], hist[next]); + angle = (max_ind + peak)*360.0/m_orientation_resolution; + + int iangle = int(angle); + + if( iangle < 0 ) iangle += 360; + if( iangle >= 360 ) iangle -= 360; + + + if( !(iangle >= 0.0 && iangle < 360.0) ) + { + angle = 0; + } + + m_orientation_map[ ind ] = iangle; + } + deallocate(hist); + } + } + + deallocate( rotation_layers ); + + compute_oriented_grid_points(); +} + +void DAISY_Impl::set_descriptor_memory( float* descriptor, long int d_size ) +{ + CV_Assert( m_descriptor_memory == false ); + CV_Assert( m_h*m_w != 0 ); + CV_Assert( d_size >= compute_descriptor_memory() ); + + m_dense_descriptors = descriptor; + m_descriptor_memory = true; +} + +void DAISY_Impl::set_workspace_memory( float* workspace, long int w_size ) +{ + CV_Assert( m_workspace_memory == false ); + CV_Assert( m_h*m_w != 0 ); + CV_Assert( w_size >= compute_workspace_memory() ); + + m_smoothed_gradient_layers = workspace; + m_workspace_memory = true; +} + +// ------------------------------------------------- +/* DAISY helper routines */ + +inline void DAISY_Impl::compute_histogram( float* hcube, int y, int x, float* histogram ) +{ + if( is_outside(x, 0, m_w-1, y, 0, m_h-1) ) return; + + float* spatial_shift = hcube + y * m_w + x; + int data_size = m_w * m_h; + + for( int h=0; h 0.99 ) bi_get_histogram( histogram, y, x, ishift+1, cube ); + else ti_get_histogram( histogram, y, x, shift , cube ); +} + +inline void DAISY_Impl::bi_get_histogram( float* histogram, double y, double x, int shift, float* hcube ) +{ + int mnx = int( x ); + int mny = int( y ); + + if( mnx >= m_w-2 || mny >= m_h-2 ) + { + memset(histogram, 0, sizeof(float)*m_hist_th_q_no); + return; + } + + int ind = mny*m_w+mnx; + // A C --> pixel positions + // B D + float* A = hcube+ind*m_hist_th_q_no; + float* B = A+m_w*m_hist_th_q_no; + float* C = A+m_hist_th_q_no; + float* D = A+(m_w+1)*m_hist_th_q_no; + + double alpha = mnx+1-x; + double beta = mny+1-y; + + float w0 = alpha*beta; + float w1 = beta-w0; // (1-alpha)*beta; + float w2 = alpha-w0; // (1-beta)*alpha; + float w3 = 1+w0-alpha-beta; // (1-beta)*(1-alpha); + + int h; + + for( h=0; h= m_hist_th_q_no ) hi -= m_hist_th_q_no; + histogram[h] = hptr[hi]; + } +} + +inline void DAISY_Impl::get_descriptor(int y, int x, float* &descriptor) +{ + CV_Assert( m_dense_descriptors != NULL ); + CV_Assert( y=0 && x>=0 ); + descriptor = &(m_dense_descriptors[(y*m_w+x)*m_descriptor_size]); +} + +inline void DAISY_Impl::get_descriptor(double y, double x, int orientation, float* descriptor ) +{ + get_unnormalized_descriptor(y, x, orientation, descriptor ); + normalize_descriptor(descriptor, m_nrm_type); +} + +inline void DAISY_Impl::get_unnormalized_descriptor(double y, double x, int orientation, float* descriptor ) +{ + if( m_disable_interpolation ) ni_get_descriptor(y,x,orientation,descriptor); + else i_get_descriptor(y,x,orientation,descriptor); +} + +inline void DAISY_Impl::i_get_descriptor(double y, double x, int orientation, float* descriptor ) +{ + // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); + // + // i'm not changing the descriptor[] values if the gridpoint is outside + // the image. you should memset the descriptor array to 0 if you don't + // want to have stupid values there. + // + CV_Assert( y >= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + CV_Assert( descriptor != NULL ); + + double shift = m_orientation_shift_table[orientation]; + + i_get_histogram( descriptor, y, x, shift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + + int r, rdt, region; + double yy, xx; + float* histogram = 0; + double* grid = m_oriented_grid_points[orientation]; + + // petals of the flower + for( r=0; r= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + CV_Assert( descriptor != NULL ); + + double shift = m_orientation_shift_table[orientation]; + int ishift = (int)shift; + if( shift - ishift > 0.5 ) ishift++; + + int iy = (int)y; if( y - iy > 0.5 ) iy++; + int ix = (int)x; if( x - ix > 0.5 ) ix++; + + // center + ni_get_histogram( descriptor, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + + double yy, xx; + float* histogram=0; + // petals of the flower + int r, rdt, region; + double* grid = m_oriented_grid_points[orientation]; + for( r=0; r 0.5 ) iy++; + ix = (int)xx; if( xx - ix > 0.5 ) ix++; + + if( is_outside(ix, 0, m_w-1, iy, 0, m_h-1) ) continue; + + histogram = descriptor+region*m_hist_th_q_no; + ni_get_histogram( histogram, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); + } + } +} + +// Warped get_descriptor's +inline bool DAISY_Impl::get_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +{ + bool rval = get_unnormalized_descriptor(y,x,orientation, H, descriptor); + if( rval ) normalize_descriptor(descriptor, m_nrm_type); + return rval; +} + +inline bool DAISY_Impl::get_unnormalized_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +{ + if( m_disable_interpolation ) return ni_get_descriptor(y,x,orientation,H,descriptor); + else return i_get_descriptor(y,x,orientation,H,descriptor); +} + +inline bool DAISY_Impl::i_get_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +{ + // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); + // + // i'm not changing the descriptor[] values if the gridpoint is outside + // the image. you should memset the descriptor array to 0 if you don't + // want to have stupid values there. + // + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( descriptor != NULL ); + + int hradius[MAX_CUBE_NO]; + + double hy, hx, ry, rx; + point_transform_via_homography( H, x, y, hx, hy ); + if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; + + point_transform_via_homography( H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); + double radius = l2norm( ry, rx, hy, hx ); + hradius[0] = quantize_radius( radius ); + + double shift = m_orientation_shift_table[orientation]; + i_get_histogram( descriptor, hy, hx, shift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + + double gy, gx; + int r, rdt, th, region; + float* histogram=0; + for( r=0; r= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( descriptor != NULL ); + + int hradius[MAX_CUBE_NO]; + double radius; + + double hy, hx, ry, rx; + + point_transform_via_homography(H, x, y, hx, hy ); + if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; + + double shift = m_orientation_shift_table[orientation]; + int ishift = (int)shift; if( shift - ishift > 0.5 ) ishift++; + + point_transform_via_homography(H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); + radius = l2norm( ry, rx, hy, hx ); + hradius[0] = quantize_radius( radius ); + + int ihx = (int)hx; if( hx - ihx > 0.5 ) ihx++; + int ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; + + int r, rdt, th, region; + double gy, gx; + float* histogram=0; + ni_get_histogram( descriptor, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + for( r=0; r 0.5 ) ihx++; + ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; + + if( is_outside(ihx, 0, m_w-1, ihy, 0, m_h-1) ) continue; + histogram = descriptor+region*m_hist_th_q_no; + ni_get_histogram( histogram, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[r]*m_cube_size ); + } + } + return true; +} + +// ------------------------------------------------- +/* DAISY interface implementation */ + +void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) +{ + // do nothing if no image + Mat image = _image.getMat(); + if( image.empty() ) + return; + + // get homography if supplied + Mat H = m_h_matrix.getMat(); + + // convert to float if case + if ( image.depth() != CV_64F ) + H.convertTo( H, CV_64F ); + /* + * daisy set_image() + */ + + // base size + m_h = image.rows; + m_w = image.cols; + + // clone image for conversion + if ( image.depth() != CV_32F ) { + + Mat work_image = image.clone(); + + // convert to gray inplace + if( work_image.channels() > 1 ) + cvtColor( work_image, work_image, COLOR_BGR2GRAY ); + + // convert to float if it is necessary + if ( work_image.depth() != CV_32F ) + { + // convert and normalize + work_image.convertTo( work_image, CV_32F ); + work_image /= 255.0f; + } else + CV_Error( Error::StsUnsupportedFormat, "" ); + + // use cloned work image + m_image = work_image.ptr(0); + + } else + // use original CV_32F image + m_image = image.ptr(0); + + // full mode if noArray() + // was passed to _descriptors + if ( _descriptors.needed() == false ) + m_mode = DAISY::COMP_FULL; + + /* + * daisy set_parameters() + */ + + m_grid_point_number = m_rad_q_no * m_th_q_no + 1; // +1 is for center pixel + m_descriptor_size = m_grid_point_number * m_hist_th_q_no; + + for( int i=0; i<360; i++ ) + { + m_orientation_shift_table[i] = i/360.0 * m_hist_th_q_no; + } + m_layer_size = m_h*m_w; + m_cube_size = m_layer_size*m_hist_th_q_no; + + compute_cube_sigmas(); + compute_grid_points(); + + + /* + * daisy initialize_single_descriptor_mode(); + */ + + // initializes for get_descriptor(double, double, int) mode: pre-computes + // convolutions of gradient layers in m_smoothed_gradient_layers + + initialize(); + compute_smoothed_gradient_layers(); + + /* + * daisy compute descriptors given operating mode + */ + + if ( m_mode == COMP_FULL ) + { + CV_Assert( H.empty() ); + CV_Assert( keypoints.empty() ); + CV_Assert( ! m_use_orientation ); + + compute_descriptors(); + normalize_descriptors(); + + cv::Mat descriptors; + descriptors = _descriptors.getMat(); + descriptors = Mat( m_h * m_w, m_descriptor_size, + CV_32F, &m_dense_descriptors[0] ); + } else + if ( m_mode == ONLY_KEYS ) + { + cv::Mat descriptors; + _descriptors.create( keypoints.size(), m_descriptor_size, CV_32F ); + descriptors = _descriptors.getMat(); + + if ( H.empty() ) + for (size_t k = 0; k < keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? keypoints[k].angle : 0, + &descriptors.at( k, 0 ) ); + } + else + for (size_t k = 0; k < keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? keypoints[k].angle : 0, + &H.at( 0 ), &descriptors.at( k, 0 ) ); + } + + } else + CV_Error( Error::StsInternal, "Unknown computation mode" ); +} + +// constructor +DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, + int _mode, int _norm, InputArray _H, bool _interpolation, bool _use_orientation ) + : m_mode(_mode), m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), + m_nrm_type(_norm), m_h_matrix(_H), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) +{ + m_w = 0; + m_h = 0; + + m_image = 0; + + m_grid_point_number = 0; + m_descriptor_size = 0; + + m_smoothed_gradient_layers = NULL; + m_dense_descriptors = NULL; + m_grid_points = NULL; + m_oriented_grid_points = NULL; + + m_scale_invariant = false; + m_rotation_invariant = false; + + m_scale_map = NULL; + m_orientation_map = NULL; + m_orientation_resolution = 36; + m_scale_map = NULL; + + m_cube_sigmas = NULL; + + m_descriptor_memory = false; + m_workspace_memory = false; + m_descriptor_normalization_threshold = 0.154; // sift magical number + + m_cube_size = 0; + m_layer_size = 0; + +} + +// destructor +DAISY_Impl::~DAISY_Impl() +{ + if( !m_workspace_memory ) deallocate( m_smoothed_gradient_layers ); + deallocate( m_grid_points, m_grid_point_number ); + deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + deallocate( m_cube_sigmas ); +} + +Ptr DAISY::create( float radius, int q_radius, int q_theta, int q_hist, + int mode, int norm, InputArray H, bool interpolation, bool use_orientation) +{ + return makePtr(radius, q_radius, q_theta, q_hist, mode, norm, H, interpolation, use_orientation); +} + + +} // END NAMESPACE XFEATURES2D +} // END NAMESPACE CV diff --git a/modules/xfeatures2d/test/test_features2d.cpp b/modules/xfeatures2d/test/test_features2d.cpp index 303274efa..a01c0a313 100644 --- a/modules/xfeatures2d/test/test_features2d.cpp +++ b/modules/xfeatures2d/test/test_features2d.cpp @@ -1010,6 +1010,13 @@ TEST( Features2d_DescriptorExtractor_SURF, regression ) test.safe_run(); } +TEST( Features2d_DescriptorExtractor_DAISY, regression ) +{ + CV_DescriptorExtractorTest > test( "descriptor-daisy", 0.05f, + DAISY::create() ); + test.safe_run(); +} + TEST( Features2d_DescriptorExtractor_FREAK, regression ) { // TODO adjust the parameters below diff --git a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp index 46d328205..176a342c5 100644 --- a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp @@ -651,6 +651,15 @@ TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression) test.safe_run(); } +TEST(Features2d_RotationInvariance_Descriptor_DAISY, regression) +{ + DescriptorRotationInvarianceTest test(BRISK::create(), + DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + NORM_L1, + 0.79f); + test.safe_run(); +} + /* * Detector's scale invariance check */ @@ -708,3 +717,12 @@ TEST(Features2d_RotationInvariance2_Detector_SURF, regression) ASSERT_LT( fabs(keypoints[1].response - keypoints[3].response), 1e-6); ASSERT_LT( fabs(keypoints[1].response - keypoints[4].response), 1e-6); } + +TEST(Features2d_ScaleInvariance_Descriptor_DAISY, regression) +{ + DescriptorScaleInvarianceTest test(BRISK::create(), + DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + NORM_L1, + 0.075f); + test.safe_run(); +} From c1b2e237752d1f8b5413e8182ce27260e848c3bc Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 11 May 2015 16:10:48 +0300 Subject: [PATCH 16/21] Fix linux warns & more cosmetics. --- modules/xfeatures2d/src/daisy.cpp | 66 +++++++++++++++---------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp index 7a71856b6..62f42bf6e 100644 --- a/modules/xfeatures2d/src/daisy.cpp +++ b/modules/xfeatures2d/src/daisy.cpp @@ -286,7 +286,7 @@ protected: void set_normalization( int nrm_type ) { m_nrm_type = nrm_type; } // applies one of the normalizations (partial,full,sift) to the desciptors. - void normalize_descriptors(int nrm_type = DAISY::NRM_NONE); + void normalize_descriptors( int nrm_type = DAISY::NRM_NONE ); // normalizes histograms individually void normalize_histograms(); @@ -320,7 +320,7 @@ protected: // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the // scales for every pixel so that the resulting descriptors are scale // invariant. - void scale_invariant( bool state=true ) + void scale_invariant( bool state = true ) { g_scale_en = (int)( (log(g_sigma_2/g_sigma_0)) / log(g_sigma_step) ) - g_scale_st; m_scale_invariant = state; @@ -329,7 +329,7 @@ protected: // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the // orientations for every pixel so that the resulting descriptors are // rotation invariant. orientation steps are 360/ori_resolution - void rotation_invariant(int ori_resolution=36, bool state=true) + void rotation_invariant( int ori_resolution = 36, bool state = true ) { m_rotation_invariant = state; m_orientation_resolution = ori_resolution; @@ -365,7 +365,7 @@ protected: return (g_cube_number+1)* m_cube_size; } - void normalize_descriptor(float* desc, int nrm_type = DAISY::NRM_NONE) + void normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) { if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); @@ -391,17 +391,17 @@ private: // precomputed operations meaning that you must call compute_descriptors() // before calling this function. if you want normalized descriptors, call // normalize_descriptors() before calling compute_descriptors() - inline void get_descriptor(int y, int x, float* &descriptor); + inline void get_descriptor( int y, int x, float* &descriptor ); // computes the descriptor and returns the result in 'descriptor' ( allocate // 'descriptor' memory first ie: float descriptor = new // float[m_descriptor_size]; -> the descriptor is normalized. - inline void get_descriptor(double y, double x, int orientation, float* descriptor ); + inline void get_descriptor( double y, double x, int orientation, float* descriptor ); // computes the descriptor and returns the result in 'descriptor' ( allocate // 'descriptor' memory first ie: float descriptor = new // float[m_descriptor_size]; -> the descriptor is NOT normalized. - inline void get_unnormalized_descriptor(double y, double x, int orientation, float* descriptor ); + inline void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ); // computes the descriptor at homography-warped grid. (y,x) is not the // coordinates of this image but the coordinates of the original grid where @@ -409,7 +409,7 @@ private: // and we warp this grid with H and compute the descriptor on this warped // grid; returns null/false if centers falls outside the image; allocate // 'descriptor' memory first. descriptor is normalized. - inline bool get_descriptor(double y, double x, int orientation, double* H, float* descriptor ); + inline bool get_descriptor( double y, double x, int orientation, double* H, float* descriptor); // computes the descriptor at homography-warped grid. (y,x) is not the // coordinates of this image but the coordinates of the original grid where @@ -417,7 +417,7 @@ private: // and we warp this grid with H and compute the descriptor on this warped // grid; returns null/false if centers falls outside the image; allocate // 'descriptor' memory first. descriptor is NOT normalized. - inline bool get_unnormalized_descriptor(double y, double x, int orientation, double* H, float* descriptor ); + inline bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ); // compute the smoothed gradient layers. inline void compute_smoothed_gradient_layers(); @@ -452,7 +452,7 @@ private: inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); // creates a 1D gaussian filter with N(mean,sigma). - inline void gaussian_1d(float* fltr, int fsz, float sigma, float mean ) + inline void gaussian_1d( float* fltr, int fsz, float sigma, float mean ) { CV_Assert(fltr != NULL); int sz = (fsz-1)/2; @@ -476,27 +476,27 @@ private: inline void conv_horizontal( float* image, int h, int w, float* kernel, int ksize ) { CvMat cvI; cvInitMatHeader(&cvI, h, w, CV_32FC1, (float*)image); - CvMat cvK; cvInitMatHeader(&cvK, 1, ksize, CV_32FC1, (float*)kernel ); + CvMat cvK; cvInitMatHeader(&cvK, 1, ksize, CV_32FC1, (float*)kernel); cvFilter2D( &cvI, &cvI, &cvK ); } inline void conv_horizontal( double* image, int h, int w, double* kernel, int ksize ) { CvMat cvI; cvInitMatHeader(&cvI, h, w, CV_64FC1, (double*)image); - CvMat cvK; cvInitMatHeader(&cvK, 1, ksize, CV_64FC1, (double*)kernel ); + CvMat cvK; cvInitMatHeader(&cvK, 1, ksize, CV_64FC1, (double*)kernel); cvFilter2D( &cvI, &cvI, &cvK ); } inline void conv_vertical( float* image, int h, int w, float* kernel, int ksize ) { CvMat cvI; cvInitMatHeader(&cvI, h, w, CV_32FC1, (float*)image); - CvMat cvK; cvInitMatHeader(&cvK, ksize, 1, CV_32FC1, (float*)kernel ); + CvMat cvK; cvInitMatHeader(&cvK, ksize, 1, CV_32FC1, (float*)kernel); cvFilter2D( &cvI, &cvI, &cvK ); } inline void conv_vertical( double* image, int h, int w, double* kernel, int ksize ) { CvMat cvI; cvInitMatHeader(&cvI, h, w, CV_64FC1, (double*)image); - CvMat cvK; cvInitMatHeader(&cvK, ksize, 1, CV_64FC1, (double*)kernel ); + CvMat cvK; cvInitMatHeader(&cvK, ksize, 1, CV_64FC1, (double*)kernel); cvFilter2D( &cvI, &cvI, &cvK ); } @@ -792,7 +792,7 @@ private: T* layers = zeros(layer_no * data_size); // smooth the data matrix - T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); + T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false ); T *dx = new T[data_size]; T *dy = new T[data_size]; @@ -853,23 +853,23 @@ private: // be careful, 'data' is destroyed afterwards template inline // original T* workspace=0 was removed - void layered_gradient( T* data, int h, int w, int layer_no, T* layers, int lwork=0 ) + void layered_gradient( T* data, int h, int w, int layer_no, T* layers, int lwork = 0 ) { int data_size = h * w; CV_Assert(layers!=NULL); memset(layers,0,sizeof(T)*data_size*layer_no); - bool empty=false; + bool was_empty = false; T* work=NULL; if( lwork < 3*data_size ) { work = new T[3*data_size]; - empty=true; + was_empty = true; } // // smooth the data matrix // T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); float kernel[5]; gaussian_1d(kernel, 5, 0.5, 0); - memcpy( work, data, sizeof(T)*data_size); + memcpy( work, data, sizeof(T)*data_size ); convolve_sym( work, h, w, kernel, 5 ); T *dx = work+data_size; @@ -894,7 +894,7 @@ private: else layer_l[index] = 0; } } - if( empty ) delete []work; + if( was_empty ) delete []work; } // casts a type T2 array into a type T1 array. @@ -915,7 +915,7 @@ private: // to be an odd number. if in_place=true, then T1 must be equal // to T2 naturally. template inline - T1* blur_gaussian_2d( T2* array, int rn, int cn, float sigma, int kernel_size=0, bool in_place=false ) + T1* blur_gaussian_2d( T2* array, int rn, int cn, float sigma, int kernel_size = 0, bool in_place = false ) { T1* out = NULL; @@ -1167,7 +1167,7 @@ void DAISY_Impl::set_cube_gaussians( double* sigma_array, int sz ) g_cube_number = sz; if( m_cube_sigmas ) deallocate( m_cube_sigmas ); - m_cube_sigmas = allocate(g_cube_number); + m_cube_sigmas = allocate( g_cube_number ); for( int r=0; r(g_grid_orientation_resolution, m_grid_point_number*2 ); + m_oriented_grid_points = allocate( g_grid_orientation_resolution, m_grid_point_number*2 ); for( int i=0; i=0 && x>=0 ); descriptor = &(m_dense_descriptors[(y*m_w+x)*m_descriptor_size]); } -inline void DAISY_Impl::get_descriptor(double y, double x, int orientation, float* descriptor ) +inline void DAISY_Impl::get_descriptor( double y, double x, int orientation, float* descriptor ) { get_unnormalized_descriptor(y, x, orientation, descriptor ); normalize_descriptor(descriptor, m_nrm_type); } -inline void DAISY_Impl::get_unnormalized_descriptor(double y, double x, int orientation, float* descriptor ) +inline void DAISY_Impl::get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ) { if( m_disable_interpolation ) ni_get_descriptor(y,x,orientation,descriptor); else i_get_descriptor(y,x,orientation,descriptor); } -inline void DAISY_Impl::i_get_descriptor(double y, double x, int orientation, float* descriptor ) +inline void DAISY_Impl::i_get_descriptor( double y, double x, int orientation, float* descriptor ) { // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); // @@ -1689,7 +1689,7 @@ inline void DAISY_Impl::i_get_descriptor(double y, double x, int orientation, fl } } -inline void DAISY_Impl::ni_get_descriptor(double y, double x, int orientation, float* descriptor ) +inline void DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, float* descriptor ) { // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); // @@ -1738,20 +1738,20 @@ inline void DAISY_Impl::ni_get_descriptor(double y, double x, int orientation, f } // Warped get_descriptor's -inline bool DAISY_Impl::get_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +inline bool DAISY_Impl::get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) { bool rval = get_unnormalized_descriptor(y,x,orientation, H, descriptor); if( rval ) normalize_descriptor(descriptor, m_nrm_type); return rval; } -inline bool DAISY_Impl::get_unnormalized_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +inline bool DAISY_Impl::get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) { if( m_disable_interpolation ) return ni_get_descriptor(y,x,orientation,H,descriptor); else return i_get_descriptor(y,x,orientation,H,descriptor); } -inline bool DAISY_Impl::i_get_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +inline bool DAISY_Impl::i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) { // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); // @@ -1806,7 +1806,7 @@ inline bool DAISY_Impl::i_get_descriptor(double y, double x, int orientation, do return true; } -inline bool DAISY_Impl::ni_get_descriptor(double y, double x, int orientation, double* H, float* descriptor ) +inline bool DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) { // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); // From 01a49e7988660fa19784bcdeae04a176a3771c94 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 11 May 2015 17:11:33 +0300 Subject: [PATCH 17/21] Fix win64 warnings. --- modules/xfeatures2d/src/daisy.cpp | 91 ++++++++++++++++--------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp index 62f42bf6e..2e9505e68 100644 --- a/modules/xfeatures2d/src/daisy.cpp +++ b/modules/xfeatures2d/src/daisy.cpp @@ -462,7 +462,7 @@ private: for( int x=-sz; x<=sz; x++ ) { counter++; - fltr[counter] = exp((-(x-mean)*(x-mean))/v); + fltr[counter] = exp((-((float)x-mean)*((float)x-mean))/v); sum += fltr[counter]; } @@ -690,8 +690,8 @@ private: template inline float l2norm( T y0, T x0, T y1, T x1 ) { - float d0 = x0 - x1; - float d1 = y0 - y1; + float d0 = (float) (x0 - x1); + float d1 = (float) (y0 - y1); return sqrt( d0*d0 + d1*d1 ); } @@ -768,7 +768,7 @@ private: template inline void divide(T1* arr, int sz, T2 num ) { - float inv_num = 1.0 / num; + float inv_num = (float) (1.0 / num); for( int i=0; i0 && x0 && x0 && y0 && y= left && center >= right); - float den = (left - 2.0 * center + right); + float den = (float) (left - 2.0 * center + right); if( den == 0 ) return 0; - else return 0.5*(left -right)/den; + else return (float) (0.5*(left -right)/den); } int DAISY_Impl::filter_size( double sigma ) @@ -1357,7 +1357,7 @@ void DAISY_Impl::compute_scales() int imsz = m_w * m_h; - float sigma = pow( g_sigma_step, g_scale_st)*g_sigma_0; + float sigma = (float) ( pow( g_sigma_step, g_scale_st)*g_sigma_0 ); float* sim = blur_gaussian_2d( m_image, m_h, m_w, sigma, filter_size(sigma), false); @@ -1375,10 +1375,10 @@ void DAISY_Impl::compute_scales() float sigma_new; float sigma_inc; - sigma_prev = g_sigma_0; + sigma_prev = (float) g_sigma_0; for( i=0; i max_dog[p] ) { max_dog[p] = dog; - m_scale_map[p] = i; + m_scale_map[p] = (float) i; } } deallocate( sim ); @@ -1408,7 +1408,7 @@ void DAISY_Impl::compute_scales() #endif for( int q=0; q 0.5 ) ihx++; int ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; @@ -1855,7 +1855,7 @@ inline bool DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, { point_transform_via_homography(H, gx+m_cube_sigmas[g_selected_cubes[r]], gy, rx, ry); radius = l2norm( ry, rx, hy, hx ); - hradius[r] = quantize_radius( radius ); + hradius[r] = quantize_radius( (float) radius ); } ihx = (int)hx; if( hx - ihx > 0.5 ) ihx++; @@ -1972,21 +1972,21 @@ void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, O if ( m_mode == ONLY_KEYS ) { cv::Mat descriptors; - _descriptors.create( keypoints.size(), m_descriptor_size, CV_32F ); + _descriptors.create( (int) keypoints.size(), m_descriptor_size, CV_32F ); descriptors = _descriptors.getMat(); if ( H.empty() ) - for (size_t k = 0; k < keypoints.size(); k++) + for (int k = 0; k < (int) keypoints.size(); k++) { get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, - m_use_orientation ? keypoints[k].angle : 0, + m_use_orientation ? (int) keypoints[k].angle : 0, &descriptors.at( k, 0 ) ); } else - for (size_t k = 0; k < keypoints.size(); k++) + for (int k = 0; k < (int) keypoints.size(); k++) { get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, - m_use_orientation ? keypoints[k].angle : 0, + m_use_orientation ? (int) keypoints[k].angle : 0, &H.at( 0 ), &descriptors.at( k, 0 ) ); } @@ -2025,11 +2025,12 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, m_descriptor_memory = false; m_workspace_memory = false; - m_descriptor_normalization_threshold = 0.154; // sift magical number m_cube_size = 0; m_layer_size = 0; + m_descriptor_normalization_threshold = 0.154f; // sift magical number + } // destructor From 6a1bf77c1ef61aeb5c1fbb565518e1a937b9a919 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 11 May 2015 20:50:22 +0300 Subject: [PATCH 18/21] Fix win64 warnings (#2). --- modules/xfeatures2d/src/daisy.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp index 2e9505e68..a9264ab4f 100644 --- a/modules/xfeatures2d/src/daisy.cpp +++ b/modules/xfeatures2d/src/daisy.cpp @@ -84,14 +84,15 @@ class DAISY_Impl : public DAISY public: /** Constructor - @param radius radius of the descriptor at the initial scale - @param q_radius amount of radial range divisions - @param q_theta amount of angular range divisions - @param q_hist amount of gradient orientations range divisions - @param mode computation of descriptors - @param norm normalization type - @param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image - @param interpolation switch to disable interpolation at minor costs of quality (default is true) + * @param radius radius of the descriptor at the initial scale + * @param q_radius amount of radial range divisions + * @param q_theta amount of angular range divisions + * @param q_hist amount of gradient orientations range divisions + * @param mode computation of descriptors + * @param norm normalization type + * @param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image + * @param interpolation switch to disable interpolation at minor costs of quality (default is true) + * @param use_orientation sample patterns using keypoints orientation, disabled by default. */ explicit DAISY_Impl(float radius=15, int q_radius=3, int q_theta=8, int q_hist=8, int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, InputArray H = noArray(), @@ -138,7 +139,7 @@ protected: int m_nrm_type; // holds optional H matrix - InputArray m_h_matrix; + Mat m_h_matrix; // input image. float* m_image; @@ -1880,7 +1881,7 @@ void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, O return; // get homography if supplied - Mat H = m_h_matrix.getMat(); + Mat H = m_h_matrix; // convert to float if case if ( image.depth() != CV_64F ) @@ -1998,7 +1999,7 @@ void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, O DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, int _mode, int _norm, InputArray _H, bool _interpolation, bool _use_orientation ) : m_mode(_mode), m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), - m_nrm_type(_norm), m_h_matrix(_H), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) + m_nrm_type(_norm), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) { m_w = 0; m_h = 0; @@ -2031,6 +2032,7 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, m_descriptor_normalization_threshold = 0.154f; // sift magical number + m_h_matrix = _H.getMat(); } // destructor From 96f1e2566096e3c95098b95273aef8b271a36070 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 11 May 2015 15:17:29 +0300 Subject: [PATCH 19/21] Squash all commits into one. --- modules/xfeatures2d/doc/xfeatures2d.bib | 11 + .../include/opencv2/xfeatures2d.hpp | 31 + modules/xfeatures2d/perf/perf_daisy.cpp | 33 + modules/xfeatures2d/src/daisy.cpp | 2057 +++++++++++++++++ modules/xfeatures2d/test/test_features2d.cpp | 7 + .../test_rotation_and_scale_invariance.cpp | 18 + 6 files changed, 2157 insertions(+) create mode 100644 modules/xfeatures2d/perf/perf_daisy.cpp create mode 100644 modules/xfeatures2d/src/daisy.cpp diff --git a/modules/xfeatures2d/doc/xfeatures2d.bib b/modules/xfeatures2d/doc/xfeatures2d.bib index 0d3918923..9d2f74190 100644 --- a/modules/xfeatures2d/doc/xfeatures2d.bib +++ b/modules/xfeatures2d/doc/xfeatures2d.bib @@ -62,3 +62,14 @@ year={2012} publisher={NIPS} } + +@article{Tola10, + author = "E. Tola and V. Lepetit and P. Fua", + title = {{DAISY: An Efficient Dense Descriptor Applied to Wide Baseline Stereo}}, + journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence", + year = 2010, + month = "May", + pages = "815--830", + volume = "32", + number = "5" +} diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 7ac50d9ee..bb54e7ce4 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -191,6 +191,37 @@ public: static Ptr create(const int lucid_kernel, const int blur_kernel); }; +/** @brief Class implementing DAISY descriptor, described in @cite Tola10 + +@param radius radius of the descriptor at the initial scale +@param q_radius amount of radial range division quantity +@param q_theta amount of angular range division quantity +@param q_hist amount of gradient orientations range division quantity +@param mode choose computation mode of descriptors where +DAISY::ONLY_KEYS means to compute descriptors only for keypoints in the list (default) and +DAISY::COMP_FULL will compute descriptors for all pixels in the given image +@param norm choose descriptors normalization type, where +DAISY::NRM_NONE will not do any normalization (default), +DAISY::NRM_PARTIAL mean that histograms are normalized independently for L2 norm equal to 1.0, +DAISY::NRM_FULL mean that descriptors are normalized for L2 norm equal to 1.0, +DAISY::NRM_SIFT mean that descriptors are normalized for L2 norm equal to 1.0 but no individual one is bigger than 0.154 as in SIFT +@param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image +@param interpolation switch to disable interpolation for speed improvement at minor quality loss +@param use_orientation sample patterns using keypoints orientation, disabled by default. + + */ +class CV_EXPORTS DAISY : public DescriptorExtractor +{ +public: + enum + { + ONLY_KEYS = 0, COMP_FULL = 1, + NRM_NONE = 100, NRM_PARTIAL = 101, NRM_FULL = 102, NRM_SIFT = 103, + }; + static Ptr create( float radius = 15, int q_radius = 3, int q_theta = 8, + int q_hist = 8, int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, + InputArray H = noArray() , bool interpolation = true, bool use_orientation = false ); +}; //! @} diff --git a/modules/xfeatures2d/perf/perf_daisy.cpp b/modules/xfeatures2d/perf/perf_daisy.cpp new file mode 100644 index 000000000..bb60b8e78 --- /dev/null +++ b/modules/xfeatures2d/perf/perf_daisy.cpp @@ -0,0 +1,33 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace cv::xfeatures2d; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +typedef perf::TestBaseWithParam daisy; + +#define DAISY_IMAGES \ + "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ + "stitching/a3.png" + +PERF_TEST_P(daisy, extract, testing::Values(DAISY_IMAGES)) +{ + string filename = getDataPath(GetParam()); + Mat frame = imread(filename, IMREAD_GRAYSCALE); + ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename; + + Mat mask; + declare.in(frame).time(90); + + // use DAISY in COMP_FULL mode (every pixel, dense baseline mode) + Ptr descriptor = DAISY::create(15, 3, 8, 8, DAISY::COMP_FULL, DAISY::NRM_NONE, noArray(), true, false); + + vector points; + vector descriptors; + TEST_CYCLE() descriptor->compute(frame, points, descriptors); + + SANITY_CHECK(descriptors, 1e-4); +} diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp new file mode 100644 index 000000000..a9264ab4f --- /dev/null +++ b/modules/xfeatures2d/src/daisy.cpp @@ -0,0 +1,2057 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2009 + * Engin Tola + * web : http://www.engintola.com + * email : engin.tola+libdaisy@gmail.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the Willow Garage nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *********************************************************************/ + +/* + "DAISY: An Efficient Dense Descriptor Applied to Wide Baseline Stereo" + by Engin Tola, Vincent Lepetit and Pascal Fua. IEEE Transactions on + Pattern Analysis and achine Intelligence, 31 Mar. 2009. + IEEE computer Society Digital Library. IEEE Computer Society, + http:doi.ieeecomputersociety.org/10.1109/TPAMI.2009.77 + + "A fast local descriptor for dense matching" by Engin Tola, Vincent + Lepetit, and Pascal Fua. Intl. Conf. on Computer Vision and Pattern + Recognition, Alaska, USA, June 2008 + + OpenCV port by: Cristian Balint + */ + +#include "precomp.hpp" +#include "opencv2/imgproc/imgproc_c.h" + +#include +#include + +namespace cv +{ +namespace xfeatures2d +{ + +// constants +const double g_sigma_0 = 1; +const double g_sigma_1 = sqrt(2.0); +const double g_sigma_2 = 8; +const double g_sigma_step = std::pow(2,1.0/2); +const int g_scale_st = int( (log(g_sigma_1/g_sigma_0)) / log(g_sigma_step) ); +static int g_scale_en = 1; + +const double g_sigma_init = 1.6; +const static int g_grid_orientation_resolution = 360; + +static const int MAX_CUBE_NO = 64; +static const int MAX_NORMALIZATION_ITER = 5; + +int g_cube_number; +int g_selected_cubes[MAX_CUBE_NO]; // m_rad_q_no < MAX_CUBE_NO + +/* + !DAISY implementation + */ +class DAISY_Impl : public DAISY +{ + +public: + /** Constructor + * @param radius radius of the descriptor at the initial scale + * @param q_radius amount of radial range divisions + * @param q_theta amount of angular range divisions + * @param q_hist amount of gradient orientations range divisions + * @param mode computation of descriptors + * @param norm normalization type + * @param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image + * @param interpolation switch to disable interpolation at minor costs of quality (default is true) + * @param use_orientation sample patterns using keypoints orientation, disabled by default. + */ + explicit DAISY_Impl(float radius=15, int q_radius=3, int q_theta=8, int q_hist=8, + int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, InputArray H = noArray(), + bool interpolation = true, bool use_orientation = false); + + virtual ~DAISY_Impl(); + + /** returns the descriptor length in bytes */ + virtual int descriptorSize() const { + // +1 is for center pixel + return ( (m_rad_q_no * m_th_q_no + 1) * m_hist_th_q_no ); + }; + /** returns the descriptor type */ + virtual int descriptorType() const { return CV_32F; } + /** returns the default norm type */ + virtual int defaultNorm() const { return NORM_L2; } + + // main compute routine + virtual void compute( InputArray image, std::vector& keypoints, OutputArray descriptors ); + +protected: + + /* + * DAISY parameters + */ + + // operation mode + int m_mode; + + // maximum radius of the descriptor region. + float m_rad; + + // the number of quantizations of the radius. + int m_rad_q_no; + + // the number of quantizations of the angle. + int m_th_q_no; + + // the number of quantizations of the gradient orientations. + int m_hist_th_q_no; + + // holds the type of the normalization to apply; equals to NRM_PARTIAL by + // default. change the value using set_normalization() function. + int m_nrm_type; + + // holds optional H matrix + Mat m_h_matrix; + + // input image. + float* m_image; + + // image height + int m_h; + + // image width + int m_w; + + // stores the descriptors : its size is [ m_w * m_h * m_descriptor_size ]. + float* m_dense_descriptors; + + // stores the layered gradients in successively smoothed form: layer[n] = + // m_gradient_layers * gaussian( sigma_n ); n>= 1; layer[0] is the layered_gradient + float* m_smoothed_gradient_layers; + + // if set to true, descriptors are scale invariant + bool m_scale_invariant; + + // if set to true, descriptors are rotation invariant + bool m_rotation_invariant; + + // number of bins in the histograms while computing orientation + int m_orientation_resolution; + + // hold the scales of the pixels + float* m_scale_map; + + // holds the orientaitons of the pixels + int* m_orientation_map; + + // Holds the oriented coordinates (y,x) of the grid points of the region. + double** m_oriented_grid_points; + + // holds the gaussian sigmas for radius quantizations for an incremental + // application + double* m_cube_sigmas; + + bool m_descriptor_memory; + bool m_workspace_memory; + + // the number of grid locations + int m_grid_point_number; + + // the size of the descriptor vector + int m_descriptor_size; + + // holds the amount of shift that's required for histogram computation + double m_orientation_shift_table[360]; + + // if enabled, descriptors are computed with casting non-integer locations + // to integer positions otherwise we use interpolation. + bool m_disable_interpolation; + + // switch to enable sample by keypoints orientation + bool m_use_orientation; + + // size of m_hsz layers at a single sigma: m_hsz * m_layer_size + int m_cube_size; + + // size of the layer : m_h*m_w + int m_layer_size; + + /* + * DAISY functions + */ + + // computes the histogram at yx; the size of histogram is m_hist_th_q_no + void compute_histogram( float* hcube, int y, int x, float* histogram ); + + // reorganizes the cube data so that histograms are sequential in memory. + void compute_histograms(); + + // emulates the way sift is normalized. + void normalize_sift_way( float* desc ); + + // normalizes the descriptor histogram by histogram + void normalize_partial( float* desc ); + + // normalizes the full descriptor. + void normalize_full( float* desc ); + + // initializes the class: computes gradient and structure-points + void initialize(); + + void update_selected_cubes(); + + int quantize_radius( float rad ); + + int filter_size( double sigma ); + + // computes scales for every pixel and scales the structure grid so that the + // resulting descriptors are scale invariant. you must set + // m_scale_invariant flag to 1 for the program to call this function + void compute_scales(); + + // Return a number in the range [-0.5, 0.5] that represents the location of + // the peak of a parabola passing through the 3 evenly spaced samples. The + // center value is assumed to be greater than or equal to the other values + // if positive, or less than if negative. + float interpolate_peak( float left, float center, float right ); + + // Smooth a histogram by using a [1/3 1/3 1/3] kernel. Assume the histogram + // is connected in a circular buffer. + void smooth_histogram( float *hist, int bins ); + + // computes pixel orientations and rotates the structure grid so that + // resulting descriptors are rotation invariant. If the scales is also + // detected, then orientations are computed at the computed scales. you must + // set m_rotation_invariant flag to 1 for the program to call this function + void compute_orientations(); + + // the clipping threshold to use in normalization: values above this value + // are clipped to this value for normalize_sift_way() function + float m_descriptor_normalization_threshold; + + // computes the sigma's of layers from descriptor parameters if the user did + // not sets it. these define the size of the petals of the descriptor. + void compute_cube_sigmas(); + + // Computes the locations of the unscaled unrotated points where the + // histograms are going to be computed according to the given parameters. + void compute_grid_points(); + + // Computes the locations of the unscaled rotated points where the + // histograms are going to be computed according to the given parameters. + void compute_oriented_grid_points(); + + // smooths each of the layers by a Gaussian having "sigma" standart + // deviation. + void smooth_layers( float*layers, int h, int w, int layer_number, float sigma ); + + // Holds the coordinates (y,x) of the grid points of the region. + double** m_grid_points; + + int get_hq() { return m_hist_th_q_no; } + int get_thq() { return m_th_q_no; } + int get_rq() { return m_rad_q_no; } + float get_rad() { return m_rad; } + + // sets the type of the normalization to apply out of {NRM_PARTIAL, + // NRM_FULL, NRM_SIFT}. Call before using get_descriptor() if you want to + // change the default normalization type. + void set_normalization( int nrm_type ) { m_nrm_type = nrm_type; } + + // applies one of the normalizations (partial,full,sift) to the desciptors. + void normalize_descriptors( int nrm_type = DAISY::NRM_NONE ); + + // normalizes histograms individually + void normalize_histograms(); + + // gets the histogram at y,x with 'orientation' from the r'th cube + float* get_histogram( int y, int x, int r ); + + // if called, I don't use interpolation in the computation of + // descriptors. + void disable_interpolation() { m_disable_interpolation = true; } + + // returns the region number. + int grid_point_number() { return m_grid_point_number; } + + // releases all the used memory; call this if you want to process + // multiple images within a loop. + void reset(); + + // releases unused memory after descriptor computation is completed. + void release_auxilary(); + + // computes the descriptors for every pixel in the image. + void compute_descriptors(); + + // returns all the descriptors. + float* get_dense_descriptors(); + + // returns oriented grid points. default is 0 orientation. + double* get_grid(int o=0); + + // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the + // scales for every pixel so that the resulting descriptors are scale + // invariant. + void scale_invariant( bool state = true ) + { + g_scale_en = (int)( (log(g_sigma_2/g_sigma_0)) / log(g_sigma_step) ) - g_scale_st; + m_scale_invariant = state; + } + + // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the + // orientations for every pixel so that the resulting descriptors are + // rotation invariant. orientation steps are 360/ori_resolution + void rotation_invariant( int ori_resolution = 36, bool state = true ) + { + m_rotation_invariant = state; + m_orientation_resolution = ori_resolution; + } + + // sets the gaussian variances manually. must be called before + // initialize() to be considered. must be exact sigma values -> f + // converts to incremental format. + void set_cube_gaussians( double* sigma_array, int sz ); + + int* get_orientation_map() { return m_orientation_map; } + + // call compute_descriptor_memory to find the amount of memory to allocate + void set_descriptor_memory( float* descriptor, long int d_size ); + + // call compute_workspace_memory to find the amount of memory to allocate + void set_workspace_memory( float* workspace, long int w_size ); + + // returns the amount of memory needed for the compute_descriptors() + // function. it is basically equal to imagesize x descriptor_size + int compute_descriptor_memory() { + if( m_h == 0 || m_descriptor_size == 0 ) { + CV_Error( Error::StsInternal, "Image and descriptor size is zero" ); + } + return m_w * m_h * m_descriptor_size; + } + + // returns the amount of memory needed for workspace. call before initialize() + int compute_workspace_memory() { + if( m_cube_size == 0 ) { + CV_Error( Error::StsInternal, "Cube size is zero" ); + } + return (g_cube_number+1)* m_cube_size; + } + + void normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) + { + if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; + else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); + else if( nrm_type == DAISY::NRM_FULL ) normalize_full(desc); + else if( nrm_type == DAISY::NRM_SIFT ) normalize_sift_way(desc); + else + CV_Error( Error::StsInternal, "No such normalization" ); + } + + // transform a point via the homography + void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) + { + double kxp = H[0]*x + H[1]*y + H[2]; + double kyp = H[3]*x + H[4]*y + H[5]; + double kp = H[6]*x + H[7]*y + H[8]; + u = kxp / kp; + v = kyp / kp; + } + +private: + + // returns the descriptor vector for the point (y, x) !!! use this for + // precomputed operations meaning that you must call compute_descriptors() + // before calling this function. if you want normalized descriptors, call + // normalize_descriptors() before calling compute_descriptors() + inline void get_descriptor( int y, int x, float* &descriptor ); + + // computes the descriptor and returns the result in 'descriptor' ( allocate + // 'descriptor' memory first ie: float descriptor = new + // float[m_descriptor_size]; -> the descriptor is normalized. + inline void get_descriptor( double y, double x, int orientation, float* descriptor ); + + // computes the descriptor and returns the result in 'descriptor' ( allocate + // 'descriptor' memory first ie: float descriptor = new + // float[m_descriptor_size]; -> the descriptor is NOT normalized. + inline void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ); + + // computes the descriptor at homography-warped grid. (y,x) is not the + // coordinates of this image but the coordinates of the original grid where + // the homography will be applied. Meaning that the grid is somewhere else + // and we warp this grid with H and compute the descriptor on this warped + // grid; returns null/false if centers falls outside the image; allocate + // 'descriptor' memory first. descriptor is normalized. + inline bool get_descriptor( double y, double x, int orientation, double* H, float* descriptor); + + // computes the descriptor at homography-warped grid. (y,x) is not the + // coordinates of this image but the coordinates of the original grid where + // the homography will be applied. Meaning that the grid is somewhere else + // and we warp this grid with H and compute the descriptor on this warped + // grid; returns null/false if centers falls outside the image; allocate + // 'descriptor' memory first. descriptor is NOT normalized. + inline bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + + // compute the smoothed gradient layers. + inline void compute_smoothed_gradient_layers(); + + // does not use interpolation while computing the histogram. + inline void ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ); + + // returns the interpolated histogram: picks either bi_get_histogram or + // ti_get_histogram depending on 'shift' + inline void i_get_histogram( float* histogram, double y, double x, double shift, float* cube ); + + // records the histogram that is computed by bilinear interpolation + // regarding the shift in the spatial coordinates. hcube is the + // histogram cube for a constant smoothness level. + inline void bi_get_histogram( float* descriptor, double y, double x, int shift, float* hcube ); + + // records the histogram that is computed by trilinear interpolation + // regarding the shift in layers and spatial coordinates. hcube is the + // histogram cube for a constant smoothness level. + inline void ti_get_histogram( float* descriptor, double y, double x, double shift, float* hcube ); + + // uses interpolation, for no interpolation call ni_get_descriptor. see also get_descriptor + inline void i_get_descriptor( double y, double x, int orientation, float* descriptor ); + + // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor + inline void ni_get_descriptor( double y, double x, int orientation, float* descriptor ); + + // uses interpolation for no interpolation call ni_get_descriptor. see also get_descriptor + inline bool i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + + // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor + inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + + // creates a 1D gaussian filter with N(mean,sigma). + inline void gaussian_1d( float* fltr, int fsz, float sigma, float mean ) + { + CV_Assert(fltr != NULL); + int sz = (fsz-1)/2; + int counter=-1; + float sum = 0.0; + float v = 2*sigma*sigma; + for( int x=-sz; x<=sz; x++ ) + { + counter++; + fltr[counter] = exp((-((float)x-mean)*((float)x-mean))/v); + sum += fltr[counter]; + } + + if( sum != 0 ) + { + for( int x=0; x + class rectangle + { + public: + T lx, ux, ly, uy; + T dx, dy; + rectangle(T xl, T xu, T yl, T yu) { lx=xl; ux=xu; ly=yl; uy=yu; dx=ux-lx; dy=uy-ly; }; + rectangle() { lx = ux = ly = uy = dx = dy = 0; }; + }; + + // checks if the number x is between lx - ux interval. + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + { + if( ( ((lx lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='&') + { + switch( oper ) + { + case '|': + if( is_inside(x,lx,ux,le,ue) || is_inside(y,ly,uy,le,ue) ) + return true; + return false; + + default: + if( is_inside(x,lx,ux,le,ue) && is_inside(y,ly,uy,le,ue) ) + return true; + return false; + } + } + + // checks if the number x is between lx - ux and/or y is between ly - uy interval. + // If the number is inside, then function returns true, else it returns false. + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline + bool is_inside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='&') + { + switch( oper ) + { + case '|': + if( is_inside(x,roi.lx,roi.ux,le,ue) || is_inside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + + default: + if( is_inside(x,roi.lx,roi.ux,le,ue) && is_inside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + } + } + + // checks if the number x is outside lx - ux interval + // the equality is checked depending on the value of le and ue parameters. + // if le=1 => lx>x is checked else lx>=x is checked + // if ue=1 => x>ux is checked else x>=ux is checked + // by default is x is searched outside of [lx,ux) + template inline + bool is_outside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + { + return !(is_inside(x,lx,ux,le,ue)); + } + + // checks if the numbers x and y is outside their intervals. + // The equality is checked depending on the value of le and ue parameters. + // If le=1 => lx>x is checked else lx>=x is checked + // If ue=1 => x>ux is checked else x>=ux is checked + // By default is x is searched outside of [lx,ux) (Similarly for y) + // By default, 'oper' is set to OR. If one of them is outside it returns + // true otherwise false. + template inline + bool is_outside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='|') + { + switch( oper ) + { + case '&': + if( is_outside(x,lx,ux,le,ue) && is_outside(y,ly,uy,le,ue) ) + return true; + return false; + default: + if( is_outside(x,lx,ux,le,ue) || is_outside(y,ly,uy,le,ue) ) + return true; + return false; + } + } + + // checks if the numbers x and y is outside their intervals. + // The equality is checked depending on the value of le and ue parameters. + // If le=1 => lx>x is checked else lx>=x is checked + // If ue=1 => x>ux is checked else x>=ux is checked + // By default is x is searched outside of [lx,ux) (Similarly for y) + // By default, 'oper' is set to OR. If one of them is outside it returns + // true otherwise false. + template inline + bool is_outside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='|') + { + switch( oper ) + { + case '&': + if( is_outside(x,roi.lx,roi.ux,le,ue) && is_outside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + default: + if( is_outside(x,roi.lx,roi.ux,le,ue) || is_outside(y,roi.ly,roi.uy,le,ue) ) + return true; + return false; + } + } + + // computes the square of a number and returns it. + template inline + T square(T a) + { + return a*a; + } + + // computes the square of an array. if in_place is enabled, the + // result is returned in the array arr. + template inline + T* square(T* arr, int sz, bool in_place=false) + { + T* out; + if( in_place ) out = arr; + else out = allocate(sz); + + for( int i=0; i inline + float l2norm( T* a, int sz) + { + float norm=0; + for( int k=0; k inline + float l2norm( T1* a, T2* b, int sz) + { + float norm=0; + for( int i=0; i inline + float l2norm( T y0, T x0, T y1, T x1 ) + { + float d0 = (float) (x0 - x1); + float d1 = (float) (y0 - y1); + + return sqrt( d0*d0 + d1*d1 ); + } + + // allocates a memory of size sz and returns a pointer to the array + template inline + T* allocate(const int sz) + { + T* array = new T[sz]; + return array; + } + + // allocates a memory of size ysz x xsz and returns a double pointer to it + template inline + T** allocate(const int ysz, const int xsz) + { + T** mat = new T*[ysz]; + int i; + + for(i=0; i(xsz); + + return mat; + } + + // deallocates the memory and sets the pointer to null. + template inline + void deallocate(T* &array) + { + delete[] array; + array = NULL; + } + + // deallocates the memory and sets the pointer to null. + template inline + void deallocate(T** &mat, int ysz) + { + if( mat == NULL ) return; + + for(int i=0; i inline + void polar2cartesian(T1 r, T1 t, T2 &y, T2 &x) + { + x = (T2)( r * cos( t ) ); + y = (T2)( r * sin( t ) ); + } + + + template inline + void convolve_sym_( T* image, int h, int w, T* kernel, int ksize ) + { + conv_horizontal( image, h, w, kernel, ksize ); + conv_vertical ( image, h, w, kernel, ksize ); + } + + template + inline void convolve_sym( T* image, int h, int w, T* kernel, int ksize, T* out=NULL ) + { + if( out == NULL ) out = image; + else memcpy( out, image, sizeof(T)*h*w ); + convolve_sym_(out, h, w, kernel, ksize); + } + + // divides the elements of the array with num + template inline + void divide(T1* arr, int sz, T2 num ) + { + float inv_num = (float) (1.0 / num); + + for( int i=0; i inline + T* zeros(int r) + { + T* data = allocate(r); + memset( data, 0, sizeof(T)*r ); + return data; + } + + template inline + T* layered_gradient( T* data, int h, int w, int layer_no=8 ) + { + int data_size = h * w; + T* layers = zeros(layer_no * data_size); + + // smooth the data matrix + T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false ); + + T *dx = new T[data_size]; + T *dy = new T[data_size]; + gradient(bdata, h, w, dy, dx); + deallocate( bdata ); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int l=0; l 0 ) layer_l[index] = value; + else layer_l[index] = 0; + } + } + deallocate(dy); + deallocate(dx); + + return layers; + } + + // computes the gradient of an image and returns the result in + // pointers to REAL. + template inline + void gradient(T* im, int h, int w, T* dy, T* dx) + { + CV_Assert( dx != NULL ); + CV_Assert( dy != NULL ); + + for( int y=0; y0 && x0 && y inline + // original T* workspace=0 was removed + void layered_gradient( T* data, int h, int w, int layer_no, T* layers, int lwork = 0 ) + { + int data_size = h * w; + CV_Assert(layers!=NULL); + memset(layers,0,sizeof(T)*data_size*layer_no); + + bool was_empty = false; + T* work=NULL; + if( lwork < 3*data_size ) { + work = new T[3*data_size]; + was_empty = true; + } + + // // smooth the data matrix + // T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); + float kernel[5]; gaussian_1d(kernel, 5, 0.5, 0); + memcpy( work, data, sizeof(T)*data_size ); + convolve_sym( work, h, w, kernel, 5 ); + + T *dx = work+data_size; + T *dy = work+2*data_size; + gradient( work, h, w, dy, dx ); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int l=0; l 0 ) layer_l[index] = value; + else layer_l[index] = 0; + } + } + if( was_empty ) delete []work; + } + + // casts a type T2 array into a type T1 array. + template inline + T1* type_cast(T2* data, int sz) + { + T1* out = new T1[sz]; + + for( int i=0; i inline + T1* blur_gaussian_2d( T2* array, int rn, int cn, float sigma, int kernel_size = 0, bool in_place = false ) + { + T1* out = NULL; + + if( in_place ) + out = (T1*)array; + else + out = type_cast(array,rn*cn); + + if( kernel_size == 0 ) + kernel_size = (int)(3*sigma); + + if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd + if( kernel_size < 3 ) kernel_size= 3; // kernel size cannot be smaller than 3 + + float* kernel = new float[kernel_size]; + gaussian_1d(kernel, kernel_size, sigma, 0); + + // !! apply the filter separately + convolve_sym( out, rn, cn, kernel, kernel_size ); + // conv_horizontal( out, rn, cn, kernel, kernel_size); + // conv_vertical ( out, rn, cn, kernel, kernel_size); + + deallocate(kernel); + return out; + } + +}; // END DAISY_Impl CLASS + + +// ------------------------------------------------- +/* DAISY computation routines */ + +float* DAISY_Impl::get_histogram( int y, int x, int r ) +{ + CV_Assert( y >= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + return m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size + (y*m_w+x)*m_hist_th_q_no; + // i_get_histogram( histogram, y, x, 0, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); +} + + +float* DAISY_Impl::get_dense_descriptors() +{ + return m_dense_descriptors; +} + +double* DAISY_Impl::get_grid(int o) +{ + CV_Assert( o >= 0 && o < 360 ); + return m_oriented_grid_points[o]; +} + +void DAISY_Impl::reset() +{ + deallocate( m_image ); + // deallocate( m_grid_points, m_grid_point_number ); + // deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + // deallocate( m_cube_sigmas ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + if( !m_descriptor_memory ) deallocate( m_dense_descriptors ); + if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); +} + +void DAISY_Impl::release_auxilary() +{ + deallocate( m_image ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + + if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); + + deallocate( m_grid_points, m_grid_point_number ); + deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + deallocate( m_cube_sigmas ); +} + +void DAISY_Impl::compute_grid_points() +{ + double r_step = m_rad / (double)m_rad_q_no; + double t_step = 2*CV_PI/ m_th_q_no; + + if( m_grid_points ) + deallocate( m_grid_points, m_grid_point_number ); + + m_grid_points = allocate(m_grid_point_number, 2); + for( int y=0; y(m_h*m_w*m_descriptor_size); + + memset(m_dense_descriptors, 0, sizeof(float)*m_h*m_w*m_descriptor_size); + + int y, x, index, orientation; +#if defined _OPENMP +#pragma omp parallel for private(y,x,index,orientation) +#endif + for( y=0; y= 0 && orientation < g_grid_orientation_resolution ) ) orientation = 0; + get_unnormalized_descriptor( y, x, orientation, &(m_dense_descriptors[index*m_descriptor_size]) ); + } + } +} + +void DAISY_Impl::smooth_layers( float* layers, int h, int w, int layer_number, float sigma ) +{ + int fsz = filter_size(sigma); + float* filter = new float[fsz]; + gaussian_1d(filter, fsz, sigma, 0); + int i; + float* layer=0; +#if defined _OPENMP +#pragma omp parallel for private(i, layer) +#endif + for( i=0; i 1e-5 ) + divide( desc, m_descriptor_size, norm); + + for( h=0; h m_descriptor_normalization_threshold ) + { + desc[ h ] = m_descriptor_normalization_threshold; + changed = true; + } + } + } +} + +void DAISY_Impl::normalize_descriptors( int nrm_type ) +{ + int number_of_descriptors = m_h * m_w; + int d; + +#if defined _OPENMP +#pragma omp parallel for private(d) +#endif + for( d=0; d(g_cube_number); + + double r_step = double(m_rad)/m_rad_q_no; + for( int r=0; r< m_rad_q_no; r++ ) + { + m_cube_sigmas[r] = (r+1)*r_step/2; + } + } + update_selected_cubes(); +} + +void DAISY_Impl::set_cube_gaussians( double* sigma_array, int sz ) +{ + g_cube_number = sz; + + if( m_cube_sigmas ) deallocate( m_cube_sigmas ); + m_cube_sigmas = allocate( g_cube_number ); + + for( int r=0; r= m_cube_sigmas[g_cube_number-1] ) return g_cube_number-1; + + float dist; + float mindist=FLT_MAX; + int mini=0; + for( int c=0; c( g_grid_orientation_resolution, m_grid_point_number*2 ); + + for( int i=0; i= left && center >= right); + + float den = (float) (left - 2.0 * center + right); + + if( den == 0 ) return 0; + else return (float) (0.5*(left -right)/den); +} + +int DAISY_Impl::filter_size( double sigma ) +{ + int fsz = (int)(5*sigma); + + // kernel size must be odd + if( fsz%2 == 0 ) fsz++; + + // kernel size cannot be smaller than 3 + if( fsz < 3 ) fsz = 3; + + return fsz; +} + +void DAISY_Impl::compute_scales() +{ + //############################################################################### + //# scale detection is work-in-progress! do not use it if you're not Engin Tola # + //############################################################################### + + int imsz = m_w * m_h; + + float sigma = (float) ( pow( g_sigma_step, g_scale_st)*g_sigma_0 ); + + float* sim = blur_gaussian_2d( m_image, m_h, m_w, sigma, filter_size(sigma), false); + + float* next_sim = NULL; + + float* max_dog = allocate(imsz); + + m_scale_map = allocate(imsz); + + memset( max_dog, 0, imsz*sizeof(float) ); + memset( m_scale_map, 0, imsz*sizeof(float) ); + + int i; + float sigma_prev; + float sigma_new; + float sigma_inc; + + sigma_prev = (float) g_sigma_0; + for( i=0; i( sim, m_h, m_w, sigma_inc, filter_size( sigma_inc ) , false); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int p=0; p max_dog[p] ) + { + max_dog[p] = dog; + m_scale_map[p] = (float) i; + } + } + deallocate( sim ); + + sim = next_sim; + } + + blur_gaussian_2d( m_scale_map, m_h, m_w, 10.0, filter_size(10), true); + +#if defined _OPENMP +#pragma omp parallel for +#endif + for( int q=0; q(m_orientation_resolution); + + for( x=0; x max_val ) + { + max_val = hist[ori]; + max_ind = ori; + } + } + + prev = max_ind-1; + if( prev < 0 ) + prev += m_orientation_resolution; + + next = max_ind+1; + if( next >= m_orientation_resolution ) + next -= m_orientation_resolution; + + peak = interpolate_peak(hist[prev], hist[max_ind], hist[next]); + angle = (float)( ((float)max_ind + peak)*360.0/m_orientation_resolution ); + + int iangle = int(angle); + + if( iangle < 0 ) iangle += 360; + if( iangle >= 360 ) iangle -= 360; + + + if( !(iangle >= 0.0 && iangle < 360.0) ) + { + angle = 0; + } + + m_orientation_map[ ind ] = iangle; + } + deallocate(hist); + } + } + + deallocate( rotation_layers ); + + compute_oriented_grid_points(); +} + +void DAISY_Impl::set_descriptor_memory( float* descriptor, long int d_size ) +{ + CV_Assert( m_descriptor_memory == false ); + CV_Assert( m_h*m_w != 0 ); + CV_Assert( d_size >= compute_descriptor_memory() ); + + m_dense_descriptors = descriptor; + m_descriptor_memory = true; +} + +void DAISY_Impl::set_workspace_memory( float* workspace, long int w_size ) +{ + CV_Assert( m_workspace_memory == false ); + CV_Assert( m_h*m_w != 0 ); + CV_Assert( w_size >= compute_workspace_memory() ); + + m_smoothed_gradient_layers = workspace; + m_workspace_memory = true; +} + +// ------------------------------------------------- +/* DAISY helper routines */ + +inline void DAISY_Impl::compute_histogram( float* hcube, int y, int x, float* histogram ) +{ + if( is_outside(x, 0, m_w-1, y, 0, m_h-1) ) return; + + float* spatial_shift = hcube + y * m_w + x; + int data_size = m_w * m_h; + + for( int h=0; h 0.99 ) bi_get_histogram( histogram, y, x, ishift+1, cube ); + else ti_get_histogram( histogram, y, x, shift , cube ); +} + +inline void DAISY_Impl::bi_get_histogram( float* histogram, double y, double x, int shift, float* hcube ) +{ + int mnx = int( x ); + int mny = int( y ); + + if( mnx >= m_w-2 || mny >= m_h-2 ) + { + memset(histogram, 0, sizeof(float)*m_hist_th_q_no); + return; + } + + int ind = mny*m_w+mnx; + // A C --> pixel positions + // B D + float* A = hcube+ind*m_hist_th_q_no; + float* B = A+m_w*m_hist_th_q_no; + float* C = A+m_hist_th_q_no; + float* D = A+(m_w+1)*m_hist_th_q_no; + + double alpha = mnx+1-x; + double beta = mny+1-y; + + float w0 = (float) (alpha*beta); + float w1 = (float) (beta-w0); // (1-alpha)*beta; + float w2 = (float) (alpha-w0); // (1-beta)*alpha; + float w3 = (float) (1+w0-alpha-beta); // (1-beta)*(1-alpha); + + int h; + + for( h=0; h= m_hist_th_q_no ) hi -= m_hist_th_q_no; + histogram[h] = hptr[hi]; + } +} + +inline void DAISY_Impl::get_descriptor( int y, int x, float* &descriptor ) +{ + CV_Assert( m_dense_descriptors != NULL ); + CV_Assert( y=0 && x>=0 ); + descriptor = &(m_dense_descriptors[(y*m_w+x)*m_descriptor_size]); +} + +inline void DAISY_Impl::get_descriptor( double y, double x, int orientation, float* descriptor ) +{ + get_unnormalized_descriptor(y, x, orientation, descriptor ); + normalize_descriptor(descriptor, m_nrm_type); +} + +inline void DAISY_Impl::get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ) +{ + if( m_disable_interpolation ) ni_get_descriptor(y,x,orientation,descriptor); + else i_get_descriptor(y,x,orientation,descriptor); +} + +inline void DAISY_Impl::i_get_descriptor( double y, double x, int orientation, float* descriptor ) +{ + // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); + // + // i'm not changing the descriptor[] values if the gridpoint is outside + // the image. you should memset the descriptor array to 0 if you don't + // want to have stupid values there. + // + CV_Assert( y >= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + CV_Assert( descriptor != NULL ); + + double shift = m_orientation_shift_table[orientation]; + + i_get_histogram( descriptor, y, x, shift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + + int r, rdt, region; + double yy, xx; + float* histogram = 0; + double* grid = m_oriented_grid_points[orientation]; + + // petals of the flower + for( r=0; r= 0 && y < m_h ); + CV_Assert( x >= 0 && x < m_w ); + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( m_oriented_grid_points ); + CV_Assert( descriptor != NULL ); + + double shift = m_orientation_shift_table[orientation]; + int ishift = (int)shift; + if( shift - ishift > 0.5 ) ishift++; + + int iy = (int)y; if( y - iy > 0.5 ) iy++; + int ix = (int)x; if( x - ix > 0.5 ) ix++; + + // center + ni_get_histogram( descriptor, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + + double yy, xx; + float* histogram=0; + // petals of the flower + int r, rdt, region; + double* grid = m_oriented_grid_points[orientation]; + for( r=0; r 0.5 ) iy++; + ix = (int)xx; if( xx - ix > 0.5 ) ix++; + + if( is_outside(ix, 0, m_w-1, iy, 0, m_h-1) ) continue; + + histogram = descriptor+region*m_hist_th_q_no; + ni_get_histogram( histogram, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); + } + } +} + +// Warped get_descriptor's +inline bool DAISY_Impl::get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) +{ + bool rval = get_unnormalized_descriptor(y,x,orientation, H, descriptor); + if( rval ) normalize_descriptor(descriptor, m_nrm_type); + return rval; +} + +inline bool DAISY_Impl::get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) +{ + if( m_disable_interpolation ) return ni_get_descriptor(y,x,orientation,H,descriptor); + else return i_get_descriptor(y,x,orientation,H,descriptor); +} + +inline bool DAISY_Impl::i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) +{ + // memset( descriptor, 0, sizeof(float)*m_descriptor_size ); + // + // i'm not changing the descriptor[] values if the gridpoint is outside + // the image. you should memset the descriptor array to 0 if you don't + // want to have stupid values there. + // + CV_Assert( orientation >= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( descriptor != NULL ); + + int hradius[MAX_CUBE_NO]; + + double hy, hx, ry, rx; + point_transform_via_homography( H, x, y, hx, hy ); + if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; + + point_transform_via_homography( H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); + double radius = l2norm( ry, rx, hy, hx ); + hradius[0] = quantize_radius( (float) radius ); + + double shift = m_orientation_shift_table[orientation]; + i_get_histogram( descriptor, hy, hx, shift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + + double gy, gx; + int r, rdt, th, region; + float* histogram=0; + for( r=0; r= 0 && orientation < 360 ); + CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( descriptor != NULL ); + + int hradius[MAX_CUBE_NO]; + double radius; + + double hy, hx, ry, rx; + + point_transform_via_homography(H, x, y, hx, hy ); + if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; + + double shift = m_orientation_shift_table[orientation]; + int ishift = (int)shift; if( shift - ishift > 0.5 ) ishift++; + + point_transform_via_homography(H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); + radius = l2norm( ry, rx, hy, hx ); + hradius[0] = quantize_radius( (float) radius ); + + int ihx = (int)hx; if( hx - ihx > 0.5 ) ihx++; + int ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; + + int r, rdt, th, region; + double gy, gx; + float* histogram=0; + ni_get_histogram( descriptor, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + for( r=0; r 0.5 ) ihx++; + ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; + + if( is_outside(ihx, 0, m_w-1, ihy, 0, m_h-1) ) continue; + histogram = descriptor+region*m_hist_th_q_no; + ni_get_histogram( histogram, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[r]*m_cube_size ); + } + } + return true; +} + +// ------------------------------------------------- +/* DAISY interface implementation */ + +void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) +{ + // do nothing if no image + Mat image = _image.getMat(); + if( image.empty() ) + return; + + // get homography if supplied + Mat H = m_h_matrix; + + // convert to float if case + if ( image.depth() != CV_64F ) + H.convertTo( H, CV_64F ); + /* + * daisy set_image() + */ + + // base size + m_h = image.rows; + m_w = image.cols; + + // clone image for conversion + if ( image.depth() != CV_32F ) { + + Mat work_image = image.clone(); + + // convert to gray inplace + if( work_image.channels() > 1 ) + cvtColor( work_image, work_image, COLOR_BGR2GRAY ); + + // convert to float if it is necessary + if ( work_image.depth() != CV_32F ) + { + // convert and normalize + work_image.convertTo( work_image, CV_32F ); + work_image /= 255.0f; + } else + CV_Error( Error::StsUnsupportedFormat, "" ); + + // use cloned work image + m_image = work_image.ptr(0); + + } else + // use original CV_32F image + m_image = image.ptr(0); + + // full mode if noArray() + // was passed to _descriptors + if ( _descriptors.needed() == false ) + m_mode = DAISY::COMP_FULL; + + /* + * daisy set_parameters() + */ + + m_grid_point_number = m_rad_q_no * m_th_q_no + 1; // +1 is for center pixel + m_descriptor_size = m_grid_point_number * m_hist_th_q_no; + + for( int i=0; i<360; i++ ) + { + m_orientation_shift_table[i] = i/360.0 * m_hist_th_q_no; + } + m_layer_size = m_h*m_w; + m_cube_size = m_layer_size*m_hist_th_q_no; + + compute_cube_sigmas(); + compute_grid_points(); + + + /* + * daisy initialize_single_descriptor_mode(); + */ + + // initializes for get_descriptor(double, double, int) mode: pre-computes + // convolutions of gradient layers in m_smoothed_gradient_layers + + initialize(); + compute_smoothed_gradient_layers(); + + /* + * daisy compute descriptors given operating mode + */ + + if ( m_mode == COMP_FULL ) + { + CV_Assert( H.empty() ); + CV_Assert( keypoints.empty() ); + CV_Assert( ! m_use_orientation ); + + compute_descriptors(); + normalize_descriptors(); + + cv::Mat descriptors; + descriptors = _descriptors.getMat(); + descriptors = Mat( m_h * m_w, m_descriptor_size, + CV_32F, &m_dense_descriptors[0] ); + } else + if ( m_mode == ONLY_KEYS ) + { + cv::Mat descriptors; + _descriptors.create( (int) keypoints.size(), m_descriptor_size, CV_32F ); + descriptors = _descriptors.getMat(); + + if ( H.empty() ) + for (int k = 0; k < (int) keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? (int) keypoints[k].angle : 0, + &descriptors.at( k, 0 ) ); + } + else + for (int k = 0; k < (int) keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? (int) keypoints[k].angle : 0, + &H.at( 0 ), &descriptors.at( k, 0 ) ); + } + + } else + CV_Error( Error::StsInternal, "Unknown computation mode" ); +} + +// constructor +DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, + int _mode, int _norm, InputArray _H, bool _interpolation, bool _use_orientation ) + : m_mode(_mode), m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), + m_nrm_type(_norm), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) +{ + m_w = 0; + m_h = 0; + + m_image = 0; + + m_grid_point_number = 0; + m_descriptor_size = 0; + + m_smoothed_gradient_layers = NULL; + m_dense_descriptors = NULL; + m_grid_points = NULL; + m_oriented_grid_points = NULL; + + m_scale_invariant = false; + m_rotation_invariant = false; + + m_scale_map = NULL; + m_orientation_map = NULL; + m_orientation_resolution = 36; + m_scale_map = NULL; + + m_cube_sigmas = NULL; + + m_descriptor_memory = false; + m_workspace_memory = false; + + m_cube_size = 0; + m_layer_size = 0; + + m_descriptor_normalization_threshold = 0.154f; // sift magical number + + m_h_matrix = _H.getMat(); +} + +// destructor +DAISY_Impl::~DAISY_Impl() +{ + if( !m_workspace_memory ) deallocate( m_smoothed_gradient_layers ); + deallocate( m_grid_points, m_grid_point_number ); + deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + deallocate( m_orientation_map ); + deallocate( m_scale_map ); + deallocate( m_cube_sigmas ); +} + +Ptr DAISY::create( float radius, int q_radius, int q_theta, int q_hist, + int mode, int norm, InputArray H, bool interpolation, bool use_orientation) +{ + return makePtr(radius, q_radius, q_theta, q_hist, mode, norm, H, interpolation, use_orientation); +} + + +} // END NAMESPACE XFEATURES2D +} // END NAMESPACE CV diff --git a/modules/xfeatures2d/test/test_features2d.cpp b/modules/xfeatures2d/test/test_features2d.cpp index 303274efa..a01c0a313 100644 --- a/modules/xfeatures2d/test/test_features2d.cpp +++ b/modules/xfeatures2d/test/test_features2d.cpp @@ -1010,6 +1010,13 @@ TEST( Features2d_DescriptorExtractor_SURF, regression ) test.safe_run(); } +TEST( Features2d_DescriptorExtractor_DAISY, regression ) +{ + CV_DescriptorExtractorTest > test( "descriptor-daisy", 0.05f, + DAISY::create() ); + test.safe_run(); +} + TEST( Features2d_DescriptorExtractor_FREAK, regression ) { // TODO adjust the parameters below diff --git a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp index 46d328205..176a342c5 100644 --- a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp @@ -651,6 +651,15 @@ TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression) test.safe_run(); } +TEST(Features2d_RotationInvariance_Descriptor_DAISY, regression) +{ + DescriptorRotationInvarianceTest test(BRISK::create(), + DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + NORM_L1, + 0.79f); + test.safe_run(); +} + /* * Detector's scale invariance check */ @@ -708,3 +717,12 @@ TEST(Features2d_RotationInvariance2_Detector_SURF, regression) ASSERT_LT( fabs(keypoints[1].response - keypoints[3].response), 1e-6); ASSERT_LT( fabs(keypoints[1].response - keypoints[4].response), 1e-6); } + +TEST(Features2d_ScaleInvariance_Descriptor_DAISY, regression) +{ + DescriptorScaleInvarianceTest test(BRISK::create(), + DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + NORM_L1, + 0.075f); + test.safe_run(); +} From 2d85137ef15d5309d26930fa82e2d0cbe911b6ee Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Sun, 17 May 2015 11:52:25 +0300 Subject: [PATCH 20/21] More fixes, reorganize, fix memleaks, more API tests. --- .../include/opencv2/xfeatures2d.hpp | 68 ++- modules/xfeatures2d/perf/perf_daisy.cpp | 6 +- modules/xfeatures2d/src/daisy.cpp | 504 +++++++++++------- .../test_rotation_and_scale_invariance.cpp | 4 +- 4 files changed, 381 insertions(+), 201 deletions(-) diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index 4241a1f7b..e5151e001 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -150,7 +150,6 @@ public: @param q_radius amount of radial range division quantity @param q_theta amount of angular range division quantity @param q_hist amount of gradient orientations range division quantity -@param mode choose computation mode of descriptors where DAISY::ONLY_KEYS means to compute descriptors only for keypoints in the list (default) and DAISY::COMP_FULL will compute descriptors for all pixels in the given image @param norm choose descriptors normalization type, where @@ -168,12 +167,73 @@ class CV_EXPORTS DAISY : public DescriptorExtractor public: enum { - ONLY_KEYS = 0, COMP_FULL = 1, NRM_NONE = 100, NRM_PARTIAL = 101, NRM_FULL = 102, NRM_SIFT = 103, }; static Ptr create( float radius = 15, int q_radius = 3, int q_theta = 8, - int q_hist = 8, int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, - InputArray H = noArray() , bool interpolation = true, bool use_orientation = false ); + int q_hist = 8, int norm = DAISY::NRM_NONE, InputArray H = noArray(), + bool interpolation = true, bool use_orientation = false ); + + /** @overload + * @param image image to extract descriptors + * @param keypoints of interest within image + * @param descriptors resulted descriptors array + */ + virtual void compute( InputArray image, std::vector& keypoints, OutputArray descriptors ) = 0; + + /** @overload + * @param image image to extract descriptors + * @param roi region of interest within image + * @param descriptors resulted descriptors array for roi image pixels + */ + virtual void compute( InputArray image, Rect roi, OutputArray descriptors ) = 0; + + /**@overload + * @param image image to extract descriptors + * @param descriptors resulted descriptors array for all image pixels + */ + virtual void compute( InputArray image, OutputArray descriptors ) = 0; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param descriptor supplied array for descriptor storage + */ + virtual void get_descriptor( double y, double x, int orientation, float* descriptor ) const = 0; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param H homography matrix for warped grid + * @param descriptor supplied array for descriptor storage + * @param get_descriptor true if descriptor was computed + */ + virtual bool get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const = 0; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param descriptor supplied array for descriptor storage + */ + virtual void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ) const = 0; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param H homography matrix for warped grid + * @param descriptor supplied array for descriptor storage + * @param get_unnormalized_descriptor true if descriptor was computed + */ + virtual bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const = 0; + + /** + * @param image set image as working + */ + virtual void set_image( InputArray image ) = 0; + }; diff --git a/modules/xfeatures2d/perf/perf_daisy.cpp b/modules/xfeatures2d/perf/perf_daisy.cpp index bb60b8e78..18ade55e4 100644 --- a/modules/xfeatures2d/perf/perf_daisy.cpp +++ b/modules/xfeatures2d/perf/perf_daisy.cpp @@ -22,12 +22,12 @@ PERF_TEST_P(daisy, extract, testing::Values(DAISY_IMAGES)) Mat mask; declare.in(frame).time(90); - // use DAISY in COMP_FULL mode (every pixel, dense baseline mode) - Ptr descriptor = DAISY::create(15, 3, 8, 8, DAISY::COMP_FULL, DAISY::NRM_NONE, noArray(), true, false); + Ptr descriptor = DAISY::create(); vector points; vector descriptors; - TEST_CYCLE() descriptor->compute(frame, points, descriptors); + // compute all daisies in image + TEST_CYCLE() descriptor->compute(frame, descriptors); SANITY_CHECK(descriptors, 1e-4); } diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp index a9264ab4f..8fd167511 100644 --- a/modules/xfeatures2d/src/daisy.cpp +++ b/modules/xfeatures2d/src/daisy.cpp @@ -88,15 +88,14 @@ public: * @param q_radius amount of radial range divisions * @param q_theta amount of angular range divisions * @param q_hist amount of gradient orientations range divisions - * @param mode computation of descriptors * @param norm normalization type * @param H optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image * @param interpolation switch to disable interpolation at minor costs of quality (default is true) * @param use_orientation sample patterns using keypoints orientation, disabled by default. */ explicit DAISY_Impl(float radius=15, int q_radius=3, int q_theta=8, int q_hist=8, - int mode = DAISY::ONLY_KEYS, int norm = DAISY::NRM_NONE, InputArray H = noArray(), - bool interpolation = true, bool use_orientation = false); + int norm = DAISY::NRM_NONE, InputArray H = noArray(), + bool interpolation = true, bool use_orientation = false); virtual ~DAISY_Impl(); @@ -105,14 +104,75 @@ public: // +1 is for center pixel return ( (m_rad_q_no * m_th_q_no + 1) * m_hist_th_q_no ); }; + /** returns the descriptor type */ virtual int descriptorType() const { return CV_32F; } + /** returns the default norm type */ virtual int defaultNorm() const { return NORM_L2; } - // main compute routine + /** + * @param image image to extract descriptors + * @param keypoints of interest within image + * @param descriptors resulted descriptors array + */ virtual void compute( InputArray image, std::vector& keypoints, OutputArray descriptors ); + /** @overload + * @param image image to extract descriptors + * @param roi region of interest within image + * @param descriptors resulted descriptors array + */ + virtual void compute( InputArray image, Rect roi, OutputArray descriptors ); + + /** @overload + * @param image image to extract descriptors + * @param descriptors resulted descriptors array + */ + virtual void compute( InputArray image, OutputArray descriptors ); + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param descriptor supplied array for descriptor storage + */ + virtual void get_descriptor( double y, double x, int orientation, float* descriptor ) const; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param H homography matrix for warped grid + * @param descriptor supplied array for descriptor storage + * @param get_descriptor true if descriptor was computed + */ + virtual bool get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param descriptor supplied array for descriptor storage + */ + virtual void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ) const; + + /** + * @param y position y on image + * @param x position x on image + * @param ori orientation on image (0->360) + * @param H homography matrix for warped grid + * @param descriptor supplied array for descriptor storage + * @param get_unnormalized_descriptor true if descriptor was computed + */ + virtual bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; + + /** + * @param image set image as working + */ + virtual void set_image( InputArray image ); + + protected: /* @@ -144,13 +204,19 @@ protected: // input image. float* m_image; + Mat m_work_image; + // image height int m_h; // image width int m_w; - // stores the descriptors : its size is [ m_w * m_h * m_descriptor_size ]. + // image roi + Rect m_roi; + + // stores the descriptors : + // its size is [ m_roi.width*m_roi.height*m_descriptor_size ]. float* m_dense_descriptors; // stores the layered gradients in successively smoothed form: layer[n] = @@ -201,7 +267,8 @@ protected: // size of m_hsz layers at a single sigma: m_hsz * m_layer_size int m_cube_size; - // size of the layer : m_h*m_w + // size of the layer : + // m_roi.width*m_roi.height int m_layer_size; /* @@ -215,20 +282,20 @@ protected: void compute_histograms(); // emulates the way sift is normalized. - void normalize_sift_way( float* desc ); + void normalize_sift_way( float* desc ) const; // normalizes the descriptor histogram by histogram - void normalize_partial( float* desc ); + void normalize_partial( float* desc ) const; // normalizes the full descriptor. - void normalize_full( float* desc ); + void normalize_full( float* desc ) const; // initializes the class: computes gradient and structure-points void initialize(); void update_selected_cubes(); - int quantize_radius( float rad ); + int quantize_radius( float rad ) const; int filter_size( double sigma ); @@ -307,7 +374,7 @@ protected: void reset(); // releases unused memory after descriptor computation is completed. - void release_auxilary(); + void release_auxiliary(); // computes the descriptors for every pixel in the image. void compute_descriptors(); @@ -355,7 +422,7 @@ protected: if( m_h == 0 || m_descriptor_size == 0 ) { CV_Error( Error::StsInternal, "Image and descriptor size is zero" ); } - return m_w * m_h * m_descriptor_size; + return m_roi.width*m_roi.height * m_descriptor_size; } // returns the amount of memory needed for workspace. call before initialize() @@ -366,7 +433,7 @@ protected: return (g_cube_number+1)* m_cube_size; } - void normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) + void normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) const { if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); @@ -377,7 +444,7 @@ protected: } // transform a point via the homography - void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) + void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) const { double kxp = H[0]*x + H[1]*y + H[2]; double kyp = H[3]*x + H[4]*y + H[5]; @@ -388,69 +455,56 @@ protected: private: + // two possible computational mode + // ONLY_KEYS -> (mode_1) compute descriptors on demand + // COMP_FULL -> (mode_2) compute all descriptors from image + enum { ONLY_KEYS = 0, COMP_FULL = 1 }; + + // set & precompute parameters + inline void set_parameters(); + + + // initializes for get_descriptor(double, double, int) mode: pre-computes + // convolutions of gradient layers in m_smoothed_gradient_layers + inline void initialize_single_descriptor_mode(); + // returns the descriptor vector for the point (y, x) !!! use this for // precomputed operations meaning that you must call compute_descriptors() // before calling this function. if you want normalized descriptors, call // normalize_descriptors() before calling compute_descriptors() inline void get_descriptor( int y, int x, float* &descriptor ); - // computes the descriptor and returns the result in 'descriptor' ( allocate - // 'descriptor' memory first ie: float descriptor = new - // float[m_descriptor_size]; -> the descriptor is normalized. - inline void get_descriptor( double y, double x, int orientation, float* descriptor ); - - // computes the descriptor and returns the result in 'descriptor' ( allocate - // 'descriptor' memory first ie: float descriptor = new - // float[m_descriptor_size]; -> the descriptor is NOT normalized. - inline void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ); - - // computes the descriptor at homography-warped grid. (y,x) is not the - // coordinates of this image but the coordinates of the original grid where - // the homography will be applied. Meaning that the grid is somewhere else - // and we warp this grid with H and compute the descriptor on this warped - // grid; returns null/false if centers falls outside the image; allocate - // 'descriptor' memory first. descriptor is normalized. - inline bool get_descriptor( double y, double x, int orientation, double* H, float* descriptor); - - // computes the descriptor at homography-warped grid. (y,x) is not the - // coordinates of this image but the coordinates of the original grid where - // the homography will be applied. Meaning that the grid is somewhere else - // and we warp this grid with H and compute the descriptor on this warped - // grid; returns null/false if centers falls outside the image; allocate - // 'descriptor' memory first. descriptor is NOT normalized. - inline bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ); - // compute the smoothed gradient layers. inline void compute_smoothed_gradient_layers(); // does not use interpolation while computing the histogram. - inline void ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ); + inline void ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ) const; // returns the interpolated histogram: picks either bi_get_histogram or // ti_get_histogram depending on 'shift' - inline void i_get_histogram( float* histogram, double y, double x, double shift, float* cube ); + inline void i_get_histogram( float* histogram, double y, double x, double shift, float* cube ) const; // records the histogram that is computed by bilinear interpolation // regarding the shift in the spatial coordinates. hcube is the // histogram cube for a constant smoothness level. - inline void bi_get_histogram( float* descriptor, double y, double x, int shift, float* hcube ); + inline void bi_get_histogram( float* descriptor, double y, double x, int shift, float* hcube ) const; // records the histogram that is computed by trilinear interpolation // regarding the shift in layers and spatial coordinates. hcube is the // histogram cube for a constant smoothness level. - inline void ti_get_histogram( float* descriptor, double y, double x, double shift, float* hcube ); + inline void ti_get_histogram( float* descriptor, double y, double x, double shift, float* hcube ) const; // uses interpolation, for no interpolation call ni_get_descriptor. see also get_descriptor - inline void i_get_descriptor( double y, double x, int orientation, float* descriptor ); + inline void i_get_descriptor( double y, double x, int orientation, float* descriptor ) const; // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor - inline void ni_get_descriptor( double y, double x, int orientation, float* descriptor ); + inline void ni_get_descriptor( double y, double x, int orientation, float* descriptor ) const; // uses interpolation for no interpolation call ni_get_descriptor. see also get_descriptor - inline bool i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + inline bool i_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor - inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ); + inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; // creates a 1D gaussian filter with N(mean,sigma). inline void gaussian_1d( float* fltr, int fsz, float sigma, float mean ) @@ -521,7 +575,7 @@ private: // if ue=1 => x<=ux is checked else x inline - bool is_inside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + bool is_inside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) const { if( ( ((lx inline - bool is_inside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='&') + bool is_inside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='&') const { switch( oper ) { @@ -569,7 +623,7 @@ private: // If the 'oper' is set '&' both of the numbers must be within the interval to return true // But if the 'oper' is set to '|' then only one of them being true is sufficient. template inline - bool is_inside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='&') + bool is_inside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='&') const { switch( oper ) { @@ -591,7 +645,7 @@ private: // if ue=1 => x>ux is checked else x>=ux is checked // by default is x is searched outside of [lx,ux) template inline - bool is_outside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) + bool is_outside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) const { return !(is_inside(x,lx,ux,le,ue)); } @@ -604,7 +658,7 @@ private: // By default, 'oper' is set to OR. If one of them is outside it returns // true otherwise false. template inline - bool is_outside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='|') + bool is_outside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='|') const { switch( oper ) { @@ -627,7 +681,7 @@ private: // By default, 'oper' is set to OR. If one of them is outside it returns // true otherwise false. template inline - bool is_outside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='|') + bool is_outside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='|') const { switch( oper ) { @@ -644,7 +698,7 @@ private: // computes the square of a number and returns it. template inline - T square(T a) + T square(T a) const { return a*a; } @@ -652,7 +706,7 @@ private: // computes the square of an array. if in_place is enabled, the // result is returned in the array arr. template inline - T* square(T* arr, int sz, bool in_place=false) + T* square(T* arr, int sz, bool in_place=false) const { T* out; if( in_place ) out = arr; @@ -666,7 +720,7 @@ private: // computes the l2norm of an array: [ sum_i( [a(i)]^2 ) ]^0.5 template inline - float l2norm( T* a, int sz) + float l2norm( T* a, int sz) const { float norm=0; for( int k=0; k inline - float l2norm( T1* a, T2* b, int sz) + float l2norm( T1* a, T2* b, int sz) const { float norm=0; for( int i=0; i inline - float l2norm( T y0, T x0, T y1, T x1 ) + float l2norm( T y0, T x0, T y1, T x1 ) const { float d0 = (float) (x0 - x1); float d1 = (float) (y0 - y1); @@ -767,7 +821,7 @@ private: // divides the elements of the array with num template inline - void divide(T1* arr, int sz, T2 num ) + void divide(T1* arr, int sz, T2 num ) const { float inv_num = (float) (1.0 / num); @@ -943,6 +997,7 @@ private: return out; } + }; // END DAISY_Impl CLASS @@ -973,27 +1028,31 @@ double* DAISY_Impl::get_grid(int o) void DAISY_Impl::reset() { - deallocate( m_image ); - // deallocate( m_grid_points, m_grid_point_number ); - // deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); - // deallocate( m_cube_sigmas ); - deallocate( m_orientation_map ); - deallocate( m_scale_map ); - if( !m_descriptor_memory ) deallocate( m_dense_descriptors ); - if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); + m_work_image.release(); + + if ( m_orientation_map ) deallocate( m_orientation_map ); + if ( m_scale_map ) deallocate( m_scale_map ); + + if ( !m_descriptor_memory && m_dense_descriptors ) + deallocate( m_dense_descriptors ); + if ( !m_workspace_memory && m_smoothed_gradient_layers ) + deallocate(m_smoothed_gradient_layers); } -void DAISY_Impl::release_auxilary() +void DAISY_Impl::release_auxiliary() { - deallocate( m_image ); - deallocate( m_orientation_map ); - deallocate( m_scale_map ); + if ( m_orientation_map ) deallocate( m_orientation_map ); + if ( m_scale_map ) deallocate( m_scale_map ); - if( !m_workspace_memory ) deallocate(m_smoothed_gradient_layers); + if ( !m_workspace_memory && m_smoothed_gradient_layers ) + deallocate( m_smoothed_gradient_layers ); - deallocate( m_grid_points, m_grid_point_number ); - deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); - deallocate( m_cube_sigmas ); + if ( m_grid_points ) deallocate( m_grid_points, m_grid_point_number ); + if ( m_oriented_grid_points ) + deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); + if ( m_cube_sigmas ) deallocate( m_cube_sigmas ); + + m_work_image.release(); } void DAISY_Impl::compute_grid_points() @@ -1029,22 +1088,29 @@ void DAISY_Impl::compute_grid_points() /// Computes the descriptor by sampling convoluted orientation maps. void DAISY_Impl::compute_descriptors() { + + int y_off = m_roi.y; + int x_off = m_roi.x; + int y_end = m_roi.y + m_roi.height; + int x_end = m_roi.x + m_roi.width; + if( m_scale_invariant ) compute_scales(); if( m_rotation_invariant ) compute_orientations(); - if( !m_descriptor_memory ) m_dense_descriptors = allocate (m_h*m_w*m_descriptor_size); + if( !m_descriptor_memory ) + m_dense_descriptors = allocate (m_roi.width*m_roi.height * m_descriptor_size); - memset(m_dense_descriptors, 0, sizeof(float)*m_h*m_w*m_descriptor_size); + memset(m_dense_descriptors, 0, sizeof(float)*m_roi.width*m_roi.height * m_descriptor_size); int y, x, index, orientation; #if defined _OPENMP #pragma omp parallel for private(y,x,index,orientation) #endif - for( y=0; y= 0 && orientation < g_grid_orientation_resolution ) ) orientation = 0; get_unnormalized_descriptor( y, x, orientation, &(m_dense_descriptors[index*m_descriptor_size]) ); @@ -1070,7 +1136,7 @@ void DAISY_Impl::smooth_layers( float* layers, int h, int w, int layer_number, f deallocate(filter); } -void DAISY_Impl::normalize_partial( float* desc ) +void DAISY_Impl::normalize_partial( float* desc ) const { float norm; for( int h=0; h= m_cube_sigmas[g_cube_number-1] ) return g_cube_number-1; @@ -1412,7 +1477,7 @@ void DAISY_Impl::compute_scales() m_scale_map[q] = (float) round( m_scale_map[q] ); } -// save( m_scale_map, m_h, m_w, "scales.dat"); + //save( m_scale_map, m_h, m_w, "scales.dat"); deallocate( sim ); deallocate( max_dog ); @@ -1521,6 +1586,7 @@ void DAISY_Impl::set_descriptor_memory( float* descriptor, long int d_size ) { CV_Assert( m_descriptor_memory == false ); CV_Assert( m_h*m_w != 0 ); + CV_Assert( m_roi.width*m_roi.height != 0 ); CV_Assert( d_size >= compute_descriptor_memory() ); m_dense_descriptors = descriptor; @@ -1531,6 +1597,7 @@ void DAISY_Impl::set_workspace_memory( float* workspace, long int w_size ) { CV_Assert( m_workspace_memory == false ); CV_Assert( m_h*m_w != 0 ); + CV_Assert( m_roi.width*m_roi.height != 0 ); CV_Assert( w_size >= compute_workspace_memory() ); m_smoothed_gradient_layers = workspace; @@ -1550,7 +1617,7 @@ inline void DAISY_Impl::compute_histogram( float* hcube, int y, int x, float* hi for( int h=0; h& keypoints, OutputArray _descriptors ) +void DAISY_Impl::set_parameters( ) { - // do nothing if no image - Mat image = _image.getMat(); - if( image.empty() ) - return; + m_grid_point_number = m_rad_q_no * m_th_q_no + 1; // +1 is for center pixel + m_descriptor_size = m_grid_point_number * m_hist_th_q_no; - // get homography if supplied - Mat H = m_h_matrix; + for( int i=0; i<360; i++ ) + { + m_orientation_shift_table[i] = i/360.0 * m_hist_th_q_no; + } + m_layer_size = m_h*m_w; + m_cube_size = m_layer_size*m_hist_th_q_no; - // convert to float if case - if ( image.depth() != CV_64F ) - H.convertTo( H, CV_64F ); - /* - * daisy set_image() - */ + compute_cube_sigmas(); + compute_grid_points(); +} + +// set/convert image array for daisy internal routines +// daisy internals use CV_32F image with norm to 1.0f +void DAISY_Impl::set_image( InputArray _image ) +{ + // release previous image + // and previous daisies workspace + reset(); + + // fetch new image + Mat image = _image.getMat(); + + // image cannot be empty + CV_Assert( ! image.empty() ); // base size m_h = image.rows; @@ -1897,108 +1980,145 @@ void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, O // clone image for conversion if ( image.depth() != CV_32F ) { - Mat work_image = image.clone(); + m_work_image = image.clone(); // convert to gray inplace - if( work_image.channels() > 1 ) - cvtColor( work_image, work_image, COLOR_BGR2GRAY ); + if( m_work_image.channels() > 1 ) + cvtColor( m_work_image, m_work_image, COLOR_BGR2GRAY ); // convert to float if it is necessary - if ( work_image.depth() != CV_32F ) + if ( m_work_image.depth() != CV_32F ) { // convert and normalize - work_image.convertTo( work_image, CV_32F ); - work_image /= 255.0f; + m_work_image.convertTo( m_work_image, CV_32F ); + m_work_image /= 255.0f; } else CV_Error( Error::StsUnsupportedFormat, "" ); // use cloned work image - m_image = work_image.ptr(0); + m_image = m_work_image.ptr(0); } else - // use original CV_32F image + // use original user supplied CV_32F image + // should be a normalized one (cannot check) m_image = image.ptr(0); - // full mode if noArray() - // was passed to _descriptors - if ( _descriptors.needed() == false ) - m_mode = DAISY::COMP_FULL; +} - /* - * daisy set_parameters() - */ - m_grid_point_number = m_rad_q_no * m_th_q_no + 1; // +1 is for center pixel - m_descriptor_size = m_grid_point_number * m_hist_th_q_no; +// ------------------------------------------------- +/* DAISY interface implementation */ - for( int i=0; i<360; i++ ) - { - m_orientation_shift_table[i] = i/360.0 * m_hist_th_q_no; - } - m_layer_size = m_h*m_w; - m_cube_size = m_layer_size*m_hist_th_q_no; +// keypoint scope +void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) +{ + // do nothing if no image + if( _image.getMat().empty() ) + return; - compute_cube_sigmas(); - compute_grid_points(); + set_image( _image ); + // whole image + m_roi = Rect( 0, 0, m_w, m_h ); - /* - * daisy initialize_single_descriptor_mode(); - */ + // get homography + Mat H = m_h_matrix; - // initializes for get_descriptor(double, double, int) mode: pre-computes - // convolutions of gradient layers in m_smoothed_gradient_layers + // convert to double if case + if ( H.depth() != CV_64F ) + H.convertTo( H, CV_64F ); - initialize(); - compute_smoothed_gradient_layers(); + set_parameters(); - /* - * daisy compute descriptors given operating mode - */ + initialize_single_descriptor_mode(); - if ( m_mode == COMP_FULL ) - { - CV_Assert( H.empty() ); - CV_Assert( keypoints.empty() ); - CV_Assert( ! m_use_orientation ); + // allocate array + _descriptors.create( (int) keypoints.size(), m_descriptor_size, CV_32F ); - compute_descriptors(); - normalize_descriptors(); + // prepare descriptors + Mat descriptors = _descriptors.getMat(); + descriptors.setTo( Scalar(0) ); - cv::Mat descriptors; - descriptors = _descriptors.getMat(); - descriptors = Mat( m_h * m_w, m_descriptor_size, - CV_32F, &m_dense_descriptors[0] ); - } else - if ( m_mode == ONLY_KEYS ) - { - cv::Mat descriptors; - _descriptors.create( (int) keypoints.size(), m_descriptor_size, CV_32F ); - descriptors = _descriptors.getMat(); - - if ( H.empty() ) - for (int k = 0; k < (int) keypoints.size(); k++) - { - get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, - m_use_orientation ? (int) keypoints[k].angle : 0, - &descriptors.at( k, 0 ) ); - } - else - for (int k = 0; k < (int) keypoints.size(); k++) - { - get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, - m_use_orientation ? (int) keypoints[k].angle : 0, - &H.at( 0 ), &descriptors.at( k, 0 ) ); - } + // iterate over keypoints + // and fill computed descriptors + if ( H.empty() ) + for (int k = 0; k < (int) keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? (int) keypoints[k].angle : 0, + &descriptors.at( k, 0 ) ); + } + else + for (int k = 0; k < (int) keypoints.size(); k++) + { + get_descriptor( keypoints[k].pt.y, keypoints[k].pt.x, + m_use_orientation ? (int) keypoints[k].angle : 0, + &H.at( 0 ), &descriptors.at( k, 0 ) ); + } - } else - CV_Error( Error::StsInternal, "Unknown computation mode" ); +} + +// full scope with roi +void DAISY_Impl::compute( InputArray _image, Rect roi, OutputArray _descriptors ) +{ + // do nothing if no image + if( _image.getMat().empty() ) + return; + + CV_Assert( m_h_matrix.empty() ); + CV_Assert( ! m_use_orientation ); + + set_image( _image ); + + m_roi = roi; + + set_parameters(); + initialize_single_descriptor_mode(); + + // compute full desc + compute_descriptors(); + normalize_descriptors(); + + Mat descriptors = _descriptors.getMat(); + descriptors = Mat( m_roi.width * m_roi.height, m_descriptor_size, + CV_32F, &m_dense_descriptors[0] ); + + release_auxiliary(); +} + +// full scope +void DAISY_Impl::compute( InputArray _image, OutputArray _descriptors ) +{ + // do nothing if no image + if( _image.getMat().empty() ) + return; + + CV_Assert( m_h_matrix.empty() ); + CV_Assert( ! m_use_orientation ); + + set_image( _image ); + + // whole image + m_roi = Rect( 0, 0, m_w, m_h ); + + set_parameters(); + initialize_single_descriptor_mode(); + + // compute full desc + compute_descriptors(); + normalize_descriptors(); + + Mat descriptors = _descriptors.getMat(); + descriptors = Mat( m_h * m_w, m_descriptor_size, + CV_32F, &m_dense_descriptors[0] ); + + release_auxiliary(); } // constructor DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, - int _mode, int _norm, InputArray _H, bool _interpolation, bool _use_orientation ) - : m_mode(_mode), m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), + int _norm, InputArray _H, bool _interpolation, bool _use_orientation ) + : m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), m_nrm_type(_norm), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) { m_w = 0; @@ -2008,7 +2128,6 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, m_grid_point_number = 0; m_descriptor_size = 0; - m_smoothed_gradient_layers = NULL; m_dense_descriptors = NULL; m_grid_points = NULL; @@ -2024,6 +2143,7 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, m_cube_sigmas = NULL; + // unused features m_descriptor_memory = false; m_workspace_memory = false; @@ -2038,7 +2158,7 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, // destructor DAISY_Impl::~DAISY_Impl() { - if( !m_workspace_memory ) deallocate( m_smoothed_gradient_layers ); + if ( !m_workspace_memory ) deallocate( m_smoothed_gradient_layers ); deallocate( m_grid_points, m_grid_point_number ); deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); deallocate( m_orientation_map ); @@ -2047,9 +2167,9 @@ DAISY_Impl::~DAISY_Impl() } Ptr DAISY::create( float radius, int q_radius, int q_theta, int q_hist, - int mode, int norm, InputArray H, bool interpolation, bool use_orientation) + int norm, InputArray H, bool interpolation, bool use_orientation) { - return makePtr(radius, q_radius, q_theta, q_hist, mode, norm, H, interpolation, use_orientation); + return makePtr(radius, q_radius, q_theta, q_hist, norm, H, interpolation, use_orientation); } diff --git a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp index 176a342c5..16d6656a8 100644 --- a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp @@ -654,7 +654,7 @@ TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression) TEST(Features2d_RotationInvariance_Descriptor_DAISY, regression) { DescriptorRotationInvarianceTest test(BRISK::create(), - DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + DAISY::create(15, 3, 8, 8, DAISY::NRM_NONE, noArray(), true, true), NORM_L1, 0.79f); test.safe_run(); @@ -721,7 +721,7 @@ TEST(Features2d_RotationInvariance2_Detector_SURF, regression) TEST(Features2d_ScaleInvariance_Descriptor_DAISY, regression) { DescriptorScaleInvarianceTest test(BRISK::create(), - DAISY::create(15, 3, 8, 8, DAISY::ONLY_KEYS, DAISY::NRM_NONE, noArray(), true, true), + DAISY::create(15, 3, 8, 8, DAISY::NRM_NONE, noArray(), true, true), NORM_L1, 0.075f); test.safe_run(); From 73bed6f3b2297c2e37e8329b5b897f3baf6ee236 Mon Sep 17 00:00:00 2001 From: cbalint13 Date: Mon, 18 May 2015 14:50:12 +0300 Subject: [PATCH 21/21] Rebase the code, massive cleanups. We still pass QA. --- .../include/opencv2/xfeatures2d.hpp | 13 +- modules/xfeatures2d/src/daisy.cpp | 1625 ++++++----------- 2 files changed, 605 insertions(+), 1033 deletions(-) diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp index e5151e001..744e78f98 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp @@ -196,7 +196,7 @@ public: /** * @param y position y on image * @param x position x on image - * @param ori orientation on image (0->360) + * @param orientation orientation on image (0->360) * @param descriptor supplied array for descriptor storage */ virtual void get_descriptor( double y, double x, int orientation, float* descriptor ) const = 0; @@ -204,7 +204,7 @@ public: /** * @param y position y on image * @param x position x on image - * @param ori orientation on image (0->360) + * @param orientation orientation on image (0->360) * @param H homography matrix for warped grid * @param descriptor supplied array for descriptor storage * @param get_descriptor true if descriptor was computed @@ -214,7 +214,7 @@ public: /** * @param y position y on image * @param x position x on image - * @param ori orientation on image (0->360) + * @param orientation orientation on image (0->360) * @param descriptor supplied array for descriptor storage */ virtual void get_unnormalized_descriptor( double y, double x, int orientation, float* descriptor ) const = 0; @@ -222,18 +222,13 @@ public: /** * @param y position y on image * @param x position x on image - * @param ori orientation on image (0->360) + * @param orientation orientation on image (0->360) * @param H homography matrix for warped grid * @param descriptor supplied array for descriptor storage * @param get_unnormalized_descriptor true if descriptor was computed */ virtual bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const = 0; - /** - * @param image set image as working - */ - virtual void set_image( InputArray image ) = 0; - }; diff --git a/modules/xfeatures2d/src/daisy.cpp b/modules/xfeatures2d/src/daisy.cpp index 8fd167511..7d6c7fd4c 100644 --- a/modules/xfeatures2d/src/daisy.cpp +++ b/modules/xfeatures2d/src/daisy.cpp @@ -49,7 +49,7 @@ */ #include "precomp.hpp" -#include "opencv2/imgproc/imgproc_c.h" + #include #include @@ -167,11 +167,6 @@ public: */ virtual bool get_unnormalized_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; - /** - * @param image set image as working - */ - virtual void set_image( InputArray image ); - protected: @@ -179,9 +174,6 @@ protected: * DAISY parameters */ - // operation mode - int m_mode; - // maximum radius of the descriptor region. float m_rad; @@ -198,30 +190,29 @@ protected: // default. change the value using set_normalization() function. int m_nrm_type; - // holds optional H matrix - Mat m_h_matrix; - - // input image. - float* m_image; + // number of bins in the histograms while computing orientation + int m_orientation_resolution; - Mat m_work_image; + // the number of grid locations + int m_grid_point_number; - // image height - int m_h; + // the size of the descriptor vector + int m_descriptor_size; - // image width - int m_w; + // size of m_hsz layers at a single sigma: m_hsz * m_layer_size + int m_cube_size; - // image roi - Rect m_roi; + // size of the layer : + // m_roi.width*m_roi.height + int m_layer_size; - // stores the descriptors : - // its size is [ m_roi.width*m_roi.height*m_descriptor_size ]. - float* m_dense_descriptors; + // the clipping threshold to use in normalization: values above this value + // are clipped to this value for normalize_sift_way() function + float m_descriptor_normalization_threshold; - // stores the layered gradients in successively smoothed form: layer[n] = - // m_gradient_layers * gaussian( sigma_n ); n>= 1; layer[0] is the layered_gradient - float* m_smoothed_gradient_layers; + /* + * DAISY switches + */ // if set to true, descriptors are scale invariant bool m_scale_invariant; @@ -229,244 +220,149 @@ protected: // if set to true, descriptors are rotation invariant bool m_rotation_invariant; - // number of bins in the histograms while computing orientation - int m_orientation_resolution; + // if enabled, descriptors are computed with casting non-integer locations + // to integer positions otherwise we use interpolation. + bool m_disable_interpolation; + + // switch to enable sample by keypoints orientation + bool m_use_orientation; + + /* + * DAISY arrays + */ + + // holds optional H matrix + Mat m_h_matrix; + + // input image. + Mat m_image; + + // image roi + Rect m_roi; + + // stores the descriptors : + // its size is [ m_roi.width*m_roi.height*m_descriptor_size ]. + Mat m_dense_descriptors; + + // stores the layered gradients in successively smoothed form : + // layer[n] = m_gradient_layers * gaussian( sigma_n ); + // n>= 1; layer[0] is the layered_gradient + Mat m_smoothed_gradient_layers; // hold the scales of the pixels - float* m_scale_map; + Mat m_scale_map; // holds the orientaitons of the pixels - int* m_orientation_map; + Mat m_orientation_map; // Holds the oriented coordinates (y,x) of the grid points of the region. - double** m_oriented_grid_points; + Mat m_oriented_grid_points; // holds the gaussian sigmas for radius quantizations for an incremental // application - double* m_cube_sigmas; - - bool m_descriptor_memory; - bool m_workspace_memory; - - // the number of grid locations - int m_grid_point_number; + Mat m_cube_sigmas; - // the size of the descriptor vector - int m_descriptor_size; + // Holds the coordinates (y,x) of the grid points of the region. + Mat m_grid_points; // holds the amount of shift that's required for histogram computation double m_orientation_shift_table[360]; - // if enabled, descriptors are computed with casting non-integer locations - // to integer positions otherwise we use interpolation. - bool m_disable_interpolation; - - // switch to enable sample by keypoints orientation - bool m_use_orientation; - // size of m_hsz layers at a single sigma: m_hsz * m_layer_size - int m_cube_size; +private: - // size of the layer : - // m_roi.width*m_roi.height - int m_layer_size; + // two possible computational mode + // ONLY_KEYS -> (mode_1) compute descriptors on demand + // COMP_FULL -> (mode_2) compute all descriptors from image + enum { ONLY_KEYS = 0, COMP_FULL = 1 }; /* * DAISY functions */ - // computes the histogram at yx; the size of histogram is m_hist_th_q_no - void compute_histogram( float* hcube, int y, int x, float* histogram ); - - // reorganizes the cube data so that histograms are sequential in memory. - void compute_histograms(); - - // emulates the way sift is normalized. - void normalize_sift_way( float* desc ) const; + // initializes the class: computes gradient and structure-points + inline void initialize(); - // normalizes the descriptor histogram by histogram - void normalize_partial( float* desc ) const; + // initializes for get_descriptor(double, double, int) mode: pre-computes + // convolutions of gradient layers in m_smoothed_gradient_layers + inline void initialize_single_descriptor_mode(); - // normalizes the full descriptor. - void normalize_full( float* desc ) const; + // set & precompute parameters + inline void set_parameters(); - // initializes the class: computes gradient and structure-points - void initialize(); + // image set image as working + inline void set_image( InputArray image ); - void update_selected_cubes(); + // releases all the used memory; call this if you want to process + // multiple images within a loop. + inline void reset(); - int quantize_radius( float rad ) const; + // releases unused memory after descriptor computation is completed. + inline void release_auxiliary(); - int filter_size( double sigma ); + // computes the descriptors for every pixel in the image. + inline void compute_descriptors(); // computes scales for every pixel and scales the structure grid so that the // resulting descriptors are scale invariant. you must set // m_scale_invariant flag to 1 for the program to call this function - void compute_scales(); - - // Return a number in the range [-0.5, 0.5] that represents the location of - // the peak of a parabola passing through the 3 evenly spaced samples. The - // center value is assumed to be greater than or equal to the other values - // if positive, or less than if negative. - float interpolate_peak( float left, float center, float right ); + inline void compute_scales(); - // Smooth a histogram by using a [1/3 1/3 1/3] kernel. Assume the histogram - // is connected in a circular buffer. - void smooth_histogram( float *hist, int bins ); + // compute the smoothed gradient layers. + inline void compute_smoothed_gradient_layers(); // computes pixel orientations and rotates the structure grid so that // resulting descriptors are rotation invariant. If the scales is also // detected, then orientations are computed at the computed scales. you must // set m_rotation_invariant flag to 1 for the program to call this function - void compute_orientations(); + inline void compute_orientations(); - // the clipping threshold to use in normalization: values above this value - // are clipped to this value for normalize_sift_way() function - float m_descriptor_normalization_threshold; + // computes the histogram at yx; the size of histogram is m_hist_th_q_no + inline void compute_histogram( float* hcube, int y, int x, float* histogram ); + + // reorganizes the cube data so that histograms are sequential in memory. + inline void compute_histograms(); // computes the sigma's of layers from descriptor parameters if the user did // not sets it. these define the size of the petals of the descriptor. - void compute_cube_sigmas(); + inline void compute_cube_sigmas(); // Computes the locations of the unscaled unrotated points where the // histograms are going to be computed according to the given parameters. - void compute_grid_points(); + inline void compute_grid_points(); // Computes the locations of the unscaled rotated points where the // histograms are going to be computed according to the given parameters. - void compute_oriented_grid_points(); + inline void compute_oriented_grid_points(); - // smooths each of the layers by a Gaussian having "sigma" standart - // deviation. - void smooth_layers( float*layers, int h, int w, int layer_number, float sigma ); - - // Holds the coordinates (y,x) of the grid points of the region. - double** m_grid_points; - - int get_hq() { return m_hist_th_q_no; } - int get_thq() { return m_th_q_no; } - int get_rq() { return m_rad_q_no; } - float get_rad() { return m_rad; } - - // sets the type of the normalization to apply out of {NRM_PARTIAL, - // NRM_FULL, NRM_SIFT}. Call before using get_descriptor() if you want to - // change the default normalization type. - void set_normalization( int nrm_type ) { m_nrm_type = nrm_type; } + // normalizes the descriptor + inline void normalize_descriptor( float* desc, int nrm_type ) const; // applies one of the normalizations (partial,full,sift) to the desciptors. - void normalize_descriptors( int nrm_type = DAISY::NRM_NONE ); - - // normalizes histograms individually - void normalize_histograms(); - - // gets the histogram at y,x with 'orientation' from the r'th cube - float* get_histogram( int y, int x, int r ); - - // if called, I don't use interpolation in the computation of - // descriptors. - void disable_interpolation() { m_disable_interpolation = true; } - - // returns the region number. - int grid_point_number() { return m_grid_point_number; } - - // releases all the used memory; call this if you want to process - // multiple images within a loop. - void reset(); - - // releases unused memory after descriptor computation is completed. - void release_auxiliary(); - - // computes the descriptors for every pixel in the image. - void compute_descriptors(); - - // returns all the descriptors. - float* get_dense_descriptors(); - - // returns oriented grid points. default is 0 orientation. - double* get_grid(int o=0); - - // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the - // scales for every pixel so that the resulting descriptors are scale - // invariant. - void scale_invariant( bool state = true ) - { - g_scale_en = (int)( (log(g_sigma_2/g_sigma_0)) / log(g_sigma_step) ) - g_scale_st; - m_scale_invariant = state; - } - - // EXPERIMENTAL: DO NOT USE IF YOU ARE NOT ENGIN TOLA: tells to compute the - // orientations for every pixel so that the resulting descriptors are - // rotation invariant. orientation steps are 360/ori_resolution - void rotation_invariant( int ori_resolution = 36, bool state = true ) - { - m_rotation_invariant = state; - m_orientation_resolution = ori_resolution; - } - - // sets the gaussian variances manually. must be called before - // initialize() to be considered. must be exact sigma values -> f - // converts to incremental format. - void set_cube_gaussians( double* sigma_array, int sz ); - - int* get_orientation_map() { return m_orientation_map; } - - // call compute_descriptor_memory to find the amount of memory to allocate - void set_descriptor_memory( float* descriptor, long int d_size ); - - // call compute_workspace_memory to find the amount of memory to allocate - void set_workspace_memory( float* workspace, long int w_size ); - - // returns the amount of memory needed for the compute_descriptors() - // function. it is basically equal to imagesize x descriptor_size - int compute_descriptor_memory() { - if( m_h == 0 || m_descriptor_size == 0 ) { - CV_Error( Error::StsInternal, "Image and descriptor size is zero" ); - } - return m_roi.width*m_roi.height * m_descriptor_size; - } + inline void normalize_descriptors( int nrm_type = DAISY::NRM_NONE ); - // returns the amount of memory needed for workspace. call before initialize() - int compute_workspace_memory() { - if( m_cube_size == 0 ) { - CV_Error( Error::StsInternal, "Cube size is zero" ); - } - return (g_cube_number+1)* m_cube_size; - } - void normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) const - { - if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; - else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); - else if( nrm_type == DAISY::NRM_FULL ) normalize_full(desc); - else if( nrm_type == DAISY::NRM_SIFT ) normalize_sift_way(desc); - else - CV_Error( Error::StsInternal, "No such normalization" ); - } + // emulates the way sift is normalized. + inline void normalize_sift_way( float* desc ) const; - // transform a point via the homography - void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) const - { - double kxp = H[0]*x + H[1]*y + H[2]; - double kyp = H[3]*x + H[4]*y + H[5]; - double kp = H[6]*x + H[7]*y + H[8]; - u = kxp / kp; - v = kyp / kp; - } + // normalizes the descriptor histogram by histogram + inline void normalize_partial( float* desc ) const; -private: + // normalizes the full descriptor. + inline void normalize_full( float* desc ) const; - // two possible computational mode - // ONLY_KEYS -> (mode_1) compute descriptors on demand - // COMP_FULL -> (mode_2) compute all descriptors from image - enum { ONLY_KEYS = 0, COMP_FULL = 1 }; + // normalizes histograms individually + inline void normalize_histograms(); - // set & precompute parameters - inline void set_parameters(); + inline void update_selected_cubes(); + // Smooth a histogram by using a [1/3 1/3 1/3] kernel. Assume the histogram + // is connected in a circular buffer. + inline void smooth_histogram( Mat hist, int bins ); - // initializes for get_descriptor(double, double, int) mode: pre-computes - // convolutions of gradient layers in m_smoothed_gradient_layers - inline void initialize_single_descriptor_mode(); + // smooths each of the layers by a Gaussian having "sigma" standart + // deviation. + inline void smooth_layers( Mat layers, int h, int w, int layer_number, float sigma ); // returns the descriptor vector for the point (y, x) !!! use this for // precomputed operations meaning that you must call compute_descriptors() @@ -474,9 +370,6 @@ private: // normalize_descriptors() before calling compute_descriptors() inline void get_descriptor( int y, int x, float* &descriptor ); - // compute the smoothed gradient layers. - inline void compute_smoothed_gradient_layers(); - // does not use interpolation while computing the histogram. inline void ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ) const; @@ -506,568 +399,196 @@ private: // does not use interpolation. for w/interpolation, call i_get_descriptor. see also get_descriptor inline bool ni_get_descriptor( double y, double x, int orientation, double* H, float* descriptor ) const; - // creates a 1D gaussian filter with N(mean,sigma). - inline void gaussian_1d( float* fltr, int fsz, float sigma, float mean ) - { - CV_Assert(fltr != NULL); - int sz = (fsz-1)/2; - int counter=-1; - float sum = 0.0; - float v = 2*sigma*sigma; - for( int x=-sz; x<=sz; x++ ) - { - counter++; - fltr[counter] = exp((-((float)x-mean)*((float)x-mean))/v); - sum += fltr[counter]; - } - - if( sum != 0 ) - { - for( int x=0; x - class rectangle - { - public: - T lx, ux, ly, uy; - T dx, dy; - rectangle(T xl, T xu, T yl, T yu) { lx=xl; ux=xu; ly=yl; uy=yu; dx=ux-lx; dy=uy-ly; }; - rectangle() { lx = ux = ly = uy = dx = dy = 0; }; - }; + inline int quantize_radius( float rad ) const; - // checks if the number x is between lx - ux interval. - // the equality is checked depending on the value of le and ue parameters. - // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline - bool is_inside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) const - { - if( ( ((lx lx<=x is checked else lx x<=ux is checked else x inline - bool is_inside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='&') const - { - switch( oper ) - { - case '|': - if( is_inside(x,lx,ux,le,ue) || is_inside(y,ly,uy,le,ue) ) - return true; - return false; - - default: - if( is_inside(x,lx,ux,le,ue) && is_inside(y,ly,uy,le,ue) ) - return true; - return false; - } - } - - // checks if the number x is between lx - ux and/or y is between ly - uy interval. - // If the number is inside, then function returns true, else it returns false. - // the equality is checked depending on the value of le and ue parameters. - // if le=1 => lx<=x is checked else lx x<=ux is checked else x inline - bool is_inside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='&') const - { - switch( oper ) - { - case '|': - if( is_inside(x,roi.lx,roi.ux,le,ue) || is_inside(y,roi.ly,roi.uy,le,ue) ) - return true; - return false; - - default: - if( is_inside(x,roi.lx,roi.ux,le,ue) && is_inside(y,roi.ly,roi.uy,le,ue) ) - return true; - return false; - } - } - - // checks if the number x is outside lx - ux interval - // the equality is checked depending on the value of le and ue parameters. - // if le=1 => lx>x is checked else lx>=x is checked - // if ue=1 => x>ux is checked else x>=ux is checked - // by default is x is searched outside of [lx,ux) - template inline - bool is_outside(T1 x, T2 lx, T3 ux, bool le=true, bool ue=false) const - { - return !(is_inside(x,lx,ux,le,ue)); - } - - // checks if the numbers x and y is outside their intervals. - // The equality is checked depending on the value of le and ue parameters. - // If le=1 => lx>x is checked else lx>=x is checked - // If ue=1 => x>ux is checked else x>=ux is checked - // By default is x is searched outside of [lx,ux) (Similarly for y) - // By default, 'oper' is set to OR. If one of them is outside it returns - // true otherwise false. - template inline - bool is_outside(T1 x, T2 lx, T3 ux, T1 y, T2 ly, T3 uy, bool le=true, bool ue=false, char oper='|') const - { - switch( oper ) - { - case '&': - if( is_outside(x,lx,ux,le,ue) && is_outside(y,ly,uy,le,ue) ) - return true; - return false; - default: - if( is_outside(x,lx,ux,le,ue) || is_outside(y,ly,uy,le,ue) ) - return true; - return false; - } - } - - // checks if the numbers x and y is outside their intervals. - // The equality is checked depending on the value of le and ue parameters. - // If le=1 => lx>x is checked else lx>=x is checked - // If ue=1 => x>ux is checked else x>=ux is checked - // By default is x is searched outside of [lx,ux) (Similarly for y) - // By default, 'oper' is set to OR. If one of them is outside it returns - // true otherwise false. - template inline - bool is_outside(T1 x, T1 y, rectangle roi, bool le=true, bool ue=false, char oper='|') const - { - switch( oper ) - { - case '&': - if( is_outside(x,roi.lx,roi.ux,le,ue) && is_outside(y,roi.ly,roi.uy,le,ue) ) - return true; - return false; - default: - if( is_outside(x,roi.lx,roi.ux,le,ue) || is_outside(y,roi.ly,roi.uy,le,ue) ) - return true; - return false; - } - } + inline int filter_size( double sigma ); - // computes the square of a number and returns it. - template inline - T square(T a) const - { - return a*a; - } - - // computes the square of an array. if in_place is enabled, the - // result is returned in the array arr. - template inline - T* square(T* arr, int sz, bool in_place=false) const - { - T* out; - if( in_place ) out = arr; - else out = allocate(sz); - - for( int i=0; i inline - float l2norm( T* a, int sz) const - { - float norm=0; - for( int k=0; k inline - float l2norm( T1* a, T2* b, int sz) const - { - float norm=0; - for( int i=0; i inline - float l2norm( T y0, T x0, T y1, T x1 ) const - { - float d0 = (float) (x0 - x1); - float d1 = (float) (y0 - y1); - return sqrt( d0*d0 + d1*d1 ); - } +// ------------------------------------------------- +/* DAISY computation routines */ - // allocates a memory of size sz and returns a pointer to the array - template inline - T* allocate(const int sz) - { - T* array = new T[sz]; - return array; - } +inline void DAISY_Impl::reset() +{ + m_image.release(); - // allocates a memory of size ysz x xsz and returns a double pointer to it - template inline - T** allocate(const int ysz, const int xsz) - { - T** mat = new T*[ysz]; - int i; + m_orientation_map.release(); + m_scale_map.release(); - for(i=0; i(xsz); + m_dense_descriptors.release(); + m_smoothed_gradient_layers.release(); +} - return mat; - } +inline void DAISY_Impl::release_auxiliary() +{ + m_orientation_map.release(); + m_scale_map.release(); - // deallocates the memory and sets the pointer to null. - template inline - void deallocate(T* &array) - { - delete[] array; - array = NULL; - } + m_smoothed_gradient_layers.release(); - // deallocates the memory and sets the pointer to null. - template inline - void deallocate(T** &mat, int ysz) - { - if( mat == NULL ) return; + m_grid_points.release(); + m_oriented_grid_points.release(); + m_cube_sigmas.release(); - for(int i=0; i inline - void polar2cartesian(T1 r, T1 t, T2 &y, T2 &x) + int sz = (fsz - 1) / 2; + int counter = -1; + float sum = 0.0f; + float v = 2 * sigma*sigma; + for( int x=-sz; x<=sz; x++ ) { - x = (T2)( r * cos( t ) ); - y = (T2)( r * sin( t ) ); + counter++; + fltr[counter] = exp((-((float)x-mean)*((float)x-mean))/v); + sum += fltr[counter]; } + if( sum != 0 ) + for( int x=0; x inline - void convolve_sym_( T* image, int h, int w, T* kernel, int ksize ) - { - conv_horizontal( image, h, w, kernel, ksize ); - conv_vertical ( image, h, w, kernel, ksize ); - } - - template - inline void convolve_sym( T* image, int h, int w, T* kernel, int ksize, T* out=NULL ) - { - if( out == NULL ) out = image; - else memcpy( out, image, sizeof(T)*h*w ); - convolve_sym_(out, h, w, kernel, ksize); - } +// computes the gradient of an image +static void gradient( Mat im, int h, int w, Mat dy, Mat dx ) +{ + CV_Assert( !dx.empty() ); + CV_Assert( !dy.empty() ); - // divides the elements of the array with num - template inline - void divide(T1* arr, int sz, T2 num ) const + for( int y=0; y0 && x(ind) = (im.at(ind+1)-im.at(ind-1)) / 2.0f; + if( x==0 ) dx.at(ind) = im.at(ind+1)-im.at(ind ); + if( x==w-1 ) dx.at(ind) = im.at(ind )-im.at(ind-1); + + // dy + if( y>0 && y(ind) = (im.at(ind+w)-im.at(ind-w)) / 2.0f; + if( y==0 ) dy.at(ind) = im.at(ind+w)-im.at(ind ); + if( y==h-1 ) dy.at(ind) = im.at(ind )-im.at(ind-w); } } +} - // returns an array filled with zeroes. - template inline - T* zeros(int r) - { - T* data = allocate(r); - memset( data, 0, sizeof(T)*r ); - return data; - } +static Mat layered_gradient( Mat data, int layer_no = 8 ) +{ + int data_size = data.rows * data.cols; + Mat layers( 1, layer_no*data_size, CV_32F, Scalar(0) ); - template inline - T* layered_gradient( T* data, int h, int w, int layer_no=8 ) - { - int data_size = h * w; - T* layers = zeros(layer_no * data_size); + float kernel[5]; + gaussian_1d(kernel, 5, 0.5f, 0.0f); + Mat Kernel(1, 5, CV_32F, (float*) kernel); - // smooth the data matrix - T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false ); + Mat cvO; + // smooth the data matrix + filter2D( data, cvO, CV_32F, Kernel, Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + filter2D( cvO, cvO, CV_32F, Kernel.t(), Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); - T *dx = new T[data_size]; - T *dy = new T[data_size]; - gradient(bdata, h, w, dy, dx); - deallocate( bdata ); + Mat dx(1, data_size, CV_32F); + Mat dy(1, data_size, CV_32F); + + gradient(cvO, data.rows, data.cols, dy, dx); + cvO.release(); #if defined _OPENMP #pragma omp parallel for #endif - for( int l=0; l(0) + l*data_size; - for( int index=0; index 0 ) layer_l[index] = value; - else layer_l[index] = 0; - } + for( int index=0; index(index) + zin * dy.at(index); + if( value > 0 ) layer_l[index] = value; + else layer_l[index] = 0; } - deallocate(dy); - deallocate(dx); - - return layers; - } + } + return layers; +} - // computes the gradient of an image and returns the result in - // pointers to REAL. - template inline - void gradient(T* im, int h, int w, T* dy, T* dx) - { - CV_Assert( dx != NULL ); - CV_Assert( dy != NULL ); +// data is not destroyed afterwards +static void layered_gradient( Mat data, int layer_no, Mat layers ) +{ + CV_Assert( !layers.empty() ); - for( int y=0; y0 && x0 && y inline - // original T* workspace=0 was removed - void layered_gradient( T* data, int h, int w, int layer_no, T* layers, int lwork = 0 ) - { - int data_size = h * w; - CV_Assert(layers!=NULL); - memset(layers,0,sizeof(T)*data_size*layer_no); - - bool was_empty = false; - T* work=NULL; - if( lwork < 3*data_size ) { - work = new T[3*data_size]; - was_empty = true; - } + float kernel[5]; + gaussian_1d(kernel, 5, 0.5f, 0.0f); + Mat Kernel(1, 5, CV_32F, (float*) kernel); - // // smooth the data matrix - // T* bdata = blur_gaussian_2d( data, h, w, 0.5, 5, false); - float kernel[5]; gaussian_1d(kernel, 5, 0.5, 0); - memcpy( work, data, sizeof(T)*data_size ); - convolve_sym( work, h, w, kernel, 5 ); + filter2D( cvI, cvI, CV_32F, Kernel, Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + filter2D( cvI, cvI, CV_32F, Kernel.t(), Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); - T *dx = work+data_size; - T *dy = work+2*data_size; - gradient( work, h, w, dy, dx ); + Mat dx(1, data_size, CV_32F); + Mat dy(1, data_size, CV_32F); + gradient( cvI, data.rows, data.cols, dy, dx ); #if defined _OPENMP #pragma omp parallel for #endif - for( int l=0; l(0) + l*data_size; - for( int index=0; index 0 ) layer_l[index] = value; - else layer_l[index] = 0; - } + for( int index=0; index(index) + zin * dy.at(index); + if( value > 0 ) layer_l[index] = value; + else layer_l[index] = 0; } - if( was_empty ) delete []work; - } - - // casts a type T2 array into a type T1 array. - template inline - T1* type_cast(T2* data, int sz) - { - T1* out = new T1[sz]; - - for( int i=0; i inline - T1* blur_gaussian_2d( T2* array, int rn, int cn, float sigma, int kernel_size = 0, bool in_place = false ) - { - T1* out = NULL; - - if( in_place ) - out = (T1*)array; - else - out = type_cast(array,rn*cn); - - if( kernel_size == 0 ) - kernel_size = (int)(3*sigma); - - if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd - if( kernel_size < 3 ) kernel_size= 3; // kernel size cannot be smaller than 3 - - float* kernel = new float[kernel_size]; - gaussian_1d(kernel, kernel_size, sigma, 0); - - // !! apply the filter separately - convolve_sym( out, rn, cn, kernel, kernel_size ); - // conv_horizontal( out, rn, cn, kernel, kernel_size); - // conv_vertical ( out, rn, cn, kernel, kernel_size); - - deallocate(kernel); - return out; - } - - -}; // END DAISY_Impl CLASS - - -// ------------------------------------------------- -/* DAISY computation routines */ - -float* DAISY_Impl::get_histogram( int y, int x, int r ) -{ - CV_Assert( y >= 0 && y < m_h ); - CV_Assert( x >= 0 && x < m_w ); - CV_Assert( m_smoothed_gradient_layers ); - CV_Assert( m_oriented_grid_points ); - return m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size + (y*m_w+x)*m_hist_th_q_no; - // i_get_histogram( histogram, y, x, 0, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); + } } - -float* DAISY_Impl::get_dense_descriptors() +// transform a point via the homography +static void point_transform_via_homography( double* H, double x, double y, double &u, double &v ) { - return m_dense_descriptors; + double kxp = H[0]*x + H[1]*y + H[2]; + double kyp = H[3]*x + H[4]*y + H[5]; + double kp = H[6]*x + H[7]*y + H[8]; + u = kxp / kp; + v = kyp / kp; } -double* DAISY_Impl::get_grid(int o) -{ - CV_Assert( o >= 0 && o < 360 ); - return m_oriented_grid_points[o]; -} - -void DAISY_Impl::reset() -{ - m_work_image.release(); - - if ( m_orientation_map ) deallocate( m_orientation_map ); - if ( m_scale_map ) deallocate( m_scale_map ); - - if ( !m_descriptor_memory && m_dense_descriptors ) - deallocate( m_dense_descriptors ); - if ( !m_workspace_memory && m_smoothed_gradient_layers ) - deallocate(m_smoothed_gradient_layers); -} - -void DAISY_Impl::release_auxiliary() -{ - if ( m_orientation_map ) deallocate( m_orientation_map ); - if ( m_scale_map ) deallocate( m_scale_map ); - - if ( !m_workspace_memory && m_smoothed_gradient_layers ) - deallocate( m_smoothed_gradient_layers ); - - if ( m_grid_points ) deallocate( m_grid_points, m_grid_point_number ); - if ( m_oriented_grid_points ) - deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); - if ( m_cube_sigmas ) deallocate( m_cube_sigmas ); - - m_work_image.release(); -} - -void DAISY_Impl::compute_grid_points() +inline void DAISY_Impl::compute_grid_points() { double r_step = m_rad / (double)m_rad_q_no; double t_step = 2*CV_PI/ m_th_q_no; - if( m_grid_points ) - deallocate( m_grid_points, m_grid_point_number ); + m_grid_points.release(); + m_grid_points = Mat( m_grid_point_number, 2, CV_64F ); - m_grid_points = allocate(m_grid_point_number, 2); for( int y=0; y(y,0) = 0; + m_grid_points.at(y,1) = 0; } for( int r=0; r(region+t,0) = (r+1)*r_step * sin( t*t_step ); + m_grid_points.at(region+t,1) = (r+1)*r_step * cos( t*t_step ); } } compute_oriented_grid_points(); } -/// Computes the descriptor by sampling convoluted orientation maps. -void DAISY_Impl::compute_descriptors() +inline void DAISY_Impl::normalize_descriptor( float* desc, int nrm_type = DAISY::NRM_NONE ) const +{ + if( nrm_type == DAISY::NRM_NONE ) nrm_type = m_nrm_type; + else if( nrm_type == DAISY::NRM_PARTIAL ) normalize_partial(desc); + else if( nrm_type == DAISY::NRM_FULL ) normalize_full(desc); + else if( nrm_type == DAISY::NRM_SIFT ) normalize_sift_way(desc); + else + CV_Error( Error::StsInternal, "No such normalization" ); +} + +// Computes the descriptor by sampling convoluted orientation maps. +inline void DAISY_Impl::compute_descriptors() { int y_off = m_roi.y; @@ -1094,12 +623,10 @@ void DAISY_Impl::compute_descriptors() int y_end = m_roi.y + m_roi.height; int x_end = m_roi.x + m_roi.width; - if( m_scale_invariant ) compute_scales(); - if( m_rotation_invariant ) compute_orientations(); - if( !m_descriptor_memory ) - m_dense_descriptors = allocate (m_roi.width*m_roi.height * m_descriptor_size); +// if( m_scale_invariant ) compute_scales(); +// if( m_rotation_invariant ) compute_orientations(); - memset(m_dense_descriptors, 0, sizeof(float)*m_roi.width*m_roi.height * m_descriptor_size); + m_dense_descriptors = Mat( m_roi.width*m_roi.height, m_descriptor_size, CV_32F, Scalar(0) ); int y, x, index, orientation; #if defined _OPENMP @@ -1109,63 +636,106 @@ void DAISY_Impl::compute_descriptors() { for( x=x_off; x= 0 && orientation < g_grid_orientation_resolution ) ) orientation = 0; - get_unnormalized_descriptor( y, x, orientation, &(m_dense_descriptors[index*m_descriptor_size]) ); + if( !m_orientation_map.empty() ) + orientation = (int) m_orientation_map.at( x, y ); + if( !( orientation >= 0 && orientation < g_grid_orientation_resolution ) ) + orientation = 0; + get_unnormalized_descriptor( y, x, orientation, m_dense_descriptors.ptr( index ) ); } } } -void DAISY_Impl::smooth_layers( float* layers, int h, int w, int layer_number, float sigma ) +inline void DAISY_Impl::smooth_layers( Mat layers, int h, int w, int layer_number, float sigma ) { - int fsz = filter_size(sigma); - float* filter = new float[fsz]; - gaussian_1d(filter, fsz, sigma, 0); + int i; - float* layer=0; + float *layer = NULL; + + int kernel_size = filter_size( sigma ); + float kernel[kernel_size]; + gaussian_1d( kernel, kernel_size, sigma, 0 ); + + float* ptr = layers.ptr(0); + #if defined _OPENMP #pragma omp parallel for private(i, layer) #endif + for( i=0; i 1e-5 ) - divide( desc, m_descriptor_size, norm); + // divide with norm + for( int i=0; i( d ), nrm_type ); } -void DAISY_Impl::initialize() +inline void DAISY_Impl::initialize() { - CV_Assert(m_h != 0); // no image ? - CV_Assert(m_w != 0); + // no image ? + CV_Assert(m_image.rows != 0); + CV_Assert(m_image.cols != 0); + if( m_layer_size == 0 ) { - m_layer_size = m_h*m_w; - m_cube_size = m_layer_size*m_hist_th_q_no; + m_layer_size = m_image.rows * m_image.cols; + m_cube_size = m_layer_size * m_hist_th_q_no; } - int glsz = compute_workspace_memory(); - if( !m_workspace_memory ) m_smoothed_gradient_layers = new float[glsz]; - - float* gradient_layers = m_smoothed_gradient_layers; + m_smoothed_gradient_layers = Mat( g_cube_number + 1, m_cube_size, CV_32F); - layered_gradient( m_image, m_h, m_w, m_hist_th_q_no, gradient_layers ); + layered_gradient( m_image, m_hist_th_q_no, m_smoothed_gradient_layers ); // assuming a 0.5 image smoothness, we pull this to 1.6 as in sift - smooth_layers( gradient_layers, m_h, m_w, m_hist_th_q_no, (float)sqrt(g_sigma_init*g_sigma_init-0.25) ); + smooth_layers( m_smoothed_gradient_layers, m_image.rows, m_image.cols, + m_hist_th_q_no, (float)sqrt(g_sigma_init*g_sigma_init-0.25) ); } -void DAISY_Impl::compute_cube_sigmas() +inline void DAISY_Impl::compute_cube_sigmas() { - if( m_cube_sigmas == NULL ) + if( m_cube_sigmas.empty() ) { - // user didn't set the sigma's; set them from the descriptor parameters + // user didn't set the sigma's; + // set them from the descriptor parameters g_cube_number = m_rad_q_no; - m_cube_sigmas = allocate(g_cube_number); + + m_cube_sigmas = Mat(1, g_cube_number, CV_64F); double r_step = double(m_rad)/m_rad_q_no; for( int r=0; r< m_rad_q_no; r++ ) { - m_cube_sigmas[r] = (r+1)*r_step/2; + m_cube_sigmas.at(r) = (r+1) * r_step/2; } } update_selected_cubes(); } -void DAISY_Impl::set_cube_gaussians( double* sigma_array, int sz ) -{ - g_cube_number = sz; - - if( m_cube_sigmas ) deallocate( m_cube_sigmas ); - m_cube_sigmas = allocate( g_cube_number ); - - for( int r=0; r= m_cube_sigmas[g_cube_number-1] ) return g_cube_number-1; + if( rad <= m_cube_sigmas.at(0) ) + return 0; + if( rad >= m_cube_sigmas.at(g_cube_number-1) ) + return g_cube_number-1; float dist; float mindist=FLT_MAX; int mini=0; for( int c=0; c(c)-rad ); if( dist < mindist ) { mindist = dist; mini=c; @@ -1269,24 +829,25 @@ int DAISY_Impl::quantize_radius( float rad ) const return mini; } -void DAISY_Impl::compute_histograms() +inline void DAISY_Impl::compute_histograms() { int r, y, x, ind; float* hist=0; for( r=0; r(0) + r * m_cube_size; + float* src = m_smoothed_gradient_layers.ptr(0) + (r+1)* m_cube_size; #if defined _OPENMP #pragma omp parallel for private(y,x,ind,hist) #endif - for( y=0; y(0) + r*m_cube_size; #if defined _OPENMP #pragma omp parallel for #endif - for( int y=0; y(0); float* cube = NULL; double sigma; for( int r=0; r(0) + (r+1)*m_cube_size; // incremental smoothing - if( r == 0 ) sigma = m_cube_sigmas[0]; - else sigma = sqrt( m_cube_sigmas[r]*m_cube_sigmas[r] - m_cube_sigmas[r-1]*m_cube_sigmas[r-1] ); + if( r == 0 ) + sigma = m_cube_sigmas.at(0); + else + sigma = sqrt( m_cube_sigmas.at(r ) * m_cube_sigmas.at(r ) + - m_cube_sigmas.at(r-1) * m_cube_sigmas.at(r-1) ); - int fsz = filter_size(sigma); - float* filter = new float[fsz]; - gaussian_1d(filter, fsz, (float)sigma, 0); + int kernel_size = filter_size( sigma ); + float kernel[kernel_size]; + gaussian_1d(kernel, kernel_size, (float)sigma, 0); #if defined _OPENMP #pragma omp parallel for #endif for( int th=0; th( g_grid_orientation_resolution, m_grid_point_number*2 ); + m_oriented_grid_points = + Mat( g_grid_orientation_resolution, m_grid_point_number*2, CV_64F ); for( int i=0; i(k,0); + double x = m_grid_points.at(k,1); - point_list[2*k+1] = x*kos + y*zin; // x - point_list[2*k ] = -x*zin + y*kos; // y + point_list.at(2*k+1) = x*kos + y*zin; // x + point_list.at(2*k ) = -x*zin + y*kos; // y } } } -void DAISY_Impl::smooth_histogram(float *hist, int hsz) +inline void DAISY_Impl::smooth_histogram(Mat hist, int hsz) { int i; float prev, temp; - prev = hist[hsz - 1]; + prev = hist.at(hsz - 1); for (i = 0; i < hsz; i++) { - temp = hist[i]; - hist[i] = (float) ((prev + hist[i] + hist[(i + 1 == hsz) ? 0 : i + 1]) / 3.0); + temp = hist.at(i); + hist.at(i) = (prev + hist.at(i) + hist.at( (i + 1 == hsz) ? 0 : i + 1) ) / 3.0f; prev = temp; } } -float DAISY_Impl::interpolate_peak(float left, float center, float right) +inline float DAISY_Impl::interpolate_peak(float left, float center, float right) { if( center < 0.0 ) { @@ -1402,7 +975,7 @@ float DAISY_Impl::interpolate_peak(float left, float center, float right) else return (float) (0.5*(left -right)/den); } -int DAISY_Impl::filter_size( double sigma ) +inline int DAISY_Impl::filter_size( double sigma ) { int fsz = (int)(5*sigma); @@ -1415,26 +988,32 @@ int DAISY_Impl::filter_size( double sigma ) return fsz; } -void DAISY_Impl::compute_scales() +inline void DAISY_Impl::compute_scales() { //############################################################################### //# scale detection is work-in-progress! do not use it if you're not Engin Tola # //############################################################################### - int imsz = m_w * m_h; - + int kernel_size = 0; float sigma = (float) ( pow( g_sigma_step, g_scale_st)*g_sigma_0 ); - float* sim = blur_gaussian_2d( m_image, m_h, m_w, sigma, filter_size(sigma), false); + if( kernel_size == 0 ) kernel_size = (int)(3*sigma); + if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd + if( kernel_size < 3 ) kernel_size = 3; // kernel size cannot be smaller than 3 + + float kernel[kernel_size]; + gaussian_1d( kernel, kernel_size, sigma, 0 ); + Mat Kernel( 1, kernel_size, CV_32F, (float*) kernel ); - float* next_sim = NULL; + Mat sim, next_sim; - float* max_dog = allocate(imsz); + // output gaussian image + filter2D( m_image, sim, CV_32F, Kernel, Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + filter2D( sim, sim, CV_32F, Kernel.t(), Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); - m_scale_map = allocate(imsz); + Mat max_dog( m_image.rows, m_image.cols, CV_32F, Scalar(0) ); + m_scale_map = Mat( m_image.rows, m_image.cols, CV_32F, Scalar(0) ); - memset( max_dog, 0, imsz*sizeof(float) ); - memset( m_scale_map, 0, imsz*sizeof(float) ); int i; float sigma_prev; @@ -1448,54 +1027,79 @@ void DAISY_Impl::compute_scales() sigma_inc = sqrt( sigma_new*sigma_new - sigma_prev*sigma_prev ); sigma_prev = sigma_new; - next_sim = blur_gaussian_2d( sim, m_h, m_w, sigma_inc, filter_size( sigma_inc ) , false); + kernel_size = filter_size( sigma_inc ); + if( kernel_size == 0 ) kernel_size = (int)(3 * sigma_inc); + if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd + if( kernel_size < 3 ) kernel_size= 3; // kernel size cannot be smaller than 3 + + float next_kernel[kernel_size]; + gaussian_1d( next_kernel, kernel_size, sigma_inc, 0 ); + Mat NextKernel( 1, kernel_size, CV_32F, (float*) next_kernel ); + + // output gaussian image + filter2D( sim, next_sim, CV_32F, NextKernel, Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + filter2D( next_sim, next_sim, CV_32F, NextKernel.t(), Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + #if defined _OPENMP #pragma omp parallel for #endif - for( int p=0; p max_dog[p] ) - { - max_dog[p] = dog; - m_scale_map[p] = (float) i; - } + for( int c=0; c(r,c) - sim.at(r,c) ); + if( dog > max_dog.at(r,c) ) + { + max_dog.at(r,c) = dog; + m_scale_map.at(r,c) = (float) i; + } + } } - deallocate( sim ); - + sim.release(); sim = next_sim; } - blur_gaussian_2d( m_scale_map, m_h, m_w, 10.0, filter_size(10), true); + kernel_size = filter_size( 10.0f ); + if( kernel_size == 0 ) kernel_size = (int)(3 * 10.0f); + if( kernel_size%2 == 0 ) kernel_size++; // kernel size must be odd + if( kernel_size < 3 ) kernel_size = 3; // kernel size cannot be smaller than 3 + + + float filter_kernel[kernel_size]; + gaussian_1d( filter_kernel, kernel_size, 10.0f, 0 ); + Mat FilterKernel( 1, kernel_size, CV_32F, (float*) filter_kernel ); + + // output gaussian image + filter2D( m_scale_map, m_scale_map, CV_32F, FilterKernel, Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); + filter2D( m_scale_map, m_scale_map, CV_32F, FilterKernel.t(), Point( -1.0f, -1.0f ), 0, BORDER_REPLICATE ); #if defined _OPENMP #pragma omp parallel for #endif - for( int q=0; q(r,c) = (float) round( m_scale_map.at(r,c) ); + } + } + //save( m_scale_map, m_image.rows, m_image.cols, "scales.dat"); } -void DAISY_Impl::compute_orientations() + +inline void DAISY_Impl::compute_orientations() { //##################################################################################### //# orientation detection is work-in-progress! do not use it if you're not Engin Tola # //##################################################################################### - CV_Assert( m_image != NULL ); + CV_Assert( !m_image.empty() ); - int data_size = m_w*m_h; - float* rotation_layers = layered_gradient( m_image, m_h, m_w, m_orientation_resolution ); + int data_size = m_image.cols * m_image.rows; + Mat rotation_layers = layered_gradient( m_image, m_orientation_resolution ); - m_orientation_map = new int[data_size]; - memset( m_orientation_map, 0, sizeof(int)*data_size ); + m_orientation_map = Mat(m_image.cols, m_image.rows, CV_16U, Scalar(0)); int ori, max_ind; int ind; @@ -1506,33 +1110,34 @@ void DAISY_Impl::compute_orientations() int x, y, kk; - float* hist=NULL; + Mat hist; float sigma_inc; - float sigma_prev = 0; + float sigma_prev = 0.0f; float sigma_new; for( int scale=0; scale(m_orientation_resolution); + hist = Mat(1, m_orientation_resolution, CV_32F); - for( x=0; x(y,x) != scale ) continue; for( ori=0; ori(ori) = rotation_layers.at(ori*data_size+ind); } for( kk=0; kk<6; kk++ ) @@ -1542,9 +1147,9 @@ void DAISY_Impl::compute_orientations() max_ind = 0; for( ori=0; ori max_val ) + if( hist.at(ori) > max_val ) { - max_val = hist[ori]; + max_val = hist.at(ori); max_ind = ori; } } @@ -1557,7 +1162,7 @@ void DAISY_Impl::compute_orientations() if( next >= m_orientation_resolution ) next -= m_orientation_resolution; - peak = interpolate_peak(hist[prev], hist[max_ind], hist[next]); + peak = interpolate_peak(hist.at(prev), hist.at(max_ind), hist.at(next)); angle = (float)( ((float)max_ind + peak)*360.0/m_orientation_resolution ); int iangle = int(angle); @@ -1565,54 +1170,26 @@ void DAISY_Impl::compute_orientations() if( iangle < 0 ) iangle += 360; if( iangle >= 360 ) iangle -= 360; - if( !(iangle >= 0.0 && iangle < 360.0) ) { angle = 0; } - - m_orientation_map[ ind ] = iangle; + m_orientation_map.at(y,x) = iangle; } - deallocate(hist); + hist.release(); } } - - deallocate( rotation_layers ); - compute_oriented_grid_points(); } -void DAISY_Impl::set_descriptor_memory( float* descriptor, long int d_size ) -{ - CV_Assert( m_descriptor_memory == false ); - CV_Assert( m_h*m_w != 0 ); - CV_Assert( m_roi.width*m_roi.height != 0 ); - CV_Assert( d_size >= compute_descriptor_memory() ); - - m_dense_descriptors = descriptor; - m_descriptor_memory = true; -} - -void DAISY_Impl::set_workspace_memory( float* workspace, long int w_size ) -{ - CV_Assert( m_workspace_memory == false ); - CV_Assert( m_h*m_w != 0 ); - CV_Assert( m_roi.width*m_roi.height != 0 ); - CV_Assert( w_size >= compute_workspace_memory() ); - - m_smoothed_gradient_layers = workspace; - m_workspace_memory = true; -} - -// ------------------------------------------------- -/* DAISY helper routines */ - inline void DAISY_Impl::compute_histogram( float* hcube, int y, int x, float* histogram ) { - if( is_outside(x, 0, m_w-1, y, 0, m_h-1) ) return; + if ( ! Point( x, y ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) return; - float* spatial_shift = hcube + y * m_w + x; - int data_size = m_w * m_h; + float* spatial_shift = hcube + y * m_image.cols + x; + int data_size = m_image.cols * m_image.rows; for( int h=0; h= m_w-2 || mny >= m_h-2 ) + if( mnx >= m_image.cols-2 || mny >= m_image.rows-2 ) { memset(histogram, 0, sizeof(float)*m_hist_th_q_no); return; } - int ind = mny*m_w+mnx; + int ind = mny*m_image.cols+mnx; // A C --> pixel positions // B D float* A = hcube+ind*m_hist_th_q_no; - float* B = A+m_w*m_hist_th_q_no; + float* B = A+m_image.cols*m_hist_th_q_no; float* C = A+m_hist_th_q_no; - float* D = A+(m_w+1)*m_hist_th_q_no; + float* D = A+(m_image.cols+1)*m_hist_th_q_no; double alpha = mnx+1-x; double beta = mny+1-y; @@ -1688,8 +1265,11 @@ inline void DAISY_Impl::ti_get_histogram( float* histogram, double y, double x, inline void DAISY_Impl::ni_get_histogram( float* histogram, int y, int x, int shift, float* hcube ) const { - if( is_outside(x, 0, m_w-1, y, 0, m_h-1) ) return; - float* hptr = hcube + (y*m_w+x)*m_hist_th_q_no; + if ( ! Point( x, y ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) return; + + float* hptr = hcube + (y*m_image.cols+x)*m_hist_th_q_no; for( int h=0; h=0 && x>=0 ); - descriptor = &(m_dense_descriptors[(y*m_w+x)*m_descriptor_size]); + CV_Assert( !m_dense_descriptors.empty() ); + CV_Assert( y=0 && x>=0 ); + descriptor = m_dense_descriptors.ptr( y*m_image.cols+x ); } inline void DAISY_Impl::get_descriptor( double y, double x, int orientation, float* descriptor ) const @@ -1725,22 +1305,24 @@ inline void DAISY_Impl::i_get_descriptor( double y, double x, int orientation, f // i'm not changing the descriptor[] values if the gridpoint is outside // the image. you should memset the descriptor array to 0 if you don't // want to have stupid values there. - // - CV_Assert( y >= 0 && y < m_h ); - CV_Assert( x >= 0 && x < m_w ); + + CV_Assert( y >= 0 && y < m_image.rows ); + CV_Assert( x >= 0 && x < m_image.cols ); CV_Assert( orientation >= 0 && orientation < 360 ); - CV_Assert( m_smoothed_gradient_layers ); - CV_Assert( m_oriented_grid_points ); + CV_Assert( !m_smoothed_gradient_layers.empty() ); + CV_Assert( !m_oriented_grid_points.empty() ); CV_Assert( descriptor != NULL ); double shift = m_orientation_shift_table[orientation]; - i_get_histogram( descriptor, y, x, shift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + float *ptr = (float *) m_smoothed_gradient_layers.ptr(0); + i_get_histogram( descriptor, y, x, shift, ptr + g_selected_cubes[0]*m_cube_size ); int r, rdt, region; double yy, xx; float* histogram = 0; - double* grid = m_oriented_grid_points[orientation]; + + Mat grid = m_oriented_grid_points.row( orientation ); // petals of the flower for( r=0; r(2*region ); + xx = x + grid.at(2*region + 1); + + if ( ! Point( xx, yy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) continue; + histogram = descriptor+region*m_hist_th_q_no; - i_get_histogram( histogram, yy, xx, shift, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); + i_get_histogram( histogram, yy, xx, shift, ptr + g_selected_cubes[r]*m_cube_size ); } } } @@ -1764,12 +1350,12 @@ inline void DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, // i'm not changing the descriptor[] values if the gridpoint is outside // the image. you should memset the descriptor array to 0 if you don't // want to have stupid values there. - // - CV_Assert( y >= 0 && y < m_h ); - CV_Assert( x >= 0 && x < m_w ); + + CV_Assert( y >= 0 && y < m_image.rows ); + CV_Assert( x >= 0 && x < m_image.cols ); CV_Assert( orientation >= 0 && orientation < 360 ); - CV_Assert( m_smoothed_gradient_layers ); - CV_Assert( m_oriented_grid_points ); + CV_Assert( !m_smoothed_gradient_layers.empty() ); + CV_Assert( !m_oriented_grid_points.empty() ); CV_Assert( descriptor != NULL ); double shift = m_orientation_shift_table[orientation]; @@ -1780,27 +1366,30 @@ inline void DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, int ix = (int)x; if( x - ix > 0.5 ) ix++; // center - ni_get_histogram( descriptor, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[0]*m_cube_size ); + float *ptr = (float *) m_smoothed_gradient_layers.ptr(0); + ni_get_histogram( descriptor, iy, ix, ishift, ptr + g_selected_cubes[0]*m_cube_size ); double yy, xx; float* histogram=0; // petals of the flower int r, rdt, region; - double* grid = m_oriented_grid_points[orientation]; + Mat grid = m_oriented_grid_points.row( orientation ); for( r=0; r(2*region ); + xx = x + grid.at(2*region+1); iy = (int)yy; if( yy - iy > 0.5 ) iy++; ix = (int)xx; if( xx - ix > 0.5 ) ix++; - if( is_outside(ix, 0, m_w-1, iy, 0, m_h-1) ) continue; + if ( ! Point( xx, yy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) continue; histogram = descriptor+region*m_hist_th_q_no; - ni_get_histogram( histogram, iy, ix, ishift, m_smoothed_gradient_layers+g_selected_cubes[r]*m_cube_size ); + ni_get_histogram( histogram, iy, ix, ishift, ptr + g_selected_cubes[r]*m_cube_size ); } } } @@ -1826,23 +1415,28 @@ inline bool DAISY_Impl::i_get_descriptor( double y, double x, int orientation, d // i'm not changing the descriptor[] values if the gridpoint is outside // the image. you should memset the descriptor array to 0 if you don't // want to have stupid values there. - // + CV_Assert( orientation >= 0 && orientation < 360 ); - CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( !m_smoothed_gradient_layers.empty() ); CV_Assert( descriptor != NULL ); int hradius[MAX_CUBE_NO]; double hy, hx, ry, rx; point_transform_via_homography( H, x, y, hx, hy ); - if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; - point_transform_via_homography( H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); - double radius = l2norm( ry, rx, hy, hx ); + if ( ! Point( hx, hy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) return false; + + point_transform_via_homography( H, x+m_cube_sigmas.at(g_selected_cubes[0]), y, rx, ry); + double d0 = rx - hx; double d1 = ry - hy; + double radius = sqrt( d0*d0 + d1*d1 ); hradius[0] = quantize_radius( (float) radius ); double shift = m_orientation_shift_table[orientation]; - i_get_histogram( descriptor, hy, hx, shift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + float *ptr = (float *) m_smoothed_gradient_layers.ptr(0); + i_get_histogram( descriptor, hy, hx, shift, ptr + hradius[0]*m_cube_size ); double gy, gx; int r, rdt, th, region; @@ -1854,21 +1448,24 @@ inline bool DAISY_Impl::i_get_descriptor( double y, double x, int orientation, d { region = rdt + th; - gy = y + m_grid_points[region][0]; - gx = x + m_grid_points[region][1]; + gy = y + m_grid_points.at(region,0); + gx = x + m_grid_points.at(region,1); point_transform_via_homography(H, gx, gy, hx, hy); if( th == 0 ) { - point_transform_via_homography(H, gx+m_cube_sigmas[g_selected_cubes[r]], gy, rx, ry); - radius = l2norm( ry, rx, hy, hx ); + point_transform_via_homography(H, gx+m_cube_sigmas.at(g_selected_cubes[r]), gy, rx, ry); + d0 = rx - hx; d1 = ry - hy; + radius = sqrt( d0*d0 + d1+d1 ); hradius[r] = quantize_radius( (float) radius ); } - if( is_outside(hx, 0, m_w-1, hy, 0, m_h-1) ) continue; + if ( ! Point( hx, hy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) continue; histogram = descriptor+region*m_hist_th_q_no; - i_get_histogram( histogram, hy, hx, shift, m_smoothed_gradient_layers+hradius[r]*m_cube_size ); + i_get_histogram( histogram, hy, hx, shift, ptr + hradius[r]*m_cube_size ); } } return true; @@ -1881,24 +1478,27 @@ inline bool DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, // i'm not changing the descriptor[] values if the gridpoint is outside // the image. you should memset the descriptor array to 0 if you don't // want to have stupid values there. - // + CV_Assert( orientation >= 0 && orientation < 360 ); - CV_Assert( m_smoothed_gradient_layers ); + CV_Assert( !m_smoothed_gradient_layers.empty() ); CV_Assert( descriptor != NULL ); int hradius[MAX_CUBE_NO]; - double radius; double hy, hx, ry, rx; point_transform_via_homography(H, x, y, hx, hy ); - if( is_outside( hx, 0, m_w, hy, 0, m_h ) ) return false; + + if ( ! Point( hx, hy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) return false; double shift = m_orientation_shift_table[orientation]; int ishift = (int)shift; if( shift - ishift > 0.5 ) ishift++; - point_transform_via_homography(H, x+m_cube_sigmas[g_selected_cubes[0]], y, rx, ry); - radius = l2norm( ry, rx, hy, hx ); + point_transform_via_homography(H, x+m_cube_sigmas.at(g_selected_cubes[0]), y, rx, ry); + double d0 = rx - hx; double d1 = ry - hy; + double radius = sqrt( d0*d0 + d1*d1 ); hradius[0] = quantize_radius( (float) radius ); int ihx = (int)hx; if( hx - ihx > 0.5 ) ihx++; @@ -1907,7 +1507,8 @@ inline bool DAISY_Impl::ni_get_descriptor( double y, double x, int orientation, int r, rdt, th, region; double gy, gx; float* histogram=0; - ni_get_histogram( descriptor, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[0]*m_cube_size ); + float *ptr = (float *) m_smoothed_gradient_layers.ptr(0); + ni_get_histogram( descriptor, ihy, ihx, ishift, ptr + hradius[0]*m_cube_size ); for( r=0; r(region,0); + gx = x + m_grid_points.at(region,1); point_transform_via_homography(H, gx, gy, hx, hy); if( th == 0 ) { - point_transform_via_homography(H, gx+m_cube_sigmas[g_selected_cubes[r]], gy, rx, ry); - radius = l2norm( ry, rx, hy, hx ); + point_transform_via_homography(H, gx+m_cube_sigmas.at(g_selected_cubes[r]), gy, rx, ry); + d0 = rx - hx; d1 = ry - hy; + radius = sqrt( d0*d0 + d1*d1 ); hradius[r] = quantize_radius( (float) radius ); } ihx = (int)hx; if( hx - ihx > 0.5 ) ihx++; ihy = (int)hy; if( hy - ihy > 0.5 ) ihy++; - if( is_outside(ihx, 0, m_w-1, ihy, 0, m_h-1) ) continue; + if ( ! Point( ihx, ihy ).inside( + Rect( 0, 0, m_image.cols-1, m_image.rows-1 ) ) + ) continue; + histogram = descriptor+region*m_hist_th_q_no; - ni_get_histogram( histogram, ihy, ihx, ishift, m_smoothed_gradient_layers+hradius[r]*m_cube_size ); + ni_get_histogram( histogram, ihy, ihx, ishift, ptr + hradius[r]*m_cube_size ); } } return true; } -void DAISY_Impl::initialize_single_descriptor_mode( ) +inline void DAISY_Impl::initialize_single_descriptor_mode( ) { initialize(); compute_smoothed_gradient_layers(); } -void DAISY_Impl::set_parameters( ) +inline void DAISY_Impl::set_parameters( ) { m_grid_point_number = m_rad_q_no * m_th_q_no + 1; // +1 is for center pixel m_descriptor_size = m_grid_point_number * m_hist_th_q_no; @@ -1952,7 +1557,7 @@ void DAISY_Impl::set_parameters( ) { m_orientation_shift_table[i] = i/360.0 * m_hist_th_q_no; } - m_layer_size = m_h*m_w; + m_layer_size = m_image.rows*m_image.cols; m_cube_size = m_layer_size*m_hist_th_q_no; compute_cube_sigmas(); @@ -1961,48 +1566,29 @@ void DAISY_Impl::set_parameters( ) // set/convert image array for daisy internal routines // daisy internals use CV_32F image with norm to 1.0f -void DAISY_Impl::set_image( InputArray _image ) +inline void DAISY_Impl::set_image( InputArray _image ) { // release previous image - // and previous daisies workspace + // and previous workspace reset(); - // fetch new image Mat image = _image.getMat(); - // image cannot be empty CV_Assert( ! image.empty() ); - - // base size - m_h = image.rows; - m_w = image.cols; - // clone image for conversion if ( image.depth() != CV_32F ) { - m_work_image = image.clone(); - + m_image = image.clone(); // convert to gray inplace - if( m_work_image.channels() > 1 ) - cvtColor( m_work_image, m_work_image, COLOR_BGR2GRAY ); - - // convert to float if it is necessary - if ( m_work_image.depth() != CV_32F ) - { - // convert and normalize - m_work_image.convertTo( m_work_image, CV_32F ); - m_work_image /= 255.0f; - } else - CV_Error( Error::StsUnsupportedFormat, "" ); - - // use cloned work image - m_image = m_work_image.ptr(0); - + if( m_image.channels() > 1 ) + cvtColor( m_image, m_image, COLOR_BGR2GRAY ); + // convert and normalize + m_image.convertTo( m_image, CV_32F ); + m_image /= 255.0f; } else // use original user supplied CV_32F image // should be a normalized one (cannot check) - m_image = image.ptr(0); - + m_image = image; } @@ -2019,7 +1605,7 @@ void DAISY_Impl::compute( InputArray _image, std::vector& keypoints, O set_image( _image ); // whole image - m_roi = Rect( 0, 0, m_w, m_h ); + m_roi = Rect( 0, 0, m_image.cols, m_image.rows ); // get homography Mat H = m_h_matrix; @@ -2080,8 +1666,7 @@ void DAISY_Impl::compute( InputArray _image, Rect roi, OutputArray _descriptors normalize_descriptors(); Mat descriptors = _descriptors.getMat(); - descriptors = Mat( m_roi.width * m_roi.height, m_descriptor_size, - CV_32F, &m_dense_descriptors[0] ); + descriptors = m_dense_descriptors; release_auxiliary(); } @@ -2099,7 +1684,7 @@ void DAISY_Impl::compute( InputArray _image, OutputArray _descriptors ) set_image( _image ); // whole image - m_roi = Rect( 0, 0, m_w, m_h ); + m_roi = Rect( 0, 0, m_image.cols, m_image.rows ); set_parameters(); initialize_single_descriptor_mode(); @@ -2109,8 +1694,7 @@ void DAISY_Impl::compute( InputArray _image, OutputArray _descriptors ) normalize_descriptors(); Mat descriptors = _descriptors.getMat(); - descriptors = Mat( m_h * m_w, m_descriptor_size, - CV_32F, &m_dense_descriptors[0] ); + descriptors = m_dense_descriptors; release_auxiliary(); } @@ -2121,31 +1705,25 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, : m_rad(_radius), m_rad_q_no(_q_radius), m_th_q_no(_q_theta), m_hist_th_q_no(_q_hist), m_nrm_type(_norm), m_disable_interpolation(_interpolation), m_use_orientation(_use_orientation) { - m_w = 0; - m_h = 0; m_image = 0; - m_grid_point_number = 0; m_descriptor_size = 0; - m_smoothed_gradient_layers = NULL; - m_dense_descriptors = NULL; - m_grid_points = NULL; - m_oriented_grid_points = NULL; + m_grid_point_number = 0; + + m_grid_points.release(); + m_dense_descriptors.release(); + m_smoothed_gradient_layers.release(); + m_oriented_grid_points.release(); m_scale_invariant = false; m_rotation_invariant = false; - m_scale_map = NULL; - m_orientation_map = NULL; + m_scale_map.release(); + m_orientation_map.release(); m_orientation_resolution = 36; - m_scale_map = NULL; - - m_cube_sigmas = NULL; - // unused features - m_descriptor_memory = false; - m_workspace_memory = false; + m_cube_sigmas.release(); m_cube_size = 0; m_layer_size = 0; @@ -2158,12 +1736,11 @@ DAISY_Impl::DAISY_Impl( float _radius, int _q_radius, int _q_theta, int _q_hist, // destructor DAISY_Impl::~DAISY_Impl() { - if ( !m_workspace_memory ) deallocate( m_smoothed_gradient_layers ); - deallocate( m_grid_points, m_grid_point_number ); - deallocate( m_oriented_grid_points, g_grid_orientation_resolution ); - deallocate( m_orientation_map ); - deallocate( m_scale_map ); - deallocate( m_cube_sigmas ); + m_scale_map.release(); + m_grid_points.release(); + m_orientation_map.release(); + m_oriented_grid_points.release(); + m_smoothed_gradient_layers.release(); } Ptr DAISY::create( float radius, int q_radius, int q_theta, int q_hist,