forked from btgraham/SparseConvNet-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpatiallySparseDatasetOpenCV.cpp
More file actions
61 lines (59 loc) · 1.59 KB
/
SpatiallySparseDatasetOpenCV.cpp
File metadata and controls
61 lines (59 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "SpatiallySparseDatasetOpenCV.h"
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include "utilities.h"
OpenCVLabeledDataSet::OpenCVLabeledDataSet
(std::string classesListFile, std::string dataDirectory, std::string wildcard,
batchType type_, int backgroundCol,
bool loadData, int flags) {
name=dataDirectory;
if (flags==0) nFeatures=1;
if (flags==1) nFeatures=3;
type=type_;
{
std::ifstream f(classesListFile.c_str());
std::string cl;
int ctr=0;
while (f >> cl)
classes[cl]=ctr++;
}
nClasses=classes.size();
for (auto &kv : classes) {
for (auto &file : globVector(dataDirectory+"/"+kv.first+"/"+wildcard)) {
OpenCVPicture* pic = new OpenCVPicture(file,backgroundCol,kv.second);
if(loadData) {
pic->loadDataWithoutScaling(flags);
assert(nFeatures==pic->mat.channels());
}
pictures.push_back(pic);
}
}
}
OpenCVUnlabeledDataSet::OpenCVUnlabeledDataSet
(std::string classesListFile, std::string dataDirectory, std::string wildcard,
int backgroundCol,
bool loadData, int flags) {
name=dataDirectory;
header="image";
type=UNLABELEDBATCH;
{
std::ifstream f(classesListFile.c_str());
std::string cl;
int ctr=0;
while (f >> cl) {
classes[cl]=ctr++;
header=header+","+cl;
}
}
nClasses=classes.size();
for (auto &file : globVector(dataDirectory+"/"+wildcard)) {
OpenCVPicture* pic = new OpenCVPicture(file,backgroundCol,0);
if(loadData) {
pic->loadDataWithoutScaling(flags);
nFeatures=pic->mat.channels();
}
pictures.push_back(pic);
}
}