OZ++ Sample: BRISKFeatureDetector

/******************************************************************************  *  * Copyright (c) 2019 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.  *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions  * are met:  * 1. Redistributions of source code must retain the above copyright  *    notice, this list of conditions, and the following disclaimer.  *  * 2. The name of the author may not be used to endorse or promote products  *    derived from this software without specific prior written permission.  *  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.  *  *  *  BRISKFeatureDetector.cpp  *  *****************************************************************************/ //2017/05/15 #include <opencv2/stitching.hpp> #include <oz++/motif/Label.h> #include <oz++/motif/RowColumn.h> #include <oz++/motif/LabeledTrackBar.h> #include <oz++/opencv/OpenCVScaleComboBox.h> #include <oz++/opencv/OpenCVMainView.h> #include <oz++/opencv/OpenCVImageView.h> #include <oz++/motif/FileOpenDialog.h> #include <opencv2/features2d/features2d.hpp> namespace OZ { class MainView :public OpenCVMainView { private:   ///////////////////////////////////////////////   //Inner classes start.   class OriginalImageView: public OpenCVImageView {   private:     cv::Mat originalImage;      cv::Mat scaledImage;          virtual void display()     {        show(scaledImage);     }     public:     OriginalImageView(View* parent, const char* name, Args& args)     :OpenCVImageView(parent, name, args)     {       try {         const char* filename = (const char*)args.get(XmNimageFileName);         int imageLoadingFlag = args.get(XmNimageLoadingFlag);         int scalingRatio = (int)args.get(XmNimageScalingRatio);         loadImage(filename, imageLoadingFlag, scalingRatio);         } catch (OZ::Exception ex) {         caught(ex);       }     }      ~OriginalImageView()     {     }          void loadImage(const char* filename,          int imageLoadingFlag= CV_LOAD_IMAGE_COLOR,                 int scalingRatio=100)     {       originalImage = readImage(filename, imageLoadingFlag);       scaleImage(originalImage, scaledImage, scalingRatio);     }         void rescale(int scalingRatio)     {       scaledImage.release();       scaleImage(originalImage, scaledImage, scalingRatio);     }   };   class DetectedImageView: public OpenCVImageView {   private:     cv::Mat originalImage;      cv::Mat detectedImage;      cv::Mat scaledImage;     //The scale image is displayed on this image view.     virtual void display()     {        show(scaledImage);     }     public:     DetectedImageView(View* parent, const char* name, Args& args)     :OpenCVImageView(parent, name, args)     {       try {         const char* filename = (const char*)args.get(XmNimageFileName);         int imageLoadingFlag = args.get(XmNimageLoadingFlag);         int scalingRatio = (int)args.get(XmNimageScalingRatio);         loadImage(filename, imageLoadingFlag, scalingRatio);       } catch (OZ::Exception ex) {         caught(ex);       }     }      ~DetectedImageView()     {     }          void loadImage(const char* filename,          int imageLoadingFlag= CV_LOAD_IMAGE_COLOR,                 int scalingRatio=100)     {       originalImage = readImage(filename, imageLoadingFlag);       detectedImage  = originalImage.clone();       detectedImage.create( originalImage.size(), originalImage.type() );       scaleImage(detectedImage, scaledImage, scalingRatio);     }         void rescale(int scalingRatio)     {       scaledImage.release();       scaleImage(detectedImage, scaledImage, scalingRatio);     }     void detect(int scalingRatio)     {       std::vector<cv::KeyPoint> keypoints;       // OPENCV_3.2.0             //  Ptr<BRISK> detector =  cv::BRISK::create();  //use default argments       //  CV_WRAP static Ptr<BRISK> create(int thresh=30, int octaves=3, float patternScale=1.0f);        //OpenCV2.4.8       //CV_WRAP explicit&