diff --git a/doc/tutorials/cvv/table_of_content_cvv/table_of_content_cvv.rst b/doc/tutorials/cvv/table_of_content_cvv/table_of_content_cvv.rst index bf7ce4955..b5bc04590 100644 --- a/doc/tutorials/cvv/table_of_content_cvv/table_of_content_cvv.rst +++ b/doc/tutorials/cvv/table_of_content_cvv/table_of_content_cvv.rst @@ -5,7 +5,7 @@ Here you will learn how to use the cvv module to ease programming computer vision software through visual debugging aids. -.. include:: ../../definitions/tocDefinitions.rst + .. include:: ../../definitions/tocDefinitions.rst + .. tabularcolumns:: m{100pt} m{300pt} @@ -27,9 +27,9 @@ Here you will learn how to use the cvv module to ease programming computer visio :width: 90pt -.. raw:: latex + .. raw:: latex - \pagebreak + \pagebreak .. toctree:: :hidden: diff --git a/modules/bioinspired/include/opencv2/bioinspired/retina.hpp b/modules/bioinspired/include/opencv2/bioinspired/retina.hpp index fdafadab8..bc3262ab3 100644 --- a/modules/bioinspired/include/opencv2/bioinspired/retina.hpp +++ b/modules/bioinspired/include/opencv2/bioinspired/retina.hpp @@ -301,12 +301,12 @@ public: */ CV_WRAP virtual void activateContoursProcessing(const bool activate)=0; }; -CV_EXPORTS Ptr createRetina(Size inputSize); -CV_EXPORTS Ptr createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); +CV_EXPORTS_W Ptr createRetina(Size inputSize); +CV_EXPORTS_W Ptr createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); #ifdef HAVE_OPENCV_OCL -CV_EXPORTS Ptr createRetina_OCL(Size inputSize); -CV_EXPORTS Ptr createRetina_OCL(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); +Ptr createRetina_OCL(Size inputSize); +Ptr createRetina_OCL(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0); #endif } } diff --git a/modules/bioinspired/include/opencv2/bioinspired/retinafasttonemapping.hpp b/modules/bioinspired/include/opencv2/bioinspired/retinafasttonemapping.hpp index 6c83f885c..5555292ca 100644 --- a/modules/bioinspired/include/opencv2/bioinspired/retinafasttonemapping.hpp +++ b/modules/bioinspired/include/opencv2/bioinspired/retinafasttonemapping.hpp @@ -93,7 +93,7 @@ namespace bioinspired{ * regarding spatio-temporal filter and the bigger retina model : * Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891. */ -class CV_EXPORTS RetinaFastToneMapping : public Algorithm +class CV_EXPORTS_W RetinaFastToneMapping : public Algorithm { public: @@ -103,7 +103,7 @@ public: @param inputImage the input image to process RGB or gray levels @param outputToneMappedImage the output tone mapped image */ - virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0; + CV_WRAP virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0; /** * setup method that updates tone mapping behaviors by adjusing the local luminance computation area @@ -111,10 +111,10 @@ public: * @param ganglioncellsNeighborhoodRadius the second stage local adaptation area * @param meanLuminanceModulatorK the factor applied to modulate the meanLuminance information (default is 1, see reference paper) */ - virtual void setup(const float photoreceptorsNeighborhoodRadius=3.f, const float ganglioncellsNeighborhoodRadius=1.f, const float meanLuminanceModulatorK=1.f)=0; + CV_WRAP virtual void setup(const float photoreceptorsNeighborhoodRadius=3.f, const float ganglioncellsNeighborhoodRadius=1.f, const float meanLuminanceModulatorK=1.f)=0; }; -CV_EXPORTS Ptr createRetinaFastToneMapping(Size inputSize); +CV_EXPORTS_W Ptr createRetinaFastToneMapping(Size inputSize); } } diff --git a/modules/bioinspired/include/opencv2/bioinspired/transientareassegmentationmodule.hpp b/modules/bioinspired/include/opencv2/bioinspired/transientareassegmentationmodule.hpp index fe3898451..950817581 100755 --- a/modules/bioinspired/include/opencv2/bioinspired/transientareassegmentationmodule.hpp +++ b/modules/bioinspired/include/opencv2/bioinspired/transientareassegmentationmodule.hpp @@ -83,12 +83,12 @@ namespace cv namespace bioinspired { -class CV_EXPORTS TransientAreasSegmentationModule: public Algorithm +class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm { public: // parameters structure - struct SegmentationParameters{ + struct CV_EXPORTS_W SegmentationParameters{ SegmentationParameters(): thresholdON(100), thresholdOFF(100), @@ -101,16 +101,16 @@ public: // context neighborhood energy filtering parameters : the aim is to get information about the energy on a wide neighborhood area to filtered out local effects contextEnergy_temporalConstant(1), contextEnergy_spatialConstant(75){};// default setup - float thresholdON, thresholdOFF; - float localEnergy_temporalConstant, localEnergy_spatialConstant; - float neighborhoodEnergy_temporalConstant, neighborhoodEnergy_spatialConstant; - float contextEnergy_temporalConstant, contextEnergy_spatialConstant; + CV_PROP_RW float thresholdON, thresholdOFF; + CV_PROP_RW float localEnergy_temporalConstant, localEnergy_spatialConstant; + CV_PROP_RW float neighborhoodEnergy_temporalConstant, neighborhoodEnergy_spatialConstant; + CV_PROP_RW float contextEnergy_temporalConstant, contextEnergy_spatialConstant; }; /** * @return the sze of the manage input and output images */ - virtual Size getSize()=0; + CV_WRAP virtual Size getSize()=0; /** * try to open an XML segmentation parameters file to adjust current segmentation instance setup @@ -119,7 +119,7 @@ public: * @param retinaParameterFile : the parameters filename * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error */ - virtual void setup(String segmentationParameterFile="", const bool applyDefaultSetupOnFailure=true)=0; + CV_WRAP virtual void setup(String segmentationParameterFile="", const bool applyDefaultSetupOnFailure=true)=0; /** * try to open an XML segmentation parameters file to adjust current segmentation instance setup @@ -128,7 +128,7 @@ public: * @param fs : the open Filestorage which contains segmentation parameters * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error */ - virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0; + CV_WRAP virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0; /** * try to open an XML segmentation parameters file to adjust current segmentation instance setup @@ -137,55 +137,55 @@ public: * @param newParameters : a parameters structures updated with the new target configuration * @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error */ - virtual void setup(SegmentationParameters newParameters)=0; + CV_WRAP virtual void setup(SegmentationParameters newParameters)=0; /** * @return the current parameters setup */ - virtual SegmentationParameters getParameters()=0; + CV_WRAP virtual SegmentationParameters getParameters()=0; /** * parameters setup display method * @return a string which contains formatted parameters information */ - virtual const String printSetup()=0; + CV_WRAP virtual const String printSetup()=0; /** * write xml/yml formated parameters information * @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information */ - virtual void write( String fs ) const=0; + CV_WRAP virtual void write( String fs ) const=0; /** * write xml/yml formated parameters information * @param fs : a cv::Filestorage object ready to be filled */ - virtual void write( cv::FileStorage& fs ) const=0; + CV_WRAP virtual void write( cv::FileStorage& fs ) const=0; /** * main processing method, get result using methods getSegmentationPicture() * @param inputToSegment : the image to process, it must match the instance buffer size ! * @param channelIndex : the channel to process in case of multichannel images */ - virtual void run(InputArray inputToSegment, const int channelIndex=0)=0; + CV_WRAP virtual void run(InputArray inputToSegment, const int channelIndex=0)=0; /** * access function * @return the last segmentation result: a boolean picture which is resampled between 0 and 255 for a display purpose */ - virtual void getSegmentationPicture(OutputArray transientAreas)=0; + CV_WRAP virtual void getSegmentationPicture(OutputArray transientAreas)=0; /** * cleans all the buffers of the instance */ - virtual void clearAllBuffers()=0; + CV_WRAP virtual void clearAllBuffers()=0; }; /** * allocator * @param Size : size of the images input to segment (output will be the same size) */ -CV_EXPORTS Ptr createTransientAreasSegmentationModule(Size inputSize); +CV_EXPORTS_W Ptr createTransientAreasSegmentationModule(Size inputSize); }} // namespaces end : cv and bioinspired diff --git a/modules/ccalib/src/ccalib.cpp b/modules/ccalib/src/ccalib.cpp index bd2e11cab..efb5bdf25 100644 --- a/modules/ccalib/src/ccalib.cpp +++ b/modules/ccalib/src/ccalib.cpp @@ -93,10 +93,11 @@ bool CustomPattern::init(Mat& image, const float pixel_size, OutputArray output) if (!detector) // if no detector chosen, use default { - detector = FeatureDetector::create("ORB"); - detector->set("nFeatures", 2000); - detector->set("scaleFactor", 1.15); - detector->set("nLevels", 30); + Ptr orb = ORB::create(); + orb->setMaxFeatures(2000); + orb->setScaleFactor(1.15); + orb->setNLevels(30); + detector = orb; } detector->detect(img_roi, keypoints); @@ -108,7 +109,7 @@ bool CustomPattern::init(Mat& image, const float pixel_size, OutputArray output) refineKeypointsPos(img_roi, keypoints); if (!descriptorExtractor) // if no extractor chosen, use default - descriptorExtractor = DescriptorExtractor::create("ORB"); + descriptorExtractor = ORB::create(); descriptorExtractor->compute(img_roi, keypoints, descriptor); if (!descriptorMatcher) diff --git a/modules/cvv/doc/Ueberblick-tut.md b/modules/cvv/doc/Ueberblick-tut.md deleted file mode 100644 index 31df83788..000000000 --- a/modules/cvv/doc/Ueberblick-tut.md +++ /dev/null @@ -1,91 +0,0 @@ -#Über CVVisual -CVVisual ist eine Debug-Bibliothek für OpenCV, die verschiedene Möglichkeiten der Darstellung von Bildern und Ergebnissen von beispielsweise Filter- und Match-Operationen von OpenCV anbietet. - -##Benutzung: Beispiel -Ist die Bibliothek eingebunden, das CVVISUAL\_DEBUG-Makro definiert und die benötigten Header in den Code eingebunden, kann durch den Aufruf einer CVVisual-Funktion mit den von OpenCV gelieferten Daten als Argumenten das CVV-Hauptfenster geöffnet werden. - -Beispielsweise könnte ein Codestück folgendermaßen aussehen: - - //... - cvv::debugDMatch(src, keypoints1, src, keypoints2, match, CVVISUAL\_LOCATION); - -![](../images_ueberblick/MainWindow.PNG) - -Die Bilder werden zusammen mit Informationen und Metadaten in der Overview-Tabelle angezeigt. -Ein Doppelklick darauf öffnet ein Tab, in dem die Bilder und Matches groß angezeigt werden. - -![](../images_ueberblick/LineMatchViewTab.PNG) - -In dieser Ansicht, genannt *Line Match View* werden die KeyPoints der Matches, d.h. die von OpenCV gelieferten ähnlichen Bildpunkte, durch Linien verbunden. Im Akkordeonmenü kann man beispielsweise deren Farbe änder. `Strg + Mausrad` erlaubt, zu zoomen. - -![](../images_ueberblick/LineMatchViewZoomed.PNG) - -Die Art der Darstellung kann im `View`-Dropdown-Menü geändert werden; so können die Matches etwa auch als Translationslinien angezeigt werden. - -![](../images_ueberblick/TranslationMatchViewTab.PNG) - -Zudem gibt es bei Matches auch die Möglichkeit, die Daten in einer Tabelle anzuzeigen, im sogenannten -*Raw View*. Die Daten können hier über einen Linksklick als JSON oder CSV ins Clipboard kopiert -werden. - -![](../images_ueberblick/RawviewTab.PNG) - -Wird `Step` geklickt wird die Ausführung des zu debuggenden Programmes, das beim Aufruf des Hauptfensters angehalten wurde fortgesetzt, bis es auf eine weitere CVVisual-Funktion -stößt: - - //... - cvv::debugFilter(src, dest, CVVISUAL\_LOCATION, filename); - -Das Hauptfenster erscheint erneut, wobei der neuen Datensatz der Tabelle hinzugefügt wird. - -![](../images_ueberblick/MainWindowTwoCalls.PNG) - -Da es sich hier um eine Filter-Operation handelt, ist die Anzeige im Tab eine andere: - -![](../images_ueberblick/DefaultFilterViewTab.PNG) - -Auch die möglichen Anzeigen unterscheiden sich von denen für Match-Operationen. -Der *Dual Filter View* erlaubt zum Beispiel zusätzlich, ein Differenzbild der beiden übergebenen anzuzeigen. - -![](../images_ueberblick/DualfilterViewDiffImg.PNG) - -Nach einem *fast-forward* (`>>`) über die weiteren Schritte des Programms - - //... - cvv::debugDMatch(src, keypoints1, src, keypoints2, match, CVVISUAL\_LOCATION) - //... - cvv::debugFilter(src, dest, CVVISUAL\_LOCATION, filename); - //... - cvv::debugFilter(src, dest, CVVISUAL\_LOCATION, filename); - //... - cvv::debugDMatch(src, keypoints1, src, keypoints2, match, CVVISUAL\_LOCATION); - //... - cvv::showImage(img, CVVISUAL\_LOCATION); - //... - cvv::finalShow(); -ergibt sich im Overview folgendes Bild: - -![](../images_ueberblick/MainWindowFull.PNG) - -Dabei wird durch den letzten Aufruf nur ein einziges Bild zur Anzeige übergeben: - -![](../images_ueberblick/SingleImageTab.PNG) - -Mithilfe der Textzeile lassen sich durch Kommandos der *Filter Query Language* von CVVisual die Datensätze ordnen, filtern und gruppieren. Hier wurde nach ID gruppiert: - -![](../images_ueberblick/OverviewFilterQueryGroupByID.PNG) - -Dies funktioniert auch im *Raw View*. - -Hinter dem letzten Aufruf einer regulären CVVisual-Funktion muss, wie oben gesehen, `finalShow` aufgerufen werden: - - //... - cvv::finalShow(); - //... - -Es wird ein weiteres Mal das Hauptfenster angezeigt; wird jedoch der nun der einzige verbleibende, der `Close`-Knopf betätigt, wird das Hauptfenster endgültig geschlossen. - -Dies beschließt die Debug-Sitzung. - -[Quelle des zur Demonstration benutzten Bildes.](http://commons.wikimedia.org/wiki/File:PNG-Gradient.png) - diff --git a/modules/cvv/doc/code_example/CMakeLists.txt b/modules/cvv/doc/code_example/CMakeLists.txt deleted file mode 100644 index 6d42e28bb..000000000 --- a/modules/cvv/doc/code_example/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(cvvisual_test) - -SET(CMAKE_PREFIX_PATH ~/software/opencv/install) - -SET(CMAKE_CXX_COMPILER "g++-4.8") -SET(CMAKE_CXX_FLAGS "-std=c++11 -O2 -pthread -Wall -Werror") - -OPTION(CVV_DEBUG_MODE "cvvisual-debug-mode" ON) -if(CVV_DEBUG_MODE MATCHES ON) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCVVISUAL_DEBUGMODE") -endif() - - -FIND_PACKAGE(OpenCV REQUIRED) -include_directories(${OpenCV_INCLUDE_DIRS}) - -FIND_PACKAGE(Qt5Core REQUIRED) -include_directories(${Qt5Core_INCLUDE_DIRS}) -FIND_PACKAGE(Qt5Widgets REQUIRED) -include_directories(${Qt5Widgets_INCLUDE_DIRS}) -add_definitions(${QT_DEFINITIONS}) - -SET(OpenCVVisual_DIR "$ENV{HOME}/<<>>") -include_directories("${OpenCVVisual_DIR}/include") -link_directories("${OpenCVVisual_DIR}/build/release") - -add_executable(cvvt main.cpp) -target_link_libraries(cvvt - opencv_core opencv_highgui opencv_imgproc opencv_features2d - opencv_cvv - Qt5Core Qt5Widgets Qt5Gui -) diff --git a/modules/cvv/doc/code_example/README.md b/modules/cvv/doc/code_example/README.md deleted file mode 100644 index d2940bfaf..000000000 --- a/modules/cvv/doc/code_example/README.md +++ /dev/null @@ -1,5 +0,0 @@ -This is a tiny example of how to use CVVisual. It requires a webcam. - -Note that the paths in CMakeLists.txt have to be set manually. - -cvvisual_test was created by Andreas Bihlmaier. \ No newline at end of file diff --git a/modules/cvv/doc/code_example/main.cpp b/modules/cvv/doc/code_example/main.cpp deleted file mode 100644 index dff64bc8b..000000000 --- a/modules/cvv/doc/code_example/main.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// system includes -#include -#include - -// library includes -#include -#include -#include - -#include -#include -#include -#include -#include - - -template std::string toString(const T& p_arg) -{ - std::stringstream ss; - - ss << p_arg; - - return ss.str(); -} - - -void -usage() -{ - printf("usage: cvvt [-r WxH]\n"); - printf("-h print this help\n"); - printf("-r WxH change resolution to width W and height H\n"); -} - - -int -main(int argc, char** argv) -{ - cv::Size* resolution = nullptr; - - // parse options - const char* optstring = "hr:"; - int opt; - while ((opt = getopt(argc, argv, optstring)) != -1) { - switch (opt) { - case 'h': - usage(); - return 0; - break; - case 'r': - { - char dummych; - resolution = new cv::Size(); - if (sscanf(optarg, "%d%c%d", &resolution->width, &dummych, &resolution->height) != 3) { - printf("%s not a valid resolution\n", optarg); - return 1; - } - } - break; - default: /* '?' */ - usage(); - return 2; - } - } - - // setup video capture - cv::VideoCapture capture(0); - if (!capture.isOpened()) { - std::cout << "Could not open VideoCapture" << std::endl; - return 3; - } - - if (resolution) { - printf("Setting resolution to %dx%d\n", resolution->width, resolution->height); - capture.set(CV_CAP_PROP_FRAME_WIDTH, resolution->width); - capture.set(CV_CAP_PROP_FRAME_HEIGHT, resolution->height); - } - - - cv::Mat prevImgGray; - std::vector prevKeypoints; - cv::Mat prevDescriptors; - - int maxFeatureCount = 500; - cv::ORB detector(maxFeatureCount); - - cv::BFMatcher matcher(cv::NORM_HAMMING); - - for (int imgId = 0; imgId < 10; imgId++) { - // capture a frame - cv::Mat imgRead; - capture >> imgRead; - printf("%d: image captured\n", imgId); - - std::string imgIdString{"imgRead"}; - imgIdString += toString(imgId); - cvv::showImage(imgRead, CVVISUAL_LOCATION, imgIdString.c_str()); - - // convert to grayscale - cv::Mat imgGray; - cv::cvtColor(imgRead, imgGray, CV_BGR2GRAY); - cvv::debugFilter(imgRead, imgGray, CVVISUAL_LOCATION, "to gray"); - - // detect ORB features - std::vector keypoints; - cv::Mat descriptors; - detector(imgGray, cv::noArray(), keypoints, descriptors); - printf("%d: detected %zd keypoints\n", imgId, keypoints.size()); - - // match them to previous image (if available) - if (!prevImgGray.empty()) { - std::vector matches; - matcher.match(prevDescriptors, descriptors, matches); - printf("%d: all matches size=%zd\n", imgId, matches.size()); - std::string allMatchIdString{"all matches "}; - allMatchIdString += toString(imgId-1) + "<->" + toString(imgId); - cvv::debugDMatch(prevImgGray, prevKeypoints, imgGray, keypoints, matches, CVVISUAL_LOCATION, allMatchIdString.c_str()); - - // remove worst (as defined by match distance) bestRatio quantile - double bestRatio = 0.8; - std::sort(matches.begin(), matches.end()); - matches.resize(int(bestRatio * matches.size())); - printf("%d: best matches size=%zd\n", imgId, matches.size()); - std::string bestMatchIdString{"best " + toString(bestRatio) + " matches "}; - bestMatchIdString += toString(imgId-1) + "<->" + toString(imgId); - cvv::debugDMatch(prevImgGray, prevKeypoints, imgGray, keypoints, matches, CVVISUAL_LOCATION, bestMatchIdString.c_str()); - } - - prevImgGray = imgGray; - prevKeypoints = keypoints; - prevDescriptors = descriptors; - } - - cvv::finalShow(); - - return 0; -} diff --git a/modules/cvv/doc/cvv.rst b/modules/cvv/doc/cvv.rst new file mode 100644 index 000000000..943849aaa --- /dev/null +++ b/modules/cvv/doc/cvv.rst @@ -0,0 +1,11 @@ +********************************************************************* +cvv. GUI for Interactive Visual Debugging of Computer Vision Programs +********************************************************************* + +The module provides an interactive GUI to debug and incrementally design computer vision algorithms. The debug statements can remain in the code after development and aid in further changes because they have neglectable overhead if the program is compiled in release mode. + +.. toctree:: + :maxdepth: 2 + + CVV API Documentation + CVV GUI Documentation diff --git a/modules/cvv/doc/cvv_api/index.rst b/modules/cvv/doc/cvv_api/index.rst new file mode 100644 index 000000000..1cf6ed7e7 --- /dev/null +++ b/modules/cvv/doc/cvv_api/index.rst @@ -0,0 +1,85 @@ +CVV : the API +************* + +.. highlight:: cpp + + +Introduction +++++++++++++ + +Namespace for all functions is **cvv**, i.e. *cvv::showImage()*. + +Compilation: + +* For development, i.e. for cvv GUI to show up, compile your code using cvv with *g++ -DCVVISUAL_DEBUGMODE*. +* For release, i.e. cvv calls doing nothing, compile your code without above flag. + +See cvv tutorial for a commented example application using cvv. + + + + +API Functions ++++++++++++++ + + +showImage +--------- +Add a single image to debug GUI (similar to :imshow:`imshow <>`). + +.. ocv:function:: void showImage(InputArray img, const CallMetaData& metaData, const string& description, const string& view) + + :param img: Image to show in debug GUI. + :param metaData: Properly initialized CallMetaData struct, i.e. information about file, line and function name for GUI. Use CVVISUAL_LOCATION macro. + :param description: Human readable description to provide context to image. + :param view: Preselect view that will be used to visualize this image in GUI. Other views can still be selected in GUI later on. + + + +debugFilter +----------- +Add two images to debug GUI for comparison. Usually the input and output of some filter operation, whose result should be inspected. + +.. ocv:function:: void debugFilter(InputArray original, InputArray result, const CallMetaData& metaData, const string& description, const string& view) + + :param original: First image for comparison, e.g. filter input. + :param result: Second image for comparison, e.g. filter output. + :param metaData: See :ocv:func:`showImage` + :param description: See :ocv:func:`showImage` + :param view: See :ocv:func:`showImage` + + + +debugDMatch +----------- +Add a filled in :basicstructures:`DMatch ` to debug GUI. The matches can are visualized for interactive inspection in different GUI views (one similar to an interactive :draw_matches:`drawMatches<>`). + +.. ocv:function:: void debugDMatch(InputArray img1, std::vector keypoints1, InputArray img2, std::vector keypoints2, std::vector matches, const CallMetaData& metaData, const string& description, const string& view, bool useTrainDescriptor) + + :param img1: First image used in :basicstructures:`DMatch `. + :param keypoints1: Keypoints of first image. + :param img2: Second image used in DMatch. + :param keypoints2: Keypoints of second image. + :param metaData: See :ocv:func:`showImage` + :param description: See :ocv:func:`showImage` + :param view: See :ocv:func:`showImage` + :param useTrainDescriptor: Use :basicstructures:`DMatch `'s train descriptor index instead of query descriptor index. + + + +finalShow +--------- +This function **must** be called *once* *after* all cvv calls if any. +As an alternative create an instance of FinalShowCaller, which calls finalShow() in its destructor (RAII-style). + +.. ocv:function:: void finalShow() + + + +setDebugFlag +------------ +Enable or disable cvv for current translation unit and thread (disabled this way has higher - but still low - overhead compared to using the compile flags). + +.. ocv:function:: void setDebugFlag(bool active) + + :param active: See above diff --git a/modules/cvv/doc/cvv_gui/index.rst b/modules/cvv/doc/cvv_gui/index.rst new file mode 100644 index 000000000..de01aff2c --- /dev/null +++ b/modules/cvv/doc/cvv_gui/index.rst @@ -0,0 +1,24 @@ +CVV : the GUI +************* + +.. highlight:: cpp + + +Introduction +++++++++++++ + +For now: See cvv tutorial. + + + +Overview +++++++++ + + +Filter +------ + + + +Views +++++++++ diff --git a/modules/cvv/doc/filterfunction-tut.md b/modules/cvv/doc/filterfunction-tut.md deleted file mode 100644 index ec8c64039..000000000 --- a/modules/cvv/doc/filterfunction-tut.md +++ /dev/null @@ -1,35 +0,0 @@ -#Introduction to filter function widgets -##The class, functions and types -If you want to enable the user to provide input to a filter you can inherit the virtual class FilterFunctionWidget. -It provides an interface for a filter accepting In images as an input and Out images as output. - -The input images are passed using: - -```cpp - InputArray = std::array,In> -``` - -and the output is provided with an output parameter of the type: - -```cpp - OutputArray = std::array,Out> -``` - -You should override following functions: - -```cpp - virtual void applyFilter(InputArray in,OutputArray out) const; - - virtual std::pair checkInput(InputArray in) const; -``` - -`applyFilter` has to apply your filter and `checkInput` should check weather the filter can be applied (the first member of the returned pair). -In case the filter can not be applied the second member of the returned pair should contain a message for the user. - -If user input changes the setting of the filter the function _emitSignal()_ of the member _signFilterSettingsChanged__ should be called. - -For a detailed example look at _CVVisual/src/qtutil/filter/grayfilterwidget.{hpp, cpp}_ - -https://github.com/CVVisualPSETeam/CVVisual/blob/master/src/qtutil/filter/grayfilterwidget.hpp - -https://github.com/CVVisualPSETeam/CVVisual/blob/master/src/qtutil/filter/grayfilterwidget.cpp diff --git a/modules/cvv/doc/filterquery-ref.md b/modules/cvv/doc/filterquery-ref.md deleted file mode 100644 index e045955b3..000000000 --- a/modules/cvv/doc/filterquery-ref.md +++ /dev/null @@ -1,106 +0,0 @@ -#Filter query language - -The filter query language is the query language used in the overview and the raw match view to simply the task of filtering, sorting and grouping data sets in a table UI. -The following is a description of the simple syntax and the supported commands. - -Just type `#` into the search field to see some supported commands, using the suggestions feature (it's inspired by the awesome z shell). - -##Syntax -A query consist basically of many subqueries starting with a `#`: - -`[raw filter subquery] #[subquery 1] [...] #[subquery n]` - -The optional first part of the query doesn't start with a `#`, it's short for `#raw [...]`. - - -There three different types of subqueries: - -###Sort query -A sort query has the following structure: - -`sort by [sort subquery 1], [...], [sort subquery n]` - -A sort subquery consist of a sort command (aka "the feature by which you want to sort the table") and a sort order: -- `[command]`: equivalent to `[command] asc` -- `[command] asc`: sorts in ascending order -- `[command] desc`: sorts in descending order - -(The sort command is typically a single word.) - -For your interest: The `[subquery n]` has higher priority than the `[subquery n+1]`. - -###Group query -A group query has the following structure: - -`group by [command 1], [...], [command n]` - -A group command is a single word declaring the feature you want to group the data sets in the table by. -The group header consist of the `n` items. - -For your interest: The raw view currently doesn't support group queries. - -###Filter query -A filter query is the basic type of query, allowing you to filter the data sets by several criterias. - -It has the following structure: - -`#[filter command] [argument]` - -It also supports several arguments for one filter command (via the comma seperated filters feature): - -`#[cs filter command] [argument 1], [...], [argument n]` - - -####Range filter query -A range filter query uses basically a comma seperated filter command with two arguments, allowing you to -filter for a range of elements (`[lower bound]` <= `element` <= `[upper bound]`). - -It has the following structure: - -`#[filter command] [lower bound], [upper bound]` - - - -##Overview -The following commands are supported in the overview: - -feauture/command | sorting supported | grouping supported | filtering supported | description ------------------|:-----------------:|:------------------:|:--------------------|:--------------------- -id | yes | yes | yes, also range | -raw | yes | yes | only basic filter | alias for description -description | yes | yes | only basic filter | -image_count | yes | yes | yes, also range | number of images -function | yes | yes | yes | calling function -file | yes | yes | yes | inheriting file -line | yes | yes | yes, also range | -type | yes | yes | yes | call type - - -##Rawview -The following command are supported in the raw (match) view: - -feauture/command | numeric type | description/property ------------------|:-------------|:--------------------------------------------- -match_distance | float | match distance -img_idx | integer | match img idx -query_idx | integer | match query idx -train_idx | integer | match train idx -x_1 | float | x coordinate of the "left" key point -y_1 | float | y coordinate of the "left" key point -size_1 | float | size of the "left" key point -angle_1 | float | angle of the "left" key point -response_1 | float | response (or strength) of the "left" key point -octave_1 | integer | octave of the "left" key point -x_2 | float | x coordinate of the "right" key point -y_2 | float | y coordinate of the "right" key point -size_2 | float | size of the "right" key point -angle_2 | float | angle of the "right" key point -response_2 | float | response (or strength) of the "right" key point -octave_2 | integer | octave of the "right" key point - - - -All commands support range filtering, sorting and grouping and therefore only the used numeric type -(integer or float) is given. - -See the opencv documentation for more information about the features. diff --git a/modules/cvv/doc/images_example/filter_tab_default.png b/modules/cvv/doc/images_example/filter_tab_default.png deleted file mode 100644 index 5cb1d40dd..000000000 Binary files a/modules/cvv/doc/images_example/filter_tab_default.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/match_tab_line.png b/modules/cvv/doc/images_example/match_tab_line.png deleted file mode 100644 index f51283443..000000000 Binary files a/modules/cvv/doc/images_example/match_tab_line.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/match_tab_translations_2.png b/modules/cvv/doc/images_example/match_tab_translations_2.png deleted file mode 100644 index fb6fb6d9d..000000000 Binary files a/modules/cvv/doc/images_example/match_tab_translations_2.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/match_translations.png b/modules/cvv/doc/images_example/match_translations.png deleted file mode 100644 index 425990c43..000000000 Binary files a/modules/cvv/doc/images_example/match_translations.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/match_translations_2_70percent.png b/modules/cvv/doc/images_example/match_translations_2_70percent.png deleted file mode 100644 index f39cce821..000000000 Binary files a/modules/cvv/doc/images_example/match_translations_2_70percent.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/overview_all.png b/modules/cvv/doc/images_example/overview_all.png deleted file mode 100644 index df20f473f..000000000 Binary files a/modules/cvv/doc/images_example/overview_all.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/overview_matches_filtered.png b/modules/cvv/doc/images_example/overview_matches_filtered.png deleted file mode 100644 index acba711db..000000000 Binary files a/modules/cvv/doc/images_example/overview_matches_filtered.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/overview_single_call.png b/modules/cvv/doc/images_example/overview_single_call.png deleted file mode 100644 index 4b33a1ef5..000000000 Binary files a/modules/cvv/doc/images_example/overview_single_call.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/overview_two_calls.png b/modules/cvv/doc/images_example/overview_two_calls.png deleted file mode 100644 index 8d6fcc37d..000000000 Binary files a/modules/cvv/doc/images_example/overview_two_calls.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/raw_view.png b/modules/cvv/doc/images_example/raw_view.png deleted file mode 100644 index 5f480545f..000000000 Binary files a/modules/cvv/doc/images_example/raw_view.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/single_filter_deep_zoom.png b/modules/cvv/doc/images_example/single_filter_deep_zoom.png deleted file mode 100644 index 03699ee17..000000000 Binary files a/modules/cvv/doc/images_example/single_filter_deep_zoom.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/single_filter_gray.png b/modules/cvv/doc/images_example/single_filter_gray.png deleted file mode 100644 index dfefbb9c5..000000000 Binary files a/modules/cvv/doc/images_example/single_filter_gray.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/single_filter_right_two_imgs_unselected.png b/modules/cvv/doc/images_example/single_filter_right_two_imgs_unselected.png deleted file mode 100644 index 8d41f4ddc..000000000 Binary files a/modules/cvv/doc/images_example/single_filter_right_two_imgs_unselected.png and /dev/null differ diff --git a/modules/cvv/doc/images_example/single_image_tab.png b/modules/cvv/doc/images_example/single_image_tab.png deleted file mode 100644 index f0cb6d600..000000000 Binary files a/modules/cvv/doc/images_example/single_image_tab.png and /dev/null differ diff --git a/modules/cvv/doc/images_tut/dilate_calltab_defaultfview.PNG b/modules/cvv/doc/images_tut/dilate_calltab_defaultfview.PNG deleted file mode 100644 index cd63d3a30..000000000 Binary files a/modules/cvv/doc/images_tut/dilate_calltab_defaultfview.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_tut/dilate_overview.PNG b/modules/cvv/doc/images_tut/dilate_overview.PNG deleted file mode 100644 index 8098ca904..000000000 Binary files a/modules/cvv/doc/images_tut/dilate_overview.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/DefaultFilterViewTab.PNG b/modules/cvv/doc/images_ueberblick/DefaultFilterViewTab.PNG deleted file mode 100644 index 51e0159d9..000000000 Binary files a/modules/cvv/doc/images_ueberblick/DefaultFilterViewTab.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/DualfilterViewDiffImg.PNG b/modules/cvv/doc/images_ueberblick/DualfilterViewDiffImg.PNG deleted file mode 100644 index 0b46e9a3c..000000000 Binary files a/modules/cvv/doc/images_ueberblick/DualfilterViewDiffImg.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/LineMatchViewTab.PNG b/modules/cvv/doc/images_ueberblick/LineMatchViewTab.PNG deleted file mode 100644 index 74c6b822b..000000000 Binary files a/modules/cvv/doc/images_ueberblick/LineMatchViewTab.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/LineMatchViewZoomed.PNG b/modules/cvv/doc/images_ueberblick/LineMatchViewZoomed.PNG deleted file mode 100644 index f87eebf16..000000000 Binary files a/modules/cvv/doc/images_ueberblick/LineMatchViewZoomed.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/MainWindow.PNG b/modules/cvv/doc/images_ueberblick/MainWindow.PNG deleted file mode 100644 index b0cb5538b..000000000 Binary files a/modules/cvv/doc/images_ueberblick/MainWindow.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/MainWindowFull.PNG b/modules/cvv/doc/images_ueberblick/MainWindowFull.PNG deleted file mode 100644 index 10fc14cb2..000000000 Binary files a/modules/cvv/doc/images_ueberblick/MainWindowFull.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/MainwindowTwoCalls.PNG b/modules/cvv/doc/images_ueberblick/MainwindowTwoCalls.PNG deleted file mode 100644 index 261bb940b..000000000 Binary files a/modules/cvv/doc/images_ueberblick/MainwindowTwoCalls.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/OverviewFilterQueryGroupByID.PNG b/modules/cvv/doc/images_ueberblick/OverviewFilterQueryGroupByID.PNG deleted file mode 100644 index 33ad2460b..000000000 Binary files a/modules/cvv/doc/images_ueberblick/OverviewFilterQueryGroupByID.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/RawViewTab.PNG b/modules/cvv/doc/images_ueberblick/RawViewTab.PNG deleted file mode 100644 index f8de61eed..000000000 Binary files a/modules/cvv/doc/images_ueberblick/RawViewTab.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/SingleImageTab.PNG b/modules/cvv/doc/images_ueberblick/SingleImageTab.PNG deleted file mode 100644 index f3c832599..000000000 Binary files a/modules/cvv/doc/images_ueberblick/SingleImageTab.PNG and /dev/null differ diff --git a/modules/cvv/doc/images_ueberblick/TranslationMatchViewTab.PNG b/modules/cvv/doc/images_ueberblick/TranslationMatchViewTab.PNG deleted file mode 100644 index 47f63efa8..000000000 Binary files a/modules/cvv/doc/images_ueberblick/TranslationMatchViewTab.PNG and /dev/null differ diff --git a/modules/cvv/doc/index.md b/modules/cvv/doc/index.md deleted file mode 100644 index 4eb20c031..000000000 --- a/modules/cvv/doc/index.md +++ /dev/null @@ -1,122 +0,0 @@ -#CVVisual Example -CVVisual is a debug visualization for OpenCV; thus, its main purpose is to offer different ways to visualize -the results of OpenCV functions to make it possible to see whether they are what the programmer had in mind; -and also to offer some functionality to try other operations on the images right in the debug window. -This text wants to illustrate the use of CVVisual on a code example. - -Image we want to debug this program: - -[code_example/main.cpp](https://github.com/CVVisualPSETeam/CVVisual/tree/master/doc/code_example/main.cpp) - -Note the includes for CVVisual: - - 10 #include - 11 #include - 12 #include - 13#include - 14 #include - -It takes 10 snapshots with the webcam. -With each, it first shows the image alone in the debug window, - - 97 cvv::showImage(imgRead, CVVISUAL_LOCATION, imgIdString.c_str()); - -then converts it to grayscale and calls CVVisual with the original and resulting image, - - 101 cv::cvtColor(imgRead, imgGray, CV_BGR2GRAY); - 102 cvv::debugFilter(imgRead, imgGray, CVVISUAL_LOCATION, "to gray"); - -detects the grayscale image's ORB features - - 107 detector(imgGray, cv::noArray(), keypoints, descriptors); - -and matches them to those of the previous image, if available. It calls cvv::debugDMatch() with the results. - - 113 matcher.match(prevDescriptors, descriptors, matches); - ... - 117 cvv::debugDMatch(prevImgGray, prevKeypoints, imgGray, keypoints, matches, CVVISUAL_LOCATION, allMatchIdString.c_str()); - -Finally, it removes the worst (as defined by match distance) 0.8 quantile of matches and calls cvv::debugDMatch() again. - - 121 std::sort(matches.begin(), matches.end()); - 122 matches.resize(int(bestRatio * matches.size())); - ... - 126 cvv::debugDMatch(prevImgGray, prevKeypoints, imgGray, keypoints, matches, CVVISUAL_LOCATION, bestMatchIdString.c_str()); - -After we started the program, the CVVisual Main Window opens with one _Call_, that is, the first image that a `cvv::showImage()` was called with (the program execution was halted at this call). - -![](../images_example/overview_single_call.png) - -The image is shown as a small thumbnail in the _Overview table_, together with additional information on it, like the line of the call and the description passed as a parameter. -We double-click it, and a tab opens, where the image is shown bigger. It looks like the webcam worked, so we press `Step` and go to the _Overview_. - -![](../images_example/single_image_tab.png) - -The window shows up again, this time with the first _Call_ to `cvv::debugFilter()` added. - -![](../images_example/overview_two_calls.png) - -We open its tab, too, because, say, the grayscale image does not exactly look like what we wanted. - -![](../images_example/filter_tab_default.png) - -After switching to _SingleFilterView_, which will be more useful to us here, we select to not show the right two images - the grayscale image and the one below, where results of filter operations in this tab are depicted. - -![](../images_example/single_filter_right_two_imgs_unselected.png) - -In `Select a filter`, a gray filter can be applied with different parameters. - -![](../images_example/single_filter_gray.png) - -This looks more like what we wanted. -Rechecking `Show image` for the unselected result image of the actual filter operation and zooming (`Ctrl` + `Mouse wheel`) into all images synchronously deeper than 60% shows the different values of the pixels. - -![](../images_example/single_filter_deep_zoom.png) - -Sadly, we can't do anything about this situation in this session, though, so we just continue. -As stepping through each single _Call_ seems quite tedious, we use the _fast-forward_ button, `>>`. -The program runs until it reaches `finalShow()`, taking images with the webcam along the way. -This saved us some clicking; on the downside, we now have quite an amount of _Calls_ in the table. - -![](../images_example/overview_all.png) - -Using the [filter query language](http://cvv.mostlynerdless.de/ref/filters-ref.html), the _Calls_ to `debugDMatch()` can be filtered out as they have the specific type "match". - -![](../images_example/overview_matches_filtered.png) - -We open the tab of the last such _Call_, and find ourselves greeted with a dense bundle of lines across both images, which represent the matches between the two. - -![](../images_example/match_tab_line.png) - -It is a bit unclear where there actually are matches in this case, so we switch to _TranslationMatchView_, which is a little bit better (especially after scrolling a bit to the right in the left image). - -![](../images_example/match_translations.png) - -_TranslationMatchView_ shows how the matching _KeyPoints_ are moved in the respective other image. -It seems more fitting for this debug session than the _LineMatchView_, thus, we `Set`it `as default`. -Still, there are too many matches for our taste. -Back in the _Overview_, we open the _Call_ before the last, which is the one where the upper 80% of matches were not yet filtered out. - -![](../images_example/match_tab_translations_2.png) - -Here, the best 70% of matches can be chosen. The result looks more acceptable, and we take a mental note to change the threshold to 0.7. - -![](../images_example/match_translations_2_70percent.png) - -The matches can also be shown in a table, the so called _RawView_: - -![](../images_example/raw_view.png) - -Here, you could copy a selection of them as CSV, JSON, Ruby or Python to the clipboard. -We don't need that in the moment, though; we just close the window, and the program finishes. -We now know what we might want to change in the program. - - -Finally, a little note on the `cvv::finalShow()` function: - -It needs to be there in every program using CVVisual, after the last call to another CVVisual function, er else, the program will crash in the end. - -Hopefully, this example shed some light on how CVVisual can be used. -If you want to learn more, refer to the [API](http://cvv.mostlynerdless.de/api) or other documentation on the [web page](http://cvv.mostlynerdless.de/). - -Credit, and special thanks, goes to Andreas Bihlmaier, supervisor of the project, who provided the example code. diff --git a/modules/cvv/doc/introduction-tut.md b/modules/cvv/doc/introduction-tut.md deleted file mode 100644 index 4d2de93fc..000000000 --- a/modules/cvv/doc/introduction-tut.md +++ /dev/null @@ -1,41 +0,0 @@ -#Introduction to using CVVisual -##Enabling debug mode -Define the CVV\_DEBUG_MODE macro somewhere in the translation unit. -##Opening the debug window -Open the debug window by putting one of the functions from the [CVVisual API](http://cvv.mostlynerdless.de/api) into your code. -In this example, we want to debug a call to 'dilate' (line.1) which is a filter, so we use debugFilter. -###Example: Code -src, dest and the structuring element elem are of type cv::Mat (see the OpenCV doc on [dilate()](http://docs.opencv.org/modules/imgproc/doc/filtering.html#dilate)); -CVVISUAL\_LOCATION is a special macro that inserts the location of the code and description and view can be either string-literals or std::strings. The later three are all optional. - -```cpp - #include - //... - cv::dilate(src, dest, elem); - cvv::debugFilter(src, dest, CVVISUAL_LOCATION, description, view); -``` - -When executing the code, the debugFilter function will open the window and halt the execution. -##The Overview Tab -![](images_tut/dilate_overview.PNG) - -You are now in the overview tab. Each time you call one of the CVVisual functions, a *Call* is added to the table. -You can see the images you passed to the funtion as well as metadata and additional information. -The text field allows you to sort or group the Calls by different criteria; see the [filter query language documentation](http://cvv.mostlynerdless.de/ref/filterquery-ref.html) on how to use it. -Now double-click on the Call or select `Open in 'CVVisual|main window'` from the context menu. -(You can also choose to remove the Call or open it in a new window there) -##Debugging a filter operation -![](images_tut/dilate_calltab_defaultfview.PNG) - -A *CallTab* opens. In the center, there are the images from the call. -In the `View` drop-down menu you find different *Views* of the Call, that is, different visualizations of it. The accordion menu on the left offers information on the images and additional options depending on the View and the type of the Call. -Important here might be that `ImageInformation` offers the possibility to zoom (you can also use `Ctrl` plus the mouse wheel); if you zoom in more than 60%, the image pixels will be overlaid with the channel values, in a 3-channel image usually in order (top-down) BGR. -As our dilate seems to have produced acceptable results, we want to continue through the code. -So, we push the `Step` button in the upper left. -The window will comes up again the next time one of the CVVisual functions is called. -Then, we see two Calls in the Overview table, the one from before and the new one. - -You need to put `finalShow()` after the last regular CVVisual function. If the program reaches it, `Step` and the fast-forward button `>>` will vanish, so we press `Close`, which does exactly what it says. - -([Source](http://commons.wikimedia.org/wiki/File:PNG-Gradient.png) of the image used for demonstration. -Note that the screenshots were taken during development and may not depict all features of the current version.) diff --git a/modules/cvv/doc/topics.yml b/modules/cvv/doc/topics.yml deleted file mode 100644 index d8437720e..000000000 --- a/modules/cvv/doc/topics.yml +++ /dev/null @@ -1,9 +0,0 @@ -filterquery: filterquery-ref.md -SingleImageView: views-ref.md#toc_2 -DefaultFilterView: views-ref.md#toc_4 -DualFilterView: views-ref.md#toc_5 -SingleFilterView: views-ref.md#toc_6 -DepthMatchView: views-ref.md#toc_8 -LineMatchView: views-ref.md#toc_9 -RawView: views-ref.md#toc_10 -TranslationMatchView: views-ref.md#toc_11 diff --git a/modules/cvv/doc/views-ref.md b/modules/cvv/doc/views-ref.md deleted file mode 100644 index 3830097e9..000000000 --- a/modules/cvv/doc/views-ref.md +++ /dev/null @@ -1,40 +0,0 @@ -#Views -##General information: -Most views offer an `ImageInformation` collapsable in their accordion menus. -The zoom can be found here. -`Ctrl`+`Mouse wheel` is also zoom; `Ctrl`+`Shift`+`Mouse wheel` is a slower zoom. -If the zoom is deeper than 60%, the image's pixels will be overlaid with their channel values; usually, the order is BGR[+alpha] from the top. - -##Single Image View: -Associated with the `debugSingleImage()` function. -Shows one single image with no features other than `Image Information`. - -##Filter Views: -Associated with the `debugFilter()` function. - -###DefaultFilterView: -Shows two images with only the basic features of `ImageInformation`, synchronized zoom and `Histogram`. - -###DualFilterView: -Shows the two images given to the CVVisual function and _Result Image_ inbetween -which represents the result of a filter that was applied to the others via the `Filter selection` collapsable, -like a difference image between the two. - -###SingleFilterView: -Allows to apply filters to the images it shows via the `Select a filter` collapsable. - -##Match Views: -Associated with the `debugDMatch()` function. - -###PointMatchView: -Interprets the translation of matches as depth value. - -###LineMatchView: -Connects matching key points in the images with lines. - -###Rawview: -Shows in a table data of the matches. -The table entries can be filtered, sorted and grouped by using commands from CVVisual's [filter query language](filterquery-ref.html) in the text box. - -###TranslationMatchView -Shows the distance between a keypoint in one image to its match in the other as an arrow or line in one image. diff --git a/modules/datasets/CMakeLists.txt b/modules/datasets/CMakeLists.txt new file mode 100644 index 000000000..d01e5b288 --- /dev/null +++ b/modules/datasets/CMakeLists.txt @@ -0,0 +1,4 @@ +set(the_description "datasets framework") +ocv_define_module(datasets opencv_core opencv_face opencv_ml opencv_flann) + +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64 diff --git a/modules/datasets/doc/datasets.rst b/modules/datasets/doc/datasets.rst new file mode 100644 index 000000000..469bd0c40 --- /dev/null +++ b/modules/datasets/doc/datasets.rst @@ -0,0 +1,105 @@ +******************************************************* +datasets. Framework for working with different datasets +******************************************************* + +.. highlight:: cpp + +The datasets module includes classes for working with different datasets: load data, evaluate different algorithms on them, etc. + +.. toctree:: + :hidden: + + datasets/ar_hmdb + datasets/ar_sports + datasets/fr_lfw + datasets/gr_chalearn + datasets/gr_skig + datasets/hpe_parse + datasets/ir_affine + datasets/ir_robot + datasets/is_bsds + datasets/is_weizmann + datasets/msm_epfl + datasets/msm_middlebury + datasets/or_imagenet + datasets/or_mnist + datasets/or_sun + datasets/pd_caltech + datasets/slam_kitti + datasets/slam_tumindoor + datasets/tr_chars + datasets/tr_svt + +Action Recognition +------------------ + + :doc:`datasets/ar_hmdb` + + :doc:`datasets/ar_sports` + +Face Recognition +---------------- + + :doc:`datasets/fr_lfw` + +Gesture Recognition +------------------- + + :doc:`datasets/gr_chalearn` + + :doc:`datasets/gr_skig` + +Human Pose Estimation +--------------------- + + :doc:`datasets/hpe_parse` + +Image Registration +------------------ + + :doc:`datasets/ir_affine` + + :doc:`datasets/ir_robot` + +Image Segmentation +------------------ + + :doc:`datasets/is_bsds` + + :doc:`datasets/is_weizmann` + +Multiview Stereo Matching +------------------------- + + :doc:`datasets/msm_epfl` + + :doc:`datasets/msm_middlebury` + +Object Recognition +------------------ + + :doc:`datasets/or_imagenet` + + :doc:`datasets/or_mnist` + + :doc:`datasets/or_sun` + +Pedestrian Detection +-------------------- + + :doc:`datasets/pd_caltech` + +SLAM +---- + + :doc:`datasets/slam_kitti` + + :doc:`datasets/slam_tumindoor` + +Text Recognition +---------------- + + :doc:`datasets/tr_chars` + + :doc:`datasets/tr_svt` + diff --git a/modules/datasets/doc/datasets/ar_hmdb.rst b/modules/datasets/doc/datasets/ar_hmdb.rst new file mode 100644 index 000000000..9cd1c78d3 --- /dev/null +++ b/modules/datasets/doc/datasets/ar_hmdb.rst @@ -0,0 +1,29 @@ +HMDB: A Large Human Motion Database +=================================== +.. ocv:class:: AR_hmdb + +Implements loading dataset: + +_`"HMDB: A Large Human Motion Database"`: http://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/ + +.. note:: Usage + + 1. From link above download dataset files: hmdb51_org.rar & test_train_splits.rar. + + 2. Unpack them. + + 3. To load data run: ./opencv/build/bin/example_datasets_ar_hmdb -p=/home/user/path_to_unpacked_folders/ + +Benchmark +""""""""" + +For this dataset was implemented benchmark, which gives accuracy: 0.107407 (using precomputed HOG/HOF "STIP" features from site, averaging for 3 splits) + +To run this benchmark execute: + +.. code-block:: bash + + ./opencv/build/bin/example_datasets_ar_hmdb_benchmark -p=/home/user/path_to_unpacked_folders/ + +(precomputed features should be unpacked in the same folder: /home/user/path_to_unpacked_folders/hmdb51_org_stips/) + diff --git a/modules/datasets/doc/datasets/ar_sports.rst b/modules/datasets/doc/datasets/ar_sports.rst new file mode 100644 index 000000000..717651f8e --- /dev/null +++ b/modules/datasets/doc/datasets/ar_sports.rst @@ -0,0 +1,14 @@ +Sports-1M Dataset +================= +.. ocv:class:: AR_sports + +Implements loading dataset: + +_`"Sports-1M Dataset"`: http://cs.stanford.edu/people/karpathy/deepvideo/ + +.. note:: Usage + + 1. From link above download dataset files (git clone https://code.google.com/p/sports-1m-dataset/). + + 2. To load data run: ./opencv/build/bin/example_datasets_ar_sports -p=/home/user/path_to_downloaded_folders/ + diff --git a/modules/datasets/doc/datasets/fr_lfw.rst b/modules/datasets/doc/datasets/fr_lfw.rst new file mode 100644 index 000000000..00182a179 --- /dev/null +++ b/modules/datasets/doc/datasets/fr_lfw.rst @@ -0,0 +1,27 @@ +Labeled Faces in the Wild +========================= +.. ocv:class:: FR_lfw + +Implements loading dataset: + +_`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/ + +.. note:: Usage + + 1. From link above download any dataset file: lfw.tgz\lfwa.tar.gz\lfw-deepfunneled.tgz\lfw-funneled.tgz and files with pairs: 10 test splits: pairs.txt and developer train split: pairsDevTrain.txt. + + 2. Unpack dataset file and place pairs.txt and pairsDevTrain.txt in created folder. + + 3. To load data run: ./opencv/build/bin/example_datasets_fr_lfw -p=/home/user/path_to_unpacked_folder/lfw2/ + +Benchmark +""""""""" + +For this dataset was implemented benchmark, which gives accuracy: 0.623833 +- 0.005223 (train split: pairsDevTrain.txt, dataset: lfwa) + +To run this benchmark execute: + +.. code-block:: bash + + ./opencv/build/bin/example_datasets_fr_lfw_benchmark -p=/home/user/path_to_unpacked_folder/lfw2/ + diff --git a/modules/datasets/doc/datasets/gr_chalearn.rst b/modules/datasets/doc/datasets/gr_chalearn.rst new file mode 100644 index 000000000..a91dc7c60 --- /dev/null +++ b/modules/datasets/doc/datasets/gr_chalearn.rst @@ -0,0 +1,18 @@ +ChaLearn Looking at People +========================== +.. ocv:class:: GR_chalearn + +Implements loading dataset: + +_`"ChaLearn Looking at People"`: http://gesture.chalearn.org/ + +.. note:: Usage + + 1. Follow instruction from site above, download files for dataset "Track 3: Gesture Recognition": Train1.zip-Train5.zip, Validation1.zip-Validation3.zip (Register on site: www.codalab.org and accept the terms and conditions of competition: https://www.codalab.org/competitions/991#learn_the_details There are three mirrors for downloading dataset files. When I downloaded data only mirror: "Universitat Oberta de Catalunya" works). + + 2. Unpack train archives Train1.zip-Train5.zip to folder Train/, validation archives Validation1.zip-Validation3.zip to folder Validation/ + + 3. Unpack all archives in Train/ & Validation/ in the folders with the same names, for example: Sample0001.zip to Sample0001/ + + 4. To load data run: ./opencv/build/bin/example_datasets_gr_chalearn -p=/home/user/path_to_unpacked_folders/ + diff --git a/modules/datasets/doc/datasets/gr_skig.rst b/modules/datasets/doc/datasets/gr_skig.rst new file mode 100644 index 000000000..483f20137 --- /dev/null +++ b/modules/datasets/doc/datasets/gr_skig.rst @@ -0,0 +1,16 @@ +Sheffield Kinect Gesture Dataset +================================ +.. ocv:class:: GR_skig + +Implements loading dataset: + +_`"Sheffield Kinect Gesture Dataset"`: http://lshao.staff.shef.ac.uk/data/SheffieldKinectGesture.htm + +.. note:: Usage + + 1. From link above download dataset files: subject1_dep.7z-subject6_dep.7z, subject1_rgb.7z-subject6_rgb.7z. + + 2. Unpack them. + + 3. To load data run: ./opencv/build/bin/example_datasets_gr_skig -p=/home/user/path_to_unpacked_folders/ + diff --git a/modules/datasets/doc/datasets/hpe_parse.rst b/modules/datasets/doc/datasets/hpe_parse.rst new file mode 100644 index 000000000..e4f88927c --- /dev/null +++ b/modules/datasets/doc/datasets/hpe_parse.rst @@ -0,0 +1,16 @@ +PARSE Dataset +============= +.. ocv:class:: HPE_parse + +Implements loading dataset: + +_`"PARSE Dataset"`: http://www.ics.uci.edu/~dramanan/papers/parse/ + +.. note:: Usage + + 1. From link above download dataset file: people.zip. + + 2. Unpack it. + + 3. To load data run: ./opencv/build/bin/example_datasets_hpe_parse -p=/home/user/path_to_unpacked_folder/people_all/ + diff --git a/modules/datasets/doc/datasets/ir_affine.rst b/modules/datasets/doc/datasets/ir_affine.rst new file mode 100644 index 000000000..eb40dd65d --- /dev/null +++ b/modules/datasets/doc/datasets/ir_affine.rst @@ -0,0 +1,16 @@ +Affine Covariant Regions Datasets +================================= +.. ocv:class:: IR_affine + +Implements loading dataset: + +_`"Affine Covariant Regions Datasets"`: http://www.robots.ox.ac.uk/~vgg/data/data-aff.html + +.. note:: Usage + + 1. From link above download dataset files: bark\\bikes\\boat\\graf\\leuven\\trees\\ubc\\wall.tar.gz. + + 2. Unpack them. + + 3. To load data, for example, for "bark", run: ./opencv/build/bin/example_datasets_ir_affine -p=/home/user/path_to_unpacked_folder/bark/ + diff --git a/modules/datasets/doc/datasets/ir_robot.rst b/modules/datasets/doc/datasets/ir_robot.rst new file mode 100644 index 000000000..8a9295ef2 --- /dev/null +++ b/modules/datasets/doc/datasets/ir_robot.rst @@ -0,0 +1,15 @@ +Robot Data Set +============== +.. ocv:class:: IR_robot + +Implements loading dataset: + +_`"Robot Data Set"`: http://roboimagedata.compute.dtu.dk/?page_id=24 + +.. note:: Usage + + 1. From link above download files for dataset "Point Feature Data Set – 2010": SET001_6.tar.gz-SET055_60.tar.gz (there are two data sets: - Full resolution images (1200×1600), ~500 Gb and - Half size image (600×800), ~115 Gb.) + 2. Unpack them to one folder. + + 3. To load data run: ./opencv/build/bin/example_datasets_ir_robot -p=/home/user/path_to_unpacked_folder/ + diff --git a/modules/datasets/doc/datasets/is_bsds.rst b/modules/datasets/doc/datasets/is_bsds.rst new file mode 100644 index 000000000..cd4910119 --- /dev/null +++ b/modules/datasets/doc/datasets/is_bsds.rst @@ -0,0 +1,16 @@ +The Berkeley Segmentation Dataset and Benchmark +=============================================== +.. ocv:class:: IS_bsds + +Implements loading dataset: + +_`"The Berkeley Segmentation Dataset and Benchmark"`: https://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/ + +.. note:: Usage + + 1. From link above download dataset files: BSDS300-human.tgz & BSDS300-images.tgz. + + 2. Unpack them. + + 3. To load data run: ./opencv/build/bin/example_datasets_is_bsds -p=/home/user/path_to_unpacked_folder/BSDS300/ + diff --git a/modules/datasets/doc/datasets/is_weizmann.rst b/modules/datasets/doc/datasets/is_weizmann.rst new file mode 100644 index 000000000..a4b570220 --- /dev/null +++ b/modules/datasets/doc/datasets/is_weizmann.rst @@ -0,0 +1,16 @@ +Weizmann Segmentation Evaluation Database +========================================= +.. ocv:class:: IS_weizmann + +Implements loading dataset: + +_`"Weizmann Segmentation Evaluation Database"`: http://www.wisdom.weizmann.ac.il/~vision/Seg_Evaluation_DB/ + +.. note:: Usage + + 1. From link above download dataset files: Weizmann_Seg_DB_1obj.ZIP & Weizmann_Seg_DB_2obj.ZIP. + + 2. Unpack them. + + 3. To load data, for example, for 1 object dataset, run: ./opencv/build/bin/example_datasets_is_weizmann -p=/home/user/path_to_unpacked_folder/1obj/ + diff --git a/modules/datasets/doc/datasets/msm_epfl.rst b/modules/datasets/doc/datasets/msm_epfl.rst new file mode 100644 index 000000000..64288e5cf --- /dev/null +++ b/modules/datasets/doc/datasets/msm_epfl.rst @@ -0,0 +1,16 @@ +EPFL Multi-View Stereo +====================== +.. ocv:class:: MSM_epfl + +Implements loading dataset: + +_`"EPFL Multi-View Stereo"`: http://cvlabwww.epfl.ch/~strecha/multiview/denseMVS.html + +.. note:: Usage + + 1. From link above download dataset files: castle_dense\\castle_dense_large\\castle_entry\\fountain\\herzjesu_dense\\herzjesu_dense_large_bounding\\cameras\\images\\p.tar.gz. + + 2. Unpack them in separate folder for each object. For example, for "fountain", in folder fountain/ : fountain_dense_bounding.tar.gz -> bounding/, fountain_dense_cameras.tar.gz -> camera/, fountain_dense_images.tar.gz -> png/, fountain_dense_p.tar.gz -> P/ + + 3. To load data, for example, for "fountain", run: ./opencv/build/bin/example_datasets_msm_epfl -p=/home/user/path_to_unpacked_folder/fountain/ + diff --git a/modules/datasets/doc/datasets/msm_middlebury.rst b/modules/datasets/doc/datasets/msm_middlebury.rst new file mode 100644 index 000000000..449d59ae2 --- /dev/null +++ b/modules/datasets/doc/datasets/msm_middlebury.rst @@ -0,0 +1,16 @@ +Stereo – Middlebury Computer Vision +=================================== +.. ocv:class:: MSM_middlebury + +Implements loading dataset: + +_`"Stereo – Middlebury Computer Vision"`: http://vision.middlebury.edu/mview/ + +.. note:: Usage + + 1. From link above download dataset files: dino\\dinoRing\\dinoSparseRing\\temple\\templeRing\\templeSparseRing.zip + + 2. Unpack them. + + 3. To load data, for example "temple" dataset, run: ./opencv/build/bin/example_datasets_msm_middlebury -p=/home/user/path_to_unpacked_folder/temple/ + diff --git a/modules/datasets/doc/datasets/or_imagenet.rst b/modules/datasets/doc/datasets/or_imagenet.rst new file mode 100644 index 000000000..48e10739c --- /dev/null +++ b/modules/datasets/doc/datasets/or_imagenet.rst @@ -0,0 +1,18 @@ +ImageNet +======== +.. ocv:class:: OR_imagenet + +Implements loading dataset: + +_`"ImageNet"`: http://www.image-net.org/ + +Currently implemented loading full list with urls. Planned to implement dataset from ILSVRC challenge. + +.. note:: Usage + + 1. From link above download dataset file: imagenet_fall11_urls.tgz + + 2. Unpack it. + + 3. To load data run: ./opencv/build/bin/example_datasets_or_imagenet -p=/home/user/path_to_unpacked_file/ + diff --git a/modules/datasets/doc/datasets/or_mnist.rst b/modules/datasets/doc/datasets/or_mnist.rst new file mode 100644 index 000000000..1253cba01 --- /dev/null +++ b/modules/datasets/doc/datasets/or_mnist.rst @@ -0,0 +1,16 @@ +MNIST +===== +.. ocv:class:: OR_mnist + +Implements loading dataset: + +_`"MNIST"`: http://yann.lecun.com/exdb/mnist/ + +.. note:: Usage + + 1. From link above download dataset files: t10k-images-idx3-ubyte.gz, t10k-labels-idx1-ubyte.gz, train-images-idx3-ubyte.gz, train-labels-idx1-ubyte.gz. + + 2. Unpack them. + + 3. To load data run: ./opencv/build/bin/example_datasets_or_mnist -p=/home/user/path_to_unpacked_files/ + diff --git a/modules/datasets/doc/datasets/or_sun.rst b/modules/datasets/doc/datasets/or_sun.rst new file mode 100644 index 000000000..d6a7cdf2e --- /dev/null +++ b/modules/datasets/doc/datasets/or_sun.rst @@ -0,0 +1,18 @@ +SUN Database +============ +.. ocv:class:: OR_sun + +Implements loading dataset: + +_`"SUN Database"`: http://sundatabase.mit.edu/ + +Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012". + +.. note:: Usage + + 1. From link above download dataset file: SUN397.tar + + 2. Unpack it. + + 3. To load data run: ./opencv/build/bin/example_datasets_or_sun -p=/home/user/path_to_unpacked_folder/SUN397/ + diff --git a/modules/datasets/doc/datasets/pd_caltech.rst b/modules/datasets/doc/datasets/pd_caltech.rst new file mode 100644 index 000000000..5bbf8c143 --- /dev/null +++ b/modules/datasets/doc/datasets/pd_caltech.rst @@ -0,0 +1,23 @@ +Caltech Pedestrian Detection Benchmark +====================================== +.. ocv:class:: PD_caltech + +Implements loading dataset: + +_`"Caltech Pedestrian Detection Benchmark"`: http://www.vision.caltech.edu/Image_Datasets/CaltechPedestrians/ + +.. note:: First version of Caltech Pedestrian dataset loading. + + Code to unpack all frames from seq files commented as their number is huge! + So currently load only meta information without data. + + Also ground truth isn't processed, as need to convert it from mat files first. + +.. note:: Usage + + 1. From link above download dataset files: set00.tar-set10.tar. + + 2. Unpack them to separate folder. + + 3. To load data run: ./opencv/build/bin/example_datasets_pd_caltech -p=/home/user/path_to_unpacked_folders/ + diff --git a/modules/datasets/doc/datasets/slam_kitti.rst b/modules/datasets/doc/datasets/slam_kitti.rst new file mode 100644 index 000000000..a84ffaf2f --- /dev/null +++ b/modules/datasets/doc/datasets/slam_kitti.rst @@ -0,0 +1,16 @@ +KITTI Vision Benchmark +====================== +.. ocv:class:: SLAM_kitti + +Implements loading dataset: + +_`"KITTI Vision Benchmark"`: http://www.cvlibs.net/datasets/kitti/eval_odometry.php + +.. note:: Usage + + 1. From link above download "Odometry" dataset files: data_odometry_gray\\data_odometry_color\\data_odometry_velodyne\\data_odometry_poses\\data_odometry_calib.zip. + + 2. Unpack data_odometry_poses.zip, it creates folder dataset/poses/. After that unpack data_odometry_gray.zip, data_odometry_color.zip, data_odometry_velodyne.zip. Folder dataset/sequences/ will be created with folders 00/..21/. Each of these folders will contain: image_0/, image_1/, image_2/, image_3/, velodyne/ and files calib.txt & times.txt. These two last files will be replaced after unpacking data_odometry_calib.zip at the end. + + 3. To load data run: ./opencv/build/bin/example_datasets_slam_kitti -p=/home/user/path_to_unpacked_folder/dataset/ + diff --git a/modules/datasets/doc/datasets/slam_tumindoor.rst b/modules/datasets/doc/datasets/slam_tumindoor.rst new file mode 100644 index 000000000..07c7767c1 --- /dev/null +++ b/modules/datasets/doc/datasets/slam_tumindoor.rst @@ -0,0 +1,16 @@ +TUMindoor Dataset +================= +.. ocv:class:: SLAM_tumindoor + +Implements loading dataset: + +_`"TUMindoor Dataset"`: http://www.navvis.lmt.ei.tum.de/dataset/ + +.. note:: Usage + + 1. From link above download dataset files: dslr\\info\\ladybug\\pointcloud.tar.bz2 for each dataset: 11-11-28 (1st floor)\\11-12-13 (1st floor N1)\\11-12-17a (4th floor)\\11-12-17b (3rd floor)\\11-12-17c (Ground I)\\11-12-18a (Ground II)\\11-12-18b (2nd floor) + + 2. Unpack them in separate folder for each dataset. dslr.tar.bz2 -> dslr/, info.tar.bz2 -> info/, ladybug.tar.bz2 -> ladybug/, pointcloud.tar.bz2 -> pointcloud/. + + 3. To load each dataset run: ./opencv/build/bin/example_datasets_slam_tumindoor -p=/home/user/path_to_unpacked_folders/ + diff --git a/modules/datasets/doc/datasets/tr_chars.rst b/modules/datasets/doc/datasets/tr_chars.rst new file mode 100644 index 000000000..eb321d08a --- /dev/null +++ b/modules/datasets/doc/datasets/tr_chars.rst @@ -0,0 +1,18 @@ +The Chars74K Dataset +==================== +.. ocv:class:: TR_chars + +Implements loading dataset: + +_`"The Chars74K Dataset"`: http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/ + +.. note:: Usage + + 1. From link above download dataset files: EnglishFnt\\EnglishHnd\\EnglishImg\\KannadaHnd\\KannadaImg.tgz, ListsTXT.tgz. + + 2. Unpack them. + + 3. Move .m files from folder ListsTXT/ to appropriate folder. For example, English/list_English_Img.m for EnglishImg.tgz. + + 4. To load data, for example "EnglishImg", run: ./opencv/build/bin/example_datasets_tr_chars -p=/home/user/path_to_unpacked_folder/English/ + diff --git a/modules/datasets/doc/datasets/tr_svt.rst b/modules/datasets/doc/datasets/tr_svt.rst new file mode 100644 index 000000000..f5aeb8643 --- /dev/null +++ b/modules/datasets/doc/datasets/tr_svt.rst @@ -0,0 +1,16 @@ +The Street View Text Dataset +============================ +.. ocv:class:: TR_svt + +Implements loading dataset: + +_`"The Street View Text Dataset"`: http://vision.ucsd.edu/~kai/svt/ + +.. note:: Usage + + 1. From link above download dataset file: svt.zip. + + 2. Unpack it. + + 3. To load data run: ./opencv/build/bin/example_datasets_tr_svt -p=/home/user/path_to_unpacked_folder/svt/svt1/ + diff --git a/modules/datasetstools/include/opencv2/datasetstools/ar_hmdb.hpp b/modules/datasets/include/opencv2/datasets/ar_hmdb.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/ar_hmdb.hpp rename to modules/datasets/include/opencv2/datasets/ar_hmdb.hpp index 85e159702..9264503ef 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/ar_hmdb.hpp +++ b/modules/datasets/include/opencv2/datasets/ar_hmdb.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_AR_HMDB_HPP -#define OPENCV_DATASETSTOOLS_AR_HMDB_HPP +#ifndef OPENCV_DATASETS_AR_HMDB_HPP +#define OPENCV_DATASETS_AR_HMDB_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct AR_hmdbObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/ar_sports.hpp b/modules/datasets/include/opencv2/datasets/ar_sports.hpp similarity index 93% rename from modules/datasetstools/include/opencv2/datasetstools/ar_sports.hpp rename to modules/datasets/include/opencv2/datasets/ar_sports.hpp index 408e2fca5..9d047a14f 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/ar_sports.hpp +++ b/modules/datasets/include/opencv2/datasets/ar_sports.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_AR_SPORTS_HPP -#define OPENCV_DATASETSTOOLS_AR_SPORTS_HPP +#ifndef OPENCV_DATASETS_AR_SPORTS_HPP +#define OPENCV_DATASETS_AR_SPORTS_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct AR_sportsObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp b/modules/datasets/include/opencv2/datasets/dataset.hpp similarity index 96% rename from modules/datasetstools/include/opencv2/datasetstools/dataset.hpp rename to modules/datasets/include/opencv2/datasets/dataset.hpp index 9cb1e7381..f9e94bffd 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp +++ b/modules/datasets/include/opencv2/datasets/dataset.hpp @@ -39,8 +39,8 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_DATASET_HPP -#define OPENCV_DATASETSTOOLS_DATASET_HPP +#ifndef OPENCV_DATASETS_DATASET_HPP +#define OPENCV_DATASETS_DATASET_HPP #include #include @@ -49,7 +49,7 @@ namespace cv { -namespace datasetstools +namespace datasets { struct Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/fr_lfw.hpp b/modules/datasets/include/opencv2/datasets/fr_lfw.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/fr_lfw.hpp rename to modules/datasets/include/opencv2/datasets/fr_lfw.hpp index dbc0a499a..8e013554e 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/fr_lfw.hpp +++ b/modules/datasets/include/opencv2/datasets/fr_lfw.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_FR_LFW_HPP -#define OPENCV_DATASETSTOOLS_FR_LFW_HPP +#ifndef OPENCV_DATASETS_FR_LFW_HPP +#define OPENCV_DATASETS_FR_LFW_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct FR_lfwObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/gr_chalearn.hpp b/modules/datasets/include/opencv2/datasets/gr_chalearn.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/gr_chalearn.hpp rename to modules/datasets/include/opencv2/datasets/gr_chalearn.hpp index efadb605d..3f79f9542 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/gr_chalearn.hpp +++ b/modules/datasets/include/opencv2/datasets/gr_chalearn.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_GR_CHALEARN_HPP -#define OPENCV_DATASETSTOOLS_GR_CHALEARN_HPP +#ifndef OPENCV_DATASETS_GR_CHALEARN_HPP +#define OPENCV_DATASETS_GR_CHALEARN_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct groundTruth diff --git a/modules/datasetstools/include/opencv2/datasetstools/gr_skig.hpp b/modules/datasets/include/opencv2/datasets/gr_skig.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/gr_skig.hpp rename to modules/datasets/include/opencv2/datasets/gr_skig.hpp index 79cfcdeb4..b4b34808d 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/gr_skig.hpp +++ b/modules/datasets/include/opencv2/datasets/gr_skig.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_GR_SKIG_HPP -#define OPENCV_DATASETSTOOLS_GR_SKIG_HPP +#ifndef OPENCV_DATASETS_GR_SKIG_HPP +#define OPENCV_DATASETS_GR_SKIG_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { enum actionType diff --git a/modules/datasetstools/include/opencv2/datasetstools/hpe_parse.hpp b/modules/datasets/include/opencv2/datasets/hpe_parse.hpp similarity index 93% rename from modules/datasetstools/include/opencv2/datasetstools/hpe_parse.hpp rename to modules/datasets/include/opencv2/datasets/hpe_parse.hpp index 7d1d1b15a..5f027a1dc 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/hpe_parse.hpp +++ b/modules/datasets/include/opencv2/datasets/hpe_parse.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_HPE_PARSE_HPP -#define OPENCV_DATASETSTOOLS_HPE_PARSE_HPP +#ifndef OPENCV_DATASETS_HPE_PARSE_HPP +#define OPENCV_DATASETS_HPE_PARSE_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct HPE_parseObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/ir_affine.hpp b/modules/datasets/include/opencv2/datasets/ir_affine.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/ir_affine.hpp rename to modules/datasets/include/opencv2/datasets/ir_affine.hpp index b3cc8782a..1ee51a2a9 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/ir_affine.hpp +++ b/modules/datasets/include/opencv2/datasets/ir_affine.hpp @@ -39,20 +39,20 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_IR_AFFINE_HPP -#define OPENCV_DATASETSTOOLS_IR_AFFINE_HPP +#ifndef OPENCV_DATASETS_IR_AFFINE_HPP +#define OPENCV_DATASETS_IR_AFFINE_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include #include namespace cv { -namespace datasetstools +namespace datasets { struct IR_affineObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp b/modules/datasets/include/opencv2/datasets/ir_robot.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp rename to modules/datasets/include/opencv2/datasets/ir_robot.hpp index fe319ba14..ac25b6f3c 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp +++ b/modules/datasets/include/opencv2/datasets/ir_robot.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_IR_ROBOT_HPP -#define OPENCV_DATASETSTOOLS_IR_ROBOT_HPP +#ifndef OPENCV_DATASETS_IR_ROBOT_HPP +#define OPENCV_DATASETS_IR_ROBOT_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { // calibration matrix from calibrationFile.mat diff --git a/modules/datasetstools/include/opencv2/datasetstools/is_bsds.hpp b/modules/datasets/include/opencv2/datasets/is_bsds.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/is_bsds.hpp rename to modules/datasets/include/opencv2/datasets/is_bsds.hpp index 880b2fcb7..72802e7e8 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/is_bsds.hpp +++ b/modules/datasets/include/opencv2/datasets/is_bsds.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_IS_BSDS_HPP -#define OPENCV_DATASETSTOOLS_IS_BSDS_HPP +#ifndef OPENCV_DATASETS_IS_BSDS_HPP +#define OPENCV_DATASETS_IS_BSDS_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct IS_bsdsObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/is_weizmann.hpp b/modules/datasets/include/opencv2/datasets/is_weizmann.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/is_weizmann.hpp rename to modules/datasets/include/opencv2/datasets/is_weizmann.hpp index 66184489f..f374282b1 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/is_weizmann.hpp +++ b/modules/datasets/include/opencv2/datasets/is_weizmann.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_IS_WEIZMANN_HPP -#define OPENCV_DATASETSTOOLS_IS_WEIZMANN_HPP +#ifndef OPENCV_DATASETS_IS_WEIZMANN_HPP +#define OPENCV_DATASETS_IS_WEIZMANN_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct IS_weizmannObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp b/modules/datasets/include/opencv2/datasets/msm_epfl.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp rename to modules/datasets/include/opencv2/datasets/msm_epfl.hpp index 1aecf6f66..e1785b0b2 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp +++ b/modules/datasets/include/opencv2/datasets/msm_epfl.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_MSM_EPFL_HPP -#define OPENCV_DATASETSTOOLS_MSM_EPFL_HPP +#ifndef OPENCV_DATASETS_MSM_EPFL_HPP +#define OPENCV_DATASETS_MSM_EPFL_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct cameraParam diff --git a/modules/datasetstools/include/opencv2/datasetstools/msm_middlebury.hpp b/modules/datasets/include/opencv2/datasets/msm_middlebury.hpp similarity index 93% rename from modules/datasetstools/include/opencv2/datasetstools/msm_middlebury.hpp rename to modules/datasets/include/opencv2/datasets/msm_middlebury.hpp index cbfbb38be..7af024e96 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/msm_middlebury.hpp +++ b/modules/datasets/include/opencv2/datasets/msm_middlebury.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_MSM_MIDDLEBURY_HPP -#define OPENCV_DATASETSTOOLS_MSM_MIDDLEBURY_HPP +#ifndef OPENCV_DATASETS_MSM_MIDDLEBURY_HPP +#define OPENCV_DATASETS_MSM_MIDDLEBURY_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct MSM_middleburyObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/or_imagenet.hpp b/modules/datasets/include/opencv2/datasets/or_imagenet.hpp similarity index 93% rename from modules/datasetstools/include/opencv2/datasetstools/or_imagenet.hpp rename to modules/datasets/include/opencv2/datasets/or_imagenet.hpp index ac401f930..2c6b74465 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/or_imagenet.hpp +++ b/modules/datasets/include/opencv2/datasets/or_imagenet.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_OR_IMAGENET_HPP -#define OPENCV_DATASETSTOOLS_OR_IMAGENET_HPP +#ifndef OPENCV_DATASETS_OR_IMAGENET_HPP +#define OPENCV_DATASETS_OR_IMAGENET_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct OR_imagenetObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/or_mnist.hpp b/modules/datasets/include/opencv2/datasets/or_mnist.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/or_mnist.hpp rename to modules/datasets/include/opencv2/datasets/or_mnist.hpp index 89763c5ee..9c946ffa3 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/or_mnist.hpp +++ b/modules/datasets/include/opencv2/datasets/or_mnist.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_OR_MNIST_HPP -#define OPENCV_DATASETSTOOLS_OR_MNIST_HPP +#ifndef OPENCV_DATASETS_OR_MNIST_HPP +#define OPENCV_DATASETS_OR_MNIST_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct OR_mnistObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/or_sun.hpp b/modules/datasets/include/opencv2/datasets/or_sun.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/or_sun.hpp rename to modules/datasets/include/opencv2/datasets/or_sun.hpp index f231d6d20..be438d4de 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/or_sun.hpp +++ b/modules/datasets/include/opencv2/datasets/or_sun.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_OR_SUN_HPP -#define OPENCV_DATASETSTOOLS_OR_SUN_HPP +#ifndef OPENCV_DATASETS_OR_SUN_HPP +#define OPENCV_DATASETS_OR_SUN_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct OR_sunObj : public Object diff --git a/modules/datasets/include/opencv2/datasets/pd_caltech.hpp b/modules/datasets/include/opencv2/datasets/pd_caltech.hpp new file mode 100644 index 000000000..69a99359d --- /dev/null +++ b/modules/datasets/include/opencv2/datasets/pd_caltech.hpp @@ -0,0 +1,84 @@ +/*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) 2014, Itseez 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 Itseez Inc 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*/ + +#ifndef OPENCV_DATASETS_PD_CALTECH_HPP +#define OPENCV_DATASETS_PD_CALTECH_HPP + +#include +#include + +#include "opencv2/datasets/dataset.hpp" + +#include + +namespace cv +{ +namespace datasets +{ + +struct PD_caltechObj : public Object +{ + //double groundTrue[][]; + //Mat image; + std::string name; + std::vector< std::string > imageNames; +}; + +// +// first version of Caltech Pedestrian dataset loading +// code to unpack all frames from seq files commented as their number is huge +// so currently load only meta information without data +// +// also ground truth isn't processed, as need to convert it from mat files first +// + +class CV_EXPORTS PD_caltech : public Dataset +{ +public: + virtual void load(const std::string &path) = 0; + + static Ptr create(); +}; + +} +} + +#endif diff --git a/modules/datasetstools/include/opencv2/datasetstools/slam_kitti.hpp b/modules/datasets/include/opencv2/datasets/slam_kitti.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/slam_kitti.hpp rename to modules/datasets/include/opencv2/datasets/slam_kitti.hpp index f133eb134..b001e8db7 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/slam_kitti.hpp +++ b/modules/datasets/include/opencv2/datasets/slam_kitti.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_SLAM_KITTI_HPP -#define OPENCV_DATASETSTOOLS_SLAM_KITTI_HPP +#ifndef OPENCV_DATASETS_SLAM_KITTI_HPP +#define OPENCV_DATASETS_SLAM_KITTI_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct pose diff --git a/modules/datasetstools/include/opencv2/datasetstools/slam_tumindoor.hpp b/modules/datasets/include/opencv2/datasets/slam_tumindoor.hpp similarity index 93% rename from modules/datasetstools/include/opencv2/datasetstools/slam_tumindoor.hpp rename to modules/datasets/include/opencv2/datasets/slam_tumindoor.hpp index 4945dca33..d743cd646 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/slam_tumindoor.hpp +++ b/modules/datasets/include/opencv2/datasets/slam_tumindoor.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_SLAM_TUMINDOOR_HPP -#define OPENCV_DATASETSTOOLS_SLAM_TUMINDOOR_HPP +#ifndef OPENCV_DATASETS_SLAM_TUMINDOOR_HPP +#define OPENCV_DATASETS_SLAM_TUMINDOOR_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { enum imageType diff --git a/modules/datasetstools/include/opencv2/datasetstools/tinyxml2/tinyxml2.h b/modules/datasets/include/opencv2/datasets/tinyxml2/tinyxml2.h similarity index 100% rename from modules/datasetstools/include/opencv2/datasetstools/tinyxml2/tinyxml2.h rename to modules/datasets/include/opencv2/datasets/tinyxml2/tinyxml2.h diff --git a/modules/datasetstools/include/opencv2/datasetstools/tr_chars.hpp b/modules/datasets/include/opencv2/datasets/tr_chars.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/tr_chars.hpp rename to modules/datasets/include/opencv2/datasets/tr_chars.hpp index c8207b45f..6b7f81885 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/tr_chars.hpp +++ b/modules/datasets/include/opencv2/datasets/tr_chars.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_TR_CHARS_HPP -#define OPENCV_DATASETSTOOLS_TR_CHARS_HPP +#ifndef OPENCV_DATASETS_TR_CHARS_HPP +#define OPENCV_DATASETS_TR_CHARS_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct TR_charsObj : public Object diff --git a/modules/datasetstools/include/opencv2/datasetstools/tr_svt.hpp b/modules/datasets/include/opencv2/datasets/tr_svt.hpp similarity index 94% rename from modules/datasetstools/include/opencv2/datasetstools/tr_svt.hpp rename to modules/datasets/include/opencv2/datasets/tr_svt.hpp index eb014af95..23b583d92 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/tr_svt.hpp +++ b/modules/datasets/include/opencv2/datasets/tr_svt.hpp @@ -39,19 +39,19 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_TR_SVT_HPP -#define OPENCV_DATASETSTOOLS_TR_SVT_HPP +#ifndef OPENCV_DATASETS_TR_SVT_HPP +#define OPENCV_DATASETS_TR_SVT_HPP #include #include -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { struct tag diff --git a/modules/datasetstools/include/opencv2/datasetstools/util.hpp b/modules/datasets/include/opencv2/datasets/util.hpp similarity index 86% rename from modules/datasetstools/include/opencv2/datasetstools/util.hpp rename to modules/datasets/include/opencv2/datasets/util.hpp index 0cf1a7295..9832e7406 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/util.hpp +++ b/modules/datasets/include/opencv2/datasets/util.hpp @@ -39,8 +39,8 @@ // //M*/ -#ifndef OPENCV_DATASETSTOOLS_UTIL_HPP -#define OPENCV_DATASETSTOOLS_UTIL_HPP +#ifndef OPENCV_DATASETS_UTIL_HPP +#define OPENCV_DATASETS_UTIL_HPP #include #include @@ -49,12 +49,14 @@ namespace cv { -namespace datasetstools +namespace datasets { -void split(const std::string &s, std::vector &elems, char delim); +void CV_EXPORTS split(const std::string &s, std::vector &elems, char delim); -void getDirList(const std::string &dirName, std::vector &fileNames); +void CV_EXPORTS createDirectory(const std::string &path); + +void CV_EXPORTS getDirList(const std::string &dirName, std::vector &fileNames); } } diff --git a/modules/datasetstools/samples/ar_hmdb.cpp b/modules/datasets/samples/ar_hmdb.cpp similarity index 97% rename from modules/datasetstools/samples/ar_hmdb.cpp rename to modules/datasets/samples/ar_hmdb.cpp index 5bb067f43..c4b2cd55c 100644 --- a/modules/datasetstools/samples/ar_hmdb.cpp +++ b/modules/datasets/samples/ar_hmdb.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/ar_hmdb.hpp" +#include "opencv2/datasets/ar_hmdb.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasets/samples/ar_hmdb_benchmark.cpp b/modules/datasets/samples/ar_hmdb_benchmark.cpp new file mode 100644 index 000000000..39ff07c31 --- /dev/null +++ b/modules/datasets/samples/ar_hmdb_benchmark.cpp @@ -0,0 +1,276 @@ +/*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) 2014, Itseez 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 Itseez Inc 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 "opencv2/datasets/ar_hmdb.hpp" +#include "opencv2/datasets/util.hpp" + +#include +#include +#include + +#include + +#include +#include +#include + +using namespace std; +using namespace cv; +using namespace cv::datasets; +using namespace cv::flann; +using namespace cv::ml; + +unsigned int getNumFiles(vector< Ptr > &curr); +unsigned int getNumFiles(vector< Ptr > &curr) +{ + unsigned int numFiles = 0; + for (unsigned int i=0; i(curr[i].get()); + vector &videoNames = example->videoNames; + for (vector::iterator it=videoNames.begin(); it!=videoNames.end(); ++it) + { + numFiles++; + } + } + + return numFiles; +} + +void fillData(const string &path, vector< Ptr > &curr, Index &flann_index, Mat1f &data, Mat1i &labels); +void fillData(const string &path, vector< Ptr > &curr, Index &flann_index, Mat1f &data, Mat1i &labels) +{ + const unsigned int descriptorNum = 162; + Mat1f sample(1, descriptorNum); + Mat1i nresps(1, 1); + Mat1f dists(1, 1); + + unsigned int numFiles = 0; + for (unsigned int i=0; i(curr[i].get()); + vector &videoNames = example->videoNames; + for (vector::iterator it=videoNames.begin(); it!=videoNames.end(); ++it) + { + string featuresFile = *it + ".txt"; + string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + featuresFile; + + ifstream infile(featuresFullPath.c_str()); + string line; + // skip header + for (unsigned int j=0; j<3; ++j) + { + getline(infile, line); + } + while (getline(infile, line)) + { + // 7 skip, hog+hof: 72+90 read + vector elems; + split(line, elems, '\t'); + + for (unsigned int j=0; j("path")); + if (parser.has("help") || path=="true") + { + parser.printMessage(); + return -1; + } + + // loading dataset + Ptr dataset = AR_hmdb::create(); + dataset->load(path); + + int numSplits = dataset->getNumSplits(); + printf("splits number: %u\n", numSplits); + + + const unsigned int descriptorNum = 162; + const unsigned int clusterNum = 4000; + const unsigned int sampleNum = 5613856; // max for all 3 splits + + vector res; + for (int currSplit=0; currSplit > &curr = dataset->getTrain(currSplit); + unsigned int numTrainFiles = getNumFiles(curr); + unsigned int numFeatures = 0; + for (unsigned int i=0; i(curr[i].get()); + vector &videoNames = example->videoNames; + for (vector::iterator it=videoNames.begin(); it!=videoNames.end(); ++it) + { + string featuresFile = *it + ".txt"; + string featuresFullPath = path + "hmdb51_org_stips/" + example->name + "/" + featuresFile; + + ifstream infile(featuresFullPath.c_str()); + string line; + // skip header + for (unsigned int j=0; j<3; ++j) + { + getline(infile, line); + } + while (getline(infile, line)) + { + numFeatures++; + if (currSample < sampleNum) + { + // 7 skip, hog+hof: 72+90 read + vector elems; + split(line, elems, '\t'); + + for (unsigned int j=0; j >(samples, centers, kmean_params); + if (resultClusters < clusterNum) + { + centers = centers.rowRange(Range(0, resultClusters)); + } + Index flann_index(centers, KDTreeIndexParams()); + printf("resulted clusters number: %u\n", resultClusters); + + + Mat1f trainData(numTrainFiles, resultClusters); + Mat1i trainLabels(numTrainFiles, 1); + + for (unsigned int i=0; i svm = SVM::create(params); + svm->train(trainData, ROW_SAMPLE, trainLabels); + + // prepare to predict + curr = dataset->getTest(currSplit); + unsigned int numTestFiles = getNumFiles(curr); + Mat1f testData(numTestFiles, resultClusters); + Mat1i testLabels(numTestFiles, 1); // ground true + + for (unsigned int i=0; ipredict(testData, testPredicted); + + unsigned int correct = 0; + for (unsigned int i=0; i @@ -51,7 +51,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/fr_lfw.cpp b/modules/datasets/samples/fr_lfw.cpp similarity index 97% rename from modules/datasetstools/samples/fr_lfw.cpp rename to modules/datasets/samples/fr_lfw.cpp index 348c69666..309ef2f0b 100644 --- a/modules/datasetstools/samples/fr_lfw.cpp +++ b/modules/datasets/samples/fr_lfw.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/fr_lfw.hpp" +#include "opencv2/datasets/fr_lfw.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasets/samples/fr_lfw_benchmark.cpp b/modules/datasets/samples/fr_lfw_benchmark.cpp new file mode 100644 index 000000000..9f578b54a --- /dev/null +++ b/modules/datasets/samples/fr_lfw_benchmark.cpp @@ -0,0 +1,175 @@ +/*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) 2014, Itseez 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 Itseez Inc 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 "opencv2/core.hpp" +#include "opencv2/imgcodecs.hpp" + +#include "opencv2/face.hpp" +#include "opencv2/datasets/fr_lfw.hpp" + +#include + +#include + +#include +#include +#include + +using namespace std; +using namespace cv; +using namespace cv::datasets; +using namespace cv::face; + +map people; + +int getLabel(const string &imagePath); +int getLabel(const string &imagePath) +{ + size_t pos = imagePath.find('/'); + string curr = imagePath.substr(0, pos); + map::iterator it = people.find(curr); + if (people.end() == it) + { + people.insert(make_pair(curr, (int)people.size())); + it = people.find(curr); + } + return (*it).second; +} + +int main(int argc, const char *argv[]) +{ + const char *keys = + "{ help h usage ? | | show this message }" + "{ path p |true| path to dataset (lfw2 folder) }"; + CommandLineParser parser(argc, argv, keys); + string path(parser.get("path")); + if (parser.has("help") || path=="true") + { + parser.printMessage(); + return -1; + } + + // These vectors hold the images and corresponding labels. + vector images; + vector labels; + + // load dataset + Ptr dataset = FR_lfw::create(); + dataset->load(path); + + unsigned int numSplits = dataset->getNumSplits(); + printf("splits number: %u\n", numSplits); + printf("train size: %u\n", (unsigned int)dataset->getTrain().size()); + printf("test size: %u\n", (unsigned int)dataset->getTest().size()); + + for (unsigned int i=0; igetTrain().size(); ++i) + { + FR_lfwObj *example = static_cast(dataset->getTrain()[i].get()); + + int currNum = getLabel(example->image1); + Mat img = imread(path+example->image1, IMREAD_GRAYSCALE); + images.push_back(img); + labels.push_back(currNum); + + currNum = getLabel(example->image2); + img = imread(path+example->image2, IMREAD_GRAYSCALE); + images.push_back(img); + labels.push_back(currNum); + } + + // 2200 pairsDevTrain, first split: correct: 373, from: 600 -> 62.1667% + Ptr model = createLBPHFaceRecognizer(); + // 2200 pairsDevTrain, first split: correct: correct: 369, from: 600 -> 61.5% + //Ptr model = createEigenFaceRecognizer(); + // 2200 pairsDevTrain, first split: correct: 372, from: 600 -> 62% + //Ptr model = createFisherFaceRecognizer(); + + model->train(images, labels); + //string saveModelPath = "face-rec-model.txt"; + //cout << "Saving the trained model to " << saveModelPath << endl; + //model->save(saveModelPath); + + vector p; + for (unsigned int j=0; j > &curr = dataset->getTest(j); + for (unsigned int i=0; i(curr[i].get()); + + //int currNum = getLabel(example->image1); + Mat img = imread(path+example->image1, IMREAD_GRAYSCALE); + int predictedLabel1 = model->predict(img); + + //currNum = getLabel(example->image2); + img = imread(path+example->image2, IMREAD_GRAYSCALE); + int predictedLabel2 = model->predict(img); + + if ((predictedLabel1 == predictedLabel2 && example->same) || + (predictedLabel1 != predictedLabel2 && !example->same)) + { + correct++; + } else + { + incorrect++; + } + } + p.push_back(1.0*correct/(correct+incorrect)); + printf("correct: %u, from: %u -> %f\n", correct, correct+incorrect, p.back()); + } + double mu = 0.0; + for (vector::iterator it=p.begin(); it!=p.end(); ++it) + { + mu += *it; + } + mu /= p.size(); + double sigma = 0.0; + for (vector::iterator it=p.begin(); it!=p.end(); ++it) + { + sigma += (*it - mu)*(*it - mu); + } + sigma = sqrt(sigma/p.size()); + double se = sigma/sqrt(p.size()); + printf("estimated mean accuracy: %f and the standard error of the mean: %f\n", mu, se); + + return 0; +} diff --git a/modules/datasetstools/samples/gr_chalearn.cpp b/modules/datasets/samples/gr_chalearn.cpp similarity index 98% rename from modules/datasetstools/samples/gr_chalearn.cpp rename to modules/datasets/samples/gr_chalearn.cpp index fa972667e..a16cd036c 100644 --- a/modules/datasetstools/samples/gr_chalearn.cpp +++ b/modules/datasets/samples/gr_chalearn.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/gr_chalearn.hpp" +#include "opencv2/datasets/gr_chalearn.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/gr_skig.cpp b/modules/datasets/samples/gr_skig.cpp similarity index 97% rename from modules/datasetstools/samples/gr_skig.cpp rename to modules/datasets/samples/gr_skig.cpp index 9eb099049..aa94c2ea5 100644 --- a/modules/datasetstools/samples/gr_skig.cpp +++ b/modules/datasets/samples/gr_skig.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/gr_skig.hpp" +#include "opencv2/datasets/gr_skig.hpp" #include @@ -51,7 +51,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/hpe_parse.cpp b/modules/datasets/samples/hpe_parse.cpp similarity index 97% rename from modules/datasetstools/samples/hpe_parse.cpp rename to modules/datasets/samples/hpe_parse.cpp index b99ee189e..c3c1b43db 100644 --- a/modules/datasetstools/samples/hpe_parse.cpp +++ b/modules/datasets/samples/hpe_parse.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/hpe_parse.hpp" +#include "opencv2/datasets/hpe_parse.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/ir_affine.cpp b/modules/datasets/samples/ir_affine.cpp similarity index 97% rename from modules/datasetstools/samples/ir_affine.cpp rename to modules/datasets/samples/ir_affine.cpp index 06bc2f227..ce57afada 100644 --- a/modules/datasetstools/samples/ir_affine.cpp +++ b/modules/datasets/samples/ir_affine.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/ir_affine.hpp" +#include "opencv2/datasets/ir_affine.hpp" #include @@ -51,7 +51,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/ir_robot.cpp b/modules/datasets/samples/ir_robot.cpp similarity index 97% rename from modules/datasetstools/samples/ir_robot.cpp rename to modules/datasets/samples/ir_robot.cpp index b06eb327b..1336e1286 100644 --- a/modules/datasetstools/samples/ir_robot.cpp +++ b/modules/datasets/samples/ir_robot.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/ir_robot.hpp" +#include "opencv2/datasets/ir_robot.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/is_bsds.cpp b/modules/datasets/samples/is_bsds.cpp similarity index 97% rename from modules/datasetstools/samples/is_bsds.cpp rename to modules/datasets/samples/is_bsds.cpp index 4c27954a5..3cec91d65 100644 --- a/modules/datasetstools/samples/is_bsds.cpp +++ b/modules/datasets/samples/is_bsds.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/is_bsds.hpp" +#include "opencv2/datasets/is_bsds.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/is_weizmann.cpp b/modules/datasets/samples/is_weizmann.cpp similarity index 97% rename from modules/datasetstools/samples/is_weizmann.cpp rename to modules/datasets/samples/is_weizmann.cpp index 6ee152fa1..c9d06e4bd 100644 --- a/modules/datasetstools/samples/is_weizmann.cpp +++ b/modules/datasets/samples/is_weizmann.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/is_weizmann.hpp" +#include "opencv2/datasets/is_weizmann.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/msm_epfl.cpp b/modules/datasets/samples/msm_epfl.cpp similarity index 98% rename from modules/datasetstools/samples/msm_epfl.cpp rename to modules/datasets/samples/msm_epfl.cpp index f80f340b5..ffe5f3869 100644 --- a/modules/datasetstools/samples/msm_epfl.cpp +++ b/modules/datasets/samples/msm_epfl.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/msm_epfl.hpp" +#include "opencv2/datasets/msm_epfl.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/msm_middlebury.cpp b/modules/datasets/samples/msm_middlebury.cpp similarity index 97% rename from modules/datasetstools/samples/msm_middlebury.cpp rename to modules/datasets/samples/msm_middlebury.cpp index 20f030e06..020b53d25 100644 --- a/modules/datasetstools/samples/msm_middlebury.cpp +++ b/modules/datasets/samples/msm_middlebury.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/msm_middlebury.hpp" +#include "opencv2/datasets/msm_middlebury.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/or_imagenet.cpp b/modules/datasets/samples/or_imagenet.cpp similarity index 97% rename from modules/datasetstools/samples/or_imagenet.cpp rename to modules/datasets/samples/or_imagenet.cpp index 99f13123b..13b9d8b01 100644 --- a/modules/datasetstools/samples/or_imagenet.cpp +++ b/modules/datasets/samples/or_imagenet.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/or_imagenet.hpp" +#include "opencv2/datasets/or_imagenet.hpp" #include @@ -52,7 +52,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/or_mnist.cpp b/modules/datasets/samples/or_mnist.cpp similarity index 95% rename from modules/datasetstools/samples/or_mnist.cpp rename to modules/datasets/samples/or_mnist.cpp index cb776ba43..7ef56ae4b 100644 --- a/modules/datasetstools/samples/or_mnist.cpp +++ b/modules/datasets/samples/or_mnist.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/or_mnist.hpp" +#include "opencv2/datasets/or_mnist.hpp" #include #include @@ -51,13 +51,13 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { const char *keys = "{ help h usage ? | | show this message }" - "{ path p |true| path to dataset (SUN397 folder) }"; + "{ path p |true| path to dataset }"; CommandLineParser parser(argc, argv, keys); string path(parser.get("path")); if (parser.has("help") || path=="true") diff --git a/modules/datasetstools/samples/or_sun.cpp b/modules/datasets/samples/or_sun.cpp similarity index 97% rename from modules/datasetstools/samples/or_sun.cpp rename to modules/datasets/samples/or_sun.cpp index 0804d8936..047b9796a 100644 --- a/modules/datasetstools/samples/or_sun.cpp +++ b/modules/datasets/samples/or_sun.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/or_sun.hpp" +#include "opencv2/datasets/or_sun.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasets/samples/pd_caltech.cpp b/modules/datasets/samples/pd_caltech.cpp new file mode 100644 index 000000000..ee17112e8 --- /dev/null +++ b/modules/datasets/samples/pd_caltech.cpp @@ -0,0 +1,86 @@ +/*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) 2014, Itseez 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 Itseez Inc 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 "opencv2/datasets/pd_caltech.hpp" + +#include + +#include + +#include +#include + +using namespace std; +using namespace cv; +using namespace cv::datasets; + +int main(int argc, char *argv[]) +{ + const char *keys = + "{ help h usage ? | | show this message }" + "{ path p |true| path to dataset }"; + CommandLineParser parser(argc, argv, keys); + string path(parser.get("path")); + if (parser.has("help") || path=="true") + { + parser.printMessage(); + return -1; + } + + Ptr dataset = PD_caltech::create(); + dataset->load(path); + + // *************** + // dataset contains for each object its images. + // currently on loading extract all images to folder path/../images/ + // For example, let output train size and first element of first object + // and number of it's images. + printf("train size: %u\n", (unsigned int)dataset->getTrain().size()); + + PD_caltechObj *example = static_cast(dataset->getTrain()[0].get()); + printf("first train object:\n"); + printf("name: %s\n", example->name.c_str()); + printf("images number: %u\n", (unsigned int)example->imageNames.size()); + printf("first image name: %s\n", example->imageNames[0].c_str()); + printf("images were extracted to path/../images/\n"); + + return 0; +} diff --git a/modules/datasetstools/samples/slam_kitti.cpp b/modules/datasets/samples/slam_kitti.cpp similarity index 98% rename from modules/datasetstools/samples/slam_kitti.cpp rename to modules/datasets/samples/slam_kitti.cpp index c2112208e..76ceb5983 100644 --- a/modules/datasetstools/samples/slam_kitti.cpp +++ b/modules/datasets/samples/slam_kitti.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/slam_kitti.hpp" +#include "opencv2/datasets/slam_kitti.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/slam_tumindoor.cpp b/modules/datasets/samples/slam_tumindoor.cpp similarity index 97% rename from modules/datasetstools/samples/slam_tumindoor.cpp rename to modules/datasets/samples/slam_tumindoor.cpp index 2ba504b66..3f78c119b 100644 --- a/modules/datasetstools/samples/slam_tumindoor.cpp +++ b/modules/datasets/samples/slam_tumindoor.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/slam_tumindoor.hpp" +#include "opencv2/datasets/slam_tumindoor.hpp" #include @@ -50,7 +50,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/tr_chars.cpp b/modules/datasets/samples/tr_chars.cpp similarity index 98% rename from modules/datasetstools/samples/tr_chars.cpp rename to modules/datasets/samples/tr_chars.cpp index 0dd28d6f7..6d8c15741 100644 --- a/modules/datasetstools/samples/tr_chars.cpp +++ b/modules/datasets/samples/tr_chars.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/tr_chars.hpp" +#include "opencv2/datasets/tr_chars.hpp" #include @@ -51,7 +51,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/samples/tr_svt.cpp b/modules/datasets/samples/tr_svt.cpp similarity index 97% rename from modules/datasetstools/samples/tr_svt.cpp rename to modules/datasets/samples/tr_svt.cpp index 9dc05303e..495e8b03e 100644 --- a/modules/datasetstools/samples/tr_svt.cpp +++ b/modules/datasets/samples/tr_svt.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/tr_svt.hpp" +#include "opencv2/datasets/tr_svt.hpp" #include @@ -51,7 +51,7 @@ using namespace std; using namespace cv; -using namespace cv::datasetstools; +using namespace cv::datasets; int main(int argc, char *argv[]) { diff --git a/modules/datasetstools/src/ar_hmdb.cpp b/modules/datasets/src/ar_hmdb.cpp similarity index 97% rename from modules/datasetstools/src/ar_hmdb.cpp rename to modules/datasets/src/ar_hmdb.cpp index d30d48507..6baa28c05 100644 --- a/modules/datasetstools/src/ar_hmdb.cpp +++ b/modules/datasets/src/ar_hmdb.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/ar_hmdb.hpp" +#include "opencv2/datasets/ar_hmdb.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/ar_sports.cpp b/modules/datasets/src/ar_sports.cpp similarity index 97% rename from modules/datasetstools/src/ar_sports.cpp rename to modules/datasets/src/ar_sports.cpp index 0f4b4cf58..83cf79c6b 100644 --- a/modules/datasetstools/src/ar_sports.cpp +++ b/modules/datasets/src/ar_sports.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/ar_sports.hpp" +#include "opencv2/datasets/ar_sports.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/dataset.cpp b/modules/datasets/src/dataset.cpp similarity index 96% rename from modules/datasetstools/src/dataset.cpp rename to modules/datasets/src/dataset.cpp index 9473f2aa3..38b74167c 100644 --- a/modules/datasetstools/src/dataset.cpp +++ b/modules/datasets/src/dataset.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/dataset.hpp" +#include "opencv2/datasets/dataset.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/fr_lfw.cpp b/modules/datasets/src/fr_lfw.cpp similarity index 80% rename from modules/datasetstools/src/fr_lfw.cpp rename to modules/datasets/src/fr_lfw.cpp index 420bd9143..16e0133c7 100644 --- a/modules/datasetstools/src/fr_lfw.cpp +++ b/modules/datasets/src/fr_lfw.cpp @@ -39,14 +39,15 @@ // //M*/ -#include "opencv2/datasetstools/fr_lfw.hpp" +#include "opencv2/datasets/fr_lfw.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { using namespace std; @@ -82,12 +83,13 @@ void FR_lfwImp::loadDataset(const string &path) getDirList(path, fileNames); for (vector::iterator it=fileNames.begin(); it!=fileNames.end(); ++it) { - if ("pairs.txt" == *it) + string &name = *it; + + if (name.length()>3 && name.substr(name.length()-4) == ".txt") { continue; } - string &name = *it; vector images; string pathFace(path + name + "/"); @@ -142,6 +144,37 @@ void FR_lfwImp::loadDataset(const string &path) num++; } + + // dev train loading to train[0] + ifstream infile2((path + "pairsDevTrain.txt").c_str()); + getline(infile2, line); // should 1100 + while (getline(infile2, line)) + { + vector elems; + split(line, elems, '\t'); + + Ptr curr(new FR_lfwObj); + string &person1 = elems[0]; + unsigned int imageNumber1 = atoi(elems[1].c_str())-1; + curr->image1 = person1 + "/" + faces[person1][imageNumber1]; + + string person2; + unsigned int imageNumber2; + if (3 == elems.size()) + { + person2 = elems[0]; + imageNumber2 = atoi(elems[2].c_str())-1; + curr->same = true; + } else + { + person2 = elems[2]; + imageNumber2 = atoi(elems[3].c_str())-1; + curr->same = false; + } + curr->image2 = person2 + "/" + faces[person2][imageNumber2]; + + train[0].push_back(curr); + } } Ptr FR_lfw::create() diff --git a/modules/datasetstools/src/gr_chalearn.cpp b/modules/datasets/src/gr_chalearn.cpp similarity index 98% rename from modules/datasetstools/src/gr_chalearn.cpp rename to modules/datasets/src/gr_chalearn.cpp index b9380193b..7cbed3ca9 100644 --- a/modules/datasetstools/src/gr_chalearn.cpp +++ b/modules/datasets/src/gr_chalearn.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/gr_chalearn.hpp" +#include "opencv2/datasets/gr_chalearn.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/gr_skig.cpp b/modules/datasets/src/gr_skig.cpp similarity index 98% rename from modules/datasetstools/src/gr_skig.cpp rename to modules/datasets/src/gr_skig.cpp index fe783fd37..954ed509a 100644 --- a/modules/datasetstools/src/gr_skig.cpp +++ b/modules/datasets/src/gr_skig.cpp @@ -39,14 +39,15 @@ // //M*/ -#include "opencv2/datasetstools/gr_skig.hpp" +#include "opencv2/datasets/gr_skig.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/hpe_parse.cpp b/modules/datasets/src/hpe_parse.cpp similarity index 97% rename from modules/datasetstools/src/hpe_parse.cpp rename to modules/datasets/src/hpe_parse.cpp index ea835fdc1..2c37a96e0 100644 --- a/modules/datasetstools/src/hpe_parse.cpp +++ b/modules/datasets/src/hpe_parse.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/hpe_parse.hpp" +#include "opencv2/datasets/hpe_parse.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/ir_affine.cpp b/modules/datasets/src/ir_affine.cpp similarity index 97% rename from modules/datasetstools/src/ir_affine.cpp rename to modules/datasets/src/ir_affine.cpp index 3373ecd15..b8946106c 100644 --- a/modules/datasetstools/src/ir_affine.cpp +++ b/modules/datasets/src/ir_affine.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/ir_affine.hpp" +#include "opencv2/datasets/ir_affine.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/ir_robot.cpp b/modules/datasets/src/ir_robot.cpp similarity index 97% rename from modules/datasetstools/src/ir_robot.cpp rename to modules/datasets/src/ir_robot.cpp index e9c0678f5..338633b46 100644 --- a/modules/datasetstools/src/ir_robot.cpp +++ b/modules/datasets/src/ir_robot.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/ir_robot.hpp" +#include "opencv2/datasets/ir_robot.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/is_bsds.cpp b/modules/datasets/src/is_bsds.cpp similarity index 97% rename from modules/datasetstools/src/is_bsds.cpp rename to modules/datasets/src/is_bsds.cpp index ebc397e30..b99315bc0 100644 --- a/modules/datasetstools/src/is_bsds.cpp +++ b/modules/datasets/src/is_bsds.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/is_bsds.hpp" +#include "opencv2/datasets/is_bsds.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/is_weizmann.cpp b/modules/datasets/src/is_weizmann.cpp similarity index 97% rename from modules/datasetstools/src/is_weizmann.cpp rename to modules/datasets/src/is_weizmann.cpp index 094521080..fc75ae742 100644 --- a/modules/datasetstools/src/is_weizmann.cpp +++ b/modules/datasets/src/is_weizmann.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/is_weizmann.hpp" +#include "opencv2/datasets/is_weizmann.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/msm_epfl.cpp b/modules/datasets/src/msm_epfl.cpp similarity index 97% rename from modules/datasetstools/src/msm_epfl.cpp rename to modules/datasets/src/msm_epfl.cpp index 220691e0c..663adedcb 100644 --- a/modules/datasetstools/src/msm_epfl.cpp +++ b/modules/datasets/src/msm_epfl.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/msm_epfl.hpp" +#include "opencv2/datasets/msm_epfl.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/msm_middlebury.cpp b/modules/datasets/src/msm_middlebury.cpp similarity index 97% rename from modules/datasetstools/src/msm_middlebury.cpp rename to modules/datasets/src/msm_middlebury.cpp index e65b1330f..a7d520d3f 100644 --- a/modules/datasetstools/src/msm_middlebury.cpp +++ b/modules/datasets/src/msm_middlebury.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/msm_middlebury.hpp" +#include "opencv2/datasets/msm_middlebury.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/or_imagenet.cpp b/modules/datasets/src/or_imagenet.cpp similarity index 97% rename from modules/datasetstools/src/or_imagenet.cpp rename to modules/datasets/src/or_imagenet.cpp index dc5986a4d..0fbebf976 100644 --- a/modules/datasetstools/src/or_imagenet.cpp +++ b/modules/datasets/src/or_imagenet.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/or_imagenet.hpp" +#include "opencv2/datasets/or_imagenet.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/or_mnist.cpp b/modules/datasets/src/or_mnist.cpp similarity index 97% rename from modules/datasetstools/src/or_mnist.cpp rename to modules/datasets/src/or_mnist.cpp index 5fe312213..cc721ee15 100644 --- a/modules/datasetstools/src/or_mnist.cpp +++ b/modules/datasets/src/or_mnist.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/or_mnist.hpp" +#include "opencv2/datasets/or_mnist.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/or_sun.cpp b/modules/datasets/src/or_sun.cpp similarity index 97% rename from modules/datasetstools/src/or_sun.cpp rename to modules/datasets/src/or_sun.cpp index 3a3492da5..29b710922 100644 --- a/modules/datasetstools/src/or_sun.cpp +++ b/modules/datasets/src/or_sun.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/or_sun.hpp" +#include "opencv2/datasets/or_sun.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasets/src/pd_caltech.cpp b/modules/datasets/src/pd_caltech.cpp new file mode 100644 index 000000000..74c596d44 --- /dev/null +++ b/modules/datasets/src/pd_caltech.cpp @@ -0,0 +1,188 @@ +/*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) 2014, Itseez 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 Itseez Inc 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 "opencv2/datasets/pd_caltech.hpp" +#include "opencv2/datasets/util.hpp" +#include "precomp.hpp" + +namespace cv +{ +namespace datasets +{ + +using namespace std; + +class CV_EXPORTS PD_caltechImp : public PD_caltech +{ +public: + PD_caltechImp() {} + //PD_caltechImp(const string &path); + virtual ~PD_caltechImp() {} + + virtual void load(const string &path); + +private: + void loadDataset(const string &path); +}; + +/*PD_caltechImp::PD_caltechImp(const string &path) +{ + loadDataset(path); +}*/ + +void PD_caltechImp::load(const string &path) +{ + loadDataset(path); +} + +void PD_caltechImp::loadDataset(const string &path) +{ + train.push_back(vector< Ptr >()); + test.push_back(vector< Ptr >()); + validation.push_back(vector< Ptr >()); + + createDirectory((path + "../images/")); + + vector objectNames; + getDirList(path, objectNames); + for (vector::iterator it=objectNames.begin(); it!=objectNames.end(); ++it) + { + Ptr curr(new PD_caltechObj); + curr->name = *it; + + string objectPath(path + "../images/" + curr->name + "/"); + createDirectory(objectPath); + + string seqImagesPath(path + curr->name + "/"); + vector seqNames; + getDirList(seqImagesPath, seqNames); + for (vector::iterator itSeq=seqNames.begin(); itSeq!=seqNames.end(); ++itSeq) + { + string &seqName = *itSeq; + + createDirectory((objectPath + seqName)); + + FILE *f = fopen((seqImagesPath + seqName).c_str(), "rb"); + + #define SKIP 28+8+512 + fseek(f, SKIP, SEEK_CUR); + + unsigned int header[9]; + size_t res = fread(header, 9, 4, f); + double fps; + res = fread(&fps, 1, 8, f); + fseek(f, 432, SEEK_CUR); + + /*printf("width %u\n", header[0]); + printf("height %u\n", header[1]); + printf("imageBitDepth %u\n", header[2]); + printf("imageBitDepthReal %u\n", header[3]); + printf("imageSizeBytes %u\n", header[4]); + printf("imageFormat %u\n", header[5]); + printf("numFrames %u\n", numFrames); + printf("fps %f\n", fps); + printf("trueImageSize %u\n", header[8]);*/ + unsigned int numFrames = header[6]; + + string ext; + switch (header[5]) + { + case 100: + case 200: + ext = "raw"; + break; + case 101: + ext = "brgb8"; + break; + case 102: + case 201: + ext = "jpg"; + break; + case 103: + ext = "jbrgb"; + break; + case 001: + case 002: + ext = "png"; + break; + } + + for (unsigned int i=0; iimageNames.push_back(imgName); + + // comment fseek and uncomment next block to unpack all frames + fseek(f, size, SEEK_CUR); + /*char *img = new char[size]; + fread(img, size, 1, f); + string imgPath(objectPath + seqName + imgName); + FILE *fImg = fopen(imgPath.c_str(), "wb"); + fwrite(img, size, 1, fImg); + fclose(fImg); + delete[] img;*/ + + fseek(f, 12, SEEK_CUR); + } + + if (0 != res) // should fix unused variable warning + { + res = 0; + } + + fclose(f); + } + + train.back().push_back(curr); + } +} + +Ptr PD_caltech::create() +{ + return Ptr(new PD_caltechImp); +} + +} +} diff --git a/modules/datasetstools/src/precomp.hpp b/modules/datasets/src/precomp.hpp similarity index 98% rename from modules/datasetstools/src/precomp.hpp rename to modules/datasets/src/precomp.hpp index 55af6624c..da5bf8b83 100644 --- a/modules/datasetstools/src/precomp.hpp +++ b/modules/datasets/src/precomp.hpp @@ -47,6 +47,4 @@ #include -#include "opencv2/datasetstools/util.hpp" - #endif diff --git a/modules/datasetstools/src/slam_kitti.cpp b/modules/datasets/src/slam_kitti.cpp similarity index 98% rename from modules/datasetstools/src/slam_kitti.cpp rename to modules/datasets/src/slam_kitti.cpp index 697889fd3..ca1904d3e 100644 --- a/modules/datasetstools/src/slam_kitti.cpp +++ b/modules/datasets/src/slam_kitti.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/slam_kitti.hpp" +#include "opencv2/datasets/slam_kitti.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/slam_tumindoor.cpp b/modules/datasets/src/slam_tumindoor.cpp similarity index 97% rename from modules/datasetstools/src/slam_tumindoor.cpp rename to modules/datasets/src/slam_tumindoor.cpp index 27712ebae..cdc354314 100644 --- a/modules/datasetstools/src/slam_tumindoor.cpp +++ b/modules/datasets/src/slam_tumindoor.cpp @@ -39,14 +39,15 @@ // //M*/ -#include "opencv2/datasetstools/slam_tumindoor.hpp" +#include "opencv2/datasets/slam_tumindoor.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" #include namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/tinyxml2/tinyxml2.cpp b/modules/datasets/src/tinyxml2/tinyxml2.cpp similarity index 99% rename from modules/datasetstools/src/tinyxml2/tinyxml2.cpp rename to modules/datasets/src/tinyxml2/tinyxml2.cpp index d88e48d15..815196995 100755 --- a/modules/datasetstools/src/tinyxml2/tinyxml2.cpp +++ b/modules/datasets/src/tinyxml2/tinyxml2.cpp @@ -21,7 +21,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "opencv2/datasetstools/tinyxml2/tinyxml2.h" +#include "opencv2/datasets/tinyxml2/tinyxml2.h" #include // yes, this one new style header, is in the Android SDK. # ifdef ANDROID_NDK diff --git a/modules/datasetstools/src/tr_chars.cpp b/modules/datasets/src/tr_chars.cpp similarity index 98% rename from modules/datasetstools/src/tr_chars.cpp rename to modules/datasets/src/tr_chars.cpp index 0760f0f78..5291c5bc8 100644 --- a/modules/datasetstools/src/tr_chars.cpp +++ b/modules/datasets/src/tr_chars.cpp @@ -39,12 +39,13 @@ // //M*/ -#include "opencv2/datasetstools/tr_chars.hpp" +#include "opencv2/datasets/tr_chars.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/tr_svt.cpp b/modules/datasets/src/tr_svt.cpp similarity index 97% rename from modules/datasetstools/src/tr_svt.cpp rename to modules/datasets/src/tr_svt.cpp index 34d7fa908..b2e11e788 100644 --- a/modules/datasetstools/src/tr_svt.cpp +++ b/modules/datasets/src/tr_svt.cpp @@ -39,14 +39,15 @@ // //M*/ -#include "opencv2/datasetstools/tr_svt.hpp" +#include "opencv2/datasets/tr_svt.hpp" +#include "opencv2/datasets/util.hpp" #include "precomp.hpp" -#include +#include namespace cv { -namespace datasetstools +namespace datasets { using namespace std; diff --git a/modules/datasetstools/src/util.cpp b/modules/datasets/src/util.cpp similarity index 93% rename from modules/datasetstools/src/util.cpp rename to modules/datasets/src/util.cpp index 24bc342a4..7f2235792 100644 --- a/modules/datasetstools/src/util.cpp +++ b/modules/datasets/src/util.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "opencv2/datasetstools/util.hpp" +#include "opencv2/datasets/util.hpp" #include @@ -48,6 +48,7 @@ #ifdef __GNUC__ #include #include + #include #else #include #include @@ -55,7 +56,7 @@ namespace cv { -namespace datasetstools +namespace datasets { using namespace std; @@ -70,6 +71,15 @@ void split(const string &s, vector &elems, char delim) } } +void createDirectory(const string &path) +{ +#ifdef __GNUC__ + mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); +#else + mkdir(path.c_str()); +#endif +} + void getDirList(const string &dirName, vector &fileNames) { #ifdef __GNUC__ diff --git a/modules/datasetstools/CMakeLists.txt b/modules/datasetstools/CMakeLists.txt deleted file mode 100644 index 3e058a5a7..000000000 --- a/modules/datasetstools/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(the_description "datasets tools") -ocv_define_module(datasetstools opencv_core) - diff --git a/modules/datasetstools/doc/datasetstools.rst b/modules/datasetstools/doc/datasetstools.rst deleted file mode 100644 index f2b0ae71f..000000000 --- a/modules/datasetstools/doc/datasetstools.rst +++ /dev/null @@ -1,347 +0,0 @@ -********************************************************* -datasetstools. Tools for working with different datasets. -********************************************************* - -.. highlight:: cpp - -The datasetstools module includes classes for working with different datasets. - -Action Recognition ------------------- - -AR_hmdb -======= -.. ocv:class:: AR_hmdb - -Implements loading dataset: - -_`"HMDB: A Large Human Motion Database"`: http://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/ - -.. note:: Usage - - 1. From link above download dataset files: hmdb51_org.rar & test_train_splits.rar. - - 2. Unpack them. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_ar_hmdb -p=/home/user/path_to_unpacked_folders/ - -AR_sports -========= -.. ocv:class:: AR_sports - -Implements loading dataset: - -_`"Sports-1M Dataset"`: http://cs.stanford.edu/people/karpathy/deepvideo/ - -.. note:: Usage - - 1. From link above download dataset files (git clone https://code.google.com/p/sports-1m-dataset/). - - 2. To load data run: ./opencv/build/bin/example_datasetstools_ar_sports -p=/home/user/path_to_downloaded_folders/ - -Face Recognition ----------------- - -FR_lfw -====== -.. ocv:class:: FR_lfw - -Implements loading dataset: - -_`"Labeled Faces in the Wild"`: http://vis-www.cs.umass.edu/lfw/ - -.. note:: Usage - - 1. From link above download any dataset file: lfw.tgz\lfwa.tar.gz\lfw-deepfunneled.tgz\lfw-funneled.tgz and file with 10 test splits: pairs.txt. - - 2. Unpack dataset file and place pairs.txt in created folder. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_fr_lfw -p=/home/user/path_to_unpacked_folder/lfw2/ - -Gesture Recognition -------------------- - -GR_chalearn -=========== -.. ocv:class:: GR_chalearn - -Implements loading dataset: - -_`"ChaLearn Looking at People"`: http://gesture.chalearn.org/ - -.. note:: Usage - - 1. Follow instruction from site above, download files for dataset "Track 3: Gesture Recognition": Train1.zip-Train5.zip, Validation1.zip-Validation3.zip (Register on site: www.codalab.org and accept the terms and conditions of competition: https://www.codalab.org/competitions/991#learn_the_details There are three mirrors for downloading dataset files. When I downloaded data only mirror: "Universitat Oberta de Catalunya" works). - - 2. Unpack train archives Train1.zip-Train5.zip to folder Train/, validation archives Validation1.zip-Validation3.zip to folder Validation/ - - 3. Unpack all archives in Train/ & Validation/ in the folders with the same names, for example: Sample0001.zip to Sample0001/ - - 4. To load data run: ./opencv/build/bin/example_datasetstools_gr_chalearn -p=/home/user/path_to_unpacked_folders/ - -GR_skig -======= -.. ocv:class:: GR_skig - -Implements loading dataset: - -_`"Sheffield Kinect Gesture Dataset"`: http://lshao.staff.shef.ac.uk/data/SheffieldKinectGesture.htm - -.. note:: Usage - - 1. From link above download dataset files: subject1_dep.7z-subject6_dep.7z, subject1_rgb.7z-subject6_rgb.7z. - - 2. Unpack them. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_gr_skig -p=/home/user/path_to_unpacked_folders/ - -Human Pose Estimation ---------------------- - -HPE_parse -========= -.. ocv:class:: HPE_parse - -Implements loading dataset: - -_`"PARSE Dataset"`: http://www.ics.uci.edu/~dramanan/papers/parse/ - -.. note:: Usage - - 1. From link above download dataset file: people.zip. - - 2. Unpack it. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_hpe_parse -p=/home/user/path_to_unpacked_folder/people_all/ - -Image Registration ------------------- - -IR_affine -========= -.. ocv:class:: IR_affine - -Implements loading dataset: - -_`"Affine Covariant Regions Datasets"`: http://www.robots.ox.ac.uk/~vgg/data/data-aff.html - -.. note:: Usage - - 1. From link above download dataset files: bark\\bikes\\boat\\graf\\leuven\\trees\\ubc\\wall.tar.gz. - - 2. Unpack them. - - 3. To load data, for example, for "bark", run: ./opencv/build/bin/example_datasetstools_ir_affine -p=/home/user/path_to_unpacked_folder/bark/ - -IR_robot -======== -.. ocv:class:: IR_robot - -Implements loading dataset: - -_`"Robot Data Set"`: http://roboimagedata.compute.dtu.dk/?page_id=24 - -.. note:: Usage - - 1. From link above download files for dataset "Point Feature Data Set – 2010": SET001_6.tar.gz-SET055_60.tar.gz (there are two data sets: - Full resolution images (1200×1600), ~500 Gb and - Half size image (600×800), ~115 Gb.) - 2. Unpack them to one folder. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_ir_robot -p=/home/user/path_to_unpacked_folder/ - -Image Segmentation ------------------- - -IS_bsds -======= -.. ocv:class:: IS_bsds - -Implements loading dataset: - -_`"The Berkeley Segmentation Dataset and Benchmark"`: https://www.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/ - -.. note:: Usage - - 1. From link above download dataset files: BSDS300-human.tgz & BSDS300-images.tgz. - - 2. Unpack them. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_is_bsds -p=/home/user/path_to_unpacked_folder/BSDS300/ - -IS_weizmann -=========== -.. ocv:class:: IS_weizmann - -Implements loading dataset: - -_`"Weizmann Segmentation Evaluation Database"`: http://www.wisdom.weizmann.ac.il/~vision/Seg_Evaluation_DB/ - -.. note:: Usage - - 1. From link above download dataset files: Weizmann_Seg_DB_1obj.ZIP & Weizmann_Seg_DB_2obj.ZIP. - - 2. Unpack them. - - 3. To load data, for example, for 1 object dataset, run: ./opencv/build/bin/example_datasetstools_is_weizmann -p=/home/user/path_to_unpacked_folder/1obj/ - -Multiview Stereo Matching -------------------------- - -MSM_epfl -======== -.. ocv:class:: MSM_epfl - -Implements loading dataset: - -_`"EPFL Multi-View Stereo"`: http://cvlabwww.epfl.ch/~strecha/multiview/denseMVS.html - -.. note:: Usage - - 1. From link above download dataset files: castle_dense\\castle_dense_large\\castle_entry\\fountain\\herzjesu_dense\\herzjesu_dense_large_bounding\\cameras\\images\\p.tar.gz. - - 2. Unpack them in separate folder for each object. For example, for "fountain", in folder fountain/ : fountain_dense_bounding.tar.gz -> bounding/, fountain_dense_cameras.tar.gz -> camera/, fountain_dense_images.tar.gz -> png/, fountain_dense_p.tar.gz -> P/ - - 3. To load data, for example, for "fountain", run: ./opencv/build/bin/example_datasetstools_msm_epfl -p=/home/user/path_to_unpacked_folder/fountain/ - -MSM_middlebury -============== -.. ocv:class:: MSM_middlebury - -Implements loading dataset: - -_`"Stereo – Middlebury Computer Vision"`: http://vision.middlebury.edu/mview/ - -.. note:: Usage - - 1. From link above download dataset files: dino\\dinoRing\\dinoSparseRing\\temple\\templeRing\\templeSparseRing.zip - - 2. Unpack them. - - 3. To load data, for example "temple" dataset, run: ./opencv/build/bin/example_datasetstools_msm_middlebury -p=/home/user/path_to_unpacked_folder/temple/ - -Object Recognition ------------------- - -OR_imagenet -=========== -.. ocv:class:: OR_imagenet - -Implements loading dataset: - -_`"ImageNet"`: http://www.image-net.org/ - -Currently implemented loading full list with urls. Planned to implement dataset from ILSVRC challenge. - -.. note:: Usage - - 1. From link above download dataset file: imagenet_fall11_urls.tgz - - 2. Unpack it. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_or_imagenet -p=/home/user/path_to_unpacked_file/ - -OR_mnist -=========== -.. ocv:class:: OR_mnist - -Implements loading dataset: - -_`"MNIST"`: http://yann.lecun.com/exdb/mnist/ - -.. note:: Usage - - 1. From link above download dataset files: t10k-images-idx3-ubyte.gz, t10k-labels-idx1-ubyte.gz, train-images-idx3-ubyte.gz, train-labels-idx1-ubyte.gz. - - 2. Unpack them. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_or_mnist -p=/home/user/path_to_unpacked_files/ - -OR_sun -====== -.. ocv:class:: OR_sun - -Implements loading dataset: - -_`"SUN Database"`: http://sundatabase.mit.edu/ - -Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012". - -.. note:: Usage - - 1. From link above download dataset file: SUN397.tar - - 2. Unpack it. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_or_sun -p=/home/user/path_to_unpacked_folder/SUN397/ - -SLAM ----- - -SLAM_kitti -========== -.. ocv:class:: SLAM_kitti - -Implements loading dataset: - -_`"KITTI Vision Benchmark"`: http://www.cvlibs.net/datasets/kitti/eval_odometry.php - -.. note:: Usage - - 1. From link above download "Odometry" dataset files: data_odometry_gray\\data_odometry_color\\data_odometry_velodyne\\data_odometry_poses\\data_odometry_calib.zip. - - 2. Unpack data_odometry_poses.zip, it creates folder dataset/poses/. After that unpack data_odometry_gray.zip, data_odometry_color.zip, data_odometry_velodyne.zip. Folder dataset/sequences/ will be created with folders 00/..21/. Each of these folders will contain: image_0/, image_1/, image_2/, image_3/, velodyne/ and files calib.txt & times.txt. These two last files will be replaced after unpacking data_odometry_calib.zip at the end. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_slam_kitti -p=/home/user/path_to_unpacked_folder/dataset/ - -SLAM_tumindoor -============== -.. ocv:class:: SLAM_tumindoor - -Implements loading dataset: - -_`"TUMindoor Dataset"`: http://www.navvis.lmt.ei.tum.de/dataset/ - -.. note:: Usage - - 1. From link above download dataset files: dslr\\info\\ladybug\\pointcloud.tar.bz2 for each dataset: 11-11-28 (1st floor)\\11-12-13 (1st floor N1)\\11-12-17a (4th floor)\\11-12-17b (3rd floor)\\11-12-17c (Ground I)\\11-12-18a (Ground II)\\11-12-18b (2nd floor) - - 2. Unpack them in separate folder for each dataset. dslr.tar.bz2 -> dslr/, info.tar.bz2 -> info/, ladybug.tar.bz2 -> ladybug/, pointcloud.tar.bz2 -> pointcloud/. - - 3. To load each dataset run: ./opencv/build/bin/example_datasetstools_slam_tumindoor -p=/home/user/path_to_unpacked_folders/ - -Text Recognition ----------------- - -TR_chars -======== -.. ocv:class:: TR_chars - -Implements loading dataset: - -_`"The Chars74K Dataset"`: http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/ - -.. note:: Usage - - 1. From link above download dataset files: EnglishFnt\\EnglishHnd\\EnglishImg\\KannadaHnd\\KannadaImg.tgz, ListsTXT.tgz. - - 2. Unpack them. - - 3. Move .m files from folder ListsTXT/ to appropriate folder. For example, English/list_English_Img.m for EnglishImg.tgz. - - 4. To load data, for example "EnglishImg", run: ./opencv/build/bin/example_datasetstools_tr_chars -p=/home/user/path_to_unpacked_folder/English/ - -TR_svt -====== -.. ocv:class:: TR_svt - -Implements loading dataset: - -_`"The Street View Text Dataset"`: http://vision.ucsd.edu/~kai/svt/ - -.. note:: Usage - - 1. From link above download dataset file: svt.zip. - - 2. Unpack it. - - 3. To load data run: ./opencv/build/bin/example_datasetstools_tr_svt -p=/home/user/path_to_unpacked_folder/svt/svt1/ - diff --git a/modules/reg/samples/map_test.cpp b/modules/reg/samples/map_test.cpp index 221125187..38fa00b7d 100644 --- a/modules/reg/samples/map_test.cpp +++ b/modules/reg/samples/map_test.cpp @@ -47,9 +47,10 @@ #include #ifdef COMPARE_FEATURES -#include +#include #include #include +using namespace cv::xfeatures2d; #endif #include "opencv2/reg/mapaffine.hpp" diff --git a/modules/surface_matching/doc/surface_matching.rst b/modules/surface_matching/doc/surface_matching.rst index e026e0d7c..3f25e2769 100644 --- a/modules/surface_matching/doc/surface_matching.rst +++ b/modules/surface_matching/doc/surface_matching.rst @@ -1,19 +1,19 @@ .. _surfacematching: -Introduction to Surface Matching -********************************************************** +surface_matching. Surface Matching +********************************** -Surface Matching -================ +Introduction to Surface Matching +================================ -Cameras and similar devices with the capability of sensation of 3D structure are getting more common everyday. Thus, using depth and intensity information for matching 3D objects (or parts) are of crucial importance for computer vision. Applications range from industrial control to guiding everyday actions for visually impaired people. The task in recognition and pose estimation in range images aims to identify and localize a queried 3D free-form object by matching it to the acquired database. +Cameras and similar devices with the capability of sensation of 3D structure are becoming more common. Thus, using depth and intensity information for matching 3D objects (or parts) are of crucial importance for computer vision. Applications range from industrial control to guiding everyday actions for visually impaired people. The task in recognition and pose estimation in range images aims to identify and localize a queried 3D free-form object by matching it to the acquired database. -From an industrial perspective, enabling robots to automatically locate and pick up randomly placed and oriented objects from a bin is an important challenge in factory automation, replacing tedious and heavy manual labor. A system should be able to recognize and locate objects with a predefined shape and estimate the position with the precision necessary for a gripping robot to pick it up. This is where vision guided robotics takes the stage. Similar tools are also capable of guiding robots (and even people) through unstructured environments, leading to automated navigation. These properties make 3D matching from point clouds a ubiquitous necessity. Within this context, I will now describe OpenCV implementation of a 3D object recognition and pose estimation algorithm using 3D features. +From an industrial perspective, enabling robots to automatically locate and pick up randomly placed and oriented objects from a bin is an important challenge in factory automation, replacing tedious and heavy manual labor. A system should be able to recognize and locate objects with a predefined shape and estimate the position with the precision necessary for a gripping robot to pick it up. This is where vision guided robotics takes the stage. Similar tools are also capable of guiding robots (and even people) through unstructured environments, leading to automated navigation. These properties make 3D matching from point clouds a ubiquitous necessity. Within this context, I will now describe the OpenCV implementation of a 3D object recognition and pose estimation algorithm using 3D features. Surface Matching Algorithm Through 3D Features ============================================== -The state of the algorithms in order to achieve the task 3D matching heavily based on [drost2010]_, which is one of the first and main practical methods presented in this area. The approach is composed of extracting 3D feature points randomly from depth images or generic point clouds, indexing them and later in runtime querying them efficiently. Only the 3D structure is considered, and a trivial hash table is used for feature queries. +The state of the algorithms in order to achieve the task 3D matching is heavily based on [drost2010]_, which is one of the first and main practical methods presented in this area. The approach is composed of extracting 3D feature points randomly from depth images or generic point clouds, indexing them and later in runtime querying them efficiently. Only the 3D structure is considered, and a trivial hash table is used for feature queries. While being fully aware that utilization of the nice CAD model structure in order to achieve a smart point sampling, I will be leaving that aside now in order to respect the generalizability of the methods (Typically for such algorithms training on a CAD model is not needed, and a point cloud would be sufficient). Below is the outline of the entire algorithm: diff --git a/modules/text/samples/webcam_demo.cpp b/modules/text/samples/webcam_demo.cpp index 3042ee218..125ff0e56 100644 --- a/modules/text/samples/webcam_demo.cpp +++ b/modules/text/samples/webcam_demo.cpp @@ -191,7 +191,9 @@ int main(int argc, char* argv[]) { //Extract MSER vector > contours; - MSER(21,(int)(0.00002*grey.cols*grey.rows),(int)(0.05*grey.cols*grey.rows),1,0.7)(grey, contours); + vector bboxes; + Ptr mser = MSER::create(21,(int)(0.00002*grey.cols*grey.rows),(int)(0.05*grey.cols*grey.rows),1,0.7); + mser->detectRegions(grey, contours, bboxes); //Convert the output of MSER to suitable input for the grouping/recognition algorithms if (contours.size() > 0) diff --git a/modules/text/src/erfilter.cpp b/modules/text/src/erfilter.cpp index 82d172e8c..621e63232 100644 --- a/modules/text/src/erfilter.cpp +++ b/modules/text/src/erfilter.cpp @@ -1766,7 +1766,9 @@ static void NN_chain_core(const int_fast32_t N, double * const D, t_members * co for (i=active_nodes.start; i& selectedPairs = std::vector()); - FREAK( const FREAK& rhs ); - FREAK& operator=( const FREAK& ); - - virtual ~FREAK(); - - /** returns the descriptor length in bytes */ - virtual int descriptorSize() const; - - /** returns the descriptor type */ - virtual int descriptorType() const; - - /** returns the default norm type */ - virtual int defaultNorm() const; - - /** select the 512 "best description pairs" - * @param images grayscale images set - * @param keypoints set of detected keypoints - * @param corrThresh correlation threshold - * @param verbose print construction information - * @return list of best pair indexes - */ - std::vector selectPairs( const std::vector& images, std::vector >& keypoints, - const double corrThresh = 0.7, bool verbose = true ); - - AlgorithmInfo* info() const; enum { NB_SCALES = 64, NB_PAIRS = 512, NB_ORIENPAIRS = 45 }; -protected: - virtual void computeImpl( InputArray image, std::vector& keypoints, OutputArray descriptors ) const; - void buildPattern(); - - template - imgType meanIntensity( InputArray image, InputArray integral, const float kp_x, const float kp_y, - const unsigned int scale, const unsigned int rot, const unsigned int point ) const; - - template - void computeDescriptors( InputArray image, std::vector& keypoints, OutputArray descriptors ) const; - - template - void extractDescriptor(srcMatType *pointsValue, void ** ptr) const; - - bool orientationNormalized; //true if the orientation is normalized, false otherwise - bool scaleNormalized; //true if the scale is normalized, false otherwise - double patternScale; //scaling of the pattern - int nOctaves; //number of octaves - bool extAll; // true if all pairs need to be extracted for pairs selection - - double patternScale0; - int nOctaves0; - std::vector selectedPairs0; - - struct PatternPoint - { - float x; // x coordinate relative to center - float y; // x coordinate relative to center - float sigma; // Gaussian smoothing sigma - }; - - struct DescriptionPair - { - uchar i; // index of the first point - uchar j; // index of the second point - }; - - struct OrientationPair - { - uchar i; // index of the first point - uchar j; // index of the second point - int weight_dx; // dx/(norm_sq))*4096 - int weight_dy; // dy/(norm_sq))*4096 - }; - - std::vector patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation) - int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries) - DescriptionPair descriptionPairs[NB_PAIRS]; - OrientationPair orientationPairs[NB_ORIENPAIRS]; + static Ptr create(bool orientationNormalized = true, + bool scaleNormalized = true, + float patternScale = 22.0f, + int nOctaves = 4, + const std::vector& selectedPairs = std::vector()); }; @@ -155,63 +72,23 @@ protected: The class implements the keypoint detector introduced by K. Konolige. */ -class CV_EXPORTS_W StarDetector : public FeatureDetector +class CV_EXPORTS StarDetector : public FeatureDetector { public: //! the full constructor - CV_WRAP StarDetector(int _maxSize=45, int _responseThreshold=30, - int _lineThresholdProjected=10, - int _lineThresholdBinarized=8, - int _suppressNonmaxSize=5); - - //! finds the keypoints in the image - CV_WRAP_AS(detect) void operator()(const Mat& image, - CV_OUT std::vector& keypoints) const; - - AlgorithmInfo* info() const; - -protected: - void detectImpl( InputArray image, std::vector& keypoints, InputArray mask=noArray() ) const; - - int maxSize; - int responseThreshold; - int lineThresholdProjected; - int lineThresholdBinarized; - int suppressNonmaxSize; + static Ptr create(int maxSize=45, int responseThreshold=30, + int lineThresholdProjected=10, + int lineThresholdBinarized=8, + int suppressNonmaxSize=5); }; -typedef StarDetector StarFeatureDetector; - /* * BRIEF Descriptor */ class CV_EXPORTS BriefDescriptorExtractor : public DescriptorExtractor { public: - static const int PATCH_SIZE = 48; - static const int KERNEL_SIZE = 9; - - // bytes is a length of descriptor in bytes. It can be equal 16, 32 or 64 bytes. - BriefDescriptorExtractor( int bytes = 32 ); - - virtual void read( const FileNode& ); - virtual void write( FileStorage& ) const; - - virtual int descriptorSize() const; - virtual int descriptorType() const; - virtual int defaultNorm() const; - - /// @todo read and write for brief - - AlgorithmInfo* info() const; - -protected: - virtual void computeImpl(InputArray image, std::vector& keypoints, OutputArray descriptors) const; - - typedef void(*PixelTestFn)(InputArray, const std::vector&, OutputArray); - - int bytes_; - PixelTestFn test_fn_; + static Ptr create( int bytes = 32 ); }; } diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp index eaa60bc2b..6278bb246 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp @@ -58,45 +58,9 @@ namespace xfeatures2d class CV_EXPORTS_W SIFT : public Feature2D { public: - CV_WRAP explicit SIFT( int nfeatures = 0, int nOctaveLayers = 3, - double contrastThreshold = 0.04, double edgeThreshold = 10, - double sigma = 1.6); - - //! returns the descriptor size in floats (128) - CV_WRAP int descriptorSize() const; - - //! returns the descriptor type - CV_WRAP int descriptorType() const; - - //! returns the default norm type - CV_WRAP int defaultNorm() const; - - //! finds the keypoints using SIFT algorithm - void operator()(InputArray img, InputArray mask, - std::vector& keypoints) const; - //! finds the keypoints and computes descriptors for them using SIFT algorithm. - //! Optionally it can compute descriptors for the user-provided keypoints - void operator()(InputArray img, InputArray mask, - std::vector& keypoints, - OutputArray descriptors, - bool useProvidedKeypoints = false) const; - - AlgorithmInfo* info() const; - - void buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const; - void buildDoGPyramid( const std::vector& pyr, std::vector& dogpyr ) const; - void findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, - std::vector& keypoints ) const; - -protected: - void detectImpl( InputArray image, std::vector& keypoints, InputArray mask = noArray() ) const; - void computeImpl( InputArray image, std::vector& keypoints, OutputArray descriptors ) const; - - CV_PROP_RW int nfeatures; - CV_PROP_RW int nOctaveLayers; - CV_PROP_RW double contrastThreshold; - CV_PROP_RW double edgeThreshold; - CV_PROP_RW double sigma; + CV_WRAP static Ptr create( int nfeatures = 0, int nOctaveLayers = 3, + double contrastThreshold = 0.04, double edgeThreshold = 10, + double sigma = 1.6); }; typedef SIFT SiftFeatureDetector; @@ -110,42 +74,24 @@ typedef SIFT SiftDescriptorExtractor; class CV_EXPORTS_W SURF : public Feature2D { public: - //! the default constructor - CV_WRAP SURF(); - //! the full constructor taking all the necessary parameters - explicit CV_WRAP SURF(double hessianThreshold, - int nOctaves = 4, int nOctaveLayers = 2, - bool extended = true, bool upright = false); - - //! returns the descriptor size in float's (64 or 128) - CV_WRAP int descriptorSize() const; - - //! returns the descriptor type - CV_WRAP int descriptorType() const; - - //! returns the descriptor type - CV_WRAP int defaultNorm() const; - - //! finds the keypoints using fast hessian detector used in SURF - void operator()(InputArray img, InputArray mask, - CV_OUT std::vector& keypoints) const; - //! finds the keypoints and computes their descriptors. Optionally it can compute descriptors for the user-provided keypoints - void operator()(InputArray img, InputArray mask, - CV_OUT std::vector& keypoints, - OutputArray descriptors, - bool useProvidedKeypoints = false) const; - - AlgorithmInfo* info() const; - - CV_PROP_RW double hessianThreshold; - CV_PROP_RW int nOctaves; - CV_PROP_RW int nOctaveLayers; - CV_PROP_RW bool extended; - CV_PROP_RW bool upright; - -protected: - void detectImpl( InputArray image, std::vector& keypoints, InputArray mask = noArray() ) const; - void computeImpl( InputArray image, std::vector& keypoints, OutputArray descriptors ) const; + CV_WRAP static Ptr create(double hessianThreshold=100, + int nOctaves = 4, int nOctaveLayers = 3, + bool extended = false, bool upright = false); + + CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0; + CV_WRAP virtual double getHessianThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int nOctaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setExtended(bool extended) = 0; + CV_WRAP virtual bool getExtended() const = 0; + + CV_WRAP virtual void setUpright(bool upright) = 0; + CV_WRAP virtual bool getUpright() const = 0; }; typedef SURF SurfFeatureDetector; diff --git a/modules/xfeatures2d/perf/perf_surf.cpp b/modules/xfeatures2d/perf/perf_surf.cpp index 1fa6965ca..165c4bb2e 100644 --- a/modules/xfeatures2d/perf/perf_surf.cpp +++ b/modules/xfeatures2d/perf/perf_surf.cpp @@ -21,10 +21,10 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES)) Mat mask; declare.in(frame).time(90); - SURF detector; + Ptr detector = SURF::create(); vector points; - TEST_CYCLE() detector(frame, mask, points); + TEST_CYCLE() detector->detect(frame, points, mask); SANITY_CHECK_KEYPOINTS(points, 1e-3); } @@ -38,12 +38,12 @@ PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES)) Mat mask; declare.in(frame).time(90); - SURF detector; + Ptr detector = SURF::create(); vector points; vector descriptors; - detector(frame, mask, points); + detector->detect(frame, points, mask); - TEST_CYCLE() detector(frame, mask, points, descriptors, true); + TEST_CYCLE() detector->compute(frame, points, descriptors); SANITY_CHECK(descriptors, 1e-4); } @@ -56,11 +56,11 @@ PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES)) Mat mask; declare.in(frame).time(90); - SURF detector; + Ptr detector = SURF::create(); vector points; vector descriptors; - TEST_CYCLE() detector(frame, mask, points, descriptors, false); + TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false); SANITY_CHECK_KEYPOINTS(points, 1e-3); SANITY_CHECK(descriptors, 1e-4); diff --git a/modules/xfeatures2d/samples/bagofwords_classification.cpp b/modules/xfeatures2d/samples/bagofwords_classification.cpp index a327c1bce..3ad77ba66 100644 --- a/modules/xfeatures2d/samples/bagofwords_classification.cpp +++ b/modules/xfeatures2d/samples/bagofwords_classification.cpp @@ -2512,6 +2512,23 @@ static void computeGnuPlotOutput( const string& resPath, const string& objClassN vocData.savePrecRecallToGnuplot( resPath + plotsDir + "/" + plotFile, precision, recall, ap, objClassName, CV_VOC_PLOT_PNG ); } +static Ptr createByName(const String& name) +{ + if( name == "SIFT" ) + return SIFT::create(); + if( name == "SURF" ) + return SURF::create(); + if( name == "ORB" ) + return ORB::create(); + if( name == "BRISK" ) + return BRISK::create(); + if( name == "KAZE" ) + return KAZE::create(); + if( name == "AKAZE" ) + return AKAZE::create(); + return Ptr(); +} + int main(int argc, char** argv) { if( argc != 3 && argc != 6 ) @@ -2520,9 +2537,6 @@ int main(int argc, char** argv) return -1; } - initModule_features2d(); - initModule_xfeatures2d(); - const string vocPath = argv[1], resPath = argv[2]; // Read or set default parameters @@ -2563,8 +2577,13 @@ int main(int argc, char** argv) } // Create detector, descriptor, matcher. - Ptr featureDetector = FeatureDetector::create( ddmParams.detectorType ); - Ptr descExtractor = DescriptorExtractor::create( ddmParams.descriptorType ); + if( ddmParams.detectorType != ddmParams.descriptorType ) + { + cout << "detector and descriptor should be the same\n"; + return -1; + } + Ptr featureDetector = createByName( ddmParams.detectorType ); + Ptr descExtractor = featureDetector; Ptr bowExtractor; if( !featureDetector || !descExtractor ) { diff --git a/modules/xfeatures2d/samples/shape_transformation.cpp b/modules/xfeatures2d/samples/shape_transformation.cpp index e21160748..33a57ef93 100644 --- a/modules/xfeatures2d/samples/shape_transformation.cpp +++ b/modules/xfeatures2d/samples/shape_transformation.cpp @@ -34,20 +34,15 @@ int main(int argc, char** argv) return -1; } - // detecting keypoints - SurfFeatureDetector detector(5000); + // detecting keypoints & computing descriptors + Ptr surf = SURF::create(5000); vector keypoints1, keypoints2; - detector.detect(img1, keypoints1); - detector.detect(img2, keypoints2); - - // computing descriptors - SurfDescriptorExtractor extractor; Mat descriptors1, descriptors2; - extractor.compute(img1, keypoints1, descriptors1); - extractor.compute(img2, keypoints2, descriptors2); + surf->detectAndCompute(img1, Mat(), keypoints1, descriptors1); + surf->detectAndCompute(img2, Mat(), keypoints2, descriptors2); // matching descriptors - BFMatcher matcher(extractor.defaultNorm()); + BFMatcher matcher(surf->defaultNorm()); vector matches; matcher.match(descriptors1, descriptors2, matches); diff --git a/modules/xfeatures2d/samples/surf_matcher.cpp b/modules/xfeatures2d/samples/surf_matcher.cpp index beb3e3ba4..1c367f17a 100644 --- a/modules/xfeatures2d/samples/surf_matcher.cpp +++ b/modules/xfeatures2d/samples/surf_matcher.cpp @@ -35,18 +35,17 @@ static double getTime() return work_end /((double)getTickFrequency() )* 1000.; } -template struct SURFDetector { - KPDetector surf; + Ptr surf; SURFDetector(double hessian = 800.0) - :surf(hessian) { + surf = SURF::create(hessian); } template void operator()(const T& in, const T& mask, std::vector& pts, T& descriptors, bool useProvided = false) { - surf(in, mask, pts, descriptors, useProvided); + surf->detectAndCompute(in, mask, pts, descriptors, useProvided); } }; @@ -191,7 +190,7 @@ int main(int argc, char* argv[]) descriptors2 = _descriptors2.getMat(ACCESS_RW); //instantiate detectors/matchers - SURFDetector surf; + SURFDetector surf; SURFMatcher matcher; diff --git a/modules/xfeatures2d/samples/video_homography.cpp b/modules/xfeatures2d/samples/video_homography.cpp index b06975e23..d68eee506 100644 --- a/modules/xfeatures2d/samples/video_homography.cpp +++ b/modules/xfeatures2d/samples/video_homography.cpp @@ -123,7 +123,7 @@ int main(int ac, char ** av) return 1; } - BriefDescriptorExtractor brief(32); + Ptr brief = BriefDescriptorExtractor::create(32); VideoCapture capture; capture.open(atoi(av[1])); @@ -143,7 +143,7 @@ int main(int ac, char ** av) vector matches; - BFMatcher desc_matcher(brief.defaultNorm()); + BFMatcher desc_matcher(brief->defaultNorm()); vector train_pts, query_pts; vector train_kpts, query_kpts; @@ -154,7 +154,7 @@ int main(int ac, char ** av) bool ref_live = true; Mat train_desc, query_desc; - FastFeatureDetector detector(10, true); + Ptr detector = FastFeatureDetector::create(10, true); Mat H_prev = Mat::eye(3, 3, CV_32FC1); for (;;) @@ -165,9 +165,8 @@ int main(int ac, char ** av) cvtColor(frame, gray, COLOR_RGB2GRAY); - detector.detect(gray, query_kpts); //Find interest points - - brief.compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location + detector->detect(gray, query_kpts); //Find interest points + brief->compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location if (!train_kpts.empty()) { diff --git a/modules/xfeatures2d/src/brief.cpp b/modules/xfeatures2d/src/brief.cpp index 58d3d5c88..ec131cbfa 100644 --- a/modules/xfeatures2d/src/brief.cpp +++ b/modules/xfeatures2d/src/brief.cpp @@ -52,9 +52,41 @@ namespace cv namespace xfeatures2d { +/* + * BRIEF Descriptor + */ +class BriefDescriptorExtractorImpl : public BriefDescriptorExtractor +{ +public: + enum { PATCH_SIZE = 48, KERNEL_SIZE = 9 }; + + // bytes is a length of descriptor in bytes. It can be equal 16, 32 or 64 bytes. + BriefDescriptorExtractorImpl( int bytes = 32 ); + + virtual void read( const FileNode& ); + virtual void write( FileStorage& ) const; + + virtual int descriptorSize() const; + virtual int descriptorType() const; + virtual int defaultNorm() const; + + virtual void compute(InputArray image, std::vector& keypoints, OutputArray descriptors); + +protected: + typedef void(*PixelTestFn)(InputArray, const std::vector&, OutputArray); + + int bytes_; + PixelTestFn test_fn_; +}; + +Ptr BriefDescriptorExtractor::create( int bytes ) +{ + return makePtr(bytes); +} + inline int smoothedSum(const Mat& sum, const KeyPoint& pt, int y, int x) { - static const int HALF_KERNEL = BriefDescriptorExtractor::KERNEL_SIZE / 2; + static const int HALF_KERNEL = BriefDescriptorExtractorImpl::KERNEL_SIZE / 2; int img_y = (int)(pt.pt.y + 0.5) + y; int img_x = (int)(pt.pt.x + 0.5) + x; @@ -99,7 +131,7 @@ static void pixelTests64(InputArray _sum, const std::vector& keypoints } } -BriefDescriptorExtractor::BriefDescriptorExtractor(int bytes) : +BriefDescriptorExtractorImpl::BriefDescriptorExtractorImpl(int bytes) : bytes_(bytes), test_fn_(NULL) { switch (bytes) @@ -118,22 +150,22 @@ BriefDescriptorExtractor::BriefDescriptorExtractor(int bytes) : } } -int BriefDescriptorExtractor::descriptorSize() const +int BriefDescriptorExtractorImpl::descriptorSize() const { return bytes_; } -int BriefDescriptorExtractor::descriptorType() const +int BriefDescriptorExtractorImpl::descriptorType() const { return CV_8UC1; } -int BriefDescriptorExtractor::defaultNorm() const +int BriefDescriptorExtractorImpl::defaultNorm() const { return NORM_HAMMING; } -void BriefDescriptorExtractor::read( const FileNode& fn) +void BriefDescriptorExtractorImpl::read( const FileNode& fn) { int dSize = fn["descriptorSize"]; switch (dSize) @@ -153,12 +185,14 @@ void BriefDescriptorExtractor::read( const FileNode& fn) bytes_ = dSize; } -void BriefDescriptorExtractor::write( FileStorage& fs) const +void BriefDescriptorExtractorImpl::write( FileStorage& fs) const { fs << "descriptorSize" << bytes_; } -void BriefDescriptorExtractor::computeImpl(InputArray image, std::vector& keypoints, OutputArray descriptors) const +void BriefDescriptorExtractorImpl::compute(InputArray image, + std::vector& keypoints, + OutputArray descriptors) { // Construct integral image for fast smoothing (box filter) Mat sum; diff --git a/modules/xfeatures2d/src/freak.cpp b/modules/xfeatures2d/src/freak.cpp index 4eb7e5df4..dbb30d195 100644 --- a/modules/xfeatures2d/src/freak.cpp +++ b/modules/xfeatures2d/src/freak.cpp @@ -46,6 +46,99 @@ namespace cv namespace xfeatures2d { +/*! + FREAK implementation + */ +class FREAK_Impl : public FREAK +{ +public: + /** Constructor + * @param orientationNormalized enable orientation normalization + * @param scaleNormalized enable scale normalization + * @param patternScale scaling of the description pattern + * @param nbOctave number of octaves covered by the detected keypoints + * @param selectedPairs (optional) user defined selected pairs + */ + explicit FREAK_Impl( bool orientationNormalized = true, + bool scaleNormalized = true, + float patternScale = 22.0f, + int nOctaves = 4, + const std::vector& selectedPairs = std::vector()); + + virtual ~FREAK_Impl(); + + /** returns the descriptor length in bytes */ + virtual int descriptorSize() const; + + /** returns the descriptor type */ + virtual int descriptorType() const; + + /** returns the default norm type */ + virtual int defaultNorm() const; + + /** select the 512 "best description pairs" + * @param images grayscale images set + * @param keypoints set of detected keypoints + * @param corrThresh correlation threshold + * @param verbose print construction information + * @return list of best pair indexes + */ + std::vector selectPairs( const std::vector& images, std::vector >& keypoints, + const double corrThresh = 0.7, bool verbose = true ); + virtual void compute( InputArray image, std::vector& keypoints, OutputArray descriptors ); + +protected: + + void buildPattern(); + + template + imgType meanIntensity( InputArray image, InputArray integral, const float kp_x, const float kp_y, + const unsigned int scale, const unsigned int rot, const unsigned int point ); + + template + void computeDescriptors( InputArray image, std::vector& keypoints, OutputArray descriptors ); + + template + void extractDescriptor(srcMatType *pointsValue, void ** ptr); + + bool orientationNormalized; //true if the orientation is normalized, false otherwise + bool scaleNormalized; //true if the scale is normalized, false otherwise + double patternScale; //scaling of the pattern + int nOctaves; //number of octaves + bool extAll; // true if all pairs need to be extracted for pairs selection + + double patternScale0; + int nOctaves0; + std::vector selectedPairs0; + + struct PatternPoint + { + float x; // x coordinate relative to center + float y; // x coordinate relative to center + float sigma; // Gaussian smoothing sigma + }; + + struct DescriptionPair + { + uchar i; // index of the first point + uchar j; // index of the second point + }; + + struct OrientationPair + { + uchar i; // index of the first point + uchar j; // index of the second point + int weight_dx; // dx/(norm_sq))*4096 + int weight_dy; // dy/(norm_sq))*4096 + }; + + std::vector patternLookup; // look-up table for the pattern points (position+sigma of all points at all scales and orientation) + int patternSizes[NB_SCALES]; // size of the pattern at a specific scale (used to check if a point is within image boundaries) + DescriptionPair descriptionPairs[NB_PAIRS]; + OrientationPair orientationPairs[NB_ORIENPAIRS]; +}; + + static const double FREAK_LOG2 = 0.693147180559945; static const int FREAK_NB_ORIENTATION = 256; static const int FREAK_NB_POINTS = 43; @@ -55,7 +148,7 @@ static const int FREAK_NB_PAIRS = FREAK::NB_PAIRS; static const int FREAK_NB_ORIENPAIRS = FREAK::NB_ORIENPAIRS; // default pairs -static const int FREAK_DEF_PAIRS[FREAK::NB_PAIRS] = +static const int FREAK_DEF_PAIRS[FREAK_Impl::NB_PAIRS] = { 404,431,818,511,181,52,311,874,774,543,719,230,417,205,11, 560,149,265,39,306,165,857,250,8,61,15,55,717,44,412, @@ -108,7 +201,7 @@ struct sortMean } }; -void FREAK::buildPattern() +void FREAK_Impl::buildPattern() { if( patternScale == patternScale0 && nOctaves == nOctaves0 && !patternLookup.empty() ) return; @@ -229,7 +322,7 @@ void FREAK::buildPattern() } } -void FREAK::computeImpl( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) const +void FREAK_Impl::compute( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) { Mat image = _image.getMat(); if( image.empty() ) @@ -237,7 +330,7 @@ void FREAK::computeImpl( InputArray _image, std::vector& keypoints, Ou if( keypoints.empty() ) return; - ((FREAK*)this)->buildPattern(); + ((FREAK_Impl*)this)->buildPattern(); // Convert to gray if not already Mat grayImage = image; @@ -271,7 +364,7 @@ void FREAK::computeImpl( InputArray _image, std::vector& keypoints, Ou } template -void FREAK::extractDescriptor(srcMatType *pointsValue, void ** ptr) const +void FREAK_Impl::extractDescriptor(srcMatType *pointsValue, void ** ptr) { std::bitset** ptrScalar = (std::bitset**) ptr; @@ -293,7 +386,7 @@ void FREAK::extractDescriptor(srcMatType *pointsValue, void ** ptr) const #if CV_SSE2 template <> -void FREAK::extractDescriptor(uchar *pointsValue, void ** ptr) const +void FREAK_Impl::extractDescriptor(uchar *pointsValue, void ** ptr) { __m128i** ptrSSE = (__m128i**) ptr; @@ -352,7 +445,7 @@ void FREAK::extractDescriptor(uchar *pointsValue, void ** ptr) const #endif template -void FREAK::computeDescriptors( InputArray _image, std::vector& keypoints, OutputArray _descriptors ) const { +void FREAK_Impl::computeDescriptors( InputArray _image, std::vector& keypoints, OutputArray _descriptors ){ Mat image = _image.getMat(); Mat imgIntegral; @@ -529,12 +622,13 @@ void FREAK::computeDescriptors( InputArray _image, std::vector& keypoi // simply take average on a square patch, not even gaussian approx template -imgType FREAK::meanIntensity( InputArray _image, InputArray _integral, +imgType FREAK_Impl::meanIntensity( InputArray _image, InputArray _integral, const float kp_x, const float kp_y, const unsigned int scale, const unsigned int rot, - const unsigned int point) const { + const unsigned int point) +{ Mat image = _image.getMat(), integral = _integral.getMat(); // get point position in image const PatternPoint& FreakPoint = patternLookup[scale*FREAK_NB_ORIENTATION*FREAK_NB_POINTS + rot*FREAK_NB_POINTS + point]; @@ -584,7 +678,7 @@ imgType FREAK::meanIntensity( InputArray _image, InputArray _integral, } // pair selection algorithm from a set of training images and corresponding keypoints -std::vector FREAK::selectPairs(const std::vector& images +std::vector FREAK_Impl::selectPairs(const std::vector& images , std::vector >& keypoints , const double corrTresh , bool verbose ) @@ -599,7 +693,7 @@ std::vector FREAK::selectPairs(const std::vector& images for( size_t i = 0;i < images.size(); ++i ) { Mat descriptorsTmp; - computeImpl(images[i],keypoints[i],descriptorsTmp); + compute(images[i],keypoints[i],descriptorsTmp); descriptors.push_back(descriptorsTmp); } @@ -705,31 +799,41 @@ void FREAKImpl::drawPattern() // ------------------------------------------------- /* FREAK interface implementation */ -FREAK::FREAK( bool _orientationNormalized, bool _scaleNormalized +FREAK_Impl::FREAK_Impl( bool _orientationNormalized, bool _scaleNormalized , float _patternScale, int _nOctaves, const std::vector& _selectedPairs ) : orientationNormalized(_orientationNormalized), scaleNormalized(_scaleNormalized), patternScale(_patternScale), nOctaves(_nOctaves), extAll(false), nOctaves0(0), selectedPairs0(_selectedPairs) { } -FREAK::~FREAK() +FREAK_Impl::~FREAK_Impl() { } -int FREAK::descriptorSize() const +int FREAK_Impl::descriptorSize() const { return FREAK_NB_PAIRS / 8; // descriptor length in bytes } -int FREAK::descriptorType() const +int FREAK_Impl::descriptorType() const { return CV_8U; } -int FREAK::defaultNorm() const +int FREAK_Impl::defaultNorm() const { return NORM_HAMMING; } +Ptr FREAK::create(bool orientationNormalized, + bool scaleNormalized, + float patternScale, + int nOctaves, + const std::vector& selectedPairs) +{ + return makePtr(orientationNormalized, scaleNormalized, + patternScale, nOctaves, selectedPairs); +} + } } // END NAMESPACE CV diff --git a/modules/xfeatures2d/src/sift.cpp b/modules/xfeatures2d/src/sift.cpp index ca1f52337..4ed1e4142 100644 --- a/modules/xfeatures2d/src/sift.cpp +++ b/modules/xfeatures2d/src/sift.cpp @@ -111,6 +111,53 @@ namespace cv namespace xfeatures2d { +/*! + SIFT implementation. + + The class implements SIFT algorithm by D. Lowe. + */ +class SIFT_Impl : public SIFT +{ +public: + explicit SIFT_Impl( int nfeatures = 0, int nOctaveLayers = 3, + double contrastThreshold = 0.04, double edgeThreshold = 10, + double sigma = 1.6); + + //! returns the descriptor size in floats (128) + int descriptorSize() const; + + //! returns the descriptor type + int descriptorType() const; + + //! returns the default norm type + int defaultNorm() const; + + //! finds the keypoints and computes descriptors for them using SIFT algorithm. + //! Optionally it can compute descriptors for the user-provided keypoints + void detectAndCompute(InputArray img, InputArray mask, + std::vector& keypoints, + OutputArray descriptors, + bool useProvidedKeypoints = false); + + void buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const; + void buildDoGPyramid( const std::vector& pyr, std::vector& dogpyr ) const; + void findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, + std::vector& keypoints ) const; + +protected: + CV_PROP_RW int nfeatures; + CV_PROP_RW int nOctaveLayers; + CV_PROP_RW double contrastThreshold; + CV_PROP_RW double edgeThreshold; + CV_PROP_RW double sigma; +}; + +Ptr SIFT::create( int _nfeatures, int _nOctaveLayers, + double _contrastThreshold, double _edgeThreshold, double _sigma ) +{ + return makePtr(_nfeatures, _nOctaveLayers, _contrastThreshold, _edgeThreshold, _sigma); +} + /******************************* Defs and macros *****************************/ // default width of descriptor histogram array @@ -196,7 +243,7 @@ static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma } -void SIFT::buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const +void SIFT_Impl::buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOctaves ) const { std::vector sig(nOctaveLayers + 3); pyr.resize(nOctaves*(nOctaveLayers + 3)); @@ -236,7 +283,7 @@ void SIFT::buildGaussianPyramid( const Mat& base, std::vector& pyr, int nOc } -void SIFT::buildDoGPyramid( const std::vector& gpyr, std::vector& dogpyr ) const +void SIFT_Impl::buildDoGPyramid( const std::vector& gpyr, std::vector& dogpyr ) const { int nOctaves = (int)gpyr.size()/(nOctaveLayers + 3); dogpyr.resize( nOctaves*(nOctaveLayers + 2) ); @@ -434,7 +481,7 @@ static bool adjustLocalExtrema( const std::vector& dog_pyr, KeyPoint& kpt, // // Detects features at extrema in DoG scale space. Bad features are discarded // based on contrast and ratio of principal curvatures. -void SIFT::findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, +void SIFT_Impl::findScaleSpaceExtrema( const std::vector& gauss_pyr, const std::vector& dog_pyr, std::vector& keypoints ) const { int nOctaves = (int)gauss_pyr.size()/(nOctaveLayers + 3); @@ -687,40 +734,33 @@ static void calcDescriptors(const std::vector& gpyr, const std::vector& keypoints) const -{ - (*this)(_image, _mask, keypoints, noArray()); -} - - -void SIFT::operator()(InputArray _image, InputArray _mask, +void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask, std::vector& keypoints, OutputArray _descriptors, - bool useProvidedKeypoints) const + bool useProvidedKeypoints) { int firstOctave = -1, actualNOctaves = 0, actualNLayers = 0; Mat image = _image.getMat(), mask = _mask.getMat(); @@ -805,15 +845,5 @@ void SIFT::operator()(InputArray _image, InputArray _mask, } } -void SIFT::detectImpl( InputArray image, std::vector& keypoints, InputArray mask) const -{ - (*this)(image.getMat(), mask.getMat(), keypoints, noArray()); -} - -void SIFT::computeImpl( InputArray image, std::vector& keypoints, OutputArray descriptors) const -{ - (*this)(image, Mat(), keypoints, descriptors, true); -} - } } diff --git a/modules/xfeatures2d/src/stardetector.cpp b/modules/xfeatures2d/src/stardetector.cpp index 0233d792e..91df25f67 100644 --- a/modules/xfeatures2d/src/stardetector.cpp +++ b/modules/xfeatures2d/src/stardetector.cpp @@ -46,6 +46,43 @@ namespace cv namespace xfeatures2d { +/*! + The "Star" Detector. + + The class implements the keypoint detector introduced by K. Konolige. + */ +class StarDetectorImpl : public StarDetector +{ +public: + //! the full constructor + StarDetectorImpl(int _maxSize=45, int _responseThreshold=30, + int _lineThresholdProjected=10, + int _lineThresholdBinarized=8, + int _suppressNonmaxSize=5); + + void detect( InputArray image, std::vector& keypoints, InputArray mask=noArray() ); + +protected: + int maxSize; + int responseThreshold; + int lineThresholdProjected; + int lineThresholdBinarized; + int suppressNonmaxSize; +}; + +Ptr StarDetector::create(int _maxSize, + int _responseThreshold, + int _lineThresholdProjected, + int _lineThresholdBinarized, + int _suppressNonmaxSize) +{ + return makePtr(_maxSize, _responseThreshold, + _lineThresholdProjected, + _lineThresholdBinarized, + _suppressNonmaxSize); +} + + template static void computeIntegralImages( const Mat& matI, Mat& matS, Mat& matT, Mat& _FT, int iiType ) @@ -432,7 +469,7 @@ StarDetectorSuppressNonmax( const Mat& responses, const Mat& sizes, } } -StarDetector::StarDetector(int _maxSize, int _responseThreshold, +StarDetectorImpl::StarDetectorImpl(int _maxSize, int _responseThreshold, int _lineThresholdProjected, int _lineThresholdBinarized, int _suppressNonmaxSize) @@ -443,32 +480,32 @@ StarDetector::StarDetector(int _maxSize, int _responseThreshold, {} -void StarDetector::detectImpl( InputArray _image, std::vector& keypoints, InputArray _mask ) const +void StarDetectorImpl::detect( InputArray _image, std::vector& keypoints, InputArray _mask ) { Mat image = _image.getMat(), mask = _mask.getMat(), grayImage = image; + if( image.empty() ) + { + keypoints.clear(); + return; + } if( image.channels() > 1 ) cvtColor( image, grayImage, COLOR_BGR2GRAY ); - (*this)(grayImage, keypoints); - KeyPointsFilter::runByPixelsMask( keypoints, mask ); -} - -void StarDetector::operator()(const Mat& img, std::vector& keypoints) const -{ Mat responses, sizes; int border; // Use 32-bit integers if we won't overflow in the integral image - if ((img.depth() == CV_8U || img.depth() == CV_8S) && - (img.rows * img.cols) < 8388608 ) // 8388608 = 2 ^ (32 - 8(bit depth) - 1(sign bit)) - border = StarDetectorComputeResponses( img, responses, sizes, maxSize, CV_32S ); + if ((grayImage.depth() == CV_8U || grayImage.depth() == CV_8S) && + (int)grayImage.total() < 8388608 ) // 8388608 = 2 ^ (32 - 8(bit depth) - 1(sign bit)) + border = StarDetectorComputeResponses( grayImage, responses, sizes, maxSize, CV_32S ); else - border = StarDetectorComputeResponses( img, responses, sizes, maxSize, CV_64F ); + border = StarDetectorComputeResponses( grayImage, responses, sizes, maxSize, CV_64F ); keypoints.clear(); if( border >= 0 ) StarDetectorSuppressNonmax( responses, sizes, keypoints, border, - responseThreshold, lineThresholdProjected, - lineThresholdBinarized, suppressNonmaxSize ); + responseThreshold, lineThresholdProjected, + lineThresholdBinarized, suppressNonmaxSize ); + KeyPointsFilter::runByPixelsMask( keypoints, mask ); } } diff --git a/modules/xfeatures2d/src/surf.cpp b/modules/xfeatures2d/src/surf.cpp index 7a985211f..673817e73 100644 --- a/modules/xfeatures2d/src/surf.cpp +++ b/modules/xfeatures2d/src/surf.cpp @@ -867,16 +867,7 @@ struct SURFInvoker : ParallelLoopBody }; -SURF::SURF() -{ - hessianThreshold = 100; - extended = false; - upright = false; - nOctaves = 4; - nOctaveLayers = 3; -} - -SURF::SURF(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, bool _upright) +SURF_Impl::SURF_Impl(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, bool _upright) { hessianThreshold = _threshold; extended = _extended; @@ -885,20 +876,15 @@ SURF::SURF(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, nOctaveLayers = _nOctaveLayers; } -int SURF::descriptorSize() const { return extended ? 128 : 64; } -int SURF::descriptorType() const { return CV_32F; } -int SURF::defaultNorm() const { return NORM_L2; } +int SURF_Impl::descriptorSize() const { return extended ? 128 : 64; } +int SURF_Impl::descriptorType() const { return CV_32F; } +int SURF_Impl::defaultNorm() const { return NORM_L2; } -void SURF::operator()(InputArray imgarg, InputArray maskarg, - CV_OUT std::vector& keypoints) const -{ - (*this)(imgarg, maskarg, keypoints, noArray(), false); -} -void SURF::operator()(InputArray _img, InputArray _mask, +void SURF_Impl::detectAndCompute(InputArray _img, InputArray _mask, CV_OUT std::vector& keypoints, OutputArray _descriptors, - bool useProvidedKeypoints) const + bool useProvidedKeypoints) { int imgtype = _img.type(), imgcn = CV_MAT_CN(imgtype); bool doDescriptors = _descriptors.needed(); @@ -1012,17 +998,11 @@ void SURF::operator()(InputArray _img, InputArray _mask, } } - -void SURF::detectImpl( InputArray image, std::vector& keypoints, InputArray mask) const +Ptr SURF::create(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, bool _upright) { - (*this)(image.getMat(), mask.getMat(), keypoints, noArray(), false); + return makePtr(_threshold, _nOctaves, _nOctaveLayers, _extended, _upright); } - -void SURF::computeImpl( InputArray image, std::vector& keypoints, OutputArray descriptors) const -{ - (*this)(image, Mat(), keypoints, descriptors, true); -} - + } } diff --git a/modules/xfeatures2d/src/surf.hpp b/modules/xfeatures2d/src/surf.hpp index 9438ac66c..2c4e271f2 100644 --- a/modules/xfeatures2d/src/surf.hpp +++ b/modules/xfeatures2d/src/surf.hpp @@ -10,6 +10,59 @@ namespace xfeatures2d //! Speeded up robust features, port from CUDA module. ////////////////////////////////// SURF ////////////////////////////////////////// +/*! + SURF implementation. + + The class implements SURF algorithm by H. Bay et al. + */ +class SURF_Impl : public SURF +{ +public: + //! the full constructor taking all the necessary parameters + explicit CV_WRAP SURF_Impl(double hessianThreshold, + int nOctaves = 4, int nOctaveLayers = 2, + bool extended = true, bool upright = false); + + //! returns the descriptor size in float's (64 or 128) + CV_WRAP int descriptorSize() const; + + //! returns the descriptor type + CV_WRAP int descriptorType() const; + + //! returns the descriptor type + CV_WRAP int defaultNorm() const; + + void set(int, double); + double get(int) const; + + //! finds the keypoints and computes their descriptors. + // Optionally it can compute descriptors for the user-provided keypoints + void detectAndCompute(InputArray img, InputArray mask, + CV_OUT std::vector& keypoints, + OutputArray descriptors, + bool useProvidedKeypoints = false); + + void setHessianThreshold(double hessianThreshold_) { hessianThreshold = hessianThreshold_; } + double getHessianThreshold() const { return hessianThreshold; } + + void setNOctaves(int nOctaves_) { nOctaves = nOctaves_; } + int getNOctaves() const { return nOctaves; } + + void setNOctaveLayers(int nOctaveLayers_) { nOctaveLayers = nOctaveLayers_; } + int getNOctaveLayers() const { return nOctaveLayers; } + + void setExtended(bool extended_) { extended = extended_; } + bool getExtended() const { return extended; } + + void setUpright(bool upright_) { upright = upright_; } + bool getUpright() const { return upright; } + + double hessianThreshold; + int nOctaves; + int nOctaveLayers; + bool extended; + bool upright; +}; class SURF_OCL { @@ -29,7 +82,7 @@ public: //! the full constructor taking all the necessary parameters SURF_OCL(); - bool init(const SURF* params); + bool init(const SURF_Impl* params); //! returns the descriptor size in float's (64 or 128) int descriptorSize() const { return params->extended ? 128 : 64; } @@ -71,7 +124,7 @@ protected: bool detectKeypoints(UMat &keypoints); - const SURF* params; + const SURF_Impl* params; //! max keypoints = min(keypointsRatio * img.size().area(), 65535) UMat sum, intBuffer; diff --git a/modules/xfeatures2d/src/surf.ocl.cpp b/modules/xfeatures2d/src/surf.ocl.cpp index f2057162c..b12ebd319 100644 --- a/modules/xfeatures2d/src/surf.ocl.cpp +++ b/modules/xfeatures2d/src/surf.ocl.cpp @@ -79,7 +79,7 @@ SURF_OCL::SURF_OCL() status = -1; } -bool SURF_OCL::init(const SURF* p) +bool SURF_OCL::init(const SURF_Impl* p) { params = p; if(status < 0) diff --git a/modules/xfeatures2d/src/xfeatures2d_init.cpp b/modules/xfeatures2d/src/xfeatures2d_init.cpp index 9db5c83fd..317867a59 100644 --- a/modules/xfeatures2d/src/xfeatures2d_init.cpp +++ b/modules/xfeatures2d/src/xfeatures2d_init.cpp @@ -41,59 +41,3 @@ //M*/ #include "precomp.hpp" - -namespace cv -{ -namespace xfeatures2d -{ - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF", - obj.info()->addParam(obj, "bytes", obj.bytes_)) - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CV_INIT_ALGORITHM(StarDetector, "Feature2D.STAR", - obj.info()->addParam(obj, "maxSize", obj.maxSize); - obj.info()->addParam(obj, "responseThreshold", obj.responseThreshold); - obj.info()->addParam(obj, "lineThresholdProjected", obj.lineThresholdProjected); - obj.info()->addParam(obj, "lineThresholdBinarized", obj.lineThresholdBinarized); - obj.info()->addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize)) - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CV_INIT_ALGORITHM(FREAK, "Feature2D.FREAK", - obj.info()->addParam(obj, "orientationNormalized", obj.orientationNormalized); - obj.info()->addParam(obj, "scaleNormalized", obj.scaleNormalized); - obj.info()->addParam(obj, "patternScale", obj.patternScale); - obj.info()->addParam(obj, "nbOctave", obj.nOctaves)) - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CV_INIT_ALGORITHM(SURF, "Feature2D.SURF", - obj.info()->addParam(obj, "hessianThreshold", obj.hessianThreshold); - obj.info()->addParam(obj, "nOctaves", obj.nOctaves); - obj.info()->addParam(obj, "nOctaveLayers", obj.nOctaveLayers); - obj.info()->addParam(obj, "extended", obj.extended); - obj.info()->addParam(obj, "upright", obj.upright)) - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CV_INIT_ALGORITHM(SIFT, "Feature2D.SIFT", - obj.info()->addParam(obj, "nFeatures", obj.nfeatures); - obj.info()->addParam(obj, "nOctaveLayers", obj.nOctaveLayers); - obj.info()->addParam(obj, "contrastThreshold", obj.contrastThreshold); - obj.info()->addParam(obj, "edgeThreshold", obj.edgeThreshold); - obj.info()->addParam(obj, "sigma", obj.sigma)) - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool initModule_xfeatures2d(void) -{ - Ptr sift = createSIFT_ptr_hidden(), surf = createSURF_ptr_hidden(); - return sift->info() != 0 && surf->info() != 0; -} - -} -} diff --git a/modules/xfeatures2d/test/test_detectors.cpp b/modules/xfeatures2d/test/test_detectors.cpp index e93a20d6e..72f5539ed 100644 --- a/modules/xfeatures2d/test/test_detectors.cpp +++ b/modules/xfeatures2d/test/test_detectors.cpp @@ -61,7 +61,7 @@ public: ~CV_DetectorsTest(); protected: void run(int); - template bool testDetector(const Mat& img, const T& detector, vector& expected); + bool testDetector(const Mat& img, Ptr detector, vector& expected); void LoadExpected(const string& file, vector& out); }; @@ -153,10 +153,10 @@ struct WrapPoint struct sortByR { bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) { return norm(kp1.pt) < norm(kp2.pt); } }; -template bool CV_DetectorsTest::testDetector(const Mat& img, const T& detector, vector& exp) +bool CV_DetectorsTest::testDetector(const Mat& img, Ptr detector, vector& exp) { vector orig_kpts; - detector(img, orig_kpts); + detector->detect(img, orig_kpts); typedef void (*TransfFunc )(const Mat&, Mat&, Mat& FransfFunc); const TransfFunc transfFunc[] = { getRotation, getZoom, getBlur, getBrightness }; @@ -173,7 +173,7 @@ template bool CV_DetectorsTest::testDetector(const Mat& img, const T& for(size_t i = 0; i < case_num; ++i) { transfFunc[i](img, affs[i], new_imgs[i]); - detector(new_imgs[i], new_kpts[i]); + detector->detect(new_imgs[i], new_kpts[i]); transform(orig_kpts.begin(), orig_kpts.end(), back_inserter(transf_kpts[i]), WrapPoint(affs[i])); //show(names[i], new_imgs[i], new_kpts[i], transf_kpts[i]); } @@ -253,14 +253,6 @@ template bool CV_DetectorsTest::testDetector(const Mat& img, const T& return true; } -struct SurfNoMaskWrap -{ - const SURF& detector; - SurfNoMaskWrap(const SURF& surf) : detector(surf) {} - SurfNoMaskWrap& operator=(const SurfNoMaskWrap&); - void operator()(const Mat& img, vector& kpts) const { detector(img, Mat(), kpts); } -}; - void CV_DetectorsTest::LoadExpected(const string& file, vector& out) { Mat mat_exp; @@ -298,14 +290,14 @@ void CV_DetectorsTest::run( int /*start_from*/ ) if (exp.empty()) return; - if (!testDetector(to_test, SurfNoMaskWrap(SURF(1536+512+512, 2)), exp)) + if (!testDetector(to_test, SURF::create(1536+512+512, 2, 2, true, false), exp)) return; LoadExpected(string(ts->get_data_path()) + "detectors/star.xml", exp); if (exp.empty()) return; - if (!testDetector(to_test, StarDetector(45, 30, 10, 8, 5), exp)) + if (!testDetector(to_test, StarDetector::create(45, 30, 10, 8, 5), exp)) return; ts->set_failed_test_info( cvtest::TS::OK); diff --git a/modules/xfeatures2d/test/test_features2d.cpp b/modules/xfeatures2d/test/test_features2d.cpp index 81ba8da18..d5f001ce1 100644 --- a/modules/xfeatures2d/test/test_features2d.cpp +++ b/modules/xfeatures2d/test/test_features2d.cpp @@ -449,8 +449,8 @@ protected: fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE ); if( fs.isOpened() ) { - SurfFeatureDetector fd; - fd.detect(img, keypoints); + Ptr fd = SURF::create(); + fd->detect(img, keypoints); write( fs, "keypoints", keypoints ); } else @@ -977,19 +977,19 @@ void CV_DescriptorMatcherTest::run( int ) TEST( Features2d_Detector_SIFT, regression ) { - CV_FeatureDetectorTest test( "detector-sift", FeatureDetector::create("SIFT") ); + CV_FeatureDetectorTest test( "detector-sift", SIFT::create() ); test.safe_run(); } TEST( Features2d_Detector_SURF, regression ) { - CV_FeatureDetectorTest test( "detector-surf", FeatureDetector::create("SURF") ); + CV_FeatureDetectorTest test( "detector-surf", SURF::create() ); test.safe_run(); } TEST( Features2d_Detector_STAR, regression ) { - CV_FeatureDetectorTest test( "detector-star", FeatureDetector::create("STAR") ); + CV_FeatureDetectorTest test( "detector-star", StarDetector::create() ); test.safe_run(); } @@ -999,14 +999,14 @@ TEST( Features2d_Detector_STAR, regression ) TEST( Features2d_DescriptorExtractor_SIFT, regression ) { CV_DescriptorExtractorTest > test( "descriptor-sift", 0.03f, - DescriptorExtractor::create("SIFT") ); + SIFT::create() ); test.safe_run(); } TEST( Features2d_DescriptorExtractor_SURF, regression ) { CV_DescriptorExtractorTest > test( "descriptor-surf", 0.05f, - DescriptorExtractor::create("SURF") ); + SURF::create() ); test.safe_run(); } @@ -1014,14 +1014,14 @@ TEST( Features2d_DescriptorExtractor_FREAK, regression ) { // TODO adjust the parameters below CV_DescriptorExtractorTest test( "descriptor-freak", (CV_DescriptorExtractorTest::DistanceType)12.f, - DescriptorExtractor::create("FREAK") ); + FREAK::create() ); test.safe_run(); } TEST( Features2d_DescriptorExtractor_BRIEF, regression ) { CV_DescriptorExtractorTest test( "descriptor-brief", 1, - DescriptorExtractor::create("BRIEF") ); + BriefDescriptorExtractor::create() ); test.safe_run(); } @@ -1049,10 +1049,10 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression) const int sz = 100; const int k = 3; - Ptr ext = DescriptorExtractor::create("SURF"); + Ptr ext = SURF::create(); ASSERT_TRUE(ext != NULL); - Ptr det = FeatureDetector::create("SURF"); + Ptr det = SURF::create(); //"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n" ASSERT_TRUE(det != NULL); @@ -1104,13 +1104,13 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression) class CV_DetectPlanarTest : public cvtest::BaseTest { public: - CV_DetectPlanarTest(const string& _fname, int _min_ninliers) : fname(_fname), min_ninliers(_min_ninliers) {} + CV_DetectPlanarTest(const string& _fname, int _min_ninliers, const Ptr& _f2d) + : fname(_fname), min_ninliers(_min_ninliers), f2d(_f2d) {} protected: void run(int) { - Ptr f = Algorithm::create("Feature2D." + fname); - if(!f) + if(f2d.empty()) return; string path = string(ts->get_data_path()) + "detectors_descriptors_evaluation/planar/"; string imgname1 = path + "box.png"; @@ -1125,15 +1125,15 @@ protected: } vector kpt1, kpt2; Mat d1, d2; - f->operator()(img1, Mat(), kpt1, d1); - f->operator()(img1, Mat(), kpt2, d2); + f2d->detectAndCompute(img1, Mat(), kpt1, d1); + f2d->detectAndCompute(img1, Mat(), kpt2, d2); for( size_t i = 0; i < kpt1.size(); i++ ) CV_Assert(kpt1[i].response > 0 ); for( size_t i = 0; i < kpt2.size(); i++ ) CV_Assert(kpt2[i].response > 0 ); vector matches; - BFMatcher(f->defaultNorm(), true).match(d1, d2, matches); + BFMatcher(f2d->defaultNorm(), true).match(d1, d2, matches); vector pt1, pt2; for( size_t i = 0; i < matches.size(); i++ ) { @@ -1154,10 +1154,11 @@ protected: string fname; int min_ninliers; + Ptr f2d; }; -TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80); test.safe_run(); } -TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80); test.safe_run(); } +TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); } +TEST(Features2d_SURFHomographyTest, regression) { CV_DetectPlanarTest test("SURF", 80, SURF::create()); test.safe_run(); } class FeatureDetectorUsingMaskTest : public cvtest::BaseTest { @@ -1222,12 +1223,12 @@ protected: TEST(Features2d_SIFT_using_mask, regression) { - FeatureDetectorUsingMaskTest test(Algorithm::create("Feature2D.SIFT")); + FeatureDetectorUsingMaskTest test(SIFT::create()); test.safe_run(); } TEST(DISABLED_Features2d_SURF_using_mask, regression) { - FeatureDetectorUsingMaskTest test(Algorithm::create("Feature2D.SURF")); + FeatureDetectorUsingMaskTest test(SURF::create()); test.safe_run(); } diff --git a/modules/xfeatures2d/test/test_keypoints.cpp b/modules/xfeatures2d/test/test_keypoints.cpp index 03eea8a88..e714331a4 100644 --- a/modules/xfeatures2d/test/test_keypoints.cpp +++ b/modules/xfeatures2d/test/test_keypoints.cpp @@ -55,13 +55,12 @@ const string IMAGE_FILENAME = "tsukuba.png"; class CV_FeatureDetectorKeypointsTest : public cvtest::BaseTest { public: - CV_FeatureDetectorKeypointsTest(const Ptr& _detector) : + explicit CV_FeatureDetectorKeypointsTest(const Ptr& _detector) : detector(_detector) {} protected: virtual void run(int) { - cv::initModule_features2d(); CV_Assert(detector); string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME; @@ -113,7 +112,7 @@ protected: ts->set_failed_test_info(cvtest::TS::OK); } - Ptr detector; + Ptr detector; }; @@ -121,18 +120,18 @@ protected: TEST(Features2d_Detector_Keypoints_SURF, validation) { - CV_FeatureDetectorKeypointsTest test(Algorithm::create("Feature2D.SURF")); + CV_FeatureDetectorKeypointsTest test(xfeatures2d::SURF::create()); test.safe_run(); } TEST(Features2d_Detector_Keypoints_SIFT, validation) { - CV_FeatureDetectorKeypointsTest test(FeatureDetector::create("SIFT")); + CV_FeatureDetectorKeypointsTest test(xfeatures2d::SIFT::create()); test.safe_run(); } TEST(Features2d_Detector_Keypoints_Star, validation) { - CV_FeatureDetectorKeypointsTest test(Algorithm::create("Feature2D.STAR")); + CV_FeatureDetectorKeypointsTest test(xfeatures2d::StarDetector::create()); test.safe_run(); } diff --git a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp index c0d7c531b..46d328205 100644 --- a/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp @@ -616,7 +616,7 @@ protected: */ TEST(Features2d_RotationInvariance_Detector_SURF, regression) { - DetectorRotationInvarianceTest test(Algorithm::create("Feature2D.SURF"), + DetectorRotationInvarianceTest test(SURF::create(), 0.44f, 0.76f); test.safe_run(); @@ -624,7 +624,7 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression) TEST(Features2d_RotationInvariance_Detector_SIFT, DISABLED_regression) { - DetectorRotationInvarianceTest test(Algorithm::create("Feature2D.SIFT"), + DetectorRotationInvarianceTest test(SIFT::create(), 0.45f, 0.70f); test.safe_run(); @@ -635,8 +635,8 @@ TEST(Features2d_RotationInvariance_Detector_SIFT, DISABLED_regression) */ TEST(Features2d_RotationInvariance_Descriptor_SURF, regression) { - DescriptorRotationInvarianceTest test(Algorithm::create("Feature2D.SURF"), - Algorithm::create("Feature2D.SURF"), + DescriptorRotationInvarianceTest test(SURF::create(), + SURF::create(), NORM_L1, 0.83f); test.safe_run(); @@ -644,8 +644,8 @@ TEST(Features2d_RotationInvariance_Descriptor_SURF, regression) TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression) { - DescriptorRotationInvarianceTest test(Algorithm::create("Feature2D.SIFT"), - Algorithm::create("Feature2D.SIFT"), + DescriptorRotationInvarianceTest test(SIFT::create(), + SIFT::create(), NORM_L1, 0.98f); test.safe_run(); @@ -656,7 +656,7 @@ TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression) */ TEST(Features2d_ScaleInvariance_Detector_SURF, regression) { - DetectorScaleInvarianceTest test(Algorithm::create("Feature2D.SURF"), + DetectorScaleInvarianceTest test(SURF::create(), 0.64f, 0.84f); test.safe_run(); @@ -664,7 +664,7 @@ TEST(Features2d_ScaleInvariance_Detector_SURF, regression) TEST(Features2d_ScaleInvariance_Detector_SIFT, regression) { - DetectorScaleInvarianceTest test(Algorithm::create("Feature2D.SIFT"), + DetectorScaleInvarianceTest test(SIFT::create(), 0.69f, 0.99f); test.safe_run(); @@ -675,8 +675,8 @@ TEST(Features2d_ScaleInvariance_Detector_SIFT, regression) */ TEST(Features2d_ScaleInvariance_Descriptor_SURF, regression) { - DescriptorScaleInvarianceTest test(Algorithm::create("Feature2D.SURF"), - Algorithm::create("Feature2D.SURF"), + DescriptorScaleInvarianceTest test(SURF::create(), + SURF::create(), NORM_L1, 0.61f); test.safe_run(); @@ -684,8 +684,8 @@ TEST(Features2d_ScaleInvariance_Descriptor_SURF, regression) TEST(Features2d_ScaleInvariance_Descriptor_SIFT, regression) { - DescriptorScaleInvarianceTest test(Algorithm::create("Feature2D.SIFT"), - Algorithm::create("Feature2D.SIFT"), + DescriptorScaleInvarianceTest test(SIFT::create(), + SIFT::create(), NORM_L1, 0.78f); test.safe_run(); @@ -698,11 +698,10 @@ TEST(Features2d_RotationInvariance2_Detector_SURF, regression) line(cross, Point(30, 50), Point(69, 50), Scalar(100), 3); line(cross, Point(50, 30), Point(50, 69), Scalar(100), 3); - SURF surf(8000., 3, 4, true, false); + Ptr surf = SURF::create(8000., 3, 4, true, false); vector keypoints; - - surf(cross, noArray(), keypoints); + surf->detect(cross, keypoints); ASSERT_EQ(keypoints.size(), (vector::size_type) 5); ASSERT_LT( fabs(keypoints[1].response - keypoints[2].response), 1e-6);