-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11254eb
commit bb28212
Showing
7 changed files
with
138 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
*.o | ||
*.d | ||
StripeReassembly | ||
StripeReassembly-debug | ||
|
||
/bin/ | ||
/data/stripes/ | ||
/data/results/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef CREATE_STRIPES_H | ||
#define CREATE_STRIPES_H | ||
|
||
#include <unistd.h> | ||
#include <string> | ||
#include <iostream> | ||
|
||
#include <opencv2/opencv.hpp> | ||
|
||
#include <stripes_generator.h> | ||
|
||
using namespace std; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <create_stripes.h> | ||
|
||
|
||
int main(int argc, char ** argv) { | ||
|
||
// Default parameters | ||
string case_name = "test0"; | ||
int stripes_n = 4; | ||
bool generate_flag = false; | ||
|
||
// Parse command line parameters | ||
const string opt_str = "t:T:n:N:gG"; | ||
int opt = getopt(argc, argv, opt_str.c_str()); | ||
|
||
while (opt != -1) { | ||
switch (opt) { | ||
case 't': case 'T': | ||
case_name = string(optarg); | ||
break; | ||
case 'n': case 'N': | ||
stripes_n = atoi(optarg); | ||
break; | ||
case 'g': case 'G': | ||
generate_flag = true; | ||
break; | ||
} | ||
|
||
opt = getopt(argc, argv, opt_str.c_str()); | ||
} | ||
|
||
cout << "Case name:\t\t" << case_name << endl; | ||
cout << "Stripes num:\t\t" << stripes_n << endl; | ||
cout << "Generate stripes:\t" << boolalpha << generate_flag << endl; | ||
cout << endl; | ||
|
||
// Generate new stripes | ||
const string stripes_folder = "data/stripes/" + case_name + "_" + to_string(stripes_n) + "/"; | ||
|
||
if (generate_flag || access(stripes_folder.c_str(), 0) == -1) { | ||
const string gt_folder = "data/gt/"; | ||
const string gt_img_path = gt_folder + case_name + ".png"; | ||
cv::Mat gt_img = cv::imread(gt_img_path); | ||
|
||
StripesGenerator stripes_generator(gt_img_path, stripes_n); | ||
stripes_generator.save_stripes(stripes_folder); | ||
} | ||
|
||
return 0; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <solve_stripes.h> | ||
|
||
int main(int argc, char ** argv) { | ||
|
||
// Default parameters | ||
string case_name = "test0"; | ||
int stripes_n = 4; | ||
Stripes::Composition comp_mod = Stripes::GREEDY; | ||
string model_path = "data/models/"; | ||
|
||
// Parse command line parameters | ||
const string opt_str = "t:T:n:N:m:M:"; | ||
int opt = getopt(argc, argv, opt_str.c_str()); | ||
|
||
while (opt != -1) { | ||
switch (opt) { | ||
case 't': case 'T': | ||
case_name = string(optarg); | ||
break; | ||
case 'n': case 'N': | ||
stripes_n = atoi(optarg); | ||
break; | ||
case 'm': case 'M': | ||
model_path = string(optarg); | ||
break; | ||
} | ||
|
||
opt = getopt(argc, argv, opt_str.c_str()); | ||
} | ||
|
||
cout << "Case name:\t\t" << case_name << endl; | ||
cout << "Stripes num:\t\t" << stripes_n << endl; | ||
cout << "OCR model path:\t\t" << model_path << endl; | ||
cout << endl; | ||
|
||
// Import stripes | ||
const string stripes_folder = "data/stripes/" + case_name + "_" + to_string(stripes_n) + "/"; | ||
Stripes stripes(model_path); | ||
|
||
for (int i = 0; i < stripes_n; i++) { | ||
const string stripe_img_path = stripes_folder + to_string(i) + ".png"; | ||
cv::Mat stripe_img = cv::imread(stripe_img_path); | ||
stripes.push(stripe_img); | ||
} | ||
|
||
stripes.reassemble(comp_mod); | ||
stripes.save_result(case_name); | ||
for (const int idx: stripes.comp_idx) { | ||
cout << idx << endl; | ||
} | ||
|
||
cv::imshow("comp_img", stripes.comp_img); | ||
cv::waitKey(); | ||
|
||
return 0; | ||
} |