diff --git a/openbr/plugins/cmake/likely.cmake b/openbr/plugins/cmake/likely.cmake deleted file mode 100644 index 6b7a114..0000000 --- a/openbr/plugins/cmake/likely.cmake +++ /dev/null @@ -1,10 +0,0 @@ -set(BR_WITH_LIKELY OFF CACHE BOOL "Build with Likely") - -if(${BR_WITH_LIKELY}) - find_package(Likely REQUIRED) - set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Likely_LIBS}) -else() - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/core/likely.cpp) - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/format/lm.cpp) - set(BR_EXCLUDED_PLUGINS ${BR_EXCLUDED_PLUGINS} plugins/gallery/lm.cpp) -endif() diff --git a/openbr/plugins/core/likely.cpp b/openbr/plugins/core/likely.cpp deleted file mode 100644 index 2163cbb..0000000 --- a/openbr/plugins/core/likely.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include - -#include -#include - -namespace br -{ - -/*! - * \ingroup transforms - * \brief Generic interface to Likely JIT compiler - * \br_link Homepage http://liblikely.org - * \br_link API Documentation https://s3.amazonaws.com/liblikely/doxygen/index.html - * \author Josh Klontz \cite jklontz - */ -class LikelyTransform : public Transform -{ - Q_OBJECT - Q_PROPERTY(QString sourceFile READ get_sourceFile WRITE set_sourceFile RESET reset_sourceFile STORED false) - BR_PROPERTY(QString, sourceFile, "") - - QByteArray bitcode; - likely_env env; - - typedef likely_mat (*Function)(likely_const_mat); - Function function; - - ~LikelyTransform() - { - likely_release_env(env); - } - - void compile() - { - const likely_const_mat data = likely_new(likely_u8 | likely_multi_channel, bitcode.size(), 1, 1, 1, bitcode.data()); - env = likely_precompiled(data, qPrintable(QFileInfo(sourceFile).baseName())); - function = (Function) likely_function(env->expr); - if (!function) - qFatal("Failed to compile: %s", qPrintable(sourceFile)); - } - - void train(const TemplateList &trainingData) - { - const likely_type source_file_type = likely_guess_file_type(qPrintable(sourceFile)); - const likely_const_mat source_code = likely_read(qPrintable(sourceFile), source_file_type, likely_void); - const likely_const_mat data = likelyFromOpenCVMats(trainingData.data().toVector().toStdVector()); - - // Pick settings to minimize code size - likely_settings settings = likely_default_settings(likely_file_bitcode, false); - settings.runtime_only = true; // The compiled algorithm should not depend on any external functions, - // except for those in the likely runtime API. - - // Construct a compilation environment - likely_mat output = NULL; - likely_const_env parent = likely_standard(settings, &output, likely_file_bitcode); - - { // Define the `data` variable - const likely_const_env env = likely_define("data", data, parent); - likely_release_env(parent); - parent = env; - } - - likely_release_env(likely_lex_parse_and_eval(source_code->data, source_file_type, parent)); - likely_release_env(parent); - - assert(output); - bitcode = QByteArray(output->data, likely_bytes(output)); - likely_release_mat(output); - - compile(); - likely_release_mat(data); - likely_release_mat(source_code); - } - - void project(const Template &src, Template &dst) const - { - const likely_const_mat srcl = likelyFromOpenCVMat(src); - const likely_const_mat dstl = function(srcl); - dst = likelyToOpenCVMat(dstl); - likely_release_mat(dstl); - likely_release_mat(srcl); - } - - void store(QDataStream &stream) const - { - stream << bitcode; - } - - void load(QDataStream &stream) - { - stream >> bitcode; - compile(); - } -}; - -BR_REGISTER(Transform, LikelyTransform) - -} // namespace br - -#include "core/likely.moc" diff --git a/openbr/plugins/format/lm.cpp b/openbr/plugins/format/lm.cpp deleted file mode 100644 index 63f5488..0000000 --- a/openbr/plugins/format/lm.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include - -#include -#include - -namespace br -{ - -/*! - * \ingroup formats - * \brief Likely matrix format - * - * \br_link www.liblikely.org - * \author Josh Klontz \cite jklontz - */ -class lmFormat : public Format -{ - Q_OBJECT - - Template read() const - { - const likely_const_mat m = likely_read(qPrintable(file.name), likely_file_guess, likely_void); - const Template result(likelyToOpenCVMat(m)); - likely_release_mat(m); - return result; - } - - void write(const Template &t) const - { - const likely_const_mat m = likelyFromOpenCVMat(t); - likely_write(m, qPrintable(file.name)); - likely_release_mat(m); - } -}; - -BR_REGISTER(Format, lmFormat) - -} // namespace br - -#include "format/lm.moc" diff --git a/openbr/plugins/gallery/lm.cpp b/openbr/plugins/gallery/lm.cpp deleted file mode 100644 index a0ed972..0000000 --- a/openbr/plugins/gallery/lm.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -#include -#include - -namespace br -{ - -/*! - * \ingroup formats - * \brief Likely matrix format - * - * www.liblikely.org - * \author Josh Klontz \cite jklontz - */ -class lmGallery : public Gallery -{ - Q_OBJECT - QList mats; - - ~lmGallery() - { - if (mats.empty()) - return; - likely_const_mat m = likelyFromOpenCVMats(mats.toVector().toStdVector()); - if (!likely_write(m, qPrintable(file.name))) - qFatal("Write failed"); - likely_release_mat(m); - } - - TemplateList readBlock(bool *done) - { - *done = true; - TemplateList templates; - const likely_const_mat m = likely_read(qPrintable(file.name), likely_file_matrix, likely_void); - foreach (const cv::Mat &mat, likelyToOpenCVMats(m)) - templates.append(mat); - likely_release_mat(m); - return templates; - } - - void write(const Template &t) - { - mats.append(t); - } -}; - -BR_REGISTER(Gallery, lmGallery) - -} // namespace br - -#include "gallery/lm.moc"