Commit 7ba5974bcf0c701deff108296f947a5707458e04
1 parent
3f8f0728
removed likely
Showing
4 changed files
with
0 additions
and
204 deletions
openbr/plugins/cmake/likely.cmake deleted
| 1 | -set(BR_WITH_LIKELY OFF CACHE BOOL "Build with Likely") | |
| 2 | - | |
| 3 | -if(${BR_WITH_LIKELY}) | |
| 4 | - find_package(Likely REQUIRED) | |
| 5 | - set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Likely_LIBS}) | |
| 6 | -else() | |
| 7 | - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/core/likely.cpp) | |
| 8 | - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/format/lm.cpp) | |
| 9 | - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/gallery/lm.cpp) | |
| 10 | -endif() |
openbr/plugins/core/likely.cpp deleted
| 1 | -#include <openbr/plugins/openbr_internal.h> | |
| 2 | -#include <openbr/core/qtutils.h> | |
| 3 | - | |
| 4 | -#include <likely.h> | |
| 5 | -#include <likely/opencv.hpp> | |
| 6 | - | |
| 7 | -namespace br | |
| 8 | -{ | |
| 9 | - | |
| 10 | -/*! | |
| 11 | - * \ingroup transforms | |
| 12 | - * \brief Generic interface to Likely JIT compiler | |
| 13 | - * \br_link Homepage http://liblikely.org | |
| 14 | - * \br_link API Documentation https://s3.amazonaws.com/liblikely/doxygen/index.html | |
| 15 | - * \author Josh Klontz \cite jklontz | |
| 16 | - */ | |
| 17 | -class LikelyTransform : public Transform | |
| 18 | -{ | |
| 19 | - Q_OBJECT | |
| 20 | - Q_PROPERTY(QString sourceFile READ get_sourceFile WRITE set_sourceFile RESET reset_sourceFile STORED false) | |
| 21 | - BR_PROPERTY(QString, sourceFile, "") | |
| 22 | - | |
| 23 | - QByteArray bitcode; | |
| 24 | - likely_env env; | |
| 25 | - | |
| 26 | - typedef likely_mat (*Function)(likely_const_mat); | |
| 27 | - Function function; | |
| 28 | - | |
| 29 | - ~LikelyTransform() | |
| 30 | - { | |
| 31 | - likely_release_env(env); | |
| 32 | - } | |
| 33 | - | |
| 34 | - void compile() | |
| 35 | - { | |
| 36 | - const likely_const_mat data = likely_new(likely_u8 | likely_multi_channel, bitcode.size(), 1, 1, 1, bitcode.data()); | |
| 37 | - env = likely_precompiled(data, qPrintable(QFileInfo(sourceFile).baseName())); | |
| 38 | - function = (Function) likely_function(env->expr); | |
| 39 | - if (!function) | |
| 40 | - qFatal("Failed to compile: %s", qPrintable(sourceFile)); | |
| 41 | - } | |
| 42 | - | |
| 43 | - void train(const TemplateList &trainingData) | |
| 44 | - { | |
| 45 | - const likely_type source_file_type = likely_guess_file_type(qPrintable(sourceFile)); | |
| 46 | - const likely_const_mat source_code = likely_read(qPrintable(sourceFile), source_file_type, likely_void); | |
| 47 | - const likely_const_mat data = likelyFromOpenCVMats(trainingData.data().toVector().toStdVector()); | |
| 48 | - | |
| 49 | - // Pick settings to minimize code size | |
| 50 | - likely_settings settings = likely_default_settings(likely_file_bitcode, false); | |
| 51 | - settings.runtime_only = true; // The compiled algorithm should not depend on any external functions, | |
| 52 | - // except for those in the likely runtime API. | |
| 53 | - | |
| 54 | - // Construct a compilation environment | |
| 55 | - likely_mat output = NULL; | |
| 56 | - likely_const_env parent = likely_standard(settings, &output, likely_file_bitcode); | |
| 57 | - | |
| 58 | - { // Define the `data` variable | |
| 59 | - const likely_const_env env = likely_define("data", data, parent); | |
| 60 | - likely_release_env(parent); | |
| 61 | - parent = env; | |
| 62 | - } | |
| 63 | - | |
| 64 | - likely_release_env(likely_lex_parse_and_eval(source_code->data, source_file_type, parent)); | |
| 65 | - likely_release_env(parent); | |
| 66 | - | |
| 67 | - assert(output); | |
| 68 | - bitcode = QByteArray(output->data, likely_bytes(output)); | |
| 69 | - likely_release_mat(output); | |
| 70 | - | |
| 71 | - compile(); | |
| 72 | - likely_release_mat(data); | |
| 73 | - likely_release_mat(source_code); | |
| 74 | - } | |
| 75 | - | |
| 76 | - void project(const Template &src, Template &dst) const | |
| 77 | - { | |
| 78 | - const likely_const_mat srcl = likelyFromOpenCVMat(src); | |
| 79 | - const likely_const_mat dstl = function(srcl); | |
| 80 | - dst = likelyToOpenCVMat(dstl); | |
| 81 | - likely_release_mat(dstl); | |
| 82 | - likely_release_mat(srcl); | |
| 83 | - } | |
| 84 | - | |
| 85 | - void store(QDataStream &stream) const | |
| 86 | - { | |
| 87 | - stream << bitcode; | |
| 88 | - } | |
| 89 | - | |
| 90 | - void load(QDataStream &stream) | |
| 91 | - { | |
| 92 | - stream >> bitcode; | |
| 93 | - compile(); | |
| 94 | - } | |
| 95 | -}; | |
| 96 | - | |
| 97 | -BR_REGISTER(Transform, LikelyTransform) | |
| 98 | - | |
| 99 | -} // namespace br | |
| 100 | - | |
| 101 | -#include "core/likely.moc" |
openbr/plugins/format/lm.cpp deleted
| 1 | -#include <openbr/plugins/openbr_internal.h> | |
| 2 | - | |
| 3 | -#include <likely.h> | |
| 4 | -#include <likely/opencv.hpp> | |
| 5 | - | |
| 6 | -namespace br | |
| 7 | -{ | |
| 8 | - | |
| 9 | -/*! | |
| 10 | - * \ingroup formats | |
| 11 | - * \brief Likely matrix format | |
| 12 | - * | |
| 13 | - * \br_link www.liblikely.org | |
| 14 | - * \author Josh Klontz \cite jklontz | |
| 15 | - */ | |
| 16 | -class lmFormat : public Format | |
| 17 | -{ | |
| 18 | - Q_OBJECT | |
| 19 | - | |
| 20 | - Template read() const | |
| 21 | - { | |
| 22 | - const likely_const_mat m = likely_read(qPrintable(file.name), likely_file_guess, likely_void); | |
| 23 | - const Template result(likelyToOpenCVMat(m)); | |
| 24 | - likely_release_mat(m); | |
| 25 | - return result; | |
| 26 | - } | |
| 27 | - | |
| 28 | - void write(const Template &t) const | |
| 29 | - { | |
| 30 | - const likely_const_mat m = likelyFromOpenCVMat(t); | |
| 31 | - likely_write(m, qPrintable(file.name)); | |
| 32 | - likely_release_mat(m); | |
| 33 | - } | |
| 34 | -}; | |
| 35 | - | |
| 36 | -BR_REGISTER(Format, lmFormat) | |
| 37 | - | |
| 38 | -} // namespace br | |
| 39 | - | |
| 40 | -#include "format/lm.moc" |
openbr/plugins/gallery/lm.cpp deleted
| 1 | -#include <openbr/plugins/openbr_internal.h> | |
| 2 | -#include <openbr/core/opencvutils.h> | |
| 3 | - | |
| 4 | -#include <likely.h> | |
| 5 | -#include <likely/opencv.hpp> | |
| 6 | - | |
| 7 | -namespace br | |
| 8 | -{ | |
| 9 | - | |
| 10 | -/*! | |
| 11 | - * \ingroup formats | |
| 12 | - * \brief Likely matrix format | |
| 13 | - * | |
| 14 | - * www.liblikely.org | |
| 15 | - * \author Josh Klontz \cite jklontz | |
| 16 | - */ | |
| 17 | -class lmGallery : public Gallery | |
| 18 | -{ | |
| 19 | - Q_OBJECT | |
| 20 | - QList<cv::Mat> mats; | |
| 21 | - | |
| 22 | - ~lmGallery() | |
| 23 | - { | |
| 24 | - if (mats.empty()) | |
| 25 | - return; | |
| 26 | - likely_const_mat m = likelyFromOpenCVMats(mats.toVector().toStdVector()); | |
| 27 | - if (!likely_write(m, qPrintable(file.name))) | |
| 28 | - qFatal("Write failed"); | |
| 29 | - likely_release_mat(m); | |
| 30 | - } | |
| 31 | - | |
| 32 | - TemplateList readBlock(bool *done) | |
| 33 | - { | |
| 34 | - *done = true; | |
| 35 | - TemplateList templates; | |
| 36 | - const likely_const_mat m = likely_read(qPrintable(file.name), likely_file_matrix, likely_void); | |
| 37 | - foreach (const cv::Mat &mat, likelyToOpenCVMats(m)) | |
| 38 | - templates.append(mat); | |
| 39 | - likely_release_mat(m); | |
| 40 | - return templates; | |
| 41 | - } | |
| 42 | - | |
| 43 | - void write(const Template &t) | |
| 44 | - { | |
| 45 | - mats.append(t); | |
| 46 | - } | |
| 47 | -}; | |
| 48 | - | |
| 49 | -BR_REGISTER(Gallery, lmGallery) | |
| 50 | - | |
| 51 | -} // namespace br | |
| 52 | - | |
| 53 | -#include "gallery/lm.moc" |