Commit eca5345ab27d225d23045fa2bf3416b19c74e3d4

Authored by Josh Klontz
1 parent dbc8909b

removed matlab gallery

openbr/plugins/gallery/matlab.cpp deleted
1 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
2 - * Copyright 2015 Rank One Corporation *  
3 - * *  
4 - * Licensed under the Apache License, Version 2.0 (the "License"); *  
5 - * you may not use this file except in compliance with the License. *  
6 - * You may obtain a copy of the License at *  
7 - * *  
8 - * http://www.apache.org/licenses/LICENSE-2.0 *  
9 - * *  
10 - * Unless required by applicable law or agreed to in writing, software *  
11 - * distributed under the License is distributed on an "AS IS" BASIS, *  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  
13 - * See the License for the specific language governing permissions and *  
14 - * limitations under the License. *  
15 - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */  
16 -  
17 -#include <openbr/plugins/openbr_internal.h>  
18 -  
19 -namespace br  
20 -{  
21 -/*!  
22 - * \ingroup galleries  
23 - * \brief A simple matrix container format that is easily read into matlab.  
24 - * Templates are concatenated into column vectors, and output into a single matrix.  
25 - * Note that this is not intended to read in .matlab files, as this is simply  
26 - * a quick and dirty for analyzing data in a more interactive environment.  
27 - * Use the loadOpenBR.m script to ingest the resultant file into Matlab  
28 - * \br_property bool writeLabels Write the subject labels of the instances in the final row of the matrix.  
29 - * \author Brendan Klare \cite bklare  
30 - */  
31 -class matlabGallery : public FileGallery  
32 -{  
33 - Q_OBJECT  
34 - Q_PROPERTY(bool writeLabels READ get_writeLabels WRITE set_writeLabels RESET reset_writeLabels STORED false)  
35 - BR_PROPERTY(bool, writeLabels, false)  
36 -  
37 - TemplateList templates;  
38 -  
39 - ~matlabGallery()  
40 - {  
41 - if (!f.open(QFile::WriteOnly))  
42 - qFatal("Failed to open %s for writting.", qPrintable(file));  
43 -  
44 - int r = templates.first().m().rows;  
45 - int c = templates.first().m().cols;  
46 -  
47 - for (int i = templates.size() - 1; i >= 0; i--) {  
48 - if (templates[i].m().rows != r || templates[i].m().cols != c) {  
49 - qDebug() << templates[i].file.name << " : template not appended to gallery b/c rows and col dimensions differ.";  
50 - templates.removeAt(i);  
51 - }  
52 - }  
53 -  
54 - cv::Mat m(r * c, templates.size(), CV_32FC1);  
55 - for (int i = 0; i < templates.size(); i++) {  
56 - cv::Mat temp;  
57 - temp = templates[i].m().reshape(1, r * c);  
58 - temp.copyTo(m.col(i));  
59 - }  
60 -  
61 - if (writeLabels) {  
62 - TemplateList _templates = TemplateList::relabel(templates, "Label", false);  
63 -  
64 - QList<int> classes = File::get<int>(_templates, "Label");  
65 - cv::Mat _m(r * c + 1, _templates.size(), CV_32FC1);  
66 - m.copyTo(_m.rowRange(cv::Range(0, r * c)));  
67 - for (int i = 0; i < _templates.size(); i++) {  
68 - _m.at<float>(r * c, i) = (float) classes[i];  
69 - }  
70 - m = _m;  
71 - }  
72 -  
73 - f.write((const char *) &m.rows, 4);  
74 - f.write((const char *) &m.cols, 4);  
75 - qint64 rowSize = m.cols * sizeof(float);  
76 - for (int i = 0; i < m.rows; i++)  
77 - f.write((const char *) m.row(i).data, rowSize);  
78 -  
79 - f.close();  
80 - }  
81 -  
82 - TemplateList readBlock(bool *done)  
83 - {  
84 - qDebug() << "matlabGallery is not intended to be read. This gallery is meant for export only.";  
85 - TemplateList t;  
86 - *done = false;  
87 - return t;  
88 - }  
89 -  
90 - void write(const Template &t)  
91 - {  
92 - if (t.m().type() != CV_32FC1)  
93 - qDebug() << t.file.name << ": template not appended to gallery b/c it must be type CV_32FC1.";  
94 - else  
95 - templates.append(t);  
96 - }  
97 -  
98 - void init()  
99 - {  
100 - FileGallery::init();  
101 - }  
102 -};  
103 -  
104 -BR_REGISTER(Gallery, matlabGallery)  
105 -  
106 -}  
107 -  
108 -#include "gallery/matlab.moc"