Commit fbcb0ac256509d807e18c1909343ec883e3c4c1e
1 parent
4650acf7
VecGallery tweaks
Showing
1 changed file
with
18 additions
and
18 deletions
openbr/plugins/gallery/vec.cpp
| ... | ... | @@ -22,15 +22,15 @@ class vecGallery : public FileGallery |
| 22 | 22 | |
| 23 | 23 | ~vecGallery() |
| 24 | 24 | { |
| 25 | - if (mats.isEmpty()) | |
| 26 | - return; | |
| 25 | + if (mats.isEmpty()) | |
| 26 | + return; | |
| 27 | 27 | |
| 28 | - writeOpen(); | |
| 28 | + writeOpen(); | |
| 29 | 29 | |
| 30 | - // Write header | |
| 31 | - int count = mats.size(); | |
| 32 | - int size = width*height; | |
| 33 | - short temp = 0; | |
| 30 | + // Write header | |
| 31 | + int count = mats.size(); | |
| 32 | + int size = width*height; | |
| 33 | + short temp = 0; | |
| 34 | 34 | |
| 35 | 35 | const size_t write1 = f.write((char*)&count,sizeof(count)); |
| 36 | 36 | const size_t write2 = f.write((char*)&size,sizeof(size)); |
| ... | ... | @@ -42,16 +42,16 @@ class vecGallery : public FileGallery |
| 42 | 42 | |
| 43 | 43 | for (int i=0; i<count; i++) { |
| 44 | 44 | uchar tmp = 0; |
| 45 | - const size_t write5 = f.write((char*)&tmp,sizeof(tmp)); | |
| 45 | + const size_t write5 = f.write((char*)&tmp,sizeof(tmp)); | |
| 46 | 46 | |
| 47 | 47 | for (int r = 0; r < height; r++) |
| 48 | 48 | for (int c = 0; c < width; c++) { |
| 49 | - short buffer = mats[i].ptr(r)[c]; | |
| 50 | - f.write((char*)&buffer, sizeof(buffer)); | |
| 51 | - } | |
| 49 | + short buffer = mats[i].ptr(r)[c]; | |
| 50 | + f.write((char*)&buffer, sizeof(buffer)); | |
| 51 | + } | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - f.close(); | |
| 54 | + f.close(); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | TemplateList readBlock(bool *done) |
| ... | ... | @@ -91,8 +91,8 @@ class vecGallery : public FileGallery |
| 91 | 91 | for (int r = 0; r < height; r++) |
| 92 | 92 | for (int c = 0; c < width; c++) |
| 93 | 93 | m.ptr(r)[c] = (uchar)vec[r*width+c]; |
| 94 | - Template t(m); | |
| 95 | - t.file.set("Label",1); | |
| 94 | + Template t(m); | |
| 95 | + t.file.set("Label",1); | |
| 96 | 96 | templates.append(t); |
| 97 | 97 | } |
| 98 | 98 | |
| ... | ... | @@ -101,10 +101,10 @@ class vecGallery : public FileGallery |
| 101 | 101 | |
| 102 | 102 | void write(const Template &t) |
| 103 | 103 | { |
| 104 | - if (t.m().rows == height && t.m().cols == width) | |
| 105 | - mats.append(t); | |
| 106 | - else | |
| 107 | - qFatal("Matrix has incorrect width/height."); | |
| 104 | + if (t.m().rows == height && t.m().cols == width && t.m().type() == CV_8UC1) | |
| 105 | + mats.append(t); | |
| 106 | + else | |
| 107 | + qFatal("Matrix has incorrect width/height/type."); | |
| 108 | 108 | } |
| 109 | 109 | }; |
| 110 | 110 | ... | ... |