Commit 3d628fa96fb02e555f96c4d8ee11d528338778ee
1 parent
4fb48f36
Distance gallery and output incremental operations from Globals->blockSize
For galleries, add a property to Gallery indicating the number of templates that will be read per block (for galleries that do incremental reads--really just galGallery and memGallery). For outputs, add two properties indicating the rows and columns of blocks to use (i.e. support non-square output blocks). For both classes, default these properties to Globals->blockSize
Showing
4 changed files
with
26 additions
and
11 deletions
openbr/openbr_plugin.cpp
| ... | ... | @@ -1101,13 +1101,19 @@ void Output::initialize(const FileList &targetFiles, const FileList &queryFiles) |
| 1101 | 1101 | { |
| 1102 | 1102 | this->targetFiles = targetFiles; |
| 1103 | 1103 | this->queryFiles = queryFiles; |
| 1104 | + if (this->blockRows == -1) | |
| 1105 | + blockRows = Globals->blockSize; | |
| 1106 | + | |
| 1107 | + if (this->blockCols == -1) | |
| 1108 | + blockCols = Globals->blockSize; | |
| 1109 | + | |
| 1104 | 1110 | selfSimilar = (queryFiles == targetFiles) && (targetFiles.size() > 1) && (queryFiles.size() > 1); |
| 1105 | 1111 | } |
| 1106 | 1112 | |
| 1107 | 1113 | void Output::setBlock(int rowBlock, int columnBlock) |
| 1108 | 1114 | { |
| 1109 | - offset = QPoint((columnBlock == -1) ? 0 : Globals->blockSize*columnBlock, | |
| 1110 | - (rowBlock == -1) ? 0 : Globals->blockSize*rowBlock); | |
| 1115 | + offset = QPoint((columnBlock == -1) ? 0 : blockCols*columnBlock, | |
| 1116 | + (rowBlock == -1) ? 0 : blockRows*rowBlock); | |
| 1111 | 1117 | if (!next.isNull()) next->setBlock(rowBlock, columnBlock); |
| 1112 | 1118 | } |
| 1113 | 1119 | ... | ... |
openbr/openbr_plugin.h
| ... | ... | @@ -996,6 +996,11 @@ class BR_EXPORT Output : public Object |
| 996 | 996 | Q_OBJECT |
| 997 | 997 | |
| 998 | 998 | public: |
| 999 | + Q_PROPERTY(int blockRows READ get_blockRows WRITE set_blockRows RESET reset_blockRows STORED false) | |
| 1000 | + Q_PROPERTY(int blockCols READ get_blockCols WRITE set_blockCols RESET reset_blockCols STORED false) | |
| 1001 | + BR_PROPERTY(int, blockRows, -1) | |
| 1002 | + BR_PROPERTY(int, blockCols, -1) | |
| 1003 | + | |
| 999 | 1004 | FileList targetFiles; /*!< \brief List of files representing the gallery templates. */ |
| 1000 | 1005 | FileList queryFiles; /*!< \brief List of files representing the probe templates. */ |
| 1001 | 1006 | bool selfSimilar; /*!< \brief \c true if the \em targetFiles == \em queryFiles, \c false otherwise. */ |
| ... | ... | @@ -1074,9 +1079,11 @@ public: |
| 1074 | 1079 | */ |
| 1075 | 1080 | class BR_EXPORT Gallery : public Object |
| 1076 | 1081 | { |
| 1077 | - Q_OBJECT | |
| 1078 | - | |
| 1082 | + Q_OBJECT | |
| 1079 | 1083 | public: |
| 1084 | + Q_PROPERTY(int readBlockSize READ get_readBlockSize WRITE set_readBlockSize RESET reset_readBlockSize STORED false) | |
| 1085 | + BR_PROPERTY(int, readBlockSize, Globals->blockSize) | |
| 1086 | + | |
| 1080 | 1087 | virtual ~Gallery() {} |
| 1081 | 1088 | TemplateList read(); /*!< \brief Retrieve all the stored templates. */ |
| 1082 | 1089 | FileList files(); /*!< \brief Retrieve all the stored template files. */ | ... | ... |
openbr/plugins/gallery.cpp
| ... | ... | @@ -123,7 +123,7 @@ class galGallery : public Gallery |
| 123 | 123 | gallery.seek(0); |
| 124 | 124 | |
| 125 | 125 | TemplateList templates; |
| 126 | - while ((templates.size() < Globals->blockSize) && !stream.atEnd()) { | |
| 126 | + while ((templates.size() < readBlockSize) && !stream.atEnd()) { | |
| 127 | 127 | Template m; |
| 128 | 128 | stream >> m; |
| 129 | 129 | templates.append(m); |
| ... | ... | @@ -348,8 +348,8 @@ class memGallery : public Gallery |
| 348 | 348 | MemoryGalleries::aligned[file] = true; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - TemplateList templates = MemoryGalleries::galleries[file].mid(block*Globals->blockSize, Globals->blockSize); | |
| 352 | - *done = (templates.size() < Globals->blockSize); | |
| 351 | + TemplateList templates = MemoryGalleries::galleries[file].mid(block*readBlockSize, readBlockSize); | |
| 352 | + *done = (templates.size() < readBlockSize); | |
| 353 | 353 | block = *done ? 0 : block+1; |
| 354 | 354 | return templates; |
| 355 | 355 | } | ... | ... |
openbr/plugins/output.cpp
| ... | ... | @@ -215,9 +215,11 @@ class mtxOutput : public Output |
| 215 | 215 | |
| 216 | 216 | this->rowBlock = rowBlock; |
| 217 | 217 | this->columnBlock = columnBlock; |
| 218 | - blockScores = cv::Mat(std::min(queryFiles.size()-rowBlock*Globals->blockSize, Globals->blockSize), | |
| 219 | - std::min(targetFiles.size()-columnBlock*Globals->blockSize, Globals->blockSize), | |
| 220 | - CV_32FC1); | |
| 218 | + | |
| 219 | + int matrixRows = std::min(queryFiles.size()-rowBlock*this->blockRows, blockRows); | |
| 220 | + int matrixCols = std::min(targetFiles.size()-columnBlock*this->blockCols, blockCols); | |
| 221 | + | |
| 222 | + blockScores = cv::Mat(matrixRows, matrixCols, CV_32FC1); | |
| 221 | 223 | } |
| 222 | 224 | |
| 223 | 225 | void setRelative(float value, int i, int j) |
| ... | ... | @@ -237,7 +239,7 @@ class mtxOutput : public Output |
| 237 | 239 | if (!f.open(QFile::ReadWrite)) |
| 238 | 240 | qFatal("Unable to open %s for modifying.", qPrintable(file)); |
| 239 | 241 | for (int i=0; i<blockScores.rows; i++) { |
| 240 | - f.seek(headerSize + sizeof(float)*(quint64(rowBlock*Globals->blockSize+i)*targetFiles.size()+(columnBlock*Globals->blockSize))); | |
| 242 | + f.seek(headerSize + sizeof(float)*(quint64(rowBlock*this->blockRows+i)*targetFiles.size()+(columnBlock*this->blockCols))); | |
| 241 | 243 | f.write((const char*)blockScores.row(i).data, sizeof(float)*blockScores.cols); |
| 242 | 244 | } |
| 243 | 245 | f.close(); | ... | ... |