Commit 31704f504a2f572d7a122f35c6785ad682b5bf13
1 parent
41119302
Add CatColsTransform
Showing
1 changed file
with
26 additions
and
1 deletions
openbr/plugins/regions.cpp
| ... | ... | @@ -114,7 +114,7 @@ BR_REGISTER(Transform, CatTransform) |
| 114 | 114 | /*! |
| 115 | 115 | * \ingroup transforms |
| 116 | 116 | * \brief Concatenates all input matrices by row into a single matrix. |
| 117 | - * All matricies must have the same row counts. | |
| 117 | + * All matricies must have the same column counts. | |
| 118 | 118 | * \author Josh Klontz \cite jklontz |
| 119 | 119 | */ |
| 120 | 120 | class CatRowsTransform : public UntrainableMetaTransform |
| ... | ... | @@ -131,6 +131,31 @@ BR_REGISTER(Transform, CatRowsTransform) |
| 131 | 131 | |
| 132 | 132 | /*! |
| 133 | 133 | * \ingroup transforms |
| 134 | + * \brief Concatenates all input matrices by column into a single matrix. | |
| 135 | + * Use after a fork to concatenate two feature matrices by column. | |
| 136 | + * \author Austin Blanton \cite imaus10 | |
| 137 | + */ | |
| 138 | +class CatColsTransform : public UntrainableMetaTransform | |
| 139 | +{ | |
| 140 | + Q_OBJECT | |
| 141 | + | |
| 142 | + void project(const Template &src, Template &dst) const | |
| 143 | + { | |
| 144 | + if (src.empty()) return; | |
| 145 | + dst.file = src.file; | |
| 146 | + Mat m = OpenCVUtils::toMatByRow(src); | |
| 147 | + // right now this just splits src in half and joins them horizontally | |
| 148 | + // TODO: add partitions parameter for more than a single split | |
| 149 | + Mat first = m.rowRange(Range(0, m.rows/2)); | |
| 150 | + Mat second = m.rowRange(Range(m.rows/2, m.rows)); | |
| 151 | + hconcat(first, second, dst); | |
| 152 | + } | |
| 153 | +}; | |
| 154 | + | |
| 155 | +BR_REGISTER(Transform, CatColsTransform) | |
| 156 | + | |
| 157 | +/*! | |
| 158 | + * \ingroup transforms | |
| 134 | 159 | * \brief Reshape the each matrix to the specified number of rows. |
| 135 | 160 | * \author Josh Klontz \cite jklontz |
| 136 | 161 | */ | ... | ... |