Commit 01d165e1a53cf03fee049d238ee2017e336edbdf
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
44 changed files
with
637 additions
and
416 deletions
app/br/br.cpp
| @@ -51,7 +51,8 @@ static void help() | @@ -51,7 +51,8 @@ static void help() | ||
| 51 | "-cluster <simmat> ... <simmat> <aggressiveness> {csv}\n" | 51 | "-cluster <simmat> ... <simmat> <aggressiveness> {csv}\n" |
| 52 | "-makeMask <target_gallery> <query_gallery> {mask}\n" | 52 | "-makeMask <target_gallery> <query_gallery> {mask}\n" |
| 53 | "-combineMasks <mask> ... <mask> {mask} (And|Or)\n" | 53 | "-combineMasks <mask> ... <mask> {mask} (And|Or)\n" |
| 54 | - "-convert <(csv,simmat,mask)> {(csv,simmat,mask)}\n" | 54 | + "-cat <gallery> ... <gallery> {gallery}\n" |
| 55 | + "-convert <template> {template}\n" | ||
| 55 | "-reformat <target_sigset> <query_sigset> <simmat> {output}\n" | 56 | "-reformat <target_sigset> <query_sigset> <simmat> {output}\n" |
| 56 | "-evalClassification <predicted_gallery> <truth_gallery>\n" | 57 | "-evalClassification <predicted_gallery> <truth_gallery>\n" |
| 57 | "-evalRegression <predicted_gallery> <truth_gallery>\n" | 58 | "-evalRegression <predicted_gallery> <truth_gallery>\n" |
| @@ -141,6 +142,9 @@ int main(int argc, char *argv[]) | @@ -141,6 +142,9 @@ int main(int argc, char *argv[]) | ||
| 141 | } else if (!strcmp(fun, "combineMasks")) { | 142 | } else if (!strcmp(fun, "combineMasks")) { |
| 142 | check(parc >= 4, "Insufficient parameter count for 'combineMasks'."); | 143 | check(parc >= 4, "Insufficient parameter count for 'combineMasks'."); |
| 143 | br_combine_masks(parc-2, parv, parv[parc-2], parv[parc-1]); | 144 | br_combine_masks(parc-2, parv, parv[parc-2], parv[parc-1]); |
| 145 | + } else if (!strcmp(fun, "cat")) { | ||
| 146 | + check(parc >= 2, "Insufficient parameter count for 'cat'."); | ||
| 147 | + br_cat(parc-1, parv, parv[parc-1]); | ||
| 144 | } else if (!strcmp(fun, "convert")) { | 148 | } else if (!strcmp(fun, "convert")) { |
| 145 | check(parc == 2, "Incorrect parameter count for 'convert'."); | 149 | check(parc == 2, "Incorrect parameter count for 'convert'."); |
| 146 | br_convert(parv[0], parv[1]); | 150 | br_convert(parv[0], parv[1]); |
app/openbr-gui/transformeditor.cpp
| @@ -28,17 +28,17 @@ br::TransformEditor::TransformEditor(Transform *transform, QWidget *parent) | @@ -28,17 +28,17 @@ br::TransformEditor::TransformEditor(Transform *transform, QWidget *parent) | ||
| 28 | layout.addWidget(&name); | 28 | layout.addWidget(&name); |
| 29 | setLayout(&layout); | 29 | setLayout(&layout); |
| 30 | 30 | ||
| 31 | - name.setCurrentIndex(name.findText(transform->name().remove("Transform"))); | 31 | + name.setCurrentIndex(name.findText(transform->objectName().remove("Transform"))); |
| 32 | const QMetaObject *mo = transform->metaObject(); | 32 | const QMetaObject *mo = transform->metaObject(); |
| 33 | for (int i=mo->propertyOffset(); i<mo->propertyCount(); i++) { | 33 | for (int i=mo->propertyOffset(); i<mo->propertyCount(); i++) { |
| 34 | QMetaProperty mp = mo->property(i); | 34 | QMetaProperty mp = mo->property(i); |
| 35 | const QString typeName = mp.typeName(); | 35 | const QString typeName = mp.typeName(); |
| 36 | if (typeName == "QList<br::Transform*>") { | 36 | if (typeName == "QList<br::Transform*>") { |
| 37 | QString separator; | 37 | QString separator; |
| 38 | - if (transform->name() == "ChainTransform") separator = "!"; | ||
| 39 | - else if (transform->name() == "PipeTransform") separator = "+"; | ||
| 40 | - else if (transform->name() == "ForkTransform") separator = "/"; | ||
| 41 | - else separator = "?"; | 38 | + if (transform->objectName() == "Chain") separator = "!"; |
| 39 | + else if (transform->objectName() == "Pipe") separator = "+"; | ||
| 40 | + else if (transform->objectName() == "Fork") separator = "/"; | ||
| 41 | + else separator = "?"; | ||
| 42 | parameters.append(new TransformListEditor(mp.read(transform).value< QList<br::Transform*> >(), separator, this)); | 42 | parameters.append(new TransformListEditor(mp.read(transform).value< QList<br::Transform*> >(), separator, this)); |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
scripts/matlab/loadMtx.m deleted
| 1 | -function [x2] = loadMtx(filename,isRowMajor) | ||
| 2 | -% [x2] = loadMtx(filename,reverse) | ||
| 3 | -% | ||
| 4 | -% Loads a *.mtx file into a Matlab matrix. | ||
| 5 | -% 'filename' - the name of the mtx file | ||
| 6 | -% 'isRowMajor' - determines whether the | ||
| 7 | -% matrix is read in row major or | ||
| 8 | -% column major order (optional, default is false) | ||
| 9 | -% | ||
| 10 | -% This file can likely be improved in terms of effeciency. | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - if nargin < 2, | ||
| 14 | - reverse = false; | ||
| 15 | - end | ||
| 16 | - | ||
| 17 | - z = fopen(filename,'r'); | ||
| 18 | - if z == -1, | ||
| 19 | - fprintf('Error opening file %s\n',filename); | ||
| 20 | - x2 = 0; | ||
| 21 | - return | ||
| 22 | - end | ||
| 23 | - | ||
| 24 | - buf = zeros(100,1); | ||
| 25 | - str_list = cell(4,1); | ||
| 26 | - for i = 1:4, | ||
| 27 | - cnt = 0; | ||
| 28 | - while true | ||
| 29 | - cnt = cnt + 1; | ||
| 30 | - [a ] = fread(z,1,'uchar'); | ||
| 31 | - if a == 10 | ||
| 32 | - break; | ||
| 33 | - end | ||
| 34 | - buf(cnt) = a; | ||
| 35 | - end | ||
| 36 | - str_list{i} = char(buf(1:cnt-1)'); | ||
| 37 | - end | ||
| 38 | - | ||
| 39 | - s = strsplit(' ',str_list{4}); | ||
| 40 | - x = str2num(s{2}); | ||
| 41 | - x1 = str2num(s{3}); | ||
| 42 | - typ = s{1}(2); | ||
| 43 | - | ||
| 44 | - %x2 = fread(z,[x1 x],'float32'); | ||
| 45 | - if strcmp(typ,'F') | ||
| 46 | - x2 = fread(z,[x1 x],'single'); | ||
| 47 | - elseif strcmp(typ,'B') | ||
| 48 | - x2 = fread(z,[x1 x],'int8'); | ||
| 49 | - else | ||
| 50 | - assert(0); | ||
| 51 | - end | ||
| 52 | - x2 = x2'; | ||
| 53 | - fclose(z); | ||
| 54 | - | ||
| 55 | - if reverse, | ||
| 56 | - sz = size(x2); | ||
| 57 | - x2 = x2'; | ||
| 58 | - x2 = reshape(x2,sz); | ||
| 59 | - end |
sdk/core/core.cpp
| @@ -315,11 +315,26 @@ void br::Compare(const File &targetGallery, const File &queryGallery, const File | @@ -315,11 +315,26 @@ void br::Compare(const File &targetGallery, const File &queryGallery, const File | ||
| 315 | 315 | ||
| 316 | void br::Convert(const File &src, const File &dst) | 316 | void br::Convert(const File &src, const File &dst) |
| 317 | { | 317 | { |
| 318 | + qDebug("Converting %s to %s", qPrintable(src.flat()), qPrintable(dst.flat())); | ||
| 318 | QScopedPointer<Format> before(Factory<Format>::make(src)); | 319 | QScopedPointer<Format> before(Factory<Format>::make(src)); |
| 319 | QScopedPointer<Format> after(Factory<Format>::make(dst)); | 320 | QScopedPointer<Format> after(Factory<Format>::make(dst)); |
| 320 | after->write(before->read()); | 321 | after->write(before->read()); |
| 321 | } | 322 | } |
| 322 | 323 | ||
| 324 | +void br::Cat(const QStringList &inputGalleries, const QString &outputGallery) | ||
| 325 | +{ | ||
| 326 | + qDebug("Concatenating %d galleries to %s", inputGalleries.size(), qPrintable(outputGallery)); | ||
| 327 | + foreach (const QString &inputGallery, inputGalleries) | ||
| 328 | + if (inputGallery == outputGallery) | ||
| 329 | + qFatal("br::Cat outputGallery must not be in inputGalleries."); | ||
| 330 | + QScopedPointer<Gallery> og(Gallery::make(outputGallery)); | ||
| 331 | + foreach (const QString &inputGallery, inputGalleries) { | ||
| 332 | + QScopedPointer<Gallery> ig(Gallery::make(inputGallery)); | ||
| 333 | + bool done = false; | ||
| 334 | + while (!done) og->writeBlock(ig->readBlock(&done)); | ||
| 335 | + } | ||
| 336 | +} | ||
| 337 | + | ||
| 323 | QSharedPointer<br::Transform> br::Transform::fromAlgorithm(const QString &algorithm) | 338 | QSharedPointer<br::Transform> br::Transform::fromAlgorithm(const QString &algorithm) |
| 324 | { | 339 | { |
| 325 | return AlgorithmManager::getAlgorithm(algorithm)->transform; | 340 | return AlgorithmManager::getAlgorithm(algorithm)->transform; |
sdk/core/qtutils.cpp
| @@ -113,7 +113,8 @@ void QtUtils::writeFile(const QString &file, const QByteArray &data, int compres | @@ -113,7 +113,8 @@ void QtUtils::writeFile(const QString &file, const QByteArray &data, int compres | ||
| 113 | QFile f(file); | 113 | QFile f(file); |
| 114 | touchDir(f); | 114 | touchDir(f); |
| 115 | if (!f.open(QFile::WriteOnly)) qFatal("QtUtils::writeFile failed to open %s for writing.", qPrintable(file)); | 115 | if (!f.open(QFile::WriteOnly)) qFatal("QtUtils::writeFile failed to open %s for writing.", qPrintable(file)); |
| 116 | - f.write(qCompress(data, compression)); | 116 | + if (compression == 0) f.write(data); |
| 117 | + else f.write(qCompress(data, compression)); | ||
| 117 | f.close(); | 118 | f.close(); |
| 118 | } | 119 | } |
| 119 | 120 |
sdk/core/qtutils.h
sdk/jitcv/jitcv.h
| @@ -83,13 +83,15 @@ struct Matrix | @@ -83,13 +83,15 @@ struct Matrix | ||
| 83 | inline uint32_t bytes() const { return bits() / 8 * elements(); } | 83 | inline uint32_t bytes() const { return bits() / 8 * elements(); } |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | -typedef void (*UnaryFunction_t)(const Matrix *src, Matrix *dst); | ||
| 87 | -typedef void (*BinaryFunction_t)(const Matrix *srcA, const Matrix *srcB, Matrix *dst); | ||
| 88 | -typedef void (*UnaryKernel_t)(const Matrix *src, Matrix *dst, uint32_t size); | ||
| 89 | -typedef void (*BinaryKernel_t)(const Matrix *srcA, const Matrix *srcB, Matrix *dst, uint32_t size); | 86 | +typedef void (*UnaryFunction)(const Matrix *src, Matrix *dst); |
| 87 | +typedef void (*BinaryFunction)(const Matrix *srcA, const Matrix *srcB, Matrix *dst); | ||
| 88 | +UnaryFunction jit_make_unary_function(const char *description); | ||
| 89 | +BinaryFunction jit_make_binary_function(const char *description); | ||
| 90 | 90 | ||
| 91 | -UnaryFunction_t jit_unary_make(const char *description); | ||
| 92 | -BinaryFunction_t jit_binary_make(const char *description); | 91 | +typedef void (*UnaryKernel)(const Matrix *src, Matrix *dst, uint32_t size); |
| 92 | +typedef void (*BinaryKernel)(const Matrix *srcA, const Matrix *srcB, Matrix *dst, uint32_t size); | ||
| 93 | +UnaryKernel jit_make_unary_kernel(const char *description, const Matrix *src); | ||
| 94 | +BinaryKernel jit_make_binary_kernel(const char *description, const Matrix *srcA, const Matrix *srcB); | ||
| 93 | 95 | ||
| 94 | } | 96 | } |
| 95 | 97 |
sdk/openbr.cpp
| @@ -31,6 +31,11 @@ const char *br_about() | @@ -31,6 +31,11 @@ const char *br_about() | ||
| 31 | return about.data(); | 31 | return about.data(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | +void br_cat(int num_input_galleries, const char *input_galleries[], const char *output_gallery) | ||
| 35 | +{ | ||
| 36 | + Cat(QtUtils::toStringList(num_input_galleries, input_galleries), output_gallery); | ||
| 37 | +} | ||
| 38 | + | ||
| 34 | void br_cluster(int num_simmats, const char *simmats[], float aggressiveness, const char *csv) | 39 | void br_cluster(int num_simmats, const char *simmats[], float aggressiveness, const char *csv) |
| 35 | { | 40 | { |
| 36 | ClusterGallery(QtUtils::toStringList(num_simmats, simmats), aggressiveness, csv); | 41 | ClusterGallery(QtUtils::toStringList(num_simmats, simmats), aggressiveness, csv); |
sdk/openbr.h
| @@ -73,6 +73,11 @@ extern "C" { | @@ -73,6 +73,11 @@ extern "C" { | ||
| 73 | BR_EXPORT const char *br_about(); | 73 | BR_EXPORT const char *br_about(); |
| 74 | 74 | ||
| 75 | /*! | 75 | /*! |
| 76 | + * \brief Wraps br::Cat() | ||
| 77 | + */ | ||
| 78 | +BR_EXPORT void br_cat(int num_input_galleries, const char *input_galleries[], const char *output_gallery); | ||
| 79 | + | ||
| 80 | +/*! | ||
| 76 | * \brief Clusters one or more similarity matrices into a list of subjects. | 81 | * \brief Clusters one or more similarity matrices into a list of subjects. |
| 77 | * | 82 | * |
| 78 | * A similarity matrix is a type of br::Output. The current clustering algorithm is a simplified implementation of \cite zhu11. | 83 | * A similarity matrix is a type of br::Output. The current clustering algorithm is a simplified implementation of \cite zhu11. |
sdk/openbr_plugin.cpp
| @@ -442,11 +442,6 @@ TemplateList TemplateList::fromInput(const br::File &input) | @@ -442,11 +442,6 @@ TemplateList TemplateList::fromInput(const br::File &input) | ||
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | /* Object - public methods */ | 444 | /* Object - public methods */ |
| 445 | -QString Object::name() const | ||
| 446 | -{ | ||
| 447 | - return metaObject()->className(); | ||
| 448 | -} | ||
| 449 | - | ||
| 450 | QStringList Object::parameters() const | 445 | QStringList Object::parameters() const |
| 451 | { | 446 | { |
| 452 | QStringList parameters; | 447 | QStringList parameters; |
| @@ -505,7 +500,7 @@ QString Object::argument(int index) const | @@ -505,7 +500,7 @@ QString Object::argument(int index) const | ||
| 505 | QString Object::description() const | 500 | QString Object::description() const |
| 506 | { | 501 | { |
| 507 | QString argumentString = arguments().join(","); | 502 | QString argumentString = arguments().join(","); |
| 508 | - return name() + (argumentString.isEmpty() ? "" : ("(" + argumentString + ")")); | 503 | + return objectName() + (argumentString.isEmpty() ? "" : ("(" + argumentString + ")")); |
| 509 | } | 504 | } |
| 510 | 505 | ||
| 511 | void Object::store(QDataStream &stream) const | 506 | void Object::store(QDataStream &stream) const |
| @@ -642,6 +637,23 @@ QStringList br::Object::parse(const QString &string, char split) | @@ -642,6 +637,23 @@ QStringList br::Object::parse(const QString &string, char split) | ||
| 642 | /* Object - private methods */ | 637 | /* Object - private methods */ |
| 643 | void Object::init(const File &file_) | 638 | void Object::init(const File &file_) |
| 644 | { | 639 | { |
| 640 | + this->file = file_; | ||
| 641 | + | ||
| 642 | + // Set name | ||
| 643 | + QString name = metaObject()->className(); | ||
| 644 | + if (name.startsWith("br::")) name = name.right(name.size()-4); | ||
| 645 | + const QMetaObject *superClass = metaObject()->superClass(); | ||
| 646 | + while (superClass != NULL) { | ||
| 647 | + QString superClassName = superClass->className(); | ||
| 648 | + if (superClassName.startsWith("br::")) | ||
| 649 | + superClassName = superClassName.right(superClassName.size()-4); | ||
| 650 | + if (name.endsWith(superClassName)) | ||
| 651 | + name = name.left(name.size() - superClassName.size()); | ||
| 652 | + superClass = superClass->superClass(); | ||
| 653 | + } | ||
| 654 | + setObjectName(name); | ||
| 655 | + | ||
| 656 | + // Set properties | ||
| 645 | for (int i=0; i<metaObject()->propertyCount(); i++) { | 657 | for (int i=0; i<metaObject()->propertyCount(); i++) { |
| 646 | QMetaProperty property = metaObject()->property(i); | 658 | QMetaProperty property = metaObject()->property(i); |
| 647 | if (property.isResettable()) | 659 | if (property.isResettable()) |
| @@ -649,13 +661,13 @@ void Object::init(const File &file_) | @@ -649,13 +661,13 @@ void Object::init(const File &file_) | ||
| 649 | qFatal("Failed to reset %s::%s", metaObject()->className(), property.name()); | 661 | qFatal("Failed to reset %s::%s", metaObject()->className(), property.name()); |
| 650 | } | 662 | } |
| 651 | 663 | ||
| 652 | - this->file = file_; | ||
| 653 | - foreach (QString name, file.localKeys()) { | ||
| 654 | - const QString value = file.value(name).toString(); | ||
| 655 | - if (name.startsWith("_Arg")) | ||
| 656 | - name = metaObject()->property(metaObject()->propertyOffset()+name.mid(4).toInt()).name(); | ||
| 657 | - setProperty(name, value); | 664 | + foreach (QString key, file.localKeys()) { |
| 665 | + const QString value = file.value(key).toString(); | ||
| 666 | + if (key.startsWith("_Arg")) | ||
| 667 | + key = metaObject()->property(metaObject()->propertyOffset()+key.mid(4).toInt()).name(); | ||
| 668 | + setProperty(key, value); | ||
| 658 | } | 669 | } |
| 670 | + | ||
| 659 | init(); | 671 | init(); |
| 660 | } | 672 | } |
| 661 | 673 | ||
| @@ -681,7 +693,9 @@ int br::Context::blocks(int size) const | @@ -681,7 +693,9 @@ int br::Context::blocks(int size) const | ||
| 681 | 693 | ||
| 682 | bool br::Context::contains(const QString &name) | 694 | bool br::Context::contains(const QString &name) |
| 683 | { | 695 | { |
| 684 | - const char *c_name = qPrintable(name); | 696 | + QByteArray bytes = name.toLocal8Bit(); |
| 697 | + const char * c_name = bytes.constData(); | ||
| 698 | + | ||
| 685 | for (int i=0; i<metaObject()->propertyCount(); i++) | 699 | for (int i=0; i<metaObject()->propertyCount(); i++) |
| 686 | if (!strcmp(c_name, metaObject()->property(i).name())) | 700 | if (!strcmp(c_name, metaObject()->property(i).name())) |
| 687 | return true; | 701 | return true; |
| @@ -1055,14 +1069,10 @@ public: | @@ -1055,14 +1069,10 @@ public: | ||
| 1055 | transform->setParent(this); | 1069 | transform->setParent(this); |
| 1056 | transforms.append(transform); | 1070 | transforms.append(transform); |
| 1057 | file = transform->file; | 1071 | file = transform->file; |
| 1072 | + setObjectName(transforms.first()->objectName()); | ||
| 1058 | } | 1073 | } |
| 1059 | 1074 | ||
| 1060 | private: | 1075 | private: |
| 1061 | - QString name() const | ||
| 1062 | - { | ||
| 1063 | - return transforms.first()->name(); | ||
| 1064 | - } | ||
| 1065 | - | ||
| 1066 | Transform *clone() const | 1076 | Transform *clone() const |
| 1067 | { | 1077 | { |
| 1068 | return new Independent(transforms.first()->clone()); | 1078 | return new Independent(transforms.first()->clone()); |
| @@ -1206,7 +1216,7 @@ static void _project(const Transform *transform, const Template *src, Template * | @@ -1206,7 +1216,7 @@ static void _project(const Transform *transform, const Template *src, Template * | ||
| 1206 | try { | 1216 | try { |
| 1207 | transform->project(*src, *dst); | 1217 | transform->project(*src, *dst); |
| 1208 | } catch (...) { | 1218 | } catch (...) { |
| 1209 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(src->file.flat()), qPrintable(transform->name())); | 1219 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src->file.flat()), qPrintable(transform->objectName())); |
| 1210 | *dst = Template(src->file); | 1220 | *dst = Template(src->file); |
| 1211 | dst->file.setBool("FTE"); | 1221 | dst->file.setBool("FTE"); |
| 1212 | } | 1222 | } |
| @@ -1217,7 +1227,7 @@ static void _backProject(const Transform *transform, const Template *dst, Templa | @@ -1217,7 +1227,7 @@ static void _backProject(const Transform *transform, const Template *dst, Templa | ||
| 1217 | try { | 1227 | try { |
| 1218 | transform->backProject(*dst, *src); | 1228 | transform->backProject(*dst, *src); |
| 1219 | } catch (...) { | 1229 | } catch (...) { |
| 1220 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(src->file.flat()), qPrintable(transform->name())); | 1230 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src->file.flat()), qPrintable(transform->objectName())); |
| 1221 | *src = Template(dst->file); | 1231 | *src = Template(dst->file); |
| 1222 | src->file.setBool("FTE"); | 1232 | src->file.setBool("FTE"); |
| 1223 | } | 1233 | } |
sdk/openbr_plugin.h
| @@ -381,7 +381,6 @@ class BR_EXPORT Object : public QObject | @@ -381,7 +381,6 @@ class BR_EXPORT Object : public QObject | ||
| 381 | public: | 381 | public: |
| 382 | File file; /*!< \brief The file used to construct the plugin. */ | 382 | File file; /*!< \brief The file used to construct the plugin. */ |
| 383 | 383 | ||
| 384 | - virtual QString name() const; /*!< \brief The plugin class name. */ | ||
| 385 | virtual void init() {} /*!< \brief Overload this function instead of the default constructor to initialize the derived class. It should be safe to call this function multiple times. */ | 384 | virtual void init() {} /*!< \brief Overload this function instead of the default constructor to initialize the derived class. It should be safe to call this function multiple times. */ |
| 386 | virtual void store(QDataStream &stream) const; /*!< \brief Serialize the object. */ | 385 | virtual void store(QDataStream &stream) const; /*!< \brief Serialize the object. */ |
| 387 | virtual void load(QDataStream &stream); /*!< \brief Deserialize the object. Default implementation calls init() after deserialization. */ | 386 | virtual void load(QDataStream &stream); /*!< \brief Deserialize the object. Default implementation calls init() after deserialization. */ |
| @@ -1100,6 +1099,14 @@ BR_EXPORT void Compare(const File &targetGallery, const File &queryGallery, cons | @@ -1100,6 +1099,14 @@ BR_EXPORT void Compare(const File &targetGallery, const File &queryGallery, cons | ||
| 1100 | */ | 1099 | */ |
| 1101 | BR_EXPORT void Convert(const File &input, const File &output); | 1100 | BR_EXPORT void Convert(const File &input, const File &output); |
| 1102 | 1101 | ||
| 1102 | +/*! | ||
| 1103 | + * \brief Concatenate several galleries into one. | ||
| 1104 | + * \param inputGalleries List of galleries to concatenate. | ||
| 1105 | + * \param outputGallery Gallery to store the concatenated result. | ||
| 1106 | + * \note outputGallery must not be in inputGalleries. | ||
| 1107 | + */ | ||
| 1108 | +BR_EXPORT void Cat(const QStringList &inputGalleries, const QString &outputGallery); | ||
| 1109 | + | ||
| 1103 | /*! @}*/ | 1110 | /*! @}*/ |
| 1104 | 1111 | ||
| 1105 | } // namespace br | 1112 | } // namespace br |
sdk/plugins/algorithms.cpp
| @@ -16,14 +16,15 @@ | @@ -16,14 +16,15 @@ | ||
| 16 | 16 | ||
| 17 | #include <openbr_plugin.h> | 17 | #include <openbr_plugin.h> |
| 18 | 18 | ||
| 19 | -using namespace br; | 19 | +namespace br |
| 20 | +{ | ||
| 20 | 21 | ||
| 21 | /*! | 22 | /*! |
| 22 | * \ingroup initializers | 23 | * \ingroup initializers |
| 23 | * \brief Initializes global abbreviations with implemented algorithms | 24 | * \brief Initializes global abbreviations with implemented algorithms |
| 24 | * \author Josh Klontz \cite jklontz | 25 | * \author Josh Klontz \cite jklontz |
| 25 | */ | 26 | */ |
| 26 | -class Algorithms : public Initializer | 27 | +class AlgorithmsInitializer : public Initializer |
| 27 | { | 28 | { |
| 28 | Q_OBJECT | 29 | Q_OBJECT |
| 29 | 30 | ||
| @@ -72,6 +73,8 @@ class Algorithms : public Initializer | @@ -72,6 +73,8 @@ class Algorithms : public Initializer | ||
| 72 | } | 73 | } |
| 73 | }; | 74 | }; |
| 74 | 75 | ||
| 75 | -BR_REGISTER(Initializer, Algorithms) | 76 | +BR_REGISTER(Initializer, AlgorithmsInitializer) |
| 77 | + | ||
| 78 | +} // namespace br | ||
| 76 | 79 | ||
| 77 | #include "algorithms.moc" | 80 | #include "algorithms.moc" |
sdk/plugins/cascade.cpp
| @@ -21,7 +21,9 @@ | @@ -21,7 +21,9 @@ | ||
| 21 | #include "core/resource.h" | 21 | #include "core/resource.h" |
| 22 | 22 | ||
| 23 | using namespace cv; | 23 | using namespace cv; |
| 24 | -using namespace br; | 24 | + |
| 25 | +namespace br | ||
| 26 | +{ | ||
| 25 | 27 | ||
| 26 | class CascadeResourceMaker : public ResourceMaker<CascadeClassifier> | 28 | class CascadeResourceMaker : public ResourceMaker<CascadeClassifier> |
| 27 | { | 29 | { |
| @@ -55,7 +57,7 @@ private: | @@ -55,7 +57,7 @@ private: | ||
| 55 | * \brief Wraps OpenCV cascade classifier | 57 | * \brief Wraps OpenCV cascade classifier |
| 56 | * \author Josh Klontz \cite jklontz | 58 | * \author Josh Klontz \cite jklontz |
| 57 | */ | 59 | */ |
| 58 | -class Cascade : public UntrainableTransform | 60 | +class CascadeTransform : public UntrainableTransform |
| 59 | { | 61 | { |
| 60 | Q_OBJECT | 62 | Q_OBJECT |
| 61 | Q_PROPERTY(QString model READ get_model WRITE set_model RESET reset_model STORED false) | 63 | Q_PROPERTY(QString model READ get_model WRITE set_model RESET reset_model STORED false) |
| @@ -87,6 +89,8 @@ class Cascade : public UntrainableTransform | @@ -87,6 +89,8 @@ class Cascade : public UntrainableTransform | ||
| 87 | } | 89 | } |
| 88 | }; | 90 | }; |
| 89 | 91 | ||
| 90 | -BR_REGISTER(Transform, Cascade) | 92 | +BR_REGISTER(Transform, CascadeTransform) |
| 93 | + | ||
| 94 | +} // namespace br | ||
| 91 | 95 | ||
| 92 | #include "cascade.moc" | 96 | #include "cascade.moc" |
sdk/plugins/cluster.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Wraps OpenCV kmeans | 29 | * \brief Wraps OpenCV kmeans |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class KMeans : public Transform | 32 | +class KMeansTransform : public Transform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_PROPERTY(int k READ get_k WRITE set_k RESET reset_k) | 35 | Q_PROPERTY(int k READ get_k WRITE set_k RESET reset_k) |
| @@ -71,6 +73,8 @@ class KMeans : public Transform | @@ -71,6 +73,8 @@ class KMeans : public Transform | ||
| 71 | } | 73 | } |
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| 74 | -BR_REGISTER(Transform, KMeans) | 76 | +BR_REGISTER(Transform, KMeansTransform) |
| 77 | + | ||
| 78 | +} | ||
| 75 | 79 | ||
| 76 | #include "cluster.moc" | 80 | #include "cluster.moc" |
sdk/plugins/compare.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/distance_sse.h" | 20 | #include "core/distance_sse.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup distances | 28 | * \ingroup distances |
| 27 | * \brief Standard distance metrics | 29 | * \brief Standard distance metrics |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class Dist : public Distance | 32 | +class DistDistance : public Distance |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_ENUMS(Metric) | 35 | Q_ENUMS(Metric) |
| @@ -110,14 +112,14 @@ private: | @@ -110,14 +112,14 @@ private: | ||
| 110 | } | 112 | } |
| 111 | }; | 113 | }; |
| 112 | 114 | ||
| 113 | -BR_REGISTER(Distance, Dist) | 115 | +BR_REGISTER(Distance, DistDistance) |
| 114 | 116 | ||
| 115 | /*! | 117 | /*! |
| 116 | * \ingroup distances | 118 | * \ingroup distances |
| 117 | * \brief Fast 8-bit L1 distance | 119 | * \brief Fast 8-bit L1 distance |
| 118 | * \author Josh Klontz \cite jklontz | 120 | * \author Josh Klontz \cite jklontz |
| 119 | */ | 121 | */ |
| 120 | -class UCharL1 : public Distance | 122 | +class UCharL1Distance : public Distance |
| 121 | { | 123 | { |
| 122 | Q_OBJECT | 124 | Q_OBJECT |
| 123 | 125 | ||
| @@ -127,7 +129,7 @@ class UCharL1 : public Distance | @@ -127,7 +129,7 @@ class UCharL1 : public Distance | ||
| 127 | } | 129 | } |
| 128 | }; | 130 | }; |
| 129 | 131 | ||
| 130 | -BR_REGISTER(Distance, UCharL1) | 132 | +BR_REGISTER(Distance, UCharL1Distance) |
| 131 | 133 | ||
| 132 | 134 | ||
| 133 | /*! | 135 | /*! |
| @@ -135,7 +137,7 @@ BR_REGISTER(Distance, UCharL1) | @@ -135,7 +137,7 @@ BR_REGISTER(Distance, UCharL1) | ||
| 135 | * \brief Fast 4-bit L1 distance | 137 | * \brief Fast 4-bit L1 distance |
| 136 | * \author Josh Klontz \cite jklontz | 138 | * \author Josh Klontz \cite jklontz |
| 137 | */ | 139 | */ |
| 138 | -class PackedUCharL1 : public Distance | 140 | +class PackedUCharL1Distance : public Distance |
| 139 | { | 141 | { |
| 140 | Q_OBJECT | 142 | Q_OBJECT |
| 141 | 143 | ||
| @@ -145,14 +147,14 @@ class PackedUCharL1 : public Distance | @@ -145,14 +147,14 @@ class PackedUCharL1 : public Distance | ||
| 145 | } | 147 | } |
| 146 | }; | 148 | }; |
| 147 | 149 | ||
| 148 | -BR_REGISTER(Distance, PackedUCharL1) | 150 | +BR_REGISTER(Distance, PackedUCharL1Distance) |
| 149 | 151 | ||
| 150 | /*! | 152 | /*! |
| 151 | * \ingroup distances | 153 | * \ingroup distances |
| 152 | * \brief Returns \c true if the templates are identical, \c false otherwise. | 154 | * \brief Returns \c true if the templates are identical, \c false otherwise. |
| 153 | * \author Josh Klontz \cite jklontz | 155 | * \author Josh Klontz \cite jklontz |
| 154 | */ | 156 | */ |
| 155 | -class Identical : public Distance | 157 | +class IdenticalDistance : public Distance |
| 156 | { | 158 | { |
| 157 | Q_OBJECT | 159 | Q_OBJECT |
| 158 | 160 | ||
| @@ -168,6 +170,8 @@ class Identical : public Distance | @@ -168,6 +170,8 @@ class Identical : public Distance | ||
| 168 | } | 170 | } |
| 169 | }; | 171 | }; |
| 170 | 172 | ||
| 171 | -BR_REGISTER(Distance, Identical) | 173 | +BR_REGISTER(Distance, IdenticalDistance) |
| 174 | + | ||
| 175 | +} // namespace br | ||
| 172 | 176 | ||
| 173 | #include "compare.moc" | 177 | #include "compare.moc" |
sdk/plugins/crop.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Crops the regions of interest. | 29 | * \brief Crops the regions of interest. |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class ROI : public UntrainableTransform | 32 | +class ROITransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | 35 | ||
| @@ -38,14 +40,14 @@ class ROI : public UntrainableTransform | @@ -38,14 +40,14 @@ class ROI : public UntrainableTransform | ||
| 38 | } | 40 | } |
| 39 | }; | 41 | }; |
| 40 | 42 | ||
| 41 | -BR_REGISTER(Transform, ROI) | 43 | +BR_REGISTER(Transform, ROITransform) |
| 42 | 44 | ||
| 43 | /*! | 45 | /*! |
| 44 | * \ingroup transforms | 46 | * \ingroup transforms |
| 45 | * \brief Resize the template | 47 | * \brief Resize the template |
| 46 | * \author Josh Klontz \cite jklontz | 48 | * \author Josh Klontz \cite jklontz |
| 47 | */ | 49 | */ |
| 48 | -class Resize : public UntrainableTransform | 50 | +class ResizeTransform : public UntrainableTransform |
| 49 | { | 51 | { |
| 50 | Q_OBJECT | 52 | Q_OBJECT |
| 51 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) | 53 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) |
| @@ -59,14 +61,14 @@ class Resize : public UntrainableTransform | @@ -59,14 +61,14 @@ class Resize : public UntrainableTransform | ||
| 59 | } | 61 | } |
| 60 | }; | 62 | }; |
| 61 | 63 | ||
| 62 | -BR_REGISTER(Transform, Resize) | 64 | +BR_REGISTER(Transform, ResizeTransform) |
| 63 | 65 | ||
| 64 | /*! | 66 | /*! |
| 65 | * \ingroup transforms | 67 | * \ingroup transforms |
| 66 | * \brief Limit the size of the template | 68 | * \brief Limit the size of the template |
| 67 | * \author Josh Klontz \cite jklontz | 69 | * \author Josh Klontz \cite jklontz |
| 68 | */ | 70 | */ |
| 69 | -class LimitSize : public UntrainableTransform | 71 | +class LimitSizeTransform : public UntrainableTransform |
| 70 | { | 72 | { |
| 71 | Q_OBJECT | 73 | Q_OBJECT |
| 72 | Q_PROPERTY(int max READ get_max WRITE set_max RESET reset_max STORED false) | 74 | Q_PROPERTY(int max READ get_max WRITE set_max RESET reset_max STORED false) |
| @@ -84,14 +86,14 @@ class LimitSize : public UntrainableTransform | @@ -84,14 +86,14 @@ class LimitSize : public UntrainableTransform | ||
| 84 | } | 86 | } |
| 85 | }; | 87 | }; |
| 86 | 88 | ||
| 87 | -BR_REGISTER(Transform, LimitSize) | 89 | +BR_REGISTER(Transform, LimitSizeTransform) |
| 88 | 90 | ||
| 89 | /*! | 91 | /*! |
| 90 | * \ingroup transforms | 92 | * \ingroup transforms |
| 91 | * \brief Crop out black borders | 93 | * \brief Crop out black borders |
| 92 | * \author Josh Klontz \cite jklontz | 94 | * \author Josh Klontz \cite jklontz |
| 93 | */ | 95 | */ |
| 94 | -class CropBlack : public UntrainableTransform | 96 | +class CropBlackTransform : public UntrainableTransform |
| 95 | { | 97 | { |
| 96 | Q_OBJECT | 98 | Q_OBJECT |
| 97 | 99 | ||
| @@ -128,6 +130,8 @@ class CropBlack : public UntrainableTransform | @@ -128,6 +130,8 @@ class CropBlack : public UntrainableTransform | ||
| 128 | } | 130 | } |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| 131 | -BR_REGISTER(Transform, CropBlack) | 133 | +BR_REGISTER(Transform, CropBlackTransform) |
| 134 | + | ||
| 135 | +} // namespace br | ||
| 132 | 136 | ||
| 133 | #include "crop.moc" | 137 | #include "crop.moc" |
sdk/plugins/cvt.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Colorspace conversion | 29 | * \brief Colorspace conversion |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class Cvt : public UntrainableTransform | 32 | +class CvtTransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_ENUMS(Code) | 35 | Q_ENUMS(Code) |
| @@ -63,14 +65,14 @@ private: | @@ -63,14 +65,14 @@ private: | ||
| 63 | } | 65 | } |
| 64 | }; | 66 | }; |
| 65 | 67 | ||
| 66 | -BR_REGISTER(Transform, Cvt) | 68 | +BR_REGISTER(Transform, CvtTransform) |
| 67 | 69 | ||
| 68 | /*! | 70 | /*! |
| 69 | * \ingroup transforms | 71 | * \ingroup transforms |
| 70 | * \brief Convert to floating point format. | 72 | * \brief Convert to floating point format. |
| 71 | * \author Josh Klontz \cite jklontz | 73 | * \author Josh Klontz \cite jklontz |
| 72 | */ | 74 | */ |
| 73 | -class CvtFloat : public UntrainableTransform | 75 | +class CvtFloatTransform : public UntrainableTransform |
| 74 | { | 76 | { |
| 75 | Q_OBJECT | 77 | Q_OBJECT |
| 76 | 78 | ||
| @@ -80,14 +82,14 @@ class CvtFloat : public UntrainableTransform | @@ -80,14 +82,14 @@ class CvtFloat : public UntrainableTransform | ||
| 80 | } | 82 | } |
| 81 | }; | 83 | }; |
| 82 | 84 | ||
| 83 | -BR_REGISTER(Transform, CvtFloat) | 85 | +BR_REGISTER(Transform, CvtFloatTransform) |
| 84 | 86 | ||
| 85 | /*! | 87 | /*! |
| 86 | * \ingroup transforms | 88 | * \ingroup transforms |
| 87 | * \brief Convert to uchar format | 89 | * \brief Convert to uchar format |
| 88 | * \author Josh Klontz \cite jklontz | 90 | * \author Josh Klontz \cite jklontz |
| 89 | */ | 91 | */ |
| 90 | -class CvtUChar : public UntrainableTransform | 92 | +class CvtUCharTransform : public UntrainableTransform |
| 91 | { | 93 | { |
| 92 | Q_OBJECT | 94 | Q_OBJECT |
| 93 | 95 | ||
| @@ -97,14 +99,14 @@ class CvtUChar : public UntrainableTransform | @@ -97,14 +99,14 @@ class CvtUChar : public UntrainableTransform | ||
| 97 | } | 99 | } |
| 98 | }; | 100 | }; |
| 99 | 101 | ||
| 100 | -BR_REGISTER(Transform, CvtUChar) | 102 | +BR_REGISTER(Transform, CvtUCharTransform) |
| 101 | 103 | ||
| 102 | /*! | 104 | /*! |
| 103 | * \ingroup transforms | 105 | * \ingroup transforms |
| 104 | * \brief Split a multi-channel matrix into several single-channel matrices. | 106 | * \brief Split a multi-channel matrix into several single-channel matrices. |
| 105 | * \author Josh Klontz \cite jklontz | 107 | * \author Josh Klontz \cite jklontz |
| 106 | */ | 108 | */ |
| 107 | -class SplitChannels : public UntrainableTransform | 109 | +class SplitChannelsTransform : public UntrainableTransform |
| 108 | { | 110 | { |
| 109 | Q_OBJECT | 111 | Q_OBJECT |
| 110 | 112 | ||
| @@ -117,14 +119,14 @@ class SplitChannels : public UntrainableTransform | @@ -117,14 +119,14 @@ class SplitChannels : public UntrainableTransform | ||
| 117 | } | 119 | } |
| 118 | }; | 120 | }; |
| 119 | 121 | ||
| 120 | -BR_REGISTER(Transform, SplitChannels) | 122 | +BR_REGISTER(Transform, SplitChannelsTransform) |
| 121 | 123 | ||
| 122 | /*! | 124 | /*! |
| 123 | * \ingroup transforms | 125 | * \ingroup transforms |
| 124 | * \brief Enforce the matrix has a certain number of channels by adding or removing channels. | 126 | * \brief Enforce the matrix has a certain number of channels by adding or removing channels. |
| 125 | * \author Josh Klontz \cite jklontz | 127 | * \author Josh Klontz \cite jklontz |
| 126 | */ | 128 | */ |
| 127 | -class EnsureChannels : public UntrainableTransform | 129 | +class EnsureChannelsTransform : public UntrainableTransform |
| 128 | { | 130 | { |
| 129 | Q_OBJECT | 131 | Q_OBJECT |
| 130 | Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false) | 132 | Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false) |
| @@ -156,6 +158,8 @@ class EnsureChannels : public UntrainableTransform | @@ -156,6 +158,8 @@ class EnsureChannels : public UntrainableTransform | ||
| 156 | } | 158 | } |
| 157 | }; | 159 | }; |
| 158 | 160 | ||
| 159 | -BR_REGISTER(Transform, EnsureChannels) | 161 | +BR_REGISTER(Transform, EnsureChannelsTransform) |
| 162 | + | ||
| 163 | +} // namespace br | ||
| 160 | 164 | ||
| 161 | #include "cvt.moc" | 165 | #include "cvt.moc" |
sdk/plugins/denoising.cpp
| @@ -18,14 +18,16 @@ | @@ -18,14 +18,16 @@ | ||
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | using namespace cv; | 20 | using namespace cv; |
| 21 | -using namespace br; | 21 | + |
| 22 | +namespace br | ||
| 23 | +{ | ||
| 22 | 24 | ||
| 23 | /*! | 25 | /*! |
| 24 | * \ingroup transforms | 26 | * \ingroup transforms |
| 25 | * \brief Wraps OpenCV Non-Local Means Denoising | 27 | * \brief Wraps OpenCV Non-Local Means Denoising |
| 26 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 27 | */ | 29 | */ |
| 28 | -class NLMeansDenoising : public UntrainableTransform | 30 | +class NLMeansDenoisingTransform : public UntrainableTransform |
| 29 | { | 31 | { |
| 30 | Q_OBJECT | 32 | Q_OBJECT |
| 31 | Q_PROPERTY(float h READ get_h WRITE set_h RESET reset_h STORED false) | 33 | Q_PROPERTY(float h READ get_h WRITE set_h RESET reset_h STORED false) |
| @@ -41,6 +43,8 @@ class NLMeansDenoising : public UntrainableTransform | @@ -41,6 +43,8 @@ class NLMeansDenoising : public UntrainableTransform | ||
| 41 | } | 43 | } |
| 42 | }; | 44 | }; |
| 43 | 45 | ||
| 44 | -BR_REGISTER(Transform, NLMeansDenoising) | 46 | +BR_REGISTER(Transform, NLMeansDenoisingTransform) |
| 47 | + | ||
| 48 | +} // namespace br | ||
| 45 | 49 | ||
| 46 | #include "denoising.moc" | 50 | #include "denoising.moc" |
sdk/plugins/draw.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Renders metadata onto the image | 29 | * \brief Renders metadata onto the image |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class Draw : public UntrainableTransform | 32 | +class DrawTransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_PROPERTY(bool verbose READ get_verbose WRITE set_verbose RESET reset_verbose STORED false) | 35 | Q_PROPERTY(bool verbose READ get_verbose WRITE set_verbose RESET reset_verbose STORED false) |
| @@ -52,14 +54,14 @@ class Draw : public UntrainableTransform | @@ -52,14 +54,14 @@ class Draw : public UntrainableTransform | ||
| 52 | } | 54 | } |
| 53 | }; | 55 | }; |
| 54 | 56 | ||
| 55 | -BR_REGISTER(Transform, Draw) | 57 | +BR_REGISTER(Transform, DrawTransform) |
| 56 | 58 | ||
| 57 | /*! | 59 | /*! |
| 58 | * \ingroup transforms | 60 | * \ingroup transforms |
| 59 | * \brief Draws a grid on the image | 61 | * \brief Draws a grid on the image |
| 60 | * \author Josh Klontz \cite jklontz | 62 | * \author Josh Klontz \cite jklontz |
| 61 | */ | 63 | */ |
| 62 | -class DrawGrid : public UntrainableTransform | 64 | +class DrawGridTransform : public UntrainableTransform |
| 63 | { | 65 | { |
| 64 | Q_OBJECT | 66 | Q_OBJECT |
| 65 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) | 67 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) |
| @@ -87,14 +89,14 @@ class DrawGrid : public UntrainableTransform | @@ -87,14 +89,14 @@ class DrawGrid : public UntrainableTransform | ||
| 87 | } | 89 | } |
| 88 | }; | 90 | }; |
| 89 | 91 | ||
| 90 | -BR_REGISTER(Transform, DrawGrid) | 92 | +BR_REGISTER(Transform, DrawGridTransform) |
| 91 | 93 | ||
| 92 | /*! | 94 | /*! |
| 93 | * \ingroup transforms | 95 | * \ingroup transforms |
| 94 | * \brief Remove landmarks. | 96 | * \brief Remove landmarks. |
| 95 | * \author Josh Klontz \cite jklontz | 97 | * \author Josh Klontz \cite jklontz |
| 96 | */ | 98 | */ |
| 97 | -class Edit : public UntrainableTransform | 99 | +class EditTransform : public UntrainableTransform |
| 98 | { | 100 | { |
| 99 | Q_OBJECT | 101 | Q_OBJECT |
| 100 | 102 | ||
| @@ -129,7 +131,7 @@ class Edit : public UntrainableTransform | @@ -129,7 +131,7 @@ class Edit : public UntrainableTransform | ||
| 129 | 131 | ||
| 130 | static void mouseCallback(int event, int x, int y, int flags, void *userdata) | 132 | static void mouseCallback(int event, int x, int y, int flags, void *userdata) |
| 131 | { | 133 | { |
| 132 | - ((const Edit*)userdata)->mouseEvent(event, x, y, flags); | 134 | + ((const EditTransform*)userdata)->mouseEvent(event, x, y, flags); |
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | void mouseEvent(int event, int x, int y, int flags) const | 137 | void mouseEvent(int event, int x, int y, int flags) const |
| @@ -149,9 +151,11 @@ class Edit : public UntrainableTransform | @@ -149,9 +151,11 @@ class Edit : public UntrainableTransform | ||
| 149 | } | 151 | } |
| 150 | }; | 152 | }; |
| 151 | 153 | ||
| 152 | -Template Edit::currentTemplate; | ||
| 153 | -QMutex Edit::currentTemplateLock; | 154 | +Template EditTransform::currentTemplate; |
| 155 | +QMutex EditTransform::currentTemplateLock; | ||
| 156 | + | ||
| 157 | +BR_REGISTER(Transform, EditTransform) | ||
| 154 | 158 | ||
| 155 | -BR_REGISTER(Transform, Edit) | 159 | +} // namespace br |
| 156 | 160 | ||
| 157 | #include "draw.moc" | 161 | #include "draw.moc" |
sdk/plugins/eigen3.cpp
| @@ -20,7 +20,8 @@ | @@ -20,7 +20,8 @@ | ||
| 20 | #include "core/common.h" | 20 | #include "core/common.h" |
| 21 | #include "core/eigenutils.h" | 21 | #include "core/eigenutils.h" |
| 22 | 22 | ||
| 23 | -using namespace br; | 23 | +namespace br |
| 24 | +{ | ||
| 24 | 25 | ||
| 25 | /*! | 26 | /*! |
| 26 | * \ingroup transforms | 27 | * \ingroup transforms |
| @@ -28,7 +29,7 @@ using namespace br; | @@ -28,7 +29,7 @@ using namespace br; | ||
| 28 | * \author Brendan Klare \cite bklare | 29 | * \author Brendan Klare \cite bklare |
| 29 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 30 | */ | 31 | */ |
| 31 | -class PCA : public Transform | 32 | +class PCATransform : public Transform |
| 32 | { | 33 | { |
| 33 | Q_OBJECT | 34 | Q_OBJECT |
| 34 | Q_PROPERTY(float keep READ get_keep WRITE set_keep RESET reset_keep STORED false) | 35 | Q_PROPERTY(float keep READ get_keep WRITE set_keep RESET reset_keep STORED false) |
| @@ -45,11 +46,11 @@ class PCA : public Transform | @@ -45,11 +46,11 @@ class PCA : public Transform | ||
| 45 | Eigen::VectorXf mean, eVals; | 46 | Eigen::VectorXf mean, eVals; |
| 46 | Eigen::MatrixXf eVecs; | 47 | Eigen::MatrixXf eVecs; |
| 47 | 48 | ||
| 48 | - friend class DFFS; | ||
| 49 | - friend class LDA; | 49 | + friend class DFFSTransform; |
| 50 | + friend class LDATransform; | ||
| 50 | 51 | ||
| 51 | public: | 52 | public: |
| 52 | - PCA() : keep(0.95), drop(0), whiten(false) {} | 53 | + PCATransform() : keep(0.95), drop(0), whiten(false) {} |
| 53 | 54 | ||
| 54 | private: | 55 | private: |
| 55 | /* | 56 | /* |
| @@ -195,14 +196,14 @@ private: | @@ -195,14 +196,14 @@ private: | ||
| 195 | } | 196 | } |
| 196 | }; | 197 | }; |
| 197 | 198 | ||
| 198 | -BR_REGISTER(Transform, PCA) | 199 | +BR_REGISTER(Transform, PCATransform) |
| 199 | 200 | ||
| 200 | /*! | 201 | /*! |
| 201 | * \ingroup transforms | 202 | * \ingroup transforms |
| 202 | * \brief Computes Distance From Feature Space (DFFS) \cite moghaddam97. | 203 | * \brief Computes Distance From Feature Space (DFFS) \cite moghaddam97. |
| 203 | * \author Josh Klontz \cite jklontz | 204 | * \author Josh Klontz \cite jklontz |
| 204 | */ | 205 | */ |
| 205 | -class DFFS : public Transform | 206 | +class DFFSTransform : public Transform |
| 206 | { | 207 | { |
| 207 | Q_OBJECT | 208 | Q_OBJECT |
| 208 | Q_PROPERTY(float keep READ get_keep WRITE set_keep RESET reset_keep STORED false) | 209 | Q_PROPERTY(float keep READ get_keep WRITE set_keep RESET reset_keep STORED false) |
| @@ -210,7 +211,7 @@ class DFFS : public Transform | @@ -210,7 +211,7 @@ class DFFS : public Transform | ||
| 210 | BR_PROPERTY(float, keep, 0.95) | 211 | BR_PROPERTY(float, keep, 0.95) |
| 211 | BR_PROPERTY(br::Transform*, transform, NULL) | 212 | BR_PROPERTY(br::Transform*, transform, NULL) |
| 212 | 213 | ||
| 213 | - PCA pca; | 214 | + PCATransform pca; |
| 214 | Transform *cvtFloat; | 215 | Transform *cvtFloat; |
| 215 | 216 | ||
| 216 | void init() | 217 | void init() |
| @@ -241,7 +242,7 @@ class DFFS : public Transform | @@ -241,7 +242,7 @@ class DFFS : public Transform | ||
| 241 | } | 242 | } |
| 242 | }; | 243 | }; |
| 243 | 244 | ||
| 244 | -BR_REGISTER(Transform, DFFS) | 245 | +BR_REGISTER(Transform, DFFSTransform) |
| 245 | 246 | ||
| 246 | /*! | 247 | /*! |
| 247 | * \ingroup transforms | 248 | * \ingroup transforms |
| @@ -249,7 +250,7 @@ BR_REGISTER(Transform, DFFS) | @@ -249,7 +250,7 @@ BR_REGISTER(Transform, DFFS) | ||
| 249 | * \author Brendan Klare \cite bklare | 250 | * \author Brendan Klare \cite bklare |
| 250 | * \author Josh Klontz \cite jklontz | 251 | * \author Josh Klontz \cite jklontz |
| 251 | */ | 252 | */ |
| 252 | -class LDA : public Transform | 253 | +class LDATransform : public Transform |
| 253 | { | 254 | { |
| 254 | Q_OBJECT | 255 | Q_OBJECT |
| 255 | Q_PROPERTY(float pcaKeep READ get_pcaKeep WRITE set_pcaKeep RESET reset_pcaKeep STORED false) | 256 | Q_PROPERTY(float pcaKeep READ get_pcaKeep WRITE set_pcaKeep RESET reset_pcaKeep STORED false) |
| @@ -268,7 +269,7 @@ class LDA : public Transform | @@ -268,7 +269,7 @@ class LDA : public Transform | ||
| 268 | int instances = trainingSet.size(); | 269 | int instances = trainingSet.size(); |
| 269 | 270 | ||
| 270 | // Perform PCA dimensionality reduction | 271 | // Perform PCA dimensionality reduction |
| 271 | - PCA pca; | 272 | + PCATransform pca; |
| 272 | pca.keep = pcaKeep; | 273 | pca.keep = pcaKeep; |
| 273 | pca.train(trainingSet); | 274 | pca.train(trainingSet); |
| 274 | mean = pca.mean; | 275 | mean = pca.mean; |
| @@ -294,7 +295,7 @@ class LDA : public Transform | @@ -294,7 +295,7 @@ class LDA : public Transform | ||
| 294 | for (int i=0; i<numClasses; i++) classMeans.col(i) /= classCounts[i]; | 295 | for (int i=0; i<numClasses; i++) classMeans.col(i) /= classCounts[i]; |
| 295 | for (int i=0; i<instances; i++) data.col(i) -= classMeans.col(classes[i]); | 296 | for (int i=0; i<instances; i++) data.col(i) -= classMeans.col(classes[i]); |
| 296 | 297 | ||
| 297 | - PCA space1; | 298 | + PCATransform space1; |
| 298 | 299 | ||
| 299 | if (!directLDA) | 300 | if (!directLDA) |
| 300 | { | 301 | { |
| @@ -389,7 +390,7 @@ class LDA : public Transform | @@ -389,7 +390,7 @@ class LDA : public Transform | ||
| 389 | // because each class is a vector used to compute the covariance, | 390 | // because each class is a vector used to compute the covariance, |
| 390 | // but one degree of freedom is lost removing the global mean. | 391 | // but one degree of freedom is lost removing the global mean. |
| 391 | int dim2 = std::min((int)space1.keep, numClasses-1); | 392 | int dim2 = std::min((int)space1.keep, numClasses-1); |
| 392 | - PCA space2; | 393 | + PCATransform space2; |
| 393 | space2.keep = dim2; | 394 | space2.keep = dim2; |
| 394 | space2.train(data2); | 395 | space2.train(data2); |
| 395 | 396 | ||
| @@ -421,6 +422,8 @@ class LDA : public Transform | @@ -421,6 +422,8 @@ class LDA : public Transform | ||
| 421 | } | 422 | } |
| 422 | }; | 423 | }; |
| 423 | 424 | ||
| 424 | -BR_REGISTER(Transform, LDA) | 425 | +BR_REGISTER(Transform, LDATransform) |
| 426 | + | ||
| 427 | +} // namespace br | ||
| 425 | 428 | ||
| 426 | #include "eigen3.moc" | 429 | #include "eigen3.moc" |
sdk/plugins/eyes.cpp
| @@ -39,7 +39,9 @@ | @@ -39,7 +39,9 @@ | ||
| 39 | #include "core/opencvutils.h" | 39 | #include "core/opencvutils.h" |
| 40 | 40 | ||
| 41 | using namespace cv; | 41 | using namespace cv; |
| 42 | -using namespace br; | 42 | + |
| 43 | +namespace br | ||
| 44 | +{ | ||
| 43 | 45 | ||
| 44 | /*! | 46 | /*! |
| 45 | * \ingroup transforms | 47 | * \ingroup transforms |
| @@ -50,7 +52,7 @@ using namespace br; | @@ -50,7 +52,7 @@ using namespace br; | ||
| 50 | * \author David Bolme | 52 | * \author David Bolme |
| 51 | * \author Josh Klontz \cite jklontz | 53 | * \author Josh Klontz \cite jklontz |
| 52 | */ | 54 | */ |
| 53 | -class ASEFEyes : public UntrainableTransform | 55 | +class ASEFEyesTransform : public UntrainableTransform |
| 54 | { | 56 | { |
| 55 | Q_OBJECT | 57 | Q_OBJECT |
| 56 | 58 | ||
| @@ -59,7 +61,7 @@ class ASEFEyes : public UntrainableTransform | @@ -59,7 +61,7 @@ class ASEFEyes : public UntrainableTransform | ||
| 59 | int width, height; | 61 | int width, height; |
| 60 | 62 | ||
| 61 | public: | 63 | public: |
| 62 | - ASEFEyes() | 64 | + ASEFEyesTransform() |
| 63 | { | 65 | { |
| 64 | QFile file; | 66 | QFile file; |
| 65 | QByteArray line, lf, rf, magic_number; | 67 | QByteArray line, lf, rf, magic_number; |
| @@ -186,6 +188,8 @@ private: | @@ -186,6 +188,8 @@ private: | ||
| 186 | } | 188 | } |
| 187 | }; | 189 | }; |
| 188 | 190 | ||
| 189 | -BR_REGISTER(Transform, ASEFEyes) | 191 | +BR_REGISTER(Transform, ASEFEyesTransform) |
| 192 | + | ||
| 193 | +} // namespace br | ||
| 190 | 194 | ||
| 191 | #include "eyes.moc" | 195 | #include "eyes.moc" |
sdk/plugins/fill.cpp
| @@ -18,14 +18,16 @@ | @@ -18,14 +18,16 @@ | ||
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | using namespace cv; | 20 | using namespace cv; |
| 21 | -using namespace br; | 21 | + |
| 22 | +namespace br | ||
| 23 | +{ | ||
| 22 | 24 | ||
| 23 | /*! | 25 | /*! |
| 24 | * \ingroup transforms | 26 | * \ingroup transforms |
| 25 | * \brief Wraps OpenCV inpainting | 27 | * \brief Wraps OpenCV inpainting |
| 26 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 27 | */ | 29 | */ |
| 28 | -class Inpaint : public UntrainableTransform | 30 | +class InpaintTransform : public UntrainableTransform |
| 29 | { | 31 | { |
| 30 | Q_OBJECT | 32 | Q_OBJECT |
| 31 | Q_ENUMS(Method) | 33 | Q_ENUMS(Method) |
| @@ -53,14 +55,14 @@ private: | @@ -53,14 +55,14 @@ private: | ||
| 53 | } | 55 | } |
| 54 | }; | 56 | }; |
| 55 | 57 | ||
| 56 | -BR_REGISTER(Transform, Inpaint) | 58 | +BR_REGISTER(Transform, InpaintTransform) |
| 57 | 59 | ||
| 58 | /*! | 60 | /*! |
| 59 | * \ingroup transforms | 61 | * \ingroup transforms |
| 60 | * \brief Fill 0 pixels with the mean of non-0 pixels. | 62 | * \brief Fill 0 pixels with the mean of non-0 pixels. |
| 61 | * \author Josh Klontz \cite jklontz | 63 | * \author Josh Klontz \cite jklontz |
| 62 | */ | 64 | */ |
| 63 | -class MeanFill : public UntrainableTransform | 65 | +class MeanFillTransform : public UntrainableTransform |
| 64 | { | 66 | { |
| 65 | Q_OBJECT | 67 | Q_OBJECT |
| 66 | 68 | ||
| @@ -71,14 +73,14 @@ class MeanFill : public UntrainableTransform | @@ -71,14 +73,14 @@ class MeanFill : public UntrainableTransform | ||
| 71 | } | 73 | } |
| 72 | }; | 74 | }; |
| 73 | 75 | ||
| 74 | -BR_REGISTER(Transform, MeanFill) | 76 | +BR_REGISTER(Transform, MeanFillTransform) |
| 75 | 77 | ||
| 76 | /*! | 78 | /*! |
| 77 | * \ingroup transforms | 79 | * \ingroup transforms |
| 78 | * \brief Fill black pixels with the specified color. | 80 | * \brief Fill black pixels with the specified color. |
| 79 | * \author Josh Klontz \cite jklontz | 81 | * \author Josh Klontz \cite jklontz |
| 80 | */ | 82 | */ |
| 81 | -class Flood : public UntrainableTransform | 83 | +class FloodTransform : public UntrainableTransform |
| 82 | { | 84 | { |
| 83 | Q_OBJECT | 85 | Q_OBJECT |
| 84 | Q_PROPERTY(int r READ get_r WRITE set_r RESET reset_r STORED false) | 86 | Q_PROPERTY(int r READ get_r WRITE set_r RESET reset_r STORED false) |
| @@ -97,14 +99,14 @@ class Flood : public UntrainableTransform | @@ -97,14 +99,14 @@ class Flood : public UntrainableTransform | ||
| 97 | } | 99 | } |
| 98 | }; | 100 | }; |
| 99 | 101 | ||
| 100 | -BR_REGISTER(Transform, Flood) | 102 | +BR_REGISTER(Transform, FloodTransform) |
| 101 | 103 | ||
| 102 | /*! | 104 | /*! |
| 103 | * \ingroup transforms | 105 | * \ingroup transforms |
| 104 | * \brief Alpha-blend two matrices | 106 | * \brief Alpha-blend two matrices |
| 105 | * \author Josh Klontz \cite jklontz | 107 | * \author Josh Klontz \cite jklontz |
| 106 | */ | 108 | */ |
| 107 | -class Blend : public UntrainableMetaTransform | 109 | +class BlendTransform : public UntrainableMetaTransform |
| 108 | { | 110 | { |
| 109 | Q_OBJECT | 111 | Q_OBJECT |
| 110 | Q_PROPERTY(float alpha READ get_alpha WRITE set_alpha RESET reset_alpha STORED false) | 112 | Q_PROPERTY(float alpha READ get_alpha WRITE set_alpha RESET reset_alpha STORED false) |
| @@ -117,6 +119,8 @@ class Blend : public UntrainableMetaTransform | @@ -117,6 +119,8 @@ class Blend : public UntrainableMetaTransform | ||
| 117 | } | 119 | } |
| 118 | }; | 120 | }; |
| 119 | 121 | ||
| 120 | -BR_REGISTER(Transform, Blend) | 122 | +BR_REGISTER(Transform, BlendTransform) |
| 123 | + | ||
| 124 | +} // namespace br | ||
| 121 | 125 | ||
| 122 | #include "fill.moc" | 126 | #include "fill.moc" |
sdk/plugins/filter.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/tanh_sse.h" | 20 | #include "core/tanh_sse.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Gamma correction | 29 | * \brief Gamma correction |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class Gamma : public UntrainableTransform | 32 | +class GammaTransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_PROPERTY(float gamma READ get_gamma WRITE set_gamma RESET reset_gamma) | 35 | Q_PROPERTY(float gamma READ get_gamma WRITE set_gamma RESET reset_gamma) |
| @@ -48,14 +50,14 @@ class Gamma : public UntrainableTransform | @@ -48,14 +50,14 @@ class Gamma : public UntrainableTransform | ||
| 48 | } | 50 | } |
| 49 | }; | 51 | }; |
| 50 | 52 | ||
| 51 | -BR_REGISTER(Transform, Gamma) | 53 | +BR_REGISTER(Transform, GammaTransform) |
| 52 | 54 | ||
| 53 | /*! | 55 | /*! |
| 54 | * \ingroup transforms | 56 | * \ingroup transforms |
| 55 | * \brief Gaussian blur | 57 | * \brief Gaussian blur |
| 56 | * \author Josh Klontz \cite jklontz | 58 | * \author Josh Klontz \cite jklontz |
| 57 | */ | 59 | */ |
| 58 | -class Blur : public UntrainableTransform | 60 | +class BlurTransform : public UntrainableTransform |
| 59 | { | 61 | { |
| 60 | Q_OBJECT | 62 | Q_OBJECT |
| 61 | Q_PROPERTY(float sigma READ get_sigma WRITE set_sigma RESET reset_sigma STORED false) | 63 | Q_PROPERTY(float sigma READ get_sigma WRITE set_sigma RESET reset_sigma STORED false) |
| @@ -67,14 +69,14 @@ class Blur : public UntrainableTransform | @@ -67,14 +69,14 @@ class Blur : public UntrainableTransform | ||
| 67 | } | 69 | } |
| 68 | }; | 70 | }; |
| 69 | 71 | ||
| 70 | -BR_REGISTER(Transform, Blur) | 72 | +BR_REGISTER(Transform, BlurTransform) |
| 71 | 73 | ||
| 72 | /*! | 74 | /*! |
| 73 | * \ingroup transforms | 75 | * \ingroup transforms |
| 74 | * \brief Difference of gaussians | 76 | * \brief Difference of gaussians |
| 75 | * \author Josh Klontz \cite jklontz | 77 | * \author Josh Klontz \cite jklontz |
| 76 | */ | 78 | */ |
| 77 | -class DoG : public UntrainableTransform | 79 | +class DoGTransform : public UntrainableTransform |
| 78 | { | 80 | { |
| 79 | Q_OBJECT | 81 | Q_OBJECT |
| 80 | Q_PROPERTY(float sigma0 READ get_sigma0 WRITE set_sigma0 RESET reset_sigma0 STORED false) | 82 | Q_PROPERTY(float sigma0 READ get_sigma0 WRITE set_sigma0 RESET reset_sigma0 STORED false) |
| @@ -109,7 +111,7 @@ class DoG : public UntrainableTransform | @@ -109,7 +111,7 @@ class DoG : public UntrainableTransform | ||
| 109 | } | 111 | } |
| 110 | }; | 112 | }; |
| 111 | 113 | ||
| 112 | -BR_REGISTER(Transform, DoG) | 114 | +BR_REGISTER(Transform, DoGTransform) |
| 113 | 115 | ||
| 114 | /*! | 116 | /*! |
| 115 | * \ingroup transforms | 117 | * \ingroup transforms |
| @@ -119,7 +121,7 @@ BR_REGISTER(Transform, DoG) | @@ -119,7 +121,7 @@ BR_REGISTER(Transform, DoG) | ||
| 119 | * \author Scott Klum \cite sklum | 121 | * \author Scott Klum \cite sklum |
| 120 | */ | 122 | */ |
| 121 | 123 | ||
| 122 | -class CSDN : public UntrainableTransform | 124 | +class CSDNTransform : public UntrainableTransform |
| 123 | { | 125 | { |
| 124 | Q_OBJECT | 126 | Q_OBJECT |
| 125 | 127 | ||
| @@ -159,7 +161,7 @@ class CSDN : public UntrainableTransform | @@ -159,7 +161,7 @@ class CSDN : public UntrainableTransform | ||
| 159 | } | 161 | } |
| 160 | }; | 162 | }; |
| 161 | 163 | ||
| 162 | -BR_REGISTER(Transform, CSDN) | 164 | +BR_REGISTER(Transform, CSDNTransform) |
| 163 | 165 | ||
| 164 | /*! | 166 | /*! |
| 165 | * \ingroup transforms | 167 | * \ingroup transforms |
| @@ -168,7 +170,7 @@ BR_REGISTER(Transform, CSDN) | @@ -168,7 +170,7 @@ BR_REGISTER(Transform, CSDN) | ||
| 168 | * Image Processing, IEEE Transactions on , vol.19, no.6, pp.1635-1650, June 2010 | 170 | * Image Processing, IEEE Transactions on , vol.19, no.6, pp.1635-1650, June 2010 |
| 169 | * \author Josh Klontz \cite jklontz | 171 | * \author Josh Klontz \cite jklontz |
| 170 | */ | 172 | */ |
| 171 | -class ContrastEq : public UntrainableTransform | 173 | +class ContrastEqTransform : public UntrainableTransform |
| 172 | { | 174 | { |
| 173 | Q_OBJECT | 175 | Q_OBJECT |
| 174 | Q_PROPERTY(float a READ get_a WRITE set_a RESET reset_a STORED false) | 176 | Q_PROPERTY(float a READ get_a WRITE set_a RESET reset_a STORED false) |
| @@ -216,14 +218,14 @@ class ContrastEq : public UntrainableTransform | @@ -216,14 +218,14 @@ class ContrastEq : public UntrainableTransform | ||
| 216 | } | 218 | } |
| 217 | }; | 219 | }; |
| 218 | 220 | ||
| 219 | -BR_REGISTER(Transform, ContrastEq) | 221 | +BR_REGISTER(Transform, ContrastEqTransform) |
| 220 | 222 | ||
| 221 | /*! | 223 | /*! |
| 222 | * \ingroup transforms | 224 | * \ingroup transforms |
| 223 | * \brief Raise each element to the specified power. | 225 | * \brief Raise each element to the specified power. |
| 224 | * \author Josh Klontz \cite jklontz | 226 | * \author Josh Klontz \cite jklontz |
| 225 | */ | 227 | */ |
| 226 | -class Pow : public UntrainableTransform | 228 | +class PowTransform : public UntrainableTransform |
| 227 | { | 229 | { |
| 228 | Q_OBJECT | 230 | Q_OBJECT |
| 229 | Q_PROPERTY(float power READ get_power WRITE set_power RESET reset_power STORED false) | 231 | Q_PROPERTY(float power READ get_power WRITE set_power RESET reset_power STORED false) |
| @@ -238,6 +240,8 @@ class Pow : public UntrainableTransform | @@ -238,6 +240,8 @@ class Pow : public UntrainableTransform | ||
| 238 | } | 240 | } |
| 239 | }; | 241 | }; |
| 240 | 242 | ||
| 241 | -BR_REGISTER(Transform, Pow) | 243 | +BR_REGISTER(Transform, PowTransform) |
| 244 | + | ||
| 245 | +} // namespace br | ||
| 242 | 246 | ||
| 243 | #include "filter.moc" | 247 | #include "filter.moc" |
sdk/plugins/format.cpp
| @@ -27,9 +27,51 @@ | @@ -27,9 +27,51 @@ | ||
| 27 | #include "core/opencvutils.h" | 27 | #include "core/opencvutils.h" |
| 28 | #include "core/qtutils.h" | 28 | #include "core/qtutils.h" |
| 29 | 29 | ||
| 30 | -using namespace br; | ||
| 31 | using namespace cv; | 30 | using namespace cv; |
| 32 | 31 | ||
| 32 | +namespace br | ||
| 33 | +{ | ||
| 34 | + | ||
| 35 | +/*! | ||
| 36 | + * \ingroup formats | ||
| 37 | + * \brief A simple binary matrix format. | ||
| 38 | + * \author Josh Klonyz \cite jklontz | ||
| 39 | + * First 4 bytes indicate the number of rows. | ||
| 40 | + * Second 4 bytes indicate the number of columns. | ||
| 41 | + * The rest of the bytes are 32-bit floating data elements. | ||
| 42 | + */ | ||
| 43 | +class binFormat : public Format | ||
| 44 | +{ | ||
| 45 | + Q_OBJECT | ||
| 46 | + | ||
| 47 | + Template read() const | ||
| 48 | + { | ||
| 49 | + QByteArray data; | ||
| 50 | + QtUtils::readFile(file, data); | ||
| 51 | + return Template(file, Mat(((quint32*)data.data())[0], | ||
| 52 | + ((quint32*)data.data())[1], | ||
| 53 | + CV_32FC1, | ||
| 54 | + data.data()+8).clone()); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + void write(const Template &t) const | ||
| 58 | + { | ||
| 59 | + Mat m; | ||
| 60 | + t.m().convertTo(m, CV_32F); | ||
| 61 | + if (m.channels() != 1) qFatal("binFormat::write only supports single channel matrices."); | ||
| 62 | + | ||
| 63 | + QByteArray data; | ||
| 64 | + QDataStream stream(&data, QFile::WriteOnly); | ||
| 65 | + stream.writeRawData((const char*)&m.rows, 4); | ||
| 66 | + stream.writeRawData((const char*)&m.cols, 4); | ||
| 67 | + stream.writeRawData((const char*)m.data, 4*m.rows*m.cols); | ||
| 68 | + | ||
| 69 | + QtUtils::writeFile(file, data); | ||
| 70 | + } | ||
| 71 | +}; | ||
| 72 | + | ||
| 73 | +BR_REGISTER(Format, binFormat) | ||
| 74 | + | ||
| 33 | /*! | 75 | /*! |
| 34 | * \ingroup formats | 76 | * \ingroup formats |
| 35 | * \brief Reads a comma separated value file. | 77 | * \brief Reads a comma separated value file. |
| @@ -50,23 +92,20 @@ class csvFormat : public Format | @@ -50,23 +92,20 @@ class csvFormat : public Format | ||
| 50 | QList< QList<float> > valsList; | 92 | QList< QList<float> > valsList; |
| 51 | foreach (const QString &line, lines) { | 93 | foreach (const QString &line, lines) { |
| 52 | QList<float> vals; | 94 | QList<float> vals; |
| 53 | - foreach (const QString &word, line.split(QRegExp(" *, *"))) { | 95 | + foreach (const QString &word, line.split(QRegExp(" *, *"), QString::SkipEmptyParts)) { |
| 54 | bool ok; | 96 | bool ok; |
| 55 | const float val = word.toFloat(&ok); | 97 | const float val = word.toFloat(&ok); |
| 56 | vals.append(val); | 98 | vals.append(val); |
| 57 | isUChar = isUChar && (val == float(uchar(val))); | 99 | isUChar = isUChar && (val == float(uchar(val))); |
| 58 | } | 100 | } |
| 59 | - valsList.append(vals); | 101 | + if (!vals.isEmpty()) |
| 102 | + valsList.append(vals); | ||
| 60 | } | 103 | } |
| 61 | 104 | ||
| 62 | - assert((valsList.size() > 0) && (valsList[0].size() > 0)); | ||
| 63 | Mat m(valsList.size(), valsList[0].size(), CV_32FC1); | 105 | Mat m(valsList.size(), valsList[0].size(), CV_32FC1); |
| 64 | - for (int i=0; i<valsList.size(); i++) { | ||
| 65 | - assert(valsList[i].size() == valsList[0].size()); | ||
| 66 | - for (int j=0; j<valsList[i].size(); j++) { | 106 | + for (int i=0; i<valsList.size(); i++) |
| 107 | + for (int j=0; j<valsList[i].size(); j++) | ||
| 67 | m.at<float>(i,j) = valsList[i][j]; | 108 | m.at<float>(i,j) = valsList[i][j]; |
| 68 | - } | ||
| 69 | - } | ||
| 70 | 109 | ||
| 71 | if (isUChar) m.convertTo(m, CV_8U); | 110 | if (isUChar) m.convertTo(m, CV_8U); |
| 72 | return Template(m); | 111 | return Template(m); |
| @@ -218,8 +257,8 @@ class matFormat : public Format | @@ -218,8 +257,8 @@ class matFormat : public Format | ||
| 218 | error |= (int(bytes) != stream.readRawData(data.data(), bytes)); | 257 | error |= (int(bytes) != stream.readRawData(data.data(), bytes)); |
| 219 | 258 | ||
| 220 | // Alignment | 259 | // Alignment |
| 221 | - int skipBytes = (bytes < 4) ? (4 - bytes) : 0; | ||
| 222 | - if (skipBytes != 0) error |= (skipBytes != stream.skipRawData(skipBytes)); | 260 | + int skipBytes = (bytes < 4) ? (4 - bytes) : (8 - bytes%8)%8; |
| 261 | + if (skipBytes != 0) stream.skipRawData(skipBytes); | ||
| 223 | 262 | ||
| 224 | if (error) qFatal("matFormat::Element Unexpected end of file."); | 263 | if (error) qFatal("matFormat::Element Unexpected end of file."); |
| 225 | } | 264 | } |
| @@ -289,7 +328,98 @@ class matFormat : public Format | @@ -289,7 +328,98 @@ class matFormat : public Format | ||
| 289 | 328 | ||
| 290 | void write(const Template &t) const | 329 | void write(const Template &t) const |
| 291 | { | 330 | { |
| 331 | + QByteArray data; | ||
| 332 | + QDataStream stream(&data, QFile::WriteOnly); | ||
| 333 | + | ||
| 334 | + { // Header | ||
| 335 | + QByteArray header = "MATLAB 5.0 MAT-file; Made with OpenBR | www.openbiometrics.org\n"; | ||
| 336 | + QByteArray buffer(116-header.size(), 0); | ||
| 337 | + stream.writeRawData(header.data(), header.size()); | ||
| 338 | + stream.writeRawData(buffer.data(), buffer.size()); | ||
| 339 | + quint64 subsystem = 0; | ||
| 340 | + quint16 version = 0x0100; | ||
| 341 | + const char *endianness = "IM"; | ||
| 342 | + stream.writeRawData((const char*)&subsystem, 8); | ||
| 343 | + stream.writeRawData((const char*)&version, 2); | ||
| 344 | + stream.writeRawData(endianness, 2); | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + for (int i=0; i<t.size(); i++) { | ||
| 348 | + const Mat &m = t[i]; | ||
| 349 | + if (m.channels() != 1) qFatal("matFormat::write only supports single channel matrices."); | ||
| 350 | + | ||
| 351 | + QByteArray subdata; | ||
| 352 | + QDataStream substream(&subdata, QFile::WriteOnly); | ||
| 353 | + | ||
| 354 | + { // Array Flags | ||
| 355 | + quint32 type = 6; | ||
| 356 | + quint32 bytes = 8; | ||
| 357 | + quint64 arrayClass = 0; | ||
| 358 | + switch (m.type()) { | ||
| 359 | + case CV_64FC1: arrayClass = 6; break; | ||
| 360 | + case CV_32FC1: arrayClass = 7; break; | ||
| 361 | + case CV_8UC1: arrayClass = 8; break; | ||
| 362 | + case CV_8SC1: arrayClass = 9; break; | ||
| 363 | + case CV_16UC1: arrayClass = 10; break; | ||
| 364 | + case CV_16SC1: arrayClass = 11; break; | ||
| 365 | + case CV_32SC1: arrayClass = 12; break; | ||
| 366 | + default: qFatal("matFormat::write unsupported matrix class."); | ||
| 367 | + } | ||
| 368 | + substream.writeRawData((const char*)&type, 4); | ||
| 369 | + substream.writeRawData((const char*)&bytes, 4); | ||
| 370 | + substream.writeRawData((const char*)&arrayClass, 8); | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + { // Dimensions Array | ||
| 374 | + quint32 type = 5; | ||
| 375 | + quint32 bytes = 8; | ||
| 376 | + substream.writeRawData((const char*)&type, 4); | ||
| 377 | + substream.writeRawData((const char*)&bytes, 4); | ||
| 378 | + substream.writeRawData((const char*)&m.rows, 4); | ||
| 379 | + substream.writeRawData((const char*)&m.cols, 4); | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + { // Array Name | ||
| 383 | + QByteArray name(qPrintable(QString("OpenBR_%1").arg(QString::number(i)))); | ||
| 384 | + quint32 type = 1; | ||
| 385 | + quint32 bytes = name.size(); | ||
| 386 | + QByteArray buffer((8 - bytes%8)%8, 0); | ||
| 387 | + substream.writeRawData((const char*)&type, 4); | ||
| 388 | + substream.writeRawData((const char*)&bytes, 4); | ||
| 389 | + substream.writeRawData(name.data(), name.size()); | ||
| 390 | + substream.writeRawData(buffer.data(), buffer.size()); | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + { // Real part | ||
| 394 | + quint32 type = 0; | ||
| 395 | + switch (m.type()) { | ||
| 396 | + case CV_8SC1: type = 1; break; | ||
| 397 | + case CV_8UC1: type = 2; break; | ||
| 398 | + case CV_16SC1: type = 3; break; | ||
| 399 | + case CV_16UC1: type = 4; break; | ||
| 400 | + case CV_32SC1: type = 5; break; | ||
| 401 | + case CV_32FC1: type = 7; break; | ||
| 402 | + case CV_64FC1: type = 9; break; | ||
| 403 | + default: qFatal("matFormat::write unsupported matrix type."); | ||
| 404 | + } | ||
| 405 | + quint32 bytes = m.elemSize() * m.rows * m.cols; | ||
| 406 | + QByteArray buffer((8 - bytes%8)%8, 0); | ||
| 407 | + substream.writeRawData((const char*)&type, 4); | ||
| 408 | + substream.writeRawData((const char*)&bytes, 4); | ||
| 409 | + substream.writeRawData((const char*)m.data, bytes); | ||
| 410 | + substream.writeRawData(buffer.data(), buffer.size()); | ||
| 411 | + } | ||
| 292 | 412 | ||
| 413 | + { // Matrix | ||
| 414 | + quint32 type = 14; | ||
| 415 | + quint32 bytes = subdata.size(); | ||
| 416 | + stream.writeRawData((const char*)&type, 4); | ||
| 417 | + stream.writeRawData((const char*)&bytes, 4); | ||
| 418 | + stream.writeRawData(subdata.data(), subdata.size()); | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + QtUtils::writeFile(file, data); | ||
| 293 | } | 423 | } |
| 294 | }; | 424 | }; |
| 295 | 425 | ||
| @@ -394,4 +524,6 @@ class xmlFormat : public Format | @@ -394,4 +524,6 @@ class xmlFormat : public Format | ||
| 394 | BR_REGISTER(Format, xmlFormat) | 524 | BR_REGISTER(Format, xmlFormat) |
| 395 | #endif // BR_EMBEDDED | 525 | #endif // BR_EMBEDDED |
| 396 | 526 | ||
| 527 | +} // namespace br | ||
| 528 | + | ||
| 397 | #include "format.moc" | 529 | #include "format.moc" |
sdk/plugins/gallery.cpp
| @@ -28,7 +28,8 @@ | @@ -28,7 +28,8 @@ | ||
| 28 | #include "core/opencvutils.h" | 28 | #include "core/opencvutils.h" |
| 29 | #include "core/qtutils.h" | 29 | #include "core/qtutils.h" |
| 30 | 30 | ||
| 31 | -using namespace br; | 31 | +namespace br |
| 32 | +{ | ||
| 32 | 33 | ||
| 33 | QDataStream &operator<<(QDataStream &stream, const Template &t) | 34 | QDataStream &operator<<(QDataStream &stream, const Template &t) |
| 34 | { | 35 | { |
| @@ -660,4 +661,6 @@ class googleGallery : public Gallery | @@ -660,4 +661,6 @@ class googleGallery : public Gallery | ||
| 660 | 661 | ||
| 661 | BR_REGISTER(Gallery, googleGallery) | 662 | BR_REGISTER(Gallery, googleGallery) |
| 662 | 663 | ||
| 664 | +} // namespace br | ||
| 665 | + | ||
| 663 | #include "gallery.moc" | 666 | #include "gallery.moc" |
sdk/plugins/hash.cpp
| @@ -19,14 +19,15 @@ | @@ -19,14 +19,15 @@ | ||
| 19 | 19 | ||
| 20 | #include "core/qtutils.h" | 20 | #include "core/qtutils.h" |
| 21 | 21 | ||
| 22 | -using namespace br; | 22 | +namespace br |
| 23 | +{ | ||
| 23 | 24 | ||
| 24 | /*! | 25 | /*! |
| 25 | * \ingroup transforms | 26 | * \ingroup transforms |
| 26 | * \brief Wraps QCryptographicHash | 27 | * \brief Wraps QCryptographicHash |
| 27 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 28 | */ | 29 | */ |
| 29 | -class CryptographicHash : public UntrainableTransform | 30 | +class CryptographicHashTransform : public UntrainableTransform |
| 30 | { | 31 | { |
| 31 | Q_OBJECT | 32 | Q_OBJECT |
| 32 | Q_ENUMS(Algorithm) | 33 | Q_ENUMS(Algorithm) |
| @@ -52,6 +53,8 @@ private: | @@ -52,6 +53,8 @@ private: | ||
| 52 | } | 53 | } |
| 53 | }; | 54 | }; |
| 54 | 55 | ||
| 55 | -BR_REGISTER(Transform, CryptographicHash) | 56 | +BR_REGISTER(Transform, CryptographicHashTransform) |
| 57 | + | ||
| 58 | +} // namespace br | ||
| 56 | 59 | ||
| 57 | #include "hash.moc" | 60 | #include "hash.moc" |
sdk/plugins/hist.cpp
| @@ -21,14 +21,16 @@ | @@ -21,14 +21,16 @@ | ||
| 21 | #include "core/opencvutils.h" | 21 | #include "core/opencvutils.h" |
| 22 | 22 | ||
| 23 | using namespace cv; | 23 | using namespace cv; |
| 24 | -using namespace br; | 24 | + |
| 25 | +namespace br | ||
| 26 | +{ | ||
| 25 | 27 | ||
| 26 | /*! | 28 | /*! |
| 27 | * \ingroup transforms | 29 | * \ingroup transforms |
| 28 | * \brief Histograms the matrix | 30 | * \brief Histograms the matrix |
| 29 | * \author Josh Klontz \cite jklontz | 31 | * \author Josh Klontz \cite jklontz |
| 30 | */ | 32 | */ |
| 31 | -class Hist : public UntrainableTransform | 33 | +class HistTransform : public UntrainableTransform |
| 32 | { | 34 | { |
| 33 | Q_OBJECT | 35 | Q_OBJECT |
| 34 | Q_PROPERTY(float max READ get_max WRITE set_max RESET reset_max STORED false) | 36 | Q_PROPERTY(float max READ get_max WRITE set_max RESET reset_max STORED false) |
| @@ -60,14 +62,14 @@ class Hist : public UntrainableTransform | @@ -60,14 +62,14 @@ class Hist : public UntrainableTransform | ||
| 60 | } | 62 | } |
| 61 | }; | 63 | }; |
| 62 | 64 | ||
| 63 | -BR_REGISTER(Transform, Hist) | 65 | +BR_REGISTER(Transform, HistTransform) |
| 64 | 66 | ||
| 65 | /*! | 67 | /*! |
| 66 | * \ingroup transforms | 68 | * \ingroup transforms |
| 67 | * \brief Converts each element to its rank-ordered value. | 69 | * \brief Converts each element to its rank-ordered value. |
| 68 | * \author Josh Klontz \cite jklontz | 70 | * \author Josh Klontz \cite jklontz |
| 69 | */ | 71 | */ |
| 70 | -class Rank : public UntrainableTransform | 72 | +class RankTransform : public UntrainableTransform |
| 71 | { | 73 | { |
| 72 | Q_OBJECT | 74 | Q_OBJECT |
| 73 | 75 | ||
| @@ -92,14 +94,14 @@ class Rank : public UntrainableTransform | @@ -92,14 +94,14 @@ class Rank : public UntrainableTransform | ||
| 92 | } | 94 | } |
| 93 | }; | 95 | }; |
| 94 | 96 | ||
| 95 | -BR_REGISTER(Transform, Rank) | 97 | +BR_REGISTER(Transform, RankTransform) |
| 96 | 98 | ||
| 97 | /*! | 99 | /*! |
| 98 | * \ingroup transforms | 100 | * \ingroup transforms |
| 99 | * \brief An integral histogram | 101 | * \brief An integral histogram |
| 100 | * \author Josh Klontz \cite jklontz | 102 | * \author Josh Klontz \cite jklontz |
| 101 | */ | 103 | */ |
| 102 | -class IntegralHist : public UntrainableTransform | 104 | +class IntegralHistTransform : public UntrainableTransform |
| 103 | { | 105 | { |
| 104 | Q_OBJECT | 106 | Q_OBJECT |
| 105 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) | 107 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) |
| @@ -128,14 +130,14 @@ class IntegralHist : public UntrainableTransform | @@ -128,14 +130,14 @@ class IntegralHist : public UntrainableTransform | ||
| 128 | } | 130 | } |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| 131 | -BR_REGISTER(Transform, IntegralHist) | 133 | +BR_REGISTER(Transform, IntegralHistTransform) |
| 132 | 134 | ||
| 133 | /*! | 135 | /*! |
| 134 | * \ingroup transforms | 136 | * \ingroup transforms |
| 135 | * \brief Detects regions of low variance | 137 | * \brief Detects regions of low variance |
| 136 | * \author Josh Klontz \cite jklontz | 138 | * \author Josh Klontz \cite jklontz |
| 137 | */ | 139 | */ |
| 138 | -class VarianceChangeDetector : public UntrainableTransform | 140 | +class VarianceChangeDetectorTransform : public UntrainableTransform |
| 139 | { | 141 | { |
| 140 | Q_OBJECT | 142 | Q_OBJECT |
| 141 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) | 143 | Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) |
| @@ -213,6 +215,8 @@ class VarianceChangeDetector : public UntrainableTransform | @@ -213,6 +215,8 @@ class VarianceChangeDetector : public UntrainableTransform | ||
| 213 | } | 215 | } |
| 214 | }; | 216 | }; |
| 215 | 217 | ||
| 216 | -BR_REGISTER(Transform, VarianceChangeDetector) | 218 | +BR_REGISTER(Transform, VarianceChangeDetectorTransform) |
| 219 | + | ||
| 220 | +} // namespace br | ||
| 217 | 221 | ||
| 218 | #include "hist.moc" | 222 | #include "hist.moc" |
sdk/plugins/keypoint.cpp
| @@ -21,14 +21,16 @@ | @@ -21,14 +21,16 @@ | ||
| 21 | #include "core/opencvutils.h" | 21 | #include "core/opencvutils.h" |
| 22 | 22 | ||
| 23 | using namespace cv; | 23 | using namespace cv; |
| 24 | -using namespace br; | 24 | + |
| 25 | +namespace br | ||
| 26 | +{ | ||
| 25 | 27 | ||
| 26 | /*! | 28 | /*! |
| 27 | * \ingroup transforms | 29 | * \ingroup transforms |
| 28 | * \brief Wraps OpenCV Key Point Detector | 30 | * \brief Wraps OpenCV Key Point Detector |
| 29 | * \author Josh Klontz \cite jklontz | 31 | * \author Josh Klontz \cite jklontz |
| 30 | */ | 32 | */ |
| 31 | -class KeyPointDetector : public UntrainableTransform | 33 | +class KeyPointDetectorTransform : public UntrainableTransform |
| 32 | { | 34 | { |
| 33 | Q_OBJECT | 35 | Q_OBJECT |
| 34 | Q_PROPERTY(QString detector READ get_detector WRITE set_detector RESET reset_detector STORED false) | 36 | Q_PROPERTY(QString detector READ get_detector WRITE set_detector RESET reset_detector STORED false) |
| @@ -62,14 +64,14 @@ class KeyPointDetector : public UntrainableTransform | @@ -62,14 +64,14 @@ class KeyPointDetector : public UntrainableTransform | ||
| 62 | } | 64 | } |
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | -BR_REGISTER(Transform, KeyPointDetector) | 67 | +BR_REGISTER(Transform, KeyPointDetectorTransform) |
| 66 | 68 | ||
| 67 | /*! | 69 | /*! |
| 68 | * \ingroup transforms | 70 | * \ingroup transforms |
| 69 | * \brief Wraps OpenCV Key Point Descriptor | 71 | * \brief Wraps OpenCV Key Point Descriptor |
| 70 | * \author Josh Klontz \cite jklontz | 72 | * \author Josh Klontz \cite jklontz |
| 71 | */ | 73 | */ |
| 72 | -class KeyPointDescriptor : public UntrainableTransform | 74 | +class KeyPointDescriptorTransform : public UntrainableTransform |
| 73 | { | 75 | { |
| 74 | Q_OBJECT | 76 | Q_OBJECT |
| 75 | Q_PROPERTY(QString descriptor READ get_descriptor WRITE set_descriptor RESET reset_descriptor STORED false) | 77 | Q_PROPERTY(QString descriptor READ get_descriptor WRITE set_descriptor RESET reset_descriptor STORED false) |
| @@ -100,14 +102,14 @@ class KeyPointDescriptor : public UntrainableTransform | @@ -100,14 +102,14 @@ class KeyPointDescriptor : public UntrainableTransform | ||
| 100 | } | 102 | } |
| 101 | }; | 103 | }; |
| 102 | 104 | ||
| 103 | -BR_REGISTER(Transform, KeyPointDescriptor) | 105 | +BR_REGISTER(Transform, KeyPointDescriptorTransform) |
| 104 | 106 | ||
| 105 | /*! | 107 | /*! |
| 106 | * \ingroup transforms | 108 | * \ingroup transforms |
| 107 | * \brief Wraps OpenCV Key Point Matcher | 109 | * \brief Wraps OpenCV Key Point Matcher |
| 108 | * \author Josh Klontz \cite jklontz | 110 | * \author Josh Klontz \cite jklontz |
| 109 | */ | 111 | */ |
| 110 | -class KeyPointMatcher : public Distance | 112 | +class KeyPointMatcherTransform : public Distance |
| 111 | { | 113 | { |
| 112 | Q_OBJECT | 114 | Q_OBJECT |
| 113 | Q_PROPERTY(QString matcher READ get_matcher WRITE set_matcher RESET reset_matcher STORED false) | 115 | Q_PROPERTY(QString matcher READ get_matcher WRITE set_matcher RESET reset_matcher STORED false) |
| @@ -146,14 +148,14 @@ class KeyPointMatcher : public Distance | @@ -146,14 +148,14 @@ class KeyPointMatcher : public Distance | ||
| 146 | } | 148 | } |
| 147 | }; | 149 | }; |
| 148 | 150 | ||
| 149 | -BR_REGISTER(Distance, KeyPointMatcher) | 151 | +BR_REGISTER(Distance, KeyPointMatcherTransform) |
| 150 | 152 | ||
| 151 | /*! | 153 | /*! |
| 152 | * \ingroup transforms | 154 | * \ingroup transforms |
| 153 | * \brief Specialize wrapper OpenCV SIFT wrapper | 155 | * \brief Specialize wrapper OpenCV SIFT wrapper |
| 154 | * \author Josh Klontz \cite jklontz | 156 | * \author Josh Klontz \cite jklontz |
| 155 | */ | 157 | */ |
| 156 | -class SIFTDescriptor : public UntrainableTransform | 158 | +class SIFTDescriptorTransform : public UntrainableTransform |
| 157 | { | 159 | { |
| 158 | Q_OBJECT | 160 | Q_OBJECT |
| 159 | Q_PROPERTY(int size READ get_size WRITE set_size RESET reset_size STORED false) | 161 | Q_PROPERTY(int size READ get_size WRITE set_size RESET reset_size STORED false) |
| @@ -174,14 +176,14 @@ class SIFTDescriptor : public UntrainableTransform | @@ -174,14 +176,14 @@ class SIFTDescriptor : public UntrainableTransform | ||
| 174 | } | 176 | } |
| 175 | }; | 177 | }; |
| 176 | 178 | ||
| 177 | -BR_REGISTER(Transform, SIFTDescriptor) | 179 | +BR_REGISTER(Transform, SIFTDescriptorTransform) |
| 178 | 180 | ||
| 179 | /*! | 181 | /*! |
| 180 | * \ingroup transforms | 182 | * \ingroup transforms |
| 181 | * \brief Add landmarks to the template in a grid layout | 183 | * \brief Add landmarks to the template in a grid layout |
| 182 | * \author Josh Klontz \cite jklontz | 184 | * \author Josh Klontz \cite jklontz |
| 183 | */ | 185 | */ |
| 184 | -class Grid : public UntrainableTransform | 186 | +class GridTransform : public UntrainableTransform |
| 185 | { | 187 | { |
| 186 | Q_OBJECT | 188 | Q_OBJECT |
| 187 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) | 189 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) |
| @@ -202,6 +204,8 @@ class Grid : public UntrainableTransform | @@ -202,6 +204,8 @@ class Grid : public UntrainableTransform | ||
| 202 | } | 204 | } |
| 203 | }; | 205 | }; |
| 204 | 206 | ||
| 205 | -BR_REGISTER(Transform, Grid) | 207 | +BR_REGISTER(Transform, GridTransform) |
| 208 | + | ||
| 209 | +} // namespace br | ||
| 206 | 210 | ||
| 207 | #include "keypoint.moc" | 211 | #include "keypoint.moc" |
sdk/plugins/lbp.cpp
| @@ -19,7 +19,9 @@ | @@ -19,7 +19,9 @@ | ||
| 19 | #include <openbr_plugin.h> | 19 | #include <openbr_plugin.h> |
| 20 | 20 | ||
| 21 | using namespace cv; | 21 | using namespace cv; |
| 22 | -using namespace br; | 22 | + |
| 23 | +namespace br | ||
| 24 | +{ | ||
| 23 | 25 | ||
| 24 | /*! | 26 | /*! |
| 25 | * \ingroup transforms | 27 | * \ingroup transforms |
| @@ -28,7 +30,7 @@ using namespace br; | @@ -28,7 +30,7 @@ using namespace br; | ||
| 28 | * Pattern Analysis and Machine Intelligence, IEEE Transactions, vol.28, no.12, pp.2037-2041, Dec. 2006 | 30 | * Pattern Analysis and Machine Intelligence, IEEE Transactions, vol.28, no.12, pp.2037-2041, Dec. 2006 |
| 29 | * \author Josh Klontz \cite jklontz | 31 | * \author Josh Klontz \cite jklontz |
| 30 | */ | 32 | */ |
| 31 | -class LBP : public UntrainableTransform | 33 | +class LBPTransform : public UntrainableTransform |
| 32 | { | 34 | { |
| 33 | Q_OBJECT | 35 | Q_OBJECT |
| 34 | Q_PROPERTY(int radius READ get_radius WRITE set_radius RESET reset_radius STORED false) | 36 | Q_PROPERTY(int radius READ get_radius WRITE set_radius RESET reset_radius STORED false) |
| @@ -41,7 +43,7 @@ class LBP : public UntrainableTransform | @@ -41,7 +43,7 @@ class LBP : public UntrainableTransform | ||
| 41 | uchar lut[256]; | 43 | uchar lut[256]; |
| 42 | uchar null; | 44 | uchar null; |
| 43 | 45 | ||
| 44 | - friend class ColoredU2; | 46 | + friend class ColoredU2Transform; |
| 45 | 47 | ||
| 46 | /* Returns the number of 0->1 or 1->0 transitions in i */ | 48 | /* Returns the number of 0->1 or 1->0 transitions in i */ |
| 47 | static int numTransitions(int i) | 49 | static int numTransitions(int i) |
| @@ -119,14 +121,14 @@ class LBP : public UntrainableTransform | @@ -119,14 +121,14 @@ class LBP : public UntrainableTransform | ||
| 119 | } | 121 | } |
| 120 | }; | 122 | }; |
| 121 | 123 | ||
| 122 | -BR_REGISTER(Transform, LBP) | 124 | +BR_REGISTER(Transform, LBPTransform) |
| 123 | 125 | ||
| 124 | /*! | 126 | /*! |
| 125 | * \ingroup transforms | 127 | * \ingroup transforms |
| 126 | * \brief For visualization of LBP patterns. | 128 | * \brief For visualization of LBP patterns. |
| 127 | * \author Josh Klontz \cite jklontz | 129 | * \author Josh Klontz \cite jklontz |
| 128 | */ | 130 | */ |
| 129 | -class ColoredU2 : public UntrainableTransform | 131 | +class ColoredU2Transform : public UntrainableTransform |
| 130 | { | 132 | { |
| 131 | Q_OBJECT | 133 | Q_OBJECT |
| 132 | 134 | ||
| @@ -150,7 +152,7 @@ class ColoredU2 : public UntrainableTransform | @@ -150,7 +152,7 @@ class ColoredU2 : public UntrainableTransform | ||
| 150 | 152 | ||
| 151 | uchar uid = 0; | 153 | uchar uid = 0; |
| 152 | for (int i=0; i<256; i++) { | 154 | for (int i=0; i<256; i++) { |
| 153 | - const int transitions = LBP::numTransitions(i); | 155 | + const int transitions = LBPTransform::numTransitions(i); |
| 154 | int u2; | 156 | int u2; |
| 155 | if (transitions <= 2) u2 = uid++; | 157 | if (transitions <= 2) u2 = uid++; |
| 156 | else u2 = 58; | 158 | else u2 = 58; |
| @@ -187,6 +189,8 @@ class ColoredU2 : public UntrainableTransform | @@ -187,6 +189,8 @@ class ColoredU2 : public UntrainableTransform | ||
| 187 | } | 189 | } |
| 188 | }; | 190 | }; |
| 189 | 191 | ||
| 190 | -BR_REGISTER(Transform, ColoredU2) | 192 | +BR_REGISTER(Transform, ColoredU2Transform) |
| 193 | + | ||
| 194 | +} // namespace br | ||
| 191 | 195 | ||
| 192 | #include "lbp.moc" | 196 | #include "lbp.moc" |
sdk/plugins/llvm.cpp
| @@ -81,25 +81,6 @@ static Mat MatFromMatrix(const Matrix &m) | @@ -81,25 +81,6 @@ static Mat MatFromMatrix(const Matrix &m) | ||
| 81 | return Mat(m.rows, m.columns, CV_MAKETYPE(depth, m.channels), m.data).clone(); | 81 | return Mat(m.rows, m.columns, CV_MAKETYPE(depth, m.channels), m.data).clone(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | -static void AllocateMatrixFromMat(Matrix &m, cv::Mat &mat) | ||
| 85 | -{ | ||
| 86 | - int cvType = -1; | ||
| 87 | - switch (m.type()) { | ||
| 88 | - case Matrix::u8: cvType = CV_8U; break; | ||
| 89 | - case Matrix::s8: cvType = CV_8S; break; | ||
| 90 | - case Matrix::u16: cvType = CV_16U; break; | ||
| 91 | - case Matrix::s16: cvType = CV_16S; break; | ||
| 92 | - case Matrix::s32: cvType = CV_32S; break; | ||
| 93 | - case Matrix::f32: cvType = CV_32F; break; | ||
| 94 | - case Matrix::f64: cvType = CV_64F; break; | ||
| 95 | - default: qFatal("OpenCV does not support Matrix format: %s", qPrintable(MatrixToString(m))); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - m.deallocate(); | ||
| 99 | - mat = Mat(m.rows, m.columns, CV_MAKETYPE(cvType, m.channels)); | ||
| 100 | - m.data = mat.data; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | QDebug operator<<(QDebug dbg, const Matrix &m) | 84 | QDebug operator<<(QDebug dbg, const Matrix &m) |
| 104 | { | 85 | { |
| 105 | dbg.nospace() << MatrixToString(m); | 86 | dbg.nospace() << MatrixToString(m); |
| @@ -140,6 +121,7 @@ struct MatrixBuilder : public Matrix | @@ -140,6 +121,7 @@ struct MatrixBuilder : public Matrix | ||
| 140 | 121 | ||
| 141 | void copyHeaderCode(const MatrixBuilder &other) const { | 122 | void copyHeaderCode(const MatrixBuilder &other) const { |
| 142 | setChannels(other.getChannels()); | 123 | setChannels(other.getChannels()); |
| 124 | + setColumns(other.getColumns()); | ||
| 143 | setRows(other.getRows()); | 125 | setRows(other.getRows()); |
| 144 | setFrames(other.getFrames()); | 126 | setFrames(other.getFrames()); |
| 145 | setHash(other.getHash()); | 127 | setHash(other.getHash()); |
| @@ -317,41 +299,42 @@ namespace br | @@ -317,41 +299,42 @@ namespace br | ||
| 317 | { | 299 | { |
| 318 | 300 | ||
| 319 | /*! | 301 | /*! |
| 320 | - * \brief LLVM Unary Kernel | 302 | + * \brief LLVM Unary Transform |
| 321 | * \author Josh Klontz \cite jklontz | 303 | * \author Josh Klontz \cite jklontz |
| 322 | */ | 304 | */ |
| 323 | -class UnaryKernel : public UntrainableMetaTransform | 305 | +class UnaryTransform : public UntrainableMetaTransform |
| 324 | { | 306 | { |
| 325 | Q_OBJECT | 307 | Q_OBJECT |
| 326 | 308 | ||
| 327 | - UnaryKernel_t kernel; | 309 | + UnaryKernel kernel; |
| 328 | quint16 hash; | 310 | quint16 hash; |
| 329 | 311 | ||
| 330 | public: | 312 | public: |
| 331 | - UnaryKernel() : kernel(NULL), hash(0) {} | 313 | + UnaryTransform() : kernel(NULL), hash(0) {} |
| 332 | virtual int preallocate(const Matrix &src, Matrix &dst) const = 0; /*!< Preallocate destintation matrix based on source matrix. */ | 314 | virtual int preallocate(const Matrix &src, Matrix &dst) const = 0; /*!< Preallocate destintation matrix based on source matrix. */ |
| 333 | virtual Value *buildPreallocate(const MatrixBuilder &src, const MatrixBuilder &dst) const { (void) src; (void) dst; return MatrixBuilder::constant(0); } | 315 | virtual Value *buildPreallocate(const MatrixBuilder &src, const MatrixBuilder &dst) const { (void) src; (void) dst; return MatrixBuilder::constant(0); } |
| 334 | virtual void build(const MatrixBuilder &src, const MatrixBuilder &dst, PHINode *i) const = 0; /*!< Build the kernel. */ | 316 | virtual void build(const MatrixBuilder &src, const MatrixBuilder &dst, PHINode *i) const = 0; /*!< Build the kernel. */ |
| 335 | 317 | ||
| 336 | - void apply(const Matrix &src, Matrix &dst) const | ||
| 337 | - { | ||
| 338 | - const int size = preallocate(src, dst); | ||
| 339 | - dst.allocate(); | ||
| 340 | - invoke(src, dst, size); | ||
| 341 | - } | ||
| 342 | - | ||
| 343 | void optimize(Function *f) const | 318 | void optimize(Function *f) const |
| 344 | { | 319 | { |
| 345 | while (TheFunctionPassManager->run(*f)); | 320 | while (TheFunctionPassManager->run(*f)); |
| 346 | TheExtraFunctionPassManager->run(*f); | 321 | TheExtraFunctionPassManager->run(*f); |
| 347 | } | 322 | } |
| 348 | 323 | ||
| 349 | - UnaryKernel_t getKernel(const Matrix *src) const | 324 | + UnaryFunction getFunction(const Matrix *src) const |
| 350 | { | 325 | { |
| 351 | - const QString functionName = mangledName(*src); | 326 | + const QString functionName = mangledName(); |
| 352 | Function *function = TheModule->getFunction(qPrintable(functionName)); | 327 | Function *function = TheModule->getFunction(qPrintable(functionName)); |
| 353 | if (function == NULL) function = compile(*src); | 328 | if (function == NULL) function = compile(*src); |
| 354 | - return (UnaryKernel_t)TheExecutionEngine->getPointerToFunction(function); | 329 | + return (UnaryFunction)TheExecutionEngine->getPointerToFunction(function); |
| 330 | + } | ||
| 331 | + | ||
| 332 | + UnaryKernel getKernel(const Matrix *src) const | ||
| 333 | + { | ||
| 334 | + const QString functionName = mangledName(*src); | ||
| 335 | + Function *function = TheModule->getFunction(qPrintable(functionName)); | ||
| 336 | + if (function == NULL) function = compileKernel(*src); | ||
| 337 | + return (UnaryKernel)TheExecutionEngine->getPointerToFunction(function); | ||
| 355 | } | 338 | } |
| 356 | 339 | ||
| 357 | private: | 340 | private: |
| @@ -433,7 +416,7 @@ private: | @@ -433,7 +416,7 @@ private: | ||
| 433 | builder.CreateRetVoid(); | 416 | builder.CreateRetVoid(); |
| 434 | 417 | ||
| 435 | optimize(function); | 418 | optimize(function); |
| 436 | - return kernel; | 419 | + return function; |
| 437 | } | 420 | } |
| 438 | 421 | ||
| 439 | Function *compileKernel(const Matrix &m) const | 422 | Function *compileKernel(const Matrix &m) const |
| @@ -476,24 +459,9 @@ private: | @@ -476,24 +459,9 @@ private: | ||
| 476 | { | 459 | { |
| 477 | const Matrix m(MatrixFromMat(src)); | 460 | const Matrix m(MatrixFromMat(src)); |
| 478 | Matrix n; | 461 | Matrix n; |
| 479 | - const int size = preallocate(m, n); | ||
| 480 | - AllocateMatrixFromMat(n, dst); | ||
| 481 | - invoke(m, n, size); | ||
| 482 | - } | ||
| 483 | - | ||
| 484 | - void invoke(const Matrix &src, Matrix &dst, int size) const | ||
| 485 | - { | ||
| 486 | - if (src.hash != hash) { | ||
| 487 | - static QMutex compilerLock; | ||
| 488 | - QMutexLocker locker(&compilerLock); | ||
| 489 | - | ||
| 490 | - if (src.hash != hash) { | ||
| 491 | - const_cast<UnaryKernel*>(this)->kernel = getKernel(&src); | ||
| 492 | - const_cast<UnaryKernel*>(this)->hash = src.hash; | ||
| 493 | - } | ||
| 494 | - } | ||
| 495 | - | ||
| 496 | - kernel(&src, &dst, size); | 462 | + UnaryFunction function = getFunction(&m); |
| 463 | + function(&m, &n); | ||
| 464 | + dst.m() = MatFromMatrix(n); | ||
| 497 | } | 465 | } |
| 498 | }; | 466 | }; |
| 499 | 467 | ||
| @@ -501,15 +469,15 @@ private: | @@ -501,15 +469,15 @@ private: | ||
| 501 | * \brief LLVM Binary Kernel | 469 | * \brief LLVM Binary Kernel |
| 502 | * \author Josh Klontz \cite jklontz | 470 | * \author Josh Klontz \cite jklontz |
| 503 | */ | 471 | */ |
| 504 | -class BinaryKernel: public UntrainableMetaTransform | 472 | +class BinaryTransform: public UntrainableMetaTransform |
| 505 | { | 473 | { |
| 506 | Q_OBJECT | 474 | Q_OBJECT |
| 507 | 475 | ||
| 508 | - BinaryKernel_t kernel; | 476 | + BinaryKernel kernel; |
| 509 | quint16 hashA, hashB; | 477 | quint16 hashA, hashB; |
| 510 | 478 | ||
| 511 | public: | 479 | public: |
| 512 | - BinaryKernel() : kernel(NULL), hashA(0), hashB(0) {} | 480 | + BinaryTransform() : kernel(NULL), hashA(0), hashB(0) {} |
| 513 | virtual int preallocate(const Matrix &srcA, const Matrix &srcB, Matrix &dst) const = 0; /*!< Preallocate destintation matrix based on source matrix. */ | 481 | virtual int preallocate(const Matrix &srcA, const Matrix &srcB, Matrix &dst) const = 0; /*!< Preallocate destintation matrix based on source matrix. */ |
| 514 | virtual void build(const MatrixBuilder &srcA, const MatrixBuilder &srcB, const MatrixBuilder &dst, PHINode *i) const = 0; /*!< Build the kernel. */ | 482 | virtual void build(const MatrixBuilder &srcA, const MatrixBuilder &srcB, const MatrixBuilder &dst, PHINode *i) const = 0; /*!< Build the kernel. */ |
| 515 | 483 | ||
| @@ -582,9 +550,9 @@ private: | @@ -582,9 +550,9 @@ private: | ||
| 582 | function = TheModule->getFunction(qPrintable(functionName)); | 550 | function = TheModule->getFunction(qPrintable(functionName)); |
| 583 | } | 551 | } |
| 584 | 552 | ||
| 585 | - const_cast<BinaryKernel*>(this)->kernel = (BinaryKernel_t)TheExecutionEngine->getPointerToFunction(function); | ||
| 586 | - const_cast<BinaryKernel*>(this)->hashA = srcA.hash; | ||
| 587 | - const_cast<BinaryKernel*>(this)->hashB = srcB.hash; | 553 | + const_cast<BinaryTransform*>(this)->kernel = (BinaryKernel)TheExecutionEngine->getPointerToFunction(function); |
| 554 | + const_cast<BinaryTransform*>(this)->hashA = srcA.hash; | ||
| 555 | + const_cast<BinaryTransform*>(this)->hashB = srcB.hash; | ||
| 588 | } | 556 | } |
| 589 | } | 557 | } |
| 590 | 558 | ||
| @@ -596,7 +564,7 @@ private: | @@ -596,7 +564,7 @@ private: | ||
| 596 | * \brief LLVM Stitchable Kernel | 564 | * \brief LLVM Stitchable Kernel |
| 597 | * \author Josh Klontz \cite jklontz | 565 | * \author Josh Klontz \cite jklontz |
| 598 | */ | 566 | */ |
| 599 | -class StitchableKernel : public UnaryKernel | 567 | +class StitchableTransform : public UnaryTransform |
| 600 | { | 568 | { |
| 601 | Q_OBJECT | 569 | Q_OBJECT |
| 602 | 570 | ||
| @@ -629,7 +597,7 @@ private: | @@ -629,7 +597,7 @@ private: | ||
| 629 | * \brief LLVM stitch transform | 597 | * \brief LLVM stitch transform |
| 630 | * \author Josh Klontz \cite jklontz | 598 | * \author Josh Klontz \cite jklontz |
| 631 | */ | 599 | */ |
| 632 | -class stitchTransform : public UnaryKernel | 600 | +class stitchTransform : public UnaryTransform |
| 633 | { | 601 | { |
| 634 | Q_OBJECT | 602 | Q_OBJECT |
| 635 | Q_PROPERTY(QList<br::Transform*> kernels READ get_kernels WRITE set_kernels RESET reset_kernels STORED false) | 603 | Q_PROPERTY(QList<br::Transform*> kernels READ get_kernels WRITE set_kernels RESET reset_kernels STORED false) |
| @@ -638,15 +606,15 @@ class stitchTransform : public UnaryKernel | @@ -638,15 +606,15 @@ class stitchTransform : public UnaryKernel | ||
| 638 | void init() | 606 | void init() |
| 639 | { | 607 | { |
| 640 | foreach (Transform *transform, kernels) | 608 | foreach (Transform *transform, kernels) |
| 641 | - if (dynamic_cast<StitchableKernel*>(transform) == NULL) | ||
| 642 | - qFatal("%s is not a stitchable kernel!", qPrintable(transform->name())); | 609 | + if (dynamic_cast<StitchableTransform*>(transform) == NULL) |
| 610 | + qFatal("%s is not a stitchable transform!", qPrintable(transform->name())); | ||
| 643 | } | 611 | } |
| 644 | 612 | ||
| 645 | int preallocate(const Matrix &src, Matrix &dst) const | 613 | int preallocate(const Matrix &src, Matrix &dst) const |
| 646 | { | 614 | { |
| 647 | Matrix tmp = src; | 615 | Matrix tmp = src; |
| 648 | foreach (const Transform *kernel, kernels) { | 616 | foreach (const Transform *kernel, kernels) { |
| 649 | - static_cast<const UnaryKernel*>(kernel)->preallocate(tmp, dst); | 617 | + static_cast<const UnaryTransform*>(kernel)->preallocate(tmp, dst); |
| 650 | tmp = dst; | 618 | tmp = dst; |
| 651 | } | 619 | } |
| 652 | return dst.elements(); | 620 | return dst.elements(); |
| @@ -658,8 +626,8 @@ class stitchTransform : public UnaryKernel | @@ -658,8 +626,8 @@ class stitchTransform : public UnaryKernel | ||
| 658 | MatrixBuilder dst(dst_); | 626 | MatrixBuilder dst(dst_); |
| 659 | Value *val = src.load(i); | 627 | Value *val = src.load(i); |
| 660 | foreach (Transform *transform, kernels) { | 628 | foreach (Transform *transform, kernels) { |
| 661 | - static_cast<UnaryKernel*>(transform)->preallocate(src, dst); | ||
| 662 | - val = static_cast<StitchableKernel*>(transform)->stitch(src, dst, val); | 629 | + static_cast<UnaryTransform*>(transform)->preallocate(src, dst); |
| 630 | + val = static_cast<StitchableTransform*>(transform)->stitch(src, dst, val); | ||
| 663 | src.copyHeader(dst); | 631 | src.copyHeader(dst); |
| 664 | src.m = dst.m; | 632 | src.m = dst.m; |
| 665 | } | 633 | } |
| @@ -674,7 +642,7 @@ BR_REGISTER(Transform, stitchTransform) | @@ -674,7 +642,7 @@ BR_REGISTER(Transform, stitchTransform) | ||
| 674 | * \brief LLVM square transform | 642 | * \brief LLVM square transform |
| 675 | * \author Josh Klontz \cite jklontz | 643 | * \author Josh Klontz \cite jklontz |
| 676 | */ | 644 | */ |
| 677 | -class squareTransform : public StitchableKernel | 645 | +class squareTransform : public StitchableTransform |
| 678 | { | 646 | { |
| 679 | Q_OBJECT | 647 | Q_OBJECT |
| 680 | 648 | ||
| @@ -692,7 +660,7 @@ BR_REGISTER(Transform, squareTransform) | @@ -692,7 +660,7 @@ BR_REGISTER(Transform, squareTransform) | ||
| 692 | * \brief LLVM pow transform | 660 | * \brief LLVM pow transform |
| 693 | * \author Josh Klontz \cite jklontz | 661 | * \author Josh Klontz \cite jklontz |
| 694 | */ | 662 | */ |
| 695 | -class powTransform : public StitchableKernel | 663 | +class powTransform : public StitchableTransform |
| 696 | { | 664 | { |
| 697 | Q_OBJECT | 665 | Q_OBJECT |
| 698 | Q_PROPERTY(double exponent READ get_exponent WRITE set_exponent RESET reset_exponent STORED false) | 666 | Q_PROPERTY(double exponent READ get_exponent WRITE set_exponent RESET reset_exponent STORED false) |
| @@ -731,7 +699,7 @@ BR_REGISTER(Transform, powTransform) | @@ -731,7 +699,7 @@ BR_REGISTER(Transform, powTransform) | ||
| 731 | * \brief LLVM sum transform | 699 | * \brief LLVM sum transform |
| 732 | * \author Josh Klontz \cite jklontz | 700 | * \author Josh Klontz \cite jklontz |
| 733 | */ | 701 | */ |
| 734 | -class sumTransform : public UnaryKernel | 702 | +class sumTransform : public UnaryTransform |
| 735 | { | 703 | { |
| 736 | Q_OBJECT | 704 | Q_OBJECT |
| 737 | Q_PROPERTY(bool channels READ get_channels WRITE set_channels RESET reset_channels STORED false) | 705 | Q_PROPERTY(bool channels READ get_channels WRITE set_channels RESET reset_channels STORED false) |
| @@ -821,7 +789,7 @@ BR_REGISTER(Transform, sumTransform) | @@ -821,7 +789,7 @@ BR_REGISTER(Transform, sumTransform) | ||
| 821 | * \brief LLVM casting transform | 789 | * \brief LLVM casting transform |
| 822 | * \author Josh Klontz \cite jklontz | 790 | * \author Josh Klontz \cite jklontz |
| 823 | */ | 791 | */ |
| 824 | -class castTransform : public StitchableKernel | 792 | +class castTransform : public StitchableTransform |
| 825 | { | 793 | { |
| 826 | Q_OBJECT | 794 | Q_OBJECT |
| 827 | Q_ENUMS(Type) | 795 | Q_ENUMS(Type) |
| @@ -865,7 +833,7 @@ BR_REGISTER(Transform, castTransform) | @@ -865,7 +833,7 @@ BR_REGISTER(Transform, castTransform) | ||
| 865 | * \brief LLVM scale transform | 833 | * \brief LLVM scale transform |
| 866 | * \author Josh Klontz \cite jklontz | 834 | * \author Josh Klontz \cite jklontz |
| 867 | */ | 835 | */ |
| 868 | -class scaleTransform : public StitchableKernel | 836 | +class scaleTransform : public StitchableTransform |
| 869 | { | 837 | { |
| 870 | Q_OBJECT | 838 | Q_OBJECT |
| 871 | Q_PROPERTY(double a READ get_a WRITE set_a RESET reset_a STORED false) | 839 | Q_PROPERTY(double a READ get_a WRITE set_a RESET reset_a STORED false) |
| @@ -885,7 +853,7 @@ BR_REGISTER(Transform, scaleTransform) | @@ -885,7 +853,7 @@ BR_REGISTER(Transform, scaleTransform) | ||
| 885 | * \brief LLVM abs transform | 853 | * \brief LLVM abs transform |
| 886 | * \author Josh Klontz \cite jklontz | 854 | * \author Josh Klontz \cite jklontz |
| 887 | */ | 855 | */ |
| 888 | -class absTransform : public StitchableKernel | 856 | +class absTransform : public StitchableTransform |
| 889 | { | 857 | { |
| 890 | Q_OBJECT | 858 | Q_OBJECT |
| 891 | 859 | ||
| @@ -907,7 +875,7 @@ BR_REGISTER(Transform, absTransform) | @@ -907,7 +875,7 @@ BR_REGISTER(Transform, absTransform) | ||
| 907 | * \brief LLVM add transform | 875 | * \brief LLVM add transform |
| 908 | * \author Josh Klontz \cite jklontz | 876 | * \author Josh Klontz \cite jklontz |
| 909 | */ | 877 | */ |
| 910 | -class addTransform : public StitchableKernel | 878 | +class addTransform : public StitchableTransform |
| 911 | { | 879 | { |
| 912 | Q_OBJECT | 880 | Q_OBJECT |
| 913 | Q_PROPERTY(double b READ get_b WRITE set_b RESET reset_b STORED false) | 881 | Q_PROPERTY(double b READ get_b WRITE set_b RESET reset_b STORED false) |
| @@ -927,7 +895,7 @@ BR_REGISTER(Transform, addTransform) | @@ -927,7 +895,7 @@ BR_REGISTER(Transform, addTransform) | ||
| 927 | * \brief LLVM clamp transform | 895 | * \brief LLVM clamp transform |
| 928 | * \author Josh Klontz \cite jklontz | 896 | * \author Josh Klontz \cite jklontz |
| 929 | */ | 897 | */ |
| 930 | -class clampTransform : public StitchableKernel | 898 | +class clampTransform : public StitchableTransform |
| 931 | { | 899 | { |
| 932 | Q_OBJECT | 900 | Q_OBJECT |
| 933 | Q_PROPERTY(double min READ get_min WRITE set_min RESET reset_min STORED false) | 901 | Q_PROPERTY(double min READ get_min WRITE set_min RESET reset_min STORED false) |
| @@ -1035,17 +1003,17 @@ class LLVMInitializer : public Initializer | @@ -1035,17 +1003,17 @@ class LLVMInitializer : public Initializer | ||
| 1035 | kernel->project(src, dst); | 1003 | kernel->project(src, dst); |
| 1036 | qDebug() << dst.m(); | 1004 | qDebug() << dst.m(); |
| 1037 | 1005 | ||
| 1038 | -// src.m() = (Mat_<qint32>(2,2) << -1, -3, 9, 27); | ||
| 1039 | -// kernel->project(src, dst); | ||
| 1040 | -// qDebug() << dst.m(); | 1006 | + src.m() = (Mat_<qint32>(2,2) << -1, -3, 9, 27); |
| 1007 | + kernel->project(src, dst); | ||
| 1008 | + qDebug() << dst.m(); | ||
| 1041 | 1009 | ||
| 1042 | -// src.m() = (Mat_<float>(2,2) << -1.5, -2.5, 3.5, 4.5); | ||
| 1043 | -// kernel->project(src, dst); | ||
| 1044 | -// qDebug() << dst.m(); | 1010 | + src.m() = (Mat_<float>(2,2) << -1.5, -2.5, 3.5, 4.5); |
| 1011 | + kernel->project(src, dst); | ||
| 1012 | + qDebug() << dst.m(); | ||
| 1045 | 1013 | ||
| 1046 | -// src.m() = (Mat_<double>(2,2) << 1.75, 2.75, -3.75, -4.75); | ||
| 1047 | -// kernel->project(src, dst); | ||
| 1048 | -// qDebug() << dst.m(); | 1014 | + src.m() = (Mat_<double>(2,2) << 1.75, 2.75, -3.75, -4.75); |
| 1015 | + kernel->project(src, dst); | ||
| 1016 | + qDebug() << dst.m(); | ||
| 1049 | } | 1017 | } |
| 1050 | 1018 | ||
| 1051 | void finalize() const | 1019 | void finalize() const |
| @@ -1091,15 +1059,29 @@ class LLVMInitializer : public Initializer | @@ -1091,15 +1059,29 @@ class LLVMInitializer : public Initializer | ||
| 1091 | 1059 | ||
| 1092 | BR_REGISTER(Initializer, LLVMInitializer) | 1060 | BR_REGISTER(Initializer, LLVMInitializer) |
| 1093 | 1061 | ||
| 1094 | -UnaryFunction_t jit_unary_make(const char *description) | 1062 | +UnaryFunction jit_make_unary_function(const char *description) |
| 1063 | +{ | ||
| 1064 | + QScopedPointer<UnaryTransform> unaryTransform(Factory<UnaryTransform>::make(description)); | ||
| 1065 | + return unaryTransform->getFunction(NULL); | ||
| 1066 | +} | ||
| 1067 | + | ||
| 1068 | +BinaryFunction jit_make_binary_function(const char *description) | ||
| 1095 | { | 1069 | { |
| 1096 | (void) description; | 1070 | (void) description; |
| 1097 | return NULL; | 1071 | return NULL; |
| 1098 | } | 1072 | } |
| 1099 | 1073 | ||
| 1100 | -BinaryFunction_t jit_binary_make(const char *description) | 1074 | +UnaryKernel jit_make_unary_kernel(const char *description, const Matrix *src) |
| 1075 | +{ | ||
| 1076 | + QScopedPointer<UnaryTransform> unaryTransform(Factory<UnaryTransform>::make(description)); | ||
| 1077 | + return unaryTransform->getKernel(src); | ||
| 1078 | +} | ||
| 1079 | + | ||
| 1080 | +BinaryKernel jit_make_binary_kernel(const char *description, const Matrix *srcA, const Matrix *srcB) | ||
| 1101 | { | 1081 | { |
| 1102 | (void) description; | 1082 | (void) description; |
| 1083 | + (void) srcA; | ||
| 1084 | + (void) srcB; | ||
| 1103 | return NULL; | 1085 | return NULL; |
| 1104 | } | 1086 | } |
| 1105 | 1087 |
sdk/plugins/mask.cpp
| @@ -18,14 +18,16 @@ | @@ -18,14 +18,16 @@ | ||
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | using namespace cv; | 20 | using namespace cv; |
| 21 | -using namespace br; | 21 | + |
| 22 | +namespace br | ||
| 23 | +{ | ||
| 22 | 24 | ||
| 23 | /*! | 25 | /*! |
| 24 | * \ingroup transforms | 26 | * \ingroup transforms |
| 25 | * \brief Applies an eliptical mask | 27 | * \brief Applies an eliptical mask |
| 26 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 27 | */ | 29 | */ |
| 28 | -class Mask : public UntrainableTransform | 30 | +class MaskTransform : public UntrainableTransform |
| 29 | { | 31 | { |
| 30 | Q_OBJECT | 32 | Q_OBJECT |
| 31 | 33 | ||
| @@ -41,14 +43,14 @@ class Mask : public UntrainableTransform | @@ -41,14 +43,14 @@ class Mask : public UntrainableTransform | ||
| 41 | } | 43 | } |
| 42 | }; | 44 | }; |
| 43 | 45 | ||
| 44 | -BR_REGISTER(Transform, Mask) | 46 | +BR_REGISTER(Transform, MaskTransform) |
| 45 | 47 | ||
| 46 | /*! | 48 | /*! |
| 47 | * \ingroup transforms | 49 | * \ingroup transforms |
| 48 | * \brief Masks image according to pixel change. | 50 | * \brief Masks image according to pixel change. |
| 49 | * \author Josh Klontz \cite jklontz | 51 | * \author Josh Klontz \cite jklontz |
| 50 | */ | 52 | */ |
| 51 | -class GradientMask : public UntrainableTransform | 53 | +class GradientMaskTransform : public UntrainableTransform |
| 52 | { | 54 | { |
| 53 | Q_OBJECT | 55 | Q_OBJECT |
| 54 | Q_PROPERTY(int delta READ get_delta WRITE set_delta RESET reset_delta STORED false) | 56 | Q_PROPERTY(int delta READ get_delta WRITE set_delta RESET reset_delta STORED false) |
| @@ -72,14 +74,14 @@ class GradientMask : public UntrainableTransform | @@ -72,14 +74,14 @@ class GradientMask : public UntrainableTransform | ||
| 72 | } | 74 | } |
| 73 | }; | 75 | }; |
| 74 | 76 | ||
| 75 | -BR_REGISTER(Transform, GradientMask) | 77 | +BR_REGISTER(Transform, GradientMaskTransform) |
| 76 | 78 | ||
| 77 | /*! | 79 | /*! |
| 78 | * \ingroup transforms | 80 | * \ingroup transforms |
| 79 | * \brief http://worldofcameras.wordpress.com/tag/skin-detection-opencv/ | 81 | * \brief http://worldofcameras.wordpress.com/tag/skin-detection-opencv/ |
| 80 | * \author Josh Klontz \cite jklontz | 82 | * \author Josh Klontz \cite jklontz |
| 81 | */ | 83 | */ |
| 82 | -class SkinMask : public UntrainableTransform | 84 | +class SkinMaskTransform : public UntrainableTransform |
| 83 | { | 85 | { |
| 84 | Q_OBJECT | 86 | Q_OBJECT |
| 85 | 87 | ||
| @@ -103,14 +105,14 @@ class SkinMask : public UntrainableTransform | @@ -103,14 +105,14 @@ class SkinMask : public UntrainableTransform | ||
| 103 | } | 105 | } |
| 104 | }; | 106 | }; |
| 105 | 107 | ||
| 106 | -BR_REGISTER(Transform, SkinMask) | 108 | +BR_REGISTER(Transform, SkinMaskTransform) |
| 107 | 109 | ||
| 108 | /*! | 110 | /*! |
| 109 | * \ingroup transforms | 111 | * \ingroup transforms |
| 110 | * \brief Morphological operator | 112 | * \brief Morphological operator |
| 111 | * \author Josh Klontz \cite jklontz | 113 | * \author Josh Klontz \cite jklontz |
| 112 | */ | 114 | */ |
| 113 | -class Morph : public UntrainableTransform | 115 | +class MorphTransform : public UntrainableTransform |
| 114 | { | 116 | { |
| 115 | Q_OBJECT | 117 | Q_OBJECT |
| 116 | Q_ENUMS(Op) | 118 | Q_ENUMS(Op) |
| @@ -145,14 +147,14 @@ private: | @@ -145,14 +147,14 @@ private: | ||
| 145 | } | 147 | } |
| 146 | }; | 148 | }; |
| 147 | 149 | ||
| 148 | -BR_REGISTER(Transform, Morph) | 150 | +BR_REGISTER(Transform, MorphTransform) |
| 149 | 151 | ||
| 150 | /*! | 152 | /*! |
| 151 | * \ingroup transforms | 153 | * \ingroup transforms |
| 152 | * \brief Set the template's label to the area of the largest convex hull. | 154 | * \brief Set the template's label to the area of the largest convex hull. |
| 153 | * \author Josh Klontz \cite jklontz | 155 | * \author Josh Klontz \cite jklontz |
| 154 | */ | 156 | */ |
| 155 | -class LargestConvexArea : public UntrainableTransform | 157 | +class LargestConvexAreaTransform : public UntrainableTransform |
| 156 | { | 158 | { |
| 157 | Q_OBJECT | 159 | Q_OBJECT |
| 158 | 160 | ||
| @@ -173,6 +175,8 @@ class LargestConvexArea : public UntrainableTransform | @@ -173,6 +175,8 @@ class LargestConvexArea : public UntrainableTransform | ||
| 173 | } | 175 | } |
| 174 | }; | 176 | }; |
| 175 | 177 | ||
| 176 | -BR_REGISTER(Transform, LargestConvexArea) | 178 | +BR_REGISTER(Transform, LargestConvexAreaTransform) |
| 179 | + | ||
| 180 | +} // namespace br | ||
| 177 | 181 | ||
| 178 | #include "mask.moc" | 182 | #include "mask.moc" |
sdk/plugins/meta.cpp
| @@ -22,7 +22,9 @@ | @@ -22,7 +22,9 @@ | ||
| 22 | #include "core/qtutils.h" | 22 | #include "core/qtutils.h" |
| 23 | 23 | ||
| 24 | using namespace cv; | 24 | using namespace cv; |
| 25 | -using namespace br; | 25 | + |
| 26 | +namespace br | ||
| 27 | +{ | ||
| 26 | 28 | ||
| 27 | static TemplateList Simplified(const TemplateList &templates) | 29 | static TemplateList Simplified(const TemplateList &templates) |
| 28 | { | 30 | { |
| @@ -119,7 +121,7 @@ class PipeTransform : public MetaTransform | @@ -119,7 +121,7 @@ class PipeTransform : public MetaTransform | ||
| 119 | try { | 121 | try { |
| 120 | dst >> *f; | 122 | dst >> *f; |
| 121 | } catch (...) { | 123 | } catch (...) { |
| 122 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->name())); | 124 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->objectName())); |
| 123 | dst = Template(src.file); | 125 | dst = Template(src.file); |
| 124 | dst.file.setBool("FTE"); | 126 | dst.file.setBool("FTE"); |
| 125 | } | 127 | } |
| @@ -148,7 +150,7 @@ class PipeTransform : public MetaTransform | @@ -148,7 +150,7 @@ class PipeTransform : public MetaTransform | ||
| 148 | try { | 150 | try { |
| 149 | src >> *f; | 151 | src >> *f; |
| 150 | } catch (...) { | 152 | } catch (...) { |
| 151 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->name())); | 153 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->objectName())); |
| 152 | src = Template(src.file); | 154 | src = Template(src.file); |
| 153 | src.file.setBool("FTE"); | 155 | src.file.setBool("FTE"); |
| 154 | } | 156 | } |
| @@ -197,7 +199,7 @@ class ChainTransform : public MetaTransform | @@ -197,7 +199,7 @@ class ChainTransform : public MetaTransform | ||
| 197 | try { | 199 | try { |
| 198 | dst >> *f; | 200 | dst >> *f; |
| 199 | } catch (...) { | 201 | } catch (...) { |
| 200 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->name())); | 202 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->objectName())); |
| 201 | dst = Template(src.file); | 203 | dst = Template(src.file); |
| 202 | dst.file.setBool("FTE"); | 204 | dst.file.setBool("FTE"); |
| 203 | } | 205 | } |
| @@ -224,7 +226,7 @@ class ChainTransform : public MetaTransform | @@ -224,7 +226,7 @@ class ChainTransform : public MetaTransform | ||
| 224 | try { | 226 | try { |
| 225 | src >> *f; | 227 | src >> *f; |
| 226 | } catch (...) { | 228 | } catch (...) { |
| 227 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->name())); | 229 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->objectName())); |
| 228 | src = Template(src.file); | 230 | src = Template(src.file); |
| 229 | src.file.setBool("FTE"); | 231 | src.file.setBool("FTE"); |
| 230 | } | 232 | } |
| @@ -264,7 +266,7 @@ class ForkTransform : public MetaTransform | @@ -264,7 +266,7 @@ class ForkTransform : public MetaTransform | ||
| 264 | try { | 266 | try { |
| 265 | dst.merge((*f)(src)); | 267 | dst.merge((*f)(src)); |
| 266 | } catch (...) { | 268 | } catch (...) { |
| 267 | - qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->name())); | 269 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src.file.flat()), qPrintable(f->objectName())); |
| 268 | dst = Template(src.file); | 270 | dst = Template(src.file); |
| 269 | dst.file.setBool("FTE"); | 271 | dst.file.setBool("FTE"); |
| 270 | } | 272 | } |
| @@ -456,8 +458,8 @@ class FTETransform : public Transform | @@ -456,8 +458,8 @@ class FTETransform : public Transform | ||
| 456 | 458 | ||
| 457 | QList<float> vals; | 459 | QList<float> vals; |
| 458 | foreach (const Template &t, projectedData) { | 460 | foreach (const Template &t, projectedData) { |
| 459 | - if (!t.file.contains(transform->name())) qFatal("FTE::train matrix metadata missing key %s.", qPrintable(transform->name())); | ||
| 460 | - vals.append(t.file.getFloat(transform->name())); | 461 | + if (!t.file.contains(transform->objectName())) qFatal("FTE::train matrix metadata missing key %s.", qPrintable(transform->objectName())); |
| 462 | + vals.append(t.file.getFloat(transform->objectName())); | ||
| 461 | } | 463 | } |
| 462 | float q1, q3; | 464 | float q1, q3; |
| 463 | Common::Median(vals, &q1, &q3); | 465 | Common::Median(vals, &q1, &q3); |
| @@ -469,14 +471,16 @@ class FTETransform : public Transform | @@ -469,14 +471,16 @@ class FTETransform : public Transform | ||
| 469 | { | 471 | { |
| 470 | Template projectedSrc; | 472 | Template projectedSrc; |
| 471 | transform->project(src, projectedSrc); | 473 | transform->project(src, projectedSrc); |
| 472 | - const float val = projectedSrc.file.getFloat(transform->name()); | 474 | + const float val = projectedSrc.file.getFloat(transform->objectName()); |
| 473 | 475 | ||
| 474 | dst = src; | 476 | dst = src; |
| 475 | - dst.file.insert(transform->name(), val); | 477 | + dst.file.insert(transform->objectName(), val); |
| 476 | dst.file.insert("FTE", (val < min) || (val > max)); | 478 | dst.file.insert("FTE", (val < min) || (val > max)); |
| 477 | } | 479 | } |
| 478 | }; | 480 | }; |
| 479 | 481 | ||
| 480 | BR_REGISTER(Transform, FTETransform) | 482 | BR_REGISTER(Transform, FTETransform) |
| 481 | 483 | ||
| 484 | +} // namespace br | ||
| 485 | + | ||
| 482 | #include "meta.moc" | 486 | #include "meta.moc" |
sdk/plugins/misc.cpp
| @@ -20,7 +20,9 @@ | @@ -20,7 +20,9 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| @@ -253,4 +255,6 @@ class RenameTransform : public UntrainableMetaTransform | @@ -253,4 +255,6 @@ class RenameTransform : public UntrainableMetaTransform | ||
| 253 | 255 | ||
| 254 | BR_REGISTER(Transform, RenameTransform) | 256 | BR_REGISTER(Transform, RenameTransform) |
| 255 | 257 | ||
| 258 | +} | ||
| 259 | + | ||
| 256 | #include "misc.moc" | 260 | #include "misc.moc" |
sdk/plugins/normalize.cpp
| @@ -23,14 +23,16 @@ | @@ -23,14 +23,16 @@ | ||
| 23 | #include "core/opencvutils.h" | 23 | #include "core/opencvutils.h" |
| 24 | 24 | ||
| 25 | using namespace cv; | 25 | using namespace cv; |
| 26 | -using namespace br; | 26 | + |
| 27 | +namespace br | ||
| 28 | +{ | ||
| 27 | 29 | ||
| 28 | /*! | 30 | /*! |
| 29 | * \ingroup transforms | 31 | * \ingroup transforms |
| 30 | * \brief Histogram equalization | 32 | * \brief Histogram equalization |
| 31 | * \author Josh Klontz \cite jklontz | 33 | * \author Josh Klontz \cite jklontz |
| 32 | */ | 34 | */ |
| 33 | -class EqualizeHist : public UntrainableTransform | 35 | +class EqualizeHistTransform : public UntrainableTransform |
| 34 | { | 36 | { |
| 35 | Q_OBJECT | 37 | Q_OBJECT |
| 36 | 38 | ||
| @@ -40,14 +42,14 @@ class EqualizeHist : public UntrainableTransform | @@ -40,14 +42,14 @@ class EqualizeHist : public UntrainableTransform | ||
| 40 | } | 42 | } |
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 43 | -BR_REGISTER(Transform, EqualizeHist) | 45 | +BR_REGISTER(Transform, EqualizeHistTransform) |
| 44 | 46 | ||
| 45 | /*! | 47 | /*! |
| 46 | * \ingroup transforms | 48 | * \ingroup transforms |
| 47 | * \brief Normalize matrix to unit length | 49 | * \brief Normalize matrix to unit length |
| 48 | * \author Josh Klontz \cite jklontz | 50 | * \author Josh Klontz \cite jklontz |
| 49 | */ | 51 | */ |
| 50 | -class Normalize : public UntrainableTransform | 52 | +class NormalizeTransform : public UntrainableTransform |
| 51 | { | 53 | { |
| 52 | Q_OBJECT | 54 | Q_OBJECT |
| 53 | Q_ENUMS(NormType) | 55 | Q_ENUMS(NormType) |
| @@ -68,14 +70,14 @@ private: | @@ -68,14 +70,14 @@ private: | ||
| 68 | } | 70 | } |
| 69 | }; | 71 | }; |
| 70 | 72 | ||
| 71 | -BR_REGISTER(Transform, Normalize) | 73 | +BR_REGISTER(Transform, NormalizeTransform) |
| 72 | 74 | ||
| 73 | /*! | 75 | /*! |
| 74 | * \ingroup transforms | 76 | * \ingroup transforms |
| 75 | * \brief Normalize each dimension based on training data. | 77 | * \brief Normalize each dimension based on training data. |
| 76 | * \author Josh Klontz \cite jklontz | 78 | * \author Josh Klontz \cite jklontz |
| 77 | */ | 79 | */ |
| 78 | -class Center : public Transform | 80 | +class CenterTransform : public Transform |
| 79 | { | 81 | { |
| 80 | Q_OBJECT | 82 | Q_OBJECT |
| 81 | Q_ENUMS(Method) | 83 | Q_ENUMS(Method) |
| @@ -180,6 +182,8 @@ private: | @@ -180,6 +182,8 @@ private: | ||
| 180 | } | 182 | } |
| 181 | }; | 183 | }; |
| 182 | 184 | ||
| 183 | -BR_REGISTER(Transform, Center) | 185 | +BR_REGISTER(Transform, CenterTransform) |
| 186 | + | ||
| 187 | +} // namespace br | ||
| 184 | 188 | ||
| 185 | #include "normalize.moc" | 189 | #include "normalize.moc" |
sdk/plugins/output.cpp
| @@ -42,7 +42,8 @@ | @@ -42,7 +42,8 @@ | ||
| 42 | #include "core/opencvutils.h" | 42 | #include "core/opencvutils.h" |
| 43 | #include "core/qtutils.h" | 43 | #include "core/qtutils.h" |
| 44 | 44 | ||
| 45 | -using namespace br; | 45 | +namespace br |
| 46 | +{ | ||
| 46 | 47 | ||
| 47 | /*! | 48 | /*! |
| 48 | * \ingroup outputs | 49 | * \ingroup outputs |
| @@ -420,4 +421,6 @@ class histOutput : public Output | @@ -420,4 +421,6 @@ class histOutput : public Output | ||
| 420 | 421 | ||
| 421 | BR_REGISTER(Output, histOutput) | 422 | BR_REGISTER(Output, histOutput) |
| 422 | 423 | ||
| 424 | +} // namespace br | ||
| 425 | + | ||
| 423 | #include "output.moc" | 426 | #include "output.moc" |
sdk/plugins/pixel.cpp
| @@ -17,14 +17,16 @@ | @@ -17,14 +17,16 @@ | ||
| 17 | #include <openbr_plugin.h> | 17 | #include <openbr_plugin.h> |
| 18 | 18 | ||
| 19 | using namespace cv; | 19 | using namespace cv; |
| 20 | -using namespace br; | 20 | + |
| 21 | +namespace br | ||
| 22 | +{ | ||
| 21 | 23 | ||
| 22 | /*! | 24 | /*! |
| 23 | * \ingroup transforms | 25 | * \ingroup transforms |
| 24 | * \brief Treat each pixel as a classification task | 26 | * \brief Treat each pixel as a classification task |
| 25 | * \author E. Taborsky \cite mmtaborsky | 27 | * \author E. Taborsky \cite mmtaborsky |
| 26 | */ | 28 | */ |
| 27 | -class PerPixelClassifier : public MetaTransform | 29 | +class PerPixelClassifierTransform : public MetaTransform |
| 28 | { | 30 | { |
| 29 | Q_OBJECT | 31 | Q_OBJECT |
| 30 | Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform) | 32 | Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform) |
| @@ -171,14 +173,14 @@ class PerPixelClassifier : public MetaTransform | @@ -171,14 +173,14 @@ class PerPixelClassifier : public MetaTransform | ||
| 171 | } | 173 | } |
| 172 | }; | 174 | }; |
| 173 | 175 | ||
| 174 | -BR_REGISTER(Transform, PerPixelClassifier) | 176 | +BR_REGISTER(Transform, PerPixelClassifierTransform) |
| 175 | 177 | ||
| 176 | /*! | 178 | /*! |
| 177 | * \ingroup transforms | 179 | * \ingroup transforms |
| 178 | * \brief Construct feature vectors of neighboring pixels | 180 | * \brief Construct feature vectors of neighboring pixels |
| 179 | * \author E. Taborsky \cite mmtaborsky | 181 | * \author E. Taborsky \cite mmtaborsky |
| 180 | */ | 182 | */ |
| 181 | -class Neighbors: public UntrainableMetaTransform | 183 | +class NeighborsTransform : public UntrainableMetaTransform |
| 182 | { | 184 | { |
| 183 | Q_OBJECT | 185 | Q_OBJECT |
| 184 | 186 | ||
| @@ -214,14 +216,14 @@ class Neighbors: public UntrainableMetaTransform | @@ -214,14 +216,14 @@ class Neighbors: public UntrainableMetaTransform | ||
| 214 | } | 216 | } |
| 215 | }; | 217 | }; |
| 216 | 218 | ||
| 217 | -BR_REGISTER(Transform, Neighbors) | 219 | +BR_REGISTER(Transform, NeighborsTransform) |
| 218 | 220 | ||
| 219 | /*! | 221 | /*! |
| 220 | * \ingroup transforms | 222 | * \ingroup transforms |
| 221 | * \brief To binary vector | 223 | * \brief To binary vector |
| 222 | * \author E. Taborsky \cite mmtaborsky | 224 | * \author E. Taborsky \cite mmtaborsky |
| 223 | */ | 225 | */ |
| 224 | -class ToBinaryVector: public UntrainableMetaTransform | 226 | +class ToBinaryVectorTransform : public UntrainableMetaTransform |
| 225 | { | 227 | { |
| 226 | Q_OBJECT | 228 | Q_OBJECT |
| 227 | Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform STORED false) | 229 | Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform STORED false) |
| @@ -264,7 +266,7 @@ class ToBinaryVector: public UntrainableMetaTransform | @@ -264,7 +266,7 @@ class ToBinaryVector: public UntrainableMetaTransform | ||
| 264 | } | 266 | } |
| 265 | }; | 267 | }; |
| 266 | 268 | ||
| 267 | -BR_REGISTER(Transform, ToBinaryVector) | 269 | +BR_REGISTER(Transform, ToBinaryVectorTransform) |
| 268 | 270 | ||
| 269 | /*! | 271 | /*! |
| 270 | * \ingroup transforms | 272 | * \ingroup transforms |
| @@ -272,7 +274,7 @@ BR_REGISTER(Transform, ToBinaryVector) | @@ -272,7 +274,7 @@ BR_REGISTER(Transform, ToBinaryVector) | ||
| 272 | * \author E. Taborsky \cite mmtaborsky | 274 | * \author E. Taborsky \cite mmtaborsky |
| 273 | */ | 275 | */ |
| 274 | 276 | ||
| 275 | -class ToMetadata: public UntrainableMetaTransform | 277 | +class ToMetadataTransform : public UntrainableMetaTransform |
| 276 | { | 278 | { |
| 277 | Q_OBJECT | 279 | Q_OBJECT |
| 278 | 280 | ||
| @@ -288,6 +290,8 @@ class ToMetadata: public UntrainableMetaTransform | @@ -288,6 +290,8 @@ class ToMetadata: public UntrainableMetaTransform | ||
| 288 | 290 | ||
| 289 | }; | 291 | }; |
| 290 | 292 | ||
| 291 | -BR_REGISTER(Transform, ToMetadata) | 293 | +BR_REGISTER(Transform, ToMetadataTransform) |
| 294 | + | ||
| 295 | +} // namespace br | ||
| 292 | 296 | ||
| 293 | #include "pixel.moc" | 297 | #include "pixel.moc" |
sdk/plugins/quantize.cpp
| @@ -19,14 +19,16 @@ | @@ -19,14 +19,16 @@ | ||
| 19 | #include "core/opencvutils.h" | 19 | #include "core/opencvutils.h" |
| 20 | 20 | ||
| 21 | using namespace cv; | 21 | using namespace cv; |
| 22 | -using namespace br; | 22 | + |
| 23 | +namespace br | ||
| 24 | +{ | ||
| 23 | 25 | ||
| 24 | /*! | 26 | /*! |
| 25 | * \ingroup transforms | 27 | * \ingroup transforms |
| 26 | * \brief Approximate floats as uchar. | 28 | * \brief Approximate floats as uchar. |
| 27 | * \author Josh Klontz \cite jklontz | 29 | * \author Josh Klontz \cite jklontz |
| 28 | */ | 30 | */ |
| 29 | -class Quantize : public Transform | 31 | +class QuantizeTransform : public Transform |
| 30 | { | 32 | { |
| 31 | Q_OBJECT | 33 | Q_OBJECT |
| 32 | Q_PROPERTY(float a READ get_a WRITE set_a RESET reset_a) | 34 | Q_PROPERTY(float a READ get_a WRITE set_a RESET reset_a) |
| @@ -48,14 +50,14 @@ class Quantize : public Transform | @@ -48,14 +50,14 @@ class Quantize : public Transform | ||
| 48 | } | 50 | } |
| 49 | }; | 51 | }; |
| 50 | 52 | ||
| 51 | -BR_REGISTER(Transform, Quantize) | 53 | +BR_REGISTER(Transform, QuantizeTransform) |
| 52 | 54 | ||
| 53 | /*! | 55 | /*! |
| 54 | * \ingroup transforms | 56 | * \ingroup transforms |
| 55 | * \brief Approximate floats as signed bit. | 57 | * \brief Approximate floats as signed bit. |
| 56 | * \author Josh Klontz \cite jklontz | 58 | * \author Josh Klontz \cite jklontz |
| 57 | */ | 59 | */ |
| 58 | -class Binarize : public UntrainableTransform | 60 | +class BinarizeTransform : public UntrainableTransform |
| 59 | { | 61 | { |
| 60 | Q_OBJECT | 62 | Q_OBJECT |
| 61 | 63 | ||
| @@ -78,14 +80,14 @@ class Binarize : public UntrainableTransform | @@ -78,14 +80,14 @@ class Binarize : public UntrainableTransform | ||
| 78 | } | 80 | } |
| 79 | }; | 81 | }; |
| 80 | 82 | ||
| 81 | -BR_REGISTER(Transform, Binarize) | 83 | +BR_REGISTER(Transform, BinarizeTransform) |
| 82 | 84 | ||
| 83 | /*! | 85 | /*! |
| 84 | * \ingroup transforms | 86 | * \ingroup transforms |
| 85 | * \brief Compress two uchar into one uchar. | 87 | * \brief Compress two uchar into one uchar. |
| 86 | * \author Josh Klontz \cite jklontz | 88 | * \author Josh Klontz \cite jklontz |
| 87 | */ | 89 | */ |
| 88 | -class Pack : public UntrainableTransform | 90 | +class PackTransform : public UntrainableTransform |
| 89 | { | 91 | { |
| 90 | Q_OBJECT | 92 | Q_OBJECT |
| 91 | 93 | ||
| @@ -104,6 +106,8 @@ class Pack : public UntrainableTransform | @@ -104,6 +106,8 @@ class Pack : public UntrainableTransform | ||
| 104 | } | 106 | } |
| 105 | }; | 107 | }; |
| 106 | 108 | ||
| 107 | -BR_REGISTER(Transform, Pack) | 109 | +BR_REGISTER(Transform, PackTransform) |
| 110 | + | ||
| 111 | +} // namespace br | ||
| 108 | 112 | ||
| 109 | #include "quantize.moc" | 113 | #include "quantize.moc" |
sdk/plugins/random.cpp
| @@ -21,14 +21,16 @@ | @@ -21,14 +21,16 @@ | ||
| 21 | #include "core/opencvutils.h" | 21 | #include "core/opencvutils.h" |
| 22 | 22 | ||
| 23 | using namespace cv; | 23 | using namespace cv; |
| 24 | -using namespace br; | 24 | + |
| 25 | +namespace br | ||
| 26 | +{ | ||
| 25 | 27 | ||
| 26 | /*! | 28 | /*! |
| 27 | * \ingroup transforms | 29 | * \ingroup transforms |
| 28 | * \brief Selects a random transform. | 30 | * \brief Selects a random transform. |
| 29 | * \author Josh Klontz \cite jklontz | 31 | * \author Josh Klontz \cite jklontz |
| 30 | */ | 32 | */ |
| 31 | -class RndTransform : public Transform | 33 | +class RndTransformTransform : public Transform |
| 32 | { | 34 | { |
| 33 | Q_OBJECT | 35 | Q_OBJECT |
| 34 | Q_PROPERTY(QList<br::Transform*> transforms READ get_transforms WRITE set_transforms RESET reset_transforms STORED false) | 36 | Q_PROPERTY(QList<br::Transform*> transforms READ get_transforms WRITE set_transforms RESET reset_transforms STORED false) |
| @@ -62,14 +64,14 @@ class RndTransform : public Transform | @@ -62,14 +64,14 @@ class RndTransform : public Transform | ||
| 62 | } | 64 | } |
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | -BR_REGISTER(Transform, RndTransform) | 67 | +BR_REGISTER(Transform, RndTransformTransform) |
| 66 | 68 | ||
| 67 | /*! | 69 | /*! |
| 68 | * \ingroup transforms | 70 | * \ingroup transforms |
| 69 | * \brief Generates a random subspace. | 71 | * \brief Generates a random subspace. |
| 70 | * \author Josh Klontz \cite jklontz | 72 | * \author Josh Klontz \cite jklontz |
| 71 | */ | 73 | */ |
| 72 | -class RndSubspace : public Transform | 74 | +class RndSubspaceTransform : public Transform |
| 73 | { | 75 | { |
| 74 | Q_OBJECT | 76 | Q_OBJECT |
| 75 | Q_PROPERTY(float fraction READ get_fraction WRITE set_fraction RESET reset_fraction STORED false) | 77 | Q_PROPERTY(float fraction READ get_fraction WRITE set_fraction RESET reset_fraction STORED false) |
| @@ -128,14 +130,14 @@ class RndSubspace : public Transform | @@ -128,14 +130,14 @@ class RndSubspace : public Transform | ||
| 128 | } | 130 | } |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| 131 | -BR_REGISTER(Transform, RndSubspace) | 133 | +BR_REGISTER(Transform, RndSubspaceTransform) |
| 132 | 134 | ||
| 133 | /*! | 135 | /*! |
| 134 | * \ingroup transforms | 136 | * \ingroup transforms |
| 135 | * \brief Selects a random region. | 137 | * \brief Selects a random region. |
| 136 | * \author Josh Klontz \cite jklontz | 138 | * \author Josh Klontz \cite jklontz |
| 137 | */ | 139 | */ |
| 138 | -class RndRegion : public Transform | 140 | +class RndRegionTransform : public Transform |
| 139 | { | 141 | { |
| 140 | Q_OBJECT | 142 | Q_OBJECT |
| 141 | Q_PROPERTY(float x READ get_x WRITE set_x RESET reset_x) | 143 | Q_PROPERTY(float x READ get_x WRITE set_x RESET reset_x) |
| @@ -167,14 +169,14 @@ class RndRegion : public Transform | @@ -167,14 +169,14 @@ class RndRegion : public Transform | ||
| 167 | } | 169 | } |
| 168 | }; | 170 | }; |
| 169 | 171 | ||
| 170 | -BR_REGISTER(Transform, RndRegion) | 172 | +BR_REGISTER(Transform, RndRegionTransform) |
| 171 | 173 | ||
| 172 | /*! | 174 | /*! |
| 173 | * \ingroup transforms | 175 | * \ingroup transforms |
| 174 | * \brief Generates a random landmark. | 176 | * \brief Generates a random landmark. |
| 175 | * \author Josh Klontz \cite jklontz | 177 | * \author Josh Klontz \cite jklontz |
| 176 | */ | 178 | */ |
| 177 | -class RndPoint : public Transform | 179 | +class RndPointTransform : public Transform |
| 178 | { | 180 | { |
| 179 | Q_OBJECT | 181 | Q_OBJECT |
| 180 | Q_PROPERTY(float x READ get_x WRITE set_x RESET reset_x) | 182 | Q_PROPERTY(float x READ get_x WRITE set_x RESET reset_x) |
| @@ -198,6 +200,8 @@ class RndPoint : public Transform | @@ -198,6 +200,8 @@ class RndPoint : public Transform | ||
| 198 | } | 200 | } |
| 199 | }; | 201 | }; |
| 200 | 202 | ||
| 201 | -BR_REGISTER(Transform, RndPoint) | 203 | +BR_REGISTER(Transform, RndPointTransform) |
| 204 | + | ||
| 205 | +} // namespace br | ||
| 202 | 206 | ||
| 203 | #include "random.moc" | 207 | #include "random.moc" |
sdk/plugins/reduce.cpp
| @@ -17,14 +17,16 @@ | @@ -17,14 +17,16 @@ | ||
| 17 | #include <openbr_plugin.h> | 17 | #include <openbr_plugin.h> |
| 18 | 18 | ||
| 19 | using namespace cv; | 19 | using namespace cv; |
| 20 | -using namespace br; | 20 | + |
| 21 | +namespace br | ||
| 22 | +{ | ||
| 21 | 23 | ||
| 22 | /*! | 24 | /*! |
| 23 | * \ingroup transforms | 25 | * \ingroup transforms |
| 24 | * \brief Subtract two matrices. | 26 | * \brief Subtract two matrices. |
| 25 | * \author Josh Klontz \cite jklontz | 27 | * \author Josh Klontz \cite jklontz |
| 26 | */ | 28 | */ |
| 27 | -class Subtract : public UntrainableMetaTransform | 29 | +class SubtractTransform : public UntrainableMetaTransform |
| 28 | { | 30 | { |
| 29 | Q_OBJECT | 31 | Q_OBJECT |
| 30 | 32 | ||
| @@ -36,14 +38,14 @@ class Subtract : public UntrainableMetaTransform | @@ -36,14 +38,14 @@ class Subtract : public UntrainableMetaTransform | ||
| 36 | } | 38 | } |
| 37 | }; | 39 | }; |
| 38 | 40 | ||
| 39 | -BR_REGISTER(Transform, Subtract) | 41 | +BR_REGISTER(Transform, SubtractTransform) |
| 40 | 42 | ||
| 41 | /*! | 43 | /*! |
| 42 | * \ingroup transforms | 44 | * \ingroup transforms |
| 43 | * \brief Take the absolute difference of two matrices. | 45 | * \brief Take the absolute difference of two matrices. |
| 44 | * \author Josh Klontz \cite jklontz | 46 | * \author Josh Klontz \cite jklontz |
| 45 | */ | 47 | */ |
| 46 | -class AbsDiff : public UntrainableMetaTransform | 48 | +class AbsDiffTransform : public UntrainableMetaTransform |
| 47 | { | 49 | { |
| 48 | Q_OBJECT | 50 | Q_OBJECT |
| 49 | 51 | ||
| @@ -55,14 +57,14 @@ class AbsDiff : public UntrainableMetaTransform | @@ -55,14 +57,14 @@ class AbsDiff : public UntrainableMetaTransform | ||
| 55 | } | 57 | } |
| 56 | }; | 58 | }; |
| 57 | 59 | ||
| 58 | -BR_REGISTER(Transform, AbsDiff) | 60 | +BR_REGISTER(Transform, AbsDiffTransform) |
| 59 | 61 | ||
| 60 | /*! | 62 | /*! |
| 61 | * \ingroup transforms | 63 | * \ingroup transforms |
| 62 | * \brief Logical AND of two matrices. | 64 | * \brief Logical AND of two matrices. |
| 63 | * \author Josh Klontz \cite jklontz | 65 | * \author Josh Klontz \cite jklontz |
| 64 | */ | 66 | */ |
| 65 | -class And : public UntrainableMetaTransform | 67 | +class AndTransform : public UntrainableMetaTransform |
| 66 | { | 68 | { |
| 67 | Q_OBJECT | 69 | Q_OBJECT |
| 68 | 70 | ||
| @@ -75,6 +77,8 @@ class And : public UntrainableMetaTransform | @@ -75,6 +77,8 @@ class And : public UntrainableMetaTransform | ||
| 75 | } | 77 | } |
| 76 | }; | 78 | }; |
| 77 | 79 | ||
| 78 | -BR_REGISTER(Transform, And) | 80 | +BR_REGISTER(Transform, AndTransform) |
| 81 | + | ||
| 82 | +} // namespace br | ||
| 79 | 83 | ||
| 80 | #include "reduce.moc" | 84 | #include "reduce.moc" |
sdk/plugins/regions.cpp
| @@ -18,14 +18,16 @@ | @@ -18,14 +18,16 @@ | ||
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | using namespace cv; | 20 | using namespace cv; |
| 21 | -using namespace br; | 21 | + |
| 22 | +namespace br | ||
| 23 | +{ | ||
| 22 | 24 | ||
| 23 | /*! | 25 | /*! |
| 24 | * \ingroup transforms | 26 | * \ingroup transforms |
| 25 | * \brief Subdivide matrix into rectangular subregions. | 27 | * \brief Subdivide matrix into rectangular subregions. |
| 26 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 27 | */ | 29 | */ |
| 28 | -class RectRegions : public UntrainableTransform | 30 | +class RectRegionsTransform : public UntrainableTransform |
| 29 | { | 31 | { |
| 30 | Q_OBJECT | 32 | Q_OBJECT |
| 31 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) | 33 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) |
| @@ -50,14 +52,14 @@ class RectRegions : public UntrainableTransform | @@ -50,14 +52,14 @@ class RectRegions : public UntrainableTransform | ||
| 50 | } | 52 | } |
| 51 | }; | 53 | }; |
| 52 | 54 | ||
| 53 | -BR_REGISTER(Transform, RectRegions) | 55 | +BR_REGISTER(Transform, RectRegionsTransform) |
| 54 | 56 | ||
| 55 | /*! | 57 | /*! |
| 56 | * \ingroup transforms | 58 | * \ingroup transforms |
| 57 | * \brief Turns each row into its own matrix. | 59 | * \brief Turns each row into its own matrix. |
| 58 | * \author Josh Klontz \cite jklontz | 60 | * \author Josh Klontz \cite jklontz |
| 59 | */ | 61 | */ |
| 60 | -class ByRow : public UntrainableTransform | 62 | +class ByRowTransform : public UntrainableTransform |
| 61 | { | 63 | { |
| 62 | Q_OBJECT | 64 | Q_OBJECT |
| 63 | 65 | ||
| @@ -68,7 +70,7 @@ class ByRow : public UntrainableTransform | @@ -68,7 +70,7 @@ class ByRow : public UntrainableTransform | ||
| 68 | } | 70 | } |
| 69 | }; | 71 | }; |
| 70 | 72 | ||
| 71 | -BR_REGISTER(Transform, ByRow) | 73 | +BR_REGISTER(Transform, ByRowTransform) |
| 72 | 74 | ||
| 73 | /*! | 75 | /*! |
| 74 | * \ingroup transforms | 76 | * \ingroup transforms |
| @@ -76,7 +78,7 @@ BR_REGISTER(Transform, ByRow) | @@ -76,7 +78,7 @@ BR_REGISTER(Transform, ByRow) | ||
| 76 | * No requirements are placed on input matrices size and type. | 78 | * No requirements are placed on input matrices size and type. |
| 77 | * \author Josh Klontz \cite jklontz | 79 | * \author Josh Klontz \cite jklontz |
| 78 | */ | 80 | */ |
| 79 | -class Cat : public UntrainableMetaTransform | 81 | +class CatTransform : public UntrainableMetaTransform |
| 80 | { | 82 | { |
| 81 | Q_OBJECT | 83 | Q_OBJECT |
| 82 | Q_PROPERTY(int partitions READ get_partitions WRITE set_partitions RESET reset_partitions) | 84 | Q_PROPERTY(int partitions READ get_partitions WRITE set_partitions RESET reset_partitions) |
| @@ -105,14 +107,14 @@ class Cat : public UntrainableMetaTransform | @@ -105,14 +107,14 @@ class Cat : public UntrainableMetaTransform | ||
| 105 | } | 107 | } |
| 106 | }; | 108 | }; |
| 107 | 109 | ||
| 108 | -BR_REGISTER(Transform, Cat) | 110 | +BR_REGISTER(Transform, CatTransform) |
| 109 | 111 | ||
| 110 | /*! | 112 | /*! |
| 111 | * \ingroup transforms | 113 | * \ingroup transforms |
| 112 | * \brief Duplicates the template data. | 114 | * \brief Duplicates the template data. |
| 113 | * \author Josh Klontz \cite jklontz | 115 | * \author Josh Klontz \cite jklontz |
| 114 | */ | 116 | */ |
| 115 | -class Dup : public UntrainableMetaTransform | 117 | +class DupTransform : public UntrainableMetaTransform |
| 116 | { | 118 | { |
| 117 | Q_OBJECT | 119 | Q_OBJECT |
| 118 | Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false) | 120 | Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false) |
| @@ -125,6 +127,8 @@ class Dup : public UntrainableMetaTransform | @@ -125,6 +127,8 @@ class Dup : public UntrainableMetaTransform | ||
| 125 | } | 127 | } |
| 126 | }; | 128 | }; |
| 127 | 129 | ||
| 128 | -BR_REGISTER(Transform, Dup) | 130 | +BR_REGISTER(Transform, DupTransform) |
| 131 | + | ||
| 132 | +} // namespace br | ||
| 129 | 133 | ||
| 130 | #include "regions.moc" | 134 | #include "regions.moc" |
sdk/plugins/register.cpp
| @@ -17,17 +17,19 @@ | @@ -17,17 +17,19 @@ | ||
| 17 | #include <opencv2/imgproc/imgproc.hpp> | 17 | #include <opencv2/imgproc/imgproc.hpp> |
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | +#include "core/opencvutils.h" | ||
| 21 | + | ||
| 20 | using namespace cv; | 22 | using namespace cv; |
| 21 | -using namespace br; | ||
| 22 | 23 | ||
| 23 | -#include "core/opencvutils.h" | 24 | +namespace br |
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Performs a two or three point registration. | 29 | * \brief Performs a two or three point registration. |
| 28 | * \author Josh Klontz \cite jklontz | 30 | * \author Josh Klontz \cite jklontz |
| 29 | */ | 31 | */ |
| 30 | -class Affine : public UntrainableTransform | 32 | +class AffineTransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) | 35 | Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) |
| @@ -101,14 +103,14 @@ class Affine : public UntrainableTransform | @@ -101,14 +103,14 @@ class Affine : public UntrainableTransform | ||
| 101 | } | 103 | } |
| 102 | }; | 104 | }; |
| 103 | 105 | ||
| 104 | -BR_REGISTER(Transform, Affine) | 106 | +BR_REGISTER(Transform, AffineTransform) |
| 105 | 107 | ||
| 106 | /*! | 108 | /*! |
| 107 | * \ingroup transforms | 109 | * \ingroup transforms |
| 108 | * \brief Flips the image about an axis. | 110 | * \brief Flips the image about an axis. |
| 109 | * \author Josh Klontz \cite jklontz | 111 | * \author Josh Klontz \cite jklontz |
| 110 | */ | 112 | */ |
| 111 | -class Flip : public UntrainableTransform | 113 | +class FlipTransform : public UntrainableTransform |
| 112 | { | 114 | { |
| 113 | Q_OBJECT | 115 | Q_OBJECT |
| 114 | Q_ENUMS(Axis) | 116 | Q_ENUMS(Axis) |
| @@ -129,6 +131,8 @@ private: | @@ -129,6 +131,8 @@ private: | ||
| 129 | } | 131 | } |
| 130 | }; | 132 | }; |
| 131 | 133 | ||
| 132 | -BR_REGISTER(Transform, Flip) | 134 | +BR_REGISTER(Transform, FlipTransform) |
| 135 | + | ||
| 136 | +} // namespace br | ||
| 133 | 137 | ||
| 134 | #include "register.moc" | 138 | #include "register.moc" |
sdk/plugins/svm.cpp
| @@ -21,7 +21,8 @@ | @@ -21,7 +21,8 @@ | ||
| 21 | 21 | ||
| 22 | #include "core/opencvutils.h" | 22 | #include "core/opencvutils.h" |
| 23 | 23 | ||
| 24 | -using namespace br; | 24 | +namespace br |
| 25 | +{ | ||
| 25 | 26 | ||
| 26 | /*! | 27 | /*! |
| 27 | * \ingroup transforms | 28 | * \ingroup transforms |
| @@ -29,7 +30,7 @@ using namespace br; | @@ -29,7 +30,7 @@ using namespace br; | ||
| 29 | * Knowledge Discovery and Data Mining 2(2), 1998. | 30 | * Knowledge Discovery and Data Mining 2(2), 1998. |
| 30 | * \author Josh Klontz \cite jklontz | 31 | * \author Josh Klontz \cite jklontz |
| 31 | */ | 32 | */ |
| 32 | -class SVM : public Transform | 33 | +class SVMTransform : public Transform |
| 33 | { | 34 | { |
| 34 | Q_OBJECT | 35 | Q_OBJECT |
| 35 | Q_ENUMS(Kernel) | 36 | Q_ENUMS(Kernel) |
| @@ -66,7 +67,7 @@ private: | @@ -66,7 +67,7 @@ private: | ||
| 66 | float a, b; | 67 | float a, b; |
| 67 | 68 | ||
| 68 | public: | 69 | public: |
| 69 | - SVM() : a(1), b(0) {} | 70 | + SVMTransform() : a(1), b(0) {} |
| 70 | 71 | ||
| 71 | private: | 72 | private: |
| 72 | void train(const TemplateList &_data) | 73 | void train(const TemplateList &_data) |
| @@ -153,6 +154,8 @@ private: | @@ -153,6 +154,8 @@ private: | ||
| 153 | } | 154 | } |
| 154 | }; | 155 | }; |
| 155 | 156 | ||
| 156 | -BR_REGISTER(Transform, SVM) | 157 | +BR_REGISTER(Transform, SVMTransform) |
| 158 | + | ||
| 159 | +} // namespace br | ||
| 157 | 160 | ||
| 158 | #include "svm.moc" | 161 | #include "svm.moc" |
sdk/plugins/synthetic.cpp
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | #include "core/opencvutils.h" | 20 | #include "core/opencvutils.h" |
| 21 | 21 | ||
| 22 | using namespace cv; | 22 | using namespace cv; |
| 23 | -using namespace br; | 23 | + |
| 24 | +namespace br | ||
| 25 | +{ | ||
| 24 | 26 | ||
| 25 | /*! | 27 | /*! |
| 26 | * \ingroup transforms | 28 | * \ingroup transforms |
| 27 | * \brief Prediction using only the red wavelength; magic numbers from jmp | 29 | * \brief Prediction using only the red wavelength; magic numbers from jmp |
| 28 | * \author E. Taborsky \cite mmtaborsky | 30 | * \author E. Taborsky \cite mmtaborsky |
| 29 | */ | 31 | */ |
| 30 | -class RedLinearRegression : public UntrainableTransform | 32 | +class RedLinearRegressionTransform : public UntrainableTransform |
| 31 | { | 33 | { |
| 32 | Q_OBJECT | 34 | Q_OBJECT |
| 33 | 35 | ||
| @@ -56,14 +58,14 @@ class RedLinearRegression : public UntrainableTransform | @@ -56,14 +58,14 @@ class RedLinearRegression : public UntrainableTransform | ||
| 56 | } | 58 | } |
| 57 | }; | 59 | }; |
| 58 | 60 | ||
| 59 | -BR_REGISTER(Transform, RedLinearRegression) | 61 | +BR_REGISTER(Transform, RedLinearRegressionTransform) |
| 60 | 62 | ||
| 61 | /*! | 63 | /*! |
| 62 | * \ingroup transforms | 64 | * \ingroup transforms |
| 63 | * \brief Prediction with magic numbers from jmp; must get input as blue;green;red | 65 | * \brief Prediction with magic numbers from jmp; must get input as blue;green;red |
| 64 | * \author E. Taborsky \cite mmtaborsky | 66 | * \author E. Taborsky \cite mmtaborsky |
| 65 | */ | 67 | */ |
| 66 | -class OrigLinearRegression : public UntrainableMetaTransform | 68 | +class OrigLinearRegressionTransform : public UntrainableMetaTransform |
| 67 | { | 69 | { |
| 68 | Q_OBJECT | 70 | Q_OBJECT |
| 69 | 71 | ||
| @@ -94,6 +96,8 @@ class OrigLinearRegression : public UntrainableMetaTransform | @@ -94,6 +96,8 @@ class OrigLinearRegression : public UntrainableMetaTransform | ||
| 94 | } | 96 | } |
| 95 | }; | 97 | }; |
| 96 | 98 | ||
| 97 | -BR_REGISTER(Transform, OrigLinearRegression) | 99 | +BR_REGISTER(Transform, OrigLinearRegressionTransform) |
| 100 | + | ||
| 101 | +} // namespace br | ||
| 98 | 102 | ||
| 99 | #include "synthetic.moc" | 103 | #include "synthetic.moc" |
sdk/plugins/wavelet.cpp
| @@ -18,14 +18,16 @@ | @@ -18,14 +18,16 @@ | ||
| 18 | #include <openbr_plugin.h> | 18 | #include <openbr_plugin.h> |
| 19 | 19 | ||
| 20 | using namespace cv; | 20 | using namespace cv; |
| 21 | -using namespace br; | 21 | + |
| 22 | +namespace br | ||
| 23 | +{ | ||
| 22 | 24 | ||
| 23 | /*! | 25 | /*! |
| 24 | * \ingroup transforms | 26 | * \ingroup transforms |
| 25 | * \brief http://en.wikipedia.org/wiki/Gabor_filter | 27 | * \brief http://en.wikipedia.org/wiki/Gabor_filter |
| 26 | * \author Josh Klontz \cite jklontz | 28 | * \author Josh Klontz \cite jklontz |
| 27 | */ | 29 | */ |
| 28 | -class Gabor : public UntrainableTransform | 30 | +class GaborTransform : public UntrainableTransform |
| 29 | { | 31 | { |
| 30 | Q_OBJECT | 32 | Q_OBJECT |
| 31 | Q_ENUMS(Component) | 33 | Q_ENUMS(Component) |
| @@ -53,7 +55,7 @@ private: | @@ -53,7 +55,7 @@ private: | ||
| 53 | 55 | ||
| 54 | Mat kReal, kImaginary; | 56 | Mat kReal, kImaginary; |
| 55 | 57 | ||
| 56 | - friend class GaborJet; | 58 | + friend class GaborJetTransform; |
| 57 | 59 | ||
| 58 | static void makeWavelet(float lambda, float theta, float psi, float sigma, float gamma, Mat &kReal, Mat &kImaginary) | 60 | static void makeWavelet(float lambda, float theta, float psi, float sigma, float gamma, Mat &kReal, Mat &kImaginary) |
| 59 | { | 61 | { |
| @@ -111,29 +113,29 @@ private: | @@ -111,29 +113,29 @@ private: | ||
| 111 | } | 113 | } |
| 112 | }; | 114 | }; |
| 113 | 115 | ||
| 114 | -BR_REGISTER(Transform, Gabor) | 116 | +BR_REGISTER(Transform, GaborTransform) |
| 115 | 117 | ||
| 116 | /*! | 118 | /*! |
| 117 | * \ingroup transforms | 119 | * \ingroup transforms |
| 118 | * \brief A vector of gabor wavelets applied at a point. | 120 | * \brief A vector of gabor wavelets applied at a point. |
| 119 | * \author Josh Klontz \cite jklontz | 121 | * \author Josh Klontz \cite jklontz |
| 120 | */ | 122 | */ |
| 121 | -class GaborJet : public UntrainableTransform | 123 | +class GaborJetTransform : public UntrainableTransform |
| 122 | { | 124 | { |
| 123 | Q_OBJECT | 125 | Q_OBJECT |
| 124 | - Q_ENUMS(Gabor::Component) | 126 | + Q_ENUMS(br::GaborTransform::Component) |
| 125 | Q_PROPERTY(QList<float> lambdas READ get_lambdas WRITE set_lambdas RESET reset_lambdas STORED false) | 127 | Q_PROPERTY(QList<float> lambdas READ get_lambdas WRITE set_lambdas RESET reset_lambdas STORED false) |
| 126 | Q_PROPERTY(QList<float> thetas READ get_thetas WRITE set_thetas RESET reset_thetas STORED false) | 128 | Q_PROPERTY(QList<float> thetas READ get_thetas WRITE set_thetas RESET reset_thetas STORED false) |
| 127 | Q_PROPERTY(QList<float> psis READ get_psis WRITE set_psis RESET reset_psis STORED false) | 129 | Q_PROPERTY(QList<float> psis READ get_psis WRITE set_psis RESET reset_psis STORED false) |
| 128 | Q_PROPERTY(QList<float> sigmas READ get_sigmas WRITE set_sigmas RESET reset_sigmas STORED false) | 130 | Q_PROPERTY(QList<float> sigmas READ get_sigmas WRITE set_sigmas RESET reset_sigmas STORED false) |
| 129 | Q_PROPERTY(QList<float> gammas READ get_gammas WRITE set_gammas RESET reset_gammas STORED false) | 131 | Q_PROPERTY(QList<float> gammas READ get_gammas WRITE set_gammas RESET reset_gammas STORED false) |
| 130 | - Q_PROPERTY(Gabor::Component component READ get_component WRITE set_component RESET reset_component STORED false) | 132 | + Q_PROPERTY(br::GaborTransform::Component component READ get_component WRITE set_component RESET reset_component STORED false) |
| 131 | BR_PROPERTY(QList<float>, lambdas, QList<float>()) | 133 | BR_PROPERTY(QList<float>, lambdas, QList<float>()) |
| 132 | BR_PROPERTY(QList<float>, thetas, QList<float>()) | 134 | BR_PROPERTY(QList<float>, thetas, QList<float>()) |
| 133 | BR_PROPERTY(QList<float>, psis, QList<float>()) | 135 | BR_PROPERTY(QList<float>, psis, QList<float>()) |
| 134 | BR_PROPERTY(QList<float>, sigmas, QList<float>()) | 136 | BR_PROPERTY(QList<float>, sigmas, QList<float>()) |
| 135 | BR_PROPERTY(QList<float>, gammas, QList<float>()) | 137 | BR_PROPERTY(QList<float>, gammas, QList<float>()) |
| 136 | - BR_PROPERTY(Gabor::Component, component, Gabor::Phase) | 138 | + BR_PROPERTY(GaborTransform::Component, component, GaborTransform::Phase) |
| 137 | 139 | ||
| 138 | QList<Mat> kReals, kImaginaries; | 140 | QList<Mat> kReals, kImaginaries; |
| 139 | 141 | ||
| @@ -147,13 +149,13 @@ class GaborJet : public UntrainableTransform | @@ -147,13 +149,13 @@ class GaborJet : public UntrainableTransform | ||
| 147 | foreach (float sigma, sigmas) | 149 | foreach (float sigma, sigmas) |
| 148 | foreach (float gamma, gammas) { | 150 | foreach (float gamma, gammas) { |
| 149 | Mat kReal, kImaginary; | 151 | Mat kReal, kImaginary; |
| 150 | - Gabor::makeWavelet(lambda, theta, psi, sigma, gamma, kReal, kImaginary); | 152 | + GaborTransform::makeWavelet(lambda, theta, psi, sigma, gamma, kReal, kImaginary); |
| 151 | kReals.append(kReal); | 153 | kReals.append(kReal); |
| 152 | kImaginaries.append(kImaginary); | 154 | kImaginaries.append(kImaginary); |
| 153 | } | 155 | } |
| 154 | } | 156 | } |
| 155 | 157 | ||
| 156 | - static float response(const cv::Mat &src, const QPointF &point, const Mat &kReal, const Mat &kImaginary, Gabor::Component component) | 158 | + static float response(const cv::Mat &src, const QPointF &point, const Mat &kReal, const Mat &kImaginary, GaborTransform::Component component) |
| 157 | { | 159 | { |
| 158 | Rect roi(std::max(std::min((int)(point.x() - kReal.cols/2.f), src.cols - kReal.cols), 0), | 160 | Rect roi(std::max(std::min((int)(point.x() - kReal.cols/2.f), src.cols - kReal.cols), 0), |
| 159 | std::max(std::min((int)(point.y() - kReal.rows/2.f), src.rows - kReal.rows), 0), | 161 | std::max(std::min((int)(point.y() - kReal.rows/2.f), src.rows - kReal.rows), 0), |
| @@ -161,27 +163,27 @@ class GaborJet : public UntrainableTransform | @@ -161,27 +163,27 @@ class GaborJet : public UntrainableTransform | ||
| 161 | kReal.rows); | 163 | kReal.rows); |
| 162 | 164 | ||
| 163 | float real = 0, imaginary = 0, magnitude = 0, phase = 0; | 165 | float real = 0, imaginary = 0, magnitude = 0, phase = 0; |
| 164 | - if (component != Gabor::Imaginary) { | 166 | + if (component != GaborTransform::Imaginary) { |
| 165 | Mat dst; | 167 | Mat dst; |
| 166 | multiply(src(roi), kReal, dst); | 168 | multiply(src(roi), kReal, dst); |
| 167 | real = sum(dst)[0]; | 169 | real = sum(dst)[0]; |
| 168 | } | 170 | } |
| 169 | - if (component != Gabor::Real) { | 171 | + if (component != GaborTransform::Real) { |
| 170 | Mat dst; | 172 | Mat dst; |
| 171 | multiply(src(roi), kImaginary, dst); | 173 | multiply(src(roi), kImaginary, dst); |
| 172 | imaginary = sum(dst)[0]; | 174 | imaginary = sum(dst)[0]; |
| 173 | } | 175 | } |
| 174 | - if ((component == Gabor::Magnitude) || (component == Gabor::Phase)) { | 176 | + if ((component == GaborTransform::Magnitude) || (component == GaborTransform::Phase)) { |
| 175 | magnitude = sqrt(real*real + imaginary*imaginary); | 177 | magnitude = sqrt(real*real + imaginary*imaginary); |
| 176 | phase = atan2(imaginary, real)*180/CV_PI; | 178 | phase = atan2(imaginary, real)*180/CV_PI; |
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | float dst = 0; | 181 | float dst = 0; |
| 180 | - if (component == Gabor::Real) dst = real; | ||
| 181 | - else if (component == Gabor::Imaginary) dst = imaginary; | ||
| 182 | - else if (component == Gabor::Magnitude) dst = magnitude; | ||
| 183 | - else if (component == Gabor::Phase) dst = phase; | ||
| 184 | - else qFatal("GaborJet::response invalid component."); | 182 | + if (component == GaborTransform::Real) dst = real; |
| 183 | + else if (component == GaborTransform::Imaginary) dst = imaginary; | ||
| 184 | + else if (component == GaborTransform::Magnitude) dst = magnitude; | ||
| 185 | + else if (component == GaborTransform::Phase) dst = phase; | ||
| 186 | + else qFatal("GaborJet::response invalid component."); | ||
| 185 | return dst; | 187 | return dst; |
| 186 | } | 188 | } |
| 187 | 189 | ||
| @@ -195,6 +197,8 @@ class GaborJet : public UntrainableTransform | @@ -195,6 +197,8 @@ class GaborJet : public UntrainableTransform | ||
| 195 | } | 197 | } |
| 196 | }; | 198 | }; |
| 197 | 199 | ||
| 198 | -BR_REGISTER(Transform, GaborJet) | 200 | +BR_REGISTER(Transform, GaborJetTransform) |
| 201 | + | ||
| 202 | +} // namespace br | ||
| 199 | 203 | ||
| 200 | #include "wavelet.moc" | 204 | #include "wavelet.moc" |