-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathBasicImageSegmentation.cpp
More file actions
81 lines (68 loc) · 1.6 KB
/
Copy pathBasicImageSegmentation.cpp
File metadata and controls
81 lines (68 loc) · 1.6 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
73
74
75
76
77
78
79
80
// BasicImageSegmentation.cpp : 定义控制台应用程序的入口点。
//
// Author: hujiagao@gmail.com
//
#include <stdio.h>
#include <tchar.h>
#include <iostream>
using namespace std;
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
#include "Timer.h"
#include "ConfigReader.h"
#include "segmentor.h"
#include "SLICSegmentor.h"
#include "MeanShiftSegmentor.h"
#include "SEEDSSegmentor.h";
#include "GraphBasedSegmentor.h"
#include "GrabCutSegmentor.h"
#include "OneCutSegmentor.h"
IMPLEMENT_DYNCRT_BASE(Segmentor);
IMPLEMENT_DYNCRT_CLASS(SLICSegmentor);
IMPLEMENT_DYNCRT_CLASS(MeanShiftSegmentor);
IMPLEMENT_DYNCRT_CLASS(SEEDSSegmentor);
IMPLEMENT_DYNCRT_CLASS(GraphBasedSegmentor);
IMPLEMENT_DYNCRT_CLASS(GrabCutSegmentor);
IMPLEMENT_DYNCRT_CLASS(OneCutSegmentor);
int main(int argc, char* argv[])
{
Mat inImage;
string imgName;
if (argc > 1)
{
imgName = string(argv[1]);
} else {
cout<<"Please input the image name:";
cin>>imgName;
cout<<endl;
}
inImage = imread(imgName);
vector<SegReq> segList;
ConfigReader re;
re.GetSegRequire(segList);
for (int i = 0; i < segList.size(); i++)
{
SegReq seg = segList[i];
string segName = seg.first;
vector<float> segArgs = seg.second;
Timer t(segName);
t.Start();
Segmentor* s = Segmentor::Create(segName+string("Segmentor"));
if (s == NULL)
{
cout<<"--Error: Cannot create segmentor: "<<segName<<endl;
continue;
}
s->SetImage(inImage);
s->SetArgs(segArgs);
s->Run();
s->ShowResult();
s->SaveResult();
t.Stop();
waitKey(1);
}
waitKey(0);
return 0;
}