Commit bb9702d2ba28c5dbc43dfe1c1122ed9a97377f02
1 parent
7873c508
implemented gallery concatenation. fixed #4
Showing
6 changed files
with
40 additions
and
3 deletions
app/br/br.cpp
| ... | ... | @@ -51,7 +51,8 @@ static void help() |
| 51 | 51 | "-cluster <simmat> ... <simmat> <aggressiveness> {csv}\n" |
| 52 | 52 | "-makeMask <target_gallery> <query_gallery> {mask}\n" |
| 53 | 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 | 56 | "-reformat <target_sigset> <query_sigset> <simmat> {output}\n" |
| 56 | 57 | "-evalClassification <predicted_gallery> <truth_gallery>\n" |
| 57 | 58 | "-evalRegression <predicted_gallery> <truth_gallery>\n" |
| ... | ... | @@ -141,6 +142,9 @@ int main(int argc, char *argv[]) |
| 141 | 142 | } else if (!strcmp(fun, "combineMasks")) { |
| 142 | 143 | check(parc >= 4, "Insufficient parameter count for 'combineMasks'."); |
| 143 | 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 | 148 | } else if (!strcmp(fun, "convert")) { |
| 145 | 149 | check(parc == 2, "Incorrect parameter count for 'convert'."); |
| 146 | 150 | br_convert(parv[0], parv[1]); | ... | ... |
sdk/core/core.cpp
| ... | ... | @@ -315,11 +315,26 @@ void br::Compare(const File &targetGallery, const File &queryGallery, const File |
| 315 | 315 | |
| 316 | 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 | 319 | QScopedPointer<Format> before(Factory<Format>::make(src)); |
| 319 | 320 | QScopedPointer<Format> after(Factory<Format>::make(dst)); |
| 320 | 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 | 338 | QSharedPointer<br::Transform> br::Transform::fromAlgorithm(const QString &algorithm) |
| 324 | 339 | { |
| 325 | 340 | return AlgorithmManager::getAlgorithm(algorithm)->transform; | ... | ... |
sdk/openbr.cpp
| ... | ... | @@ -31,6 +31,11 @@ const char *br_about() |
| 31 | 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 | 39 | void br_cluster(int num_simmats, const char *simmats[], float aggressiveness, const char *csv) |
| 35 | 40 | { |
| 36 | 41 | ClusterGallery(QtUtils::toStringList(num_simmats, simmats), aggressiveness, csv); | ... | ... |
sdk/openbr.h
| ... | ... | @@ -73,6 +73,11 @@ extern "C" { |
| 73 | 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 | 81 | * \brief Clusters one or more similarity matrices into a list of subjects. |
| 77 | 82 | * |
| 78 | 83 | * A similarity matrix is a type of br::Output. The current clustering algorithm is a simplified implementation of \cite zhu11. | ... | ... |
sdk/openbr_plugin.h
| ... | ... | @@ -1098,6 +1098,14 @@ BR_EXPORT void Compare(const File &targetGallery, const File &queryGallery, cons |
| 1098 | 1098 | */ |
| 1099 | 1099 | BR_EXPORT void Convert(const File &input, const File &output); |
| 1100 | 1100 | |
| 1101 | +/*! | |
| 1102 | + * \brief Concatenate several galleries into one. | |
| 1103 | + * \param inputGalleries List of galleries to concatenate. | |
| 1104 | + * \param outputGallery Gallery to store the concatenated result. | |
| 1105 | + * \note outputGallery must not be in inputGalleries. | |
| 1106 | + */ | |
| 1107 | +BR_EXPORT void Cat(const QStringList &inputGalleries, const QString &outputGallery); | |
| 1108 | + | |
| 1101 | 1109 | /*! @}*/ |
| 1102 | 1110 | |
| 1103 | 1111 | } // namespace br | ... | ... |
sdk/plugins/regions.cpp
| ... | ... | @@ -76,7 +76,7 @@ BR_REGISTER(Transform, ByRow) |
| 76 | 76 | * No requirements are placed on input matrices size and type. |
| 77 | 77 | * \author Josh Klontz \cite jklontz |
| 78 | 78 | */ |
| 79 | -class Cat : public UntrainableMetaTransform | |
| 79 | +class CatTransform : public UntrainableMetaTransform | |
| 80 | 80 | { |
| 81 | 81 | Q_OBJECT |
| 82 | 82 | Q_PROPERTY(int partitions READ get_partitions WRITE set_partitions RESET reset_partitions) |
| ... | ... | @@ -105,7 +105,7 @@ class Cat : public UntrainableMetaTransform |
| 105 | 105 | } |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | -BR_REGISTER(Transform, Cat) | |
| 108 | +BR_REGISTER(Transform, CatTransform) | |
| 109 | 109 | |
| 110 | 110 | /*! |
| 111 | 111 | * \ingroup transforms | ... | ... |