Skip to content

Commit 1c1e747

Browse files
committed
Add comments.
1 parent ed9da72 commit 1c1e747

File tree

5 files changed

+96
-12
lines changed

5 files changed

+96
-12
lines changed

animeloop-cli.xcodeproj/project.pbxproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
88537E911E4C501900385BCB /* Project object */ = {
220220
isa = PBXProject;
221221
attributes = {
222-
LastUpgradeCheck = 0820;
222+
LastUpgradeCheck = 0900;
223223
ORGANIZATIONNAME = ShinCurry;
224224
TargetAttributes = {
225225
88537E981E4C501900385BCB = {
@@ -272,15 +272,21 @@
272272
CLANG_CXX_LIBRARY = "libc++";
273273
CLANG_ENABLE_MODULES = YES;
274274
CLANG_ENABLE_OBJC_ARC = YES;
275+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
275276
CLANG_WARN_BOOL_CONVERSION = YES;
277+
CLANG_WARN_COMMA = YES;
276278
CLANG_WARN_CONSTANT_CONVERSION = YES;
277279
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
278280
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
279281
CLANG_WARN_EMPTY_BODY = YES;
280282
CLANG_WARN_ENUM_CONVERSION = YES;
281283
CLANG_WARN_INFINITE_RECURSION = YES;
282284
CLANG_WARN_INT_CONVERSION = YES;
285+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
286+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
283287
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
288+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
289+
CLANG_WARN_STRICT_PROTOTYPES = YES;
284290
CLANG_WARN_SUSPICIOUS_MOVE = YES;
285291
CLANG_WARN_UNREACHABLE_CODE = YES;
286292
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -319,15 +325,21 @@
319325
CLANG_CXX_LIBRARY = "libc++";
320326
CLANG_ENABLE_MODULES = YES;
321327
CLANG_ENABLE_OBJC_ARC = YES;
328+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
322329
CLANG_WARN_BOOL_CONVERSION = YES;
330+
CLANG_WARN_COMMA = YES;
323331
CLANG_WARN_CONSTANT_CONVERSION = YES;
324332
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
325333
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
326334
CLANG_WARN_EMPTY_BODY = YES;
327335
CLANG_WARN_ENUM_CONVERSION = YES;
328336
CLANG_WARN_INFINITE_RECURSION = YES;
329337
CLANG_WARN_INT_CONVERSION = YES;
338+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
339+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
330340
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
341+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
342+
CLANG_WARN_STRICT_PROTOTYPES = YES;
331343
CLANG_WARN_SUSPICIOUS_MOVE = YES;
332344
CLANG_WARN_UNREACHABLE_CODE = YES;
333345
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

animeloop-cli/filter.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ using namespace std;
1818
using namespace cv;
1919

2020

21-
// filter 0 找出所有起始帧和结束帧相同的片段,并去重
21+
/**
22+
filter 0
23+
Find all loop fragments that the begin frame is same as end one, then remove the repetition.
24+
25+
@param loop LoopVideo instance
26+
@param durations reference of durations value
27+
*/
2228
void al::filter_0(const LoopVideo * loop, LoopDurations &durations) {
2329
LoopDurations _durations;
2430
int min_duration_frame = loop->kMinduration * loop->info.fps;
@@ -69,8 +75,15 @@ void al::filter_0(const LoopVideo * loop, LoopDurations &durations) {
6975
durations = _durations;
7076
}
7177

72-
// filter 1 筛选相近片段相似度高的片段
73-
// MAGIC NUMBER ===> if (distance_begin >= 25 && distance_end >= 25) {
78+
/**
79+
filter 1
80+
find the loop fragments that is same as nearby one, then remove it.
81+
82+
MAGIC NUMBER ===> if (distance_begin >= 25 && distance_end >= 25) {
83+
84+
@param loop LoopVideo instance
85+
@param durations reference of durations value
86+
*/
7487
void al::filter_1(const al::LoopVideo * loop, LoopDurations &durations) {
7588
LoopDurations _durations;
7689
auto hashs = loop->phash_strings;
@@ -91,8 +104,15 @@ void al::filter_1(const al::LoopVideo * loop, LoopDurations &durations) {
91104
durations = _durations;
92105
}
93106

94-
// filter 2 筛选临近帧像素变化小的片段
95-
// MAGIC NUMBER ===> if (variance > 1.0) {
107+
/**
108+
filter 2
109+
find the loop fragments with a small frame pixels change.
110+
111+
MAGIC NUMBER ===> if (variance > 1.0) {
112+
113+
@param loop LoopVideo instance
114+
@param durations reference of durations value
115+
*/
96116
void al::filter_2(const al::LoopVideo * loop, al::LoopDurations &durations) {
97117
LoopDurations _durations;
98118
auto hashs = loop->phash_strings;
@@ -116,7 +136,13 @@ void al::filter_2(const al::LoopVideo * loop, al::LoopDurations &durations) {
116136
durations = _durations;
117137
}
118138

119-
// filter 3 筛选起始或者结束帧为黑色或白色的片段
139+
/**
140+
filter 3
141+
find the loop fragments that the color of begin/end frame is most black or white, then remove it.
142+
143+
@param loop LoopVideo instance
144+
@param durations reference of durations value
145+
*/
120146
void al::filter_3(const al::LoopVideo * loop, al::LoopDurations &durations) {
121147
LoopDurations _durations;
122148

animeloop-cli/loop_video.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ al::LoopVideo::LoopVideo(std::string series, std::string episode, std::string in
4848
create_directories(this->caches_path);
4949
}
5050

51-
this->face_cascade_filename = "./lbpcascade_animeface.xml";
52-
face_cascade.load(this->face_cascade_filename.string());
51+
// this->face_cascade_filename = "./lbpcascade_animeface.xml";
52+
// face_cascade.load(this->face_cascade_filename.string());
5353
}
5454

5555
void al::LoopVideo::init() {
@@ -86,7 +86,6 @@ void al::LoopVideo::print(LoopDurations durations) {
8686
}
8787
}
8888

89-
9089
void al::LoopVideo::generate(const LoopDurations durations) {
9190
VideoInfo info = get_info(this->input_path.string());
9291

animeloop-cli/loop_video.hpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace al {
3333
boost::filesystem::path phash_filename;
3434
boost::filesystem::path resized_video_filename;
3535
std::string output_type = "mp4";
36-
boost::filesystem::path face_cascade_filename;
36+
// boost::filesystem::path face_cascade_filename;
3737

3838
// Effect the final results.
3939
double kMinduration = 0.6;
@@ -50,13 +50,39 @@ namespace al {
5050
LoopDurations filtered_durations;
5151
FrameVector frames;
5252

53+
/**
54+
Class LoopVideo constructor.
55+
56+
@param series series title
57+
@param episode episode title
58+
@param input input file path
59+
@param output output file path
60+
*/
5361
LoopVideo(std::string series, std::string episode, std::string input, std::string output);
54-
cv::CascadeClassifier face_cascade;
62+
// cv::CascadeClassifier face_cascade;
5563

64+
/**
65+
Initial resized video file, pHash and dHash file for cache.
66+
*/
5667
void init();
68+
69+
/**
70+
Animeloop algorithm filter workflow.
71+
*/
5772
void filter();
73+
74+
/**
75+
Print durations data.
76+
77+
@param durations durations data
78+
*/
5879
void print(LoopDurations durations);
5980

81+
/**
82+
Generate loop video files from durations data.
83+
84+
@param durations durations data
85+
*/
6086
void generate(const al::LoopDurations filtered_durations);
6187

6288
private:

animeloop-cli/utils.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ namespace al {
2020
VideoInfo get_info(std::string filename);
2121
VideoInfo get_info(cv::VideoCapture &capture);
2222

23+
/**
24+
Resize a video and write into a new file.
25+
26+
@param file intput path of origin video file
27+
@param output output path of resized video file
28+
@param size resizing size
29+
*/
2330
void resize_video(std::string file, std::string output, cv::Size size);
2431

2532
bool get_frames(std::string file, FrameVector &frames);
@@ -29,7 +36,21 @@ namespace al {
2936
double get_variance(std::vector<int> distances);
3037
double get_mean(cv::Mat image);
3138

39+
40+
/**
41+
Convert seconds value to a time string.
42+
43+
@param seconds seconds value
44+
@return Time string
45+
*/
3246
std::string time_string(double seconds);
47+
48+
/**
49+
Generate the MD5 checksum of a file.
50+
51+
@param filename file path
52+
@return md5 string value
53+
*/
3354
std::string md5_of_file(std::string filename);
3455
}
3556

0 commit comments

Comments
 (0)