Commit 1952d8269d9432eb4c7b16e4991ef2a01c41c866
1 parent
c9e43a5f
bug fixes
Showing
5 changed files
with
20 additions
and
16 deletions
sdk/core/opencvutils.cpp
| ... | ... | @@ -143,6 +143,7 @@ Mat OpenCVUtils::toMatByRow(const QList<Mat> &src) |
| 143 | 143 | |
| 144 | 144 | int rows = 0; foreach (const Mat &m, src) rows += m.rows; |
| 145 | 145 | int cols = src.first().cols; |
| 146 | + if (cols == 0) qFatal("Columnless matrix!"); | |
| 146 | 147 | int type = src.first().type(); |
| 147 | 148 | Mat dst(rows, cols, type); |
| 148 | 149 | ... | ... |
sdk/plugins/algorithms.cpp
| ... | ... | @@ -50,7 +50,7 @@ class AlgorithmsInitializer : public Initializer |
| 50 | 50 | Globals->abbreviations.insert("SmallSIFT", "Open+LimitSize(512)+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); |
| 51 | 51 | Globals->abbreviations.insert("SmallSURF", "Open+LimitSize(512)+KeyPointDetector(SURF)+KeyPointDescriptor(SURF):KeyPointMatcher(BruteForce)"); |
| 52 | 52 | Globals->abbreviations.insert("ColorHist", "Open+LimitSize(512)!EnsureChannels(3)+SplitChannels+Hist(256,0,8)+Cat+Normalize(L1):L2"); |
| 53 | - Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+WordWise(RowWisePCA(8)+RowWiseMeanCenter+Binarize,Identity):L2"); | |
| 53 | + Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+WordWise(RowWisePCA(8)+RowWiseMeanCenter+Binarize,RowWisePCA):L2"); | |
| 54 | 54 | |
| 55 | 55 | // Hash |
| 56 | 56 | Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); | ... | ... |
sdk/plugins/cvt.cpp
| ... | ... | @@ -181,12 +181,17 @@ class RGTransform : public UntrainableTransform |
| 181 | 181 | for (int i=0; i<m.rows; i++) |
| 182 | 182 | for (int j=0; j<m.cols; j++) { |
| 183 | 183 | Vec3b v = m.at<Vec3b>(i,j); |
| 184 | - uchar& b = v[0]; | |
| 185 | - uchar& g = v[1]; | |
| 186 | - uchar& r = v[2]; | |
| 187 | - | |
| 188 | - R.at<uchar>(i, j) = saturate_cast<uchar>(255.0*r/(r+g+b)); | |
| 189 | - G.at<uchar>(i, j) = saturate_cast<uchar>(255.0*g/(r+g+b)); | |
| 184 | + const int b = v[0]; | |
| 185 | + const int g = v[1]; | |
| 186 | + const int r = v[2]; | |
| 187 | + const int sum = b + g + r; | |
| 188 | + if (sum > 0) { | |
| 189 | + R.at<uchar>(i, j) = saturate_cast<uchar>(255.0*r/(r+g+b)); | |
| 190 | + G.at<uchar>(i, j) = saturate_cast<uchar>(255.0*g/(r+g+b)); | |
| 191 | + } else { | |
| 192 | + R.at<uchar>(i, j) = 0; | |
| 193 | + G.at<uchar>(i, j) = 0; | |
| 194 | + } | |
| 190 | 195 | } |
| 191 | 196 | |
| 192 | 197 | dst.append(R); | ... | ... |
sdk/plugins/eigen3.cpp
| ... | ... | @@ -145,15 +145,15 @@ protected: |
| 145 | 145 | |
| 146 | 146 | if (keep < 1) { |
| 147 | 147 | // Keep eigenvectors that retain a certain energy percentage. |
| 148 | - double totalEnergy = allEVals.sum(); | |
| 148 | + const double totalEnergy = allEVals.sum(); | |
| 149 | 149 | if (totalEnergy == 0) { |
| 150 | 150 | keep = 0; |
| 151 | 151 | } else { |
| 152 | 152 | double currentEnergy = 0; |
| 153 | - int i; | |
| 154 | - for (i=1; i<=allEVals.rows(); i++) { | |
| 155 | - currentEnergy += allEVals(allEVals.rows()-i); | |
| 156 | - if (currentEnergy / totalEnergy >= keep) break; | |
| 153 | + int i=0; | |
| 154 | + while ((currentEnergy / totalEnergy < keep) && (i < allEVals.rows())) { | |
| 155 | + currentEnergy += allEVals(allEVals.rows()-(i+1)); | |
| 156 | + i++; | |
| 157 | 157 | } |
| 158 | 158 | keep = i - drop; |
| 159 | 159 | } | ... | ... |
sdk/plugins/integral.cpp
| ... | ... | @@ -159,9 +159,7 @@ class WordWiseTransform : public Transform |
| 159 | 159 | |
| 160 | 160 | void project(const Template &src, Template &dst) const |
| 161 | 161 | { |
| 162 | - Template reworded; | |
| 163 | - getWords->project(src, reworded); | |
| 164 | - byWord->project(reworded, dst); | |
| 162 | + byWord->project(reword(src), dst); | |
| 165 | 163 | } |
| 166 | 164 | |
| 167 | 165 | Template reword(const Template &src) const |
| ... | ... | @@ -177,7 +175,7 @@ class WordWiseTransform : public Transform |
| 177 | 175 | QVector<int> indicies(numWords, 0); |
| 178 | 176 | for (int i=0; i<src.m().rows; i++) { |
| 179 | 177 | const int word = words.m().at<uchar>(i,0); |
| 180 | - reworded[word].row(indicies[word]++) = src.m().row(i); | |
| 178 | + src.m().row(i).copyTo(reworded[word].row(indicies[word]++)); | |
| 181 | 179 | } |
| 182 | 180 | return reworded; |
| 183 | 181 | } | ... | ... |