-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRegionsSingleImage.cpp
More file actions
72 lines (61 loc) · 1.52 KB
/
RegionsSingleImage.cpp
File metadata and controls
72 lines (61 loc) · 1.52 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
62
63
64
65
66
67
68
69
70
71
72
#include "RegionsSingleImage.hpp"
#include <iostream>
#include <vector>
using std::vector;
using std::cerr;
using std::cout;
using std::endl;
RegionsSingleImage::RegionsSingleImage(std::string fName){
#ifdef __CVLOADIMAGE_WORKING__
im = cvLoadImage(fName.c_str(), CV_LOAD_IMAGE_COLOR);
#else
im = readImage(fName.c_str(), CV_LOAD_IMAGE_COLOR);
#endif
if(im == NULL)
{
cerr << "Could not read image from " << fName << endl;
assert(false);
}
list = new std::vector<Region *>;
}
RegionsSingleImage::RegionsSingleImage(IplImage *I)
{
assert(I != NULL);
im = cvCreateImage(cvGetSize(I), I->depth, I->nChannels);
cvCopy(I, im, 0);
list = new std::vector<Region *>;
}
RegionsSingleImage::~RegionsSingleImage()
{
if(list)
for(unsigned int i=0; i< list->size(); i++)
if(list->at(i))
delete(list->at(i));
delete(list);
cvReleaseImage(&im);
}
unsigned int RegionsSingleImage::length()
{
return (unsigned int)(list->size());
}
Region * RegionsSingleImage::get(int i)
{
return list->at(i);
}
void RegionsSingleImage::set(int i, Region *r)
{
list->at(i) = r;
}
const IplImage *RegionsSingleImage::getImage(){
return (const IplImage *)im;
}
std::vector<double> * RegionsSingleImage::getUniqueScores(){
vector<double> *v = new vector<double>;
v->reserve(list->size());
for(unsigned int i=0; i<list->size(); i++)
v->push_back(list->at(i)->detScore);
sort(v->begin(), v->end());
vector<double>::iterator uniElem = unique(v->begin(), v->end());
v->erase(uniElem, v->end());
return v;
}