Repository navigation
Expand file tree
/
Copy pathfileUtils.cpp
More file actions
97 lines (84 loc) · 2.58 KB
/
Copy pathfileUtils.cpp
File metadata and controls
97 lines (84 loc) · 2.58 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "projectHeader.h"
#include "projectFunctions.h"
void getImagenamelist(string shotfilename,string imagedir, int num_examples,vector<string> &imageList)
{
vector<int> startframes;
vector<int> endframes;
vector<int> keyframes;
vector<int> sizes;
readInputShotsFile(shotfilename,startframes,endframes,keyframes,sizes,num_examples);
cout<<"The total number of shots are "<<startframes.size()<<endl;
for(int i=0; i<startframes.size(); i++)
{
int middle = (startframes[i] + endframes[i]) / 2 + 25;
stringstream imagename;
imagename<<imagedir<<"/image_"<<middle<<".jpg";
imageList.push_back(imagename.str());
}
}
string getActualName(string filename)
{
int firstindx = filename.find_last_of("/");
if(firstindx == filename.npos)
{
firstindx = 0;
}
else
{
firstindx = firstindx + 1;
}
int lastindx = filename.find_last_of(".");
if(lastindx == filename.npos)
{
lastindx = filename.length() - 1;
}
int len = lastindx - firstindx;
string actualstr = filename.substr(firstindx,len);
return actualstr;
}
int readInputShotsFile(string inputshotfilename,vector<int>& startframes,vector<int>& endframes,vector<int>& keyframes,vector<int>& sizes,int num_max)
{
cout<<"Inside readInputShotsFile"<<endl;
cout<<"Reading file "<<inputshotfilename<<endl;
ifstream inputframenos(inputshotfilename.c_str(),ios::in);
if(!inputframenos.good())
{
cout<<"Cannot open file "<<inputshotfilename<<endl;
exit(0);
}
int prev_start, prev_end;
int framenum = 0;
int start_frame = 0;
int end_frame = 1000000;
int key = 0;
int size = 0;
do
{
// The first "shot"
inputframenos>>start_frame;
inputframenos>>end_frame;
inputframenos>>key>>size;
// inputframenos>>inputlabel;
if(framenum > 0)
{
if(start_frame == prev_start && end_frame == prev_end)
continue;
}
prev_start = start_frame;
prev_end = end_frame;
startframes.push_back(start_frame);
endframes.push_back(end_frame);
keyframes.push_back(key);
sizes.push_back(size);
framenum++;
}
while(inputframenos.good());
inputframenos.close();
if(keyframes.size() > num_max)
{
keyframes.erase(keyframes.begin()+num_max,keyframes.end());
startframes.erase(startframes.begin()+num_max,startframes.end());
endframes.erase(endframes.begin()+num_max,endframes.end());
}
return framenum;
}