Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
yq committed Nov 24, 2018
1 parent f227113 commit 304b688
Show file tree
Hide file tree
Showing 71 changed files with 180 additions and 129 deletions.
246 changes: 123 additions & 123 deletions data/symbols/arial.box
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
0 100 4650 132 4694 0
132 4650 171 4694 0
1 171 4650 193 4694 0
193 4650 237 4694 0
2 237 4650 270 4694 0
270 4650 308 4694 0
3 308 4650 340 4694 0
340 4650 376 4694 0
4 376 4650 410 4694 0
410 4650 448 4694 0
5 448 4650 480 4694 0
480 4650 517 4694 0
6 517 4650 550 4694 0
550 4650 588 4694 0
7 588 4650 620 4694 0
620 4650 658 4694 0
8 658 4650 690 4694 0
690 4650 728 4694 0
9 728 4650 760 4694 0
760 4650 792 4694 0
A 792 4650 836 4694 0
836 4650 869 4694 0
B 869 4650 905 4694 0
905 4649 943 4695 0
C 943 4649 984 4695 0
984 4649 1022 4695 0
D 1022 4650 1061 4694 0
1061 4650 1100 4694 0
E 1100 4650 1136 4694 0
1136 4650 1176 4694 0
F 1176 4650 1209 4694 0
1209 4693 1210 4694 0
G 100 4511 142 4557 0
142 4511 181 4557 0
H 181 4512 218 4556 0
218 4512 259 4556 0
I 259 4512 273 4556 0
273 4511 312 4556 0
J 312 4511 341 4556 0
341 4511 381 4556 0
K 381 4512 420 4556 0
420 4512 456 4556 0
L 456 4512 488 4556 0
488 4512 524 4556 0
M 524 4512 567 4556 0
567 4512 608 4556 0
N 608 4512 645 4556 0
645 4511 685 4557 0
O 685 4511 728 4557 0
728 4511 767 4557 0
P 767 4512 804 4556 0
804 4508 841 4557 0
Q 841 4508 885 4557 0
885 4508 923 4557 0
R 923 4512 964 4556 0
964 4511 1000 4557 0
S 1000 4511 1037 4557 0
1037 4511 1073 4557 0
T 1073 4512 1111 4556 0
1111 4511 1148 4556 0
U 1148 4511 1186 4556 0
1186 4511 1223 4556 0
V 1223 4512 1264 4556 0
1264 4555 1265 4556 0
W 100 4374 155 4418 0
155 4374 185 4418 0
X 185 4374 227 4418 0
227 4374 259 4418 0
Y 259 4374 301 4418 0
301 4374 335 4418 0
Z 335 4374 372 4418 0
372 4374 408 4418 0
a 408 4374 441 4409 0
441 4374 480 4418 0
b 480 4374 511 4418 0
511 4374 548 4418 0
c 548 4374 580 4409 0
580 4374 615 4418 0
d 615 4374 647 4418 0
647 4374 685 4418 0
e 685 4374 718 4409 0
718 4374 754 4418 0
f 754 4374 778 4418 0
778 4364 811 4418 0
g 811 4364 843 4409 0
843 4364 883 4418 0
h 883 4374 913 4418 0
913 4374 953 4418 0
i 953 4374 966 4418 0
966 4364 1000 4418 0
j 1000 4364 1019 4418 0
1019 4364 1059 4418 0
k 1059 4374 1089 4418 0
1089 4374 1126 4418 0
l 1126 4374 1139 4418 0
1139 4417 1140 4418 0
m 100 4236 144 4271 0
144 4236 183 4271 0
n 183 4236 213 4271 0
213 4236 251 4271 0
o 251 4236 284 4271 0
284 4226 323 4271 0
p 323 4226 354 4271 0
354 4226 391 4271 0
q 391 4226 423 4271 0
423 4226 463 4271 0
r 463 4236 486 4271 0
486 4236 520 4271 0
s 520 4236 551 4271 0
551 4236 586 4280 0
t 586 4236 608 4280 0
608 4236 645 4280 0
u 645 4236 675 4270 0
675 4236 712 4270 0
v 712 4236 745 4270 0
745 4236 779 4270 0
w 779 4236 823 4270 0
823 4236 857 4270 0
x 857 4236 890 4270 0
890 4226 924 4270 0
y 924 4226 957 4270 0
957 4226 991 4270 0
z 991 4236 1023 4270 0
0 100 643 136 692 0
136 643 182 692 0
1 182 643 206 692 0
206 643 257 692 0
2 257 643 294 692 0
294 643 338 692 0
3 338 643 374 692 0
374 643 416 692 0
4 416 643 454 692 0
454 643 498 692 0
5 498 643 534 692 0
534 643 578 692 0
6 578 643 614 692 0
614 643 658 692 0
7 658 643 694 692 0
694 643 738 692 0
8 738 643 774 692 0
774 643 818 692 0
9 818 643 854 692 0
854 643 892 693 0
A 892 643 940 693 0
940 643 981 693 0
B 981 643 1021 693 0
1021 642 1066 694 0
C 1066 642 1112 694 0
1112 642 1158 694 0
D 1158 643 1201 693 0
1201 643 1248 693 0
E 1248 643 1288 693 0
1288 643 1335 693 0
F 1335 643 1372 693 0
1372 692 1373 693 0
G 100 486 147 538 0
147 486 193 538 0
H 193 487 235 537 0
235 487 284 537 0
I 284 487 298 537 0
298 486 344 537 0
J 344 486 376 537 0
376 486 424 537 0
K 424 487 467 537 0
467 487 511 537 0
L 511 487 546 537 0
546 487 589 537 0
M 589 487 637 537 0
637 487 685 537 0
N 685 487 727 537 0
727 486 773 538 0
O 773 486 822 538 0
822 486 868 538 0
P 868 487 909 537 0
909 483 952 538 0
Q 952 483 1001 538 0
1001 483 1047 538 0
R 1047 487 1093 537 0
1093 486 1135 538 0
S 1135 486 1177 538 0
1177 486 1220 538 0
T 1220 487 1262 537 0
1262 486 1305 537 0
U 1305 486 1347 537 0
1347 486 1391 537 0
V 1391 487 1438 537 0
1438 536 1439 537 0
W 100 331 163 381 0
163 331 199 381 0
X 199 331 246 381 0
246 331 285 381 0
Y 285 331 332 381 0
332 331 372 381 0
Z 372 331 413 381 0
413 330 456 381 0
a 456 330 492 371 0
492 330 537 381 0
b 537 330 572 381 0
572 330 616 381 0
c 616 330 651 371 0
651 330 692 381 0
d 692 330 728 381 0
728 330 773 381 0
e 773 330 809 371 0
809 330 851 381 0
f 851 331 878 381 0
878 319 916 381 0
g 916 319 952 371 0
952 319 998 381 0
h 998 331 1032 381 0
1032 331 1078 381 0
i 1078 331 1092 381 0
1092 319 1133 381 0
j 1133 319 1153 381 0
1153 319 1200 381 0
k 1200 331 1234 381 0
1234 331 1277 381 0
l 1277 331 1291 381 0
1291 380 1292 381 0
m 100 175 150 215 0
150 175 195 215 0
n 195 175 229 215 0
229 174 273 215 0
o 273 174 311 215 0
311 163 355 215 0
p 355 163 390 215 0
390 163 434 215 0
q 434 163 469 215 0
469 163 515 215 0
r 515 175 541 215 0
541 174 580 215 0
s 580 174 614 215 0
614 174 657 225 0
t 657 174 680 225 0
680 174 723 225 0
u 723 174 757 214 0
757 174 800 214 0
v 800 175 837 214 0
837 175 877 214 0
w 877 175 927 214 0
927 175 967 214 0
x 967 175 1004 214 0
1004 163 1044 214 0
y 1044 163 1081 214 0
1081 163 1122 214 0
z 1122 175 1157 214 0
Binary file added data/symbols/arial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial.tif
Binary file not shown.
Binary file modified data/symbols/arial_0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_15.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_18.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_19.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_20.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_21.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_22.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_24.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_25.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_26.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_27.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_28.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_29.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/symbols/arial_30.jpg
Binary file modified data/symbols/arial_31.jpg
Binary file modified data/symbols/arial_32.jpg
Binary file modified data/symbols/arial_33.jpg
Binary file modified data/symbols/arial_34.jpg
Binary file modified data/symbols/arial_35.jpg
Binary file modified data/symbols/arial_36.jpg
Binary file modified data/symbols/arial_37.jpg
Binary file modified data/symbols/arial_38.jpg
Binary file modified data/symbols/arial_39.jpg
Binary file modified data/symbols/arial_4.jpg
Binary file modified data/symbols/arial_40.jpg
Binary file modified data/symbols/arial_41.jpg
Binary file modified data/symbols/arial_42.jpg
Binary file modified data/symbols/arial_43.jpg
Binary file modified data/symbols/arial_44.jpg
Binary file modified data/symbols/arial_45.jpg
Binary file modified data/symbols/arial_46.jpg
Binary file modified data/symbols/arial_47.jpg
Binary file modified data/symbols/arial_48.jpg
Binary file modified data/symbols/arial_49.jpg
Binary file modified data/symbols/arial_5.jpg
Binary file modified data/symbols/arial_50.jpg
Binary file modified data/symbols/arial_51.jpg
Binary file modified data/symbols/arial_52.jpg
Binary file modified data/symbols/arial_53.jpg
Binary file modified data/symbols/arial_54.jpg
Binary file modified data/symbols/arial_55.jpg
Binary file modified data/symbols/arial_56.jpg
Binary file modified data/symbols/arial_57.jpg
Binary file modified data/symbols/arial_58.jpg
Binary file modified data/symbols/arial_59.jpg
Binary file modified data/symbols/arial_6.jpg
Binary file modified data/symbols/arial_60.jpg
Binary file modified data/symbols/arial_61.jpg
Binary file modified data/symbols/arial_7.jpg
Binary file modified data/symbols/arial_8.jpg
Binary file modified data/symbols/arial_9.jpg
22 changes: 18 additions & 4 deletions data/symbols/auto_text2image.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
#!/bin/bash

if [[ "$OSTYPE" = "linux-gnu" ]]; then
fonts_dir='/usr/share/fonts/'
else
fonts_dir='/Library/Fonts/'
fi

echo "Fonts Dir: " $fonts_dir

text2image \
--text symbols.txt \
--outputbase arial_bold_italic \
--font='Arial Bold Italic' \
--fonts_dir /usr/share/fonts/ \
--outputbase arial \
--font='Arial' \
--fonts_dir $fonts_dir \
--degrade_image=false \
--rotate_image=false \
--xsize=1800 \
--ysize=800 \
--ptsize=14 \
--box_padding 4 \
--glyph_resized_size 32 \
--glyph_resized_size 48 \
--output_individual_glyph_images \
2 changes: 2 additions & 0 deletions include/ocr_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class OcrExtractor {

OcrExtractor();
void add_img(const cv::Mat & piece);
bool has_next();
cv::Mat next_roi();

};

Expand Down
5 changes: 4 additions & 1 deletion include/stripes_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class StripesSolver {

enum Metric {
PIXEL,
WORD
WORD,
COMP_EVA
};

enum Composition {
Expand Down Expand Up @@ -52,6 +53,8 @@ class StripesSolver {

double m_metric_word(const cv::Mat & piece0, const cv::Mat & piece1);

double m_metric_comp_eva(const cv::Mat & piece0, const cv::Mat & piece1);

void save_result(const string & case_name);

private:
Expand Down
8 changes: 8 additions & 0 deletions src/ocr_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,12 @@ void OcrExtractor::add_img(const cv::Mat & piece) {

}

}

bool OcrExtractor::has_next() {
return roi_idx < roi_arr.size();
}

cv::Mat OcrExtractor::next_roi() {
return roi_arr[roi_idx++];
}
6 changes: 5 additions & 1 deletion src/solver/solve_puzzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void solve_stripes( const string & stripes_folder,
const int vertical_n) {

StripesSolver::Composition comp_mode = StripesSolver::GREEDY;
StripesSolver::Metric metric_mode = StripesSolver::PIXEL;
StripesSolver::Metric metric_mode = StripesSolver::COMP_EVA;

cout << "Composition mode: \t" << comp_mode << endl;
cout << "Metric mode: \t" << metric_mode << endl;
Expand Down Expand Up @@ -83,6 +83,10 @@ int main(int argc, char ** argv) {
int vertical_n = 4;
string model_path = "data/models/";

cv::Mat arial_img = cv::imread("data/symbols/arial.png");
cv::imshow("arial_img", arial_img);
cv::waitKey();

// Parse command line parameters
const string opt_str = "t:T:n:N:m:M:sS";
int opt = getopt(argc, argv, opt_str.c_str());
Expand Down
20 changes: 20 additions & 0 deletions src/solver/stripes_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ double StripesSolver::m_metric_word(const cv::Mat & piece0, const cv::Mat & piec

}

double StripesSolver::m_metric_comp_eva(const cv::Mat & piece0, const cv::Mat & piece1) {

cv::Mat && merged_img = merge_imgs(piece0, piece1);
const int seam_x = piece0.cols;

ocr_ectractor.add_img(merged_img);

while (ocr_ectractor.has_next()) {
cv::Mat ocr = ocr_ectractor.next_roi();
cv::imshow("ocr", ocr);
cv::waitKey();
}

return 0;

}

bool StripesSolver::reassemble_greedy() {

// Compute matching score for each pair
Expand All @@ -141,6 +158,9 @@ bool StripesSolver::reassemble_greedy() {
case WORD:
m_score = m_metric_word(stripes[i], stripes[j]);
break;
case COMP_EVA:
m_score = m_metric_comp_eva(stripes[i], stripes[j]);
break;
}

#ifdef DEBUG
Expand Down

0 comments on commit 304b688

Please sign in to comment.