Skip to content

Commit

Permalink
add real case
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlyqing00 committed Jan 14, 2019
1 parent 4aa578a commit 5e56f47
Show file tree
Hide file tree
Showing 130 changed files with 347 additions and 98 deletions.
125 changes: 70 additions & 55 deletions calibrate_imgs.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,88 @@
import numpy as np
import cv2
import os

INF = 10000000
def calibrate_imgs():
def calibrate_imgs(img, crop_flag=False):

img = cv2.imread('data/real_test/real0_raw_21/19.jpg')
if crop_flag:
width_margin = 140
height_margin = 110
height = img.shape[0]
width = img.shape[1]
img = img[height_margin:height - height_margin, width_margin:width - width_margin]

img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img_canny = cv2.Canny(img_gray, 70, 150)
lines = cv2.HoughLinesP(img_canny, 1, np.pi/180, 80, 30, 10)
img_x = cv2.Sobel(img_gray, cv2.CV_16S, 1, 0)
img_absx = cv2.convertScaleAbs(img_x)
_, img_bin = cv2.threshold(img_absx, 128, 255, cv2.THRESH_BINARY)
lines = cv2.HoughLinesP(img_bin, 1, np.pi/180, 80, 30, 10)

left_top_point = [INF, INF]
left_bottom_point = [INF, 0]
right_top_point = [0, INF]
right_bottom_point = [0, 0]
x_left = INF
x_right = 0
for i in range(len(lines)):
x0, y0, x1, y1 = lines[i][0]

delta = (left_top_point[0] - x0) + (left_top_point[1] - y0)
if delta > 0:
left_top_point[0] = x0
left_top_point[1] = y0
if abs(x0 - x1) > 20:
continue

delta = (x0 - right_top_point[0]) + (right_top_point[1] - y0)
if delta > 0:
right_top_point[0] = x0
right_top_point[1] = y0

delta = (left_bottom_point[0] - x0) + (y0 - left_bottom_point[1])
if delta > 0:
left_bottom_point[0] = x0
left_bottom_point[1] = y0

delta = (x0 - right_bottom_point[0]) + (y0 - right_bottom_point[1])
if delta > 0:
right_bottom_point[0] = x0
right_bottom_point[1] = y0
if abs(y0 - y1) < 20:
continue

x_left = min(x_left, x0)
x_right = max(x_right, x0)

print(left_top_point, left_bottom_point, right_top_point, right_bottom_point)

dst_height = 3800
src_height = (left_bottom_point[1] - left_top_point[1] + right_bottom_point[1] - right_top_point[1]) / 2
src_width = (right_top_point[0] - left_top_point[0] + right_bottom_point[0] - left_bottom_point[0]) / 2
dst_width = int(round(src_width * src_height / dst_height))
# print(left_top_point, left_bottom_point, right_top_point, right_bottom_point)

src_anchor = np.float32([left_top_point, left_bottom_point, right_top_point, right_bottom_point])
dst_height = 1800 # 6450
src_height = img.shape[0]
src_width = x_right - x_left
dst_width = int(round(src_width * dst_height / src_height))

# src_anchor = np.float32([left_top_point, left_bottom_point, right_top_point, right_bottom_point])
# # dst_anchor = np.float32( \
# # [left_top_point, \
# # [left_top_point[0], left_top_point[1] + dst_height], \
# # [left_top_point[0] + dst_width, left_top_point[1]], \
# # [left_top_point[0] + dst_width, left_top_point[1] + dst_height]])
# dst_anchor = np.float32( \
# [left_top_point, \
# [left_top_point[0], left_top_point[1] + dst_height], \
# [left_top_point[0] + dst_width, left_top_point[1]], \
# [left_top_point[0] + dst_width, left_top_point[1] + dst_height]])
dst_anchor = np.float32( \
[[0, 0], \
[0, dst_height], \
[dst_width, 0], \
[dst_width, dst_height]])
print(src_anchor)
print(dst_anchor)

mat = cv2.getPerspectiveTransform(src_anchor, dst_anchor)
print(mat)
stripe = cv2.warpPerspective(img, mat, (dst_width, dst_height))
stripe = cv2.resize(stripe, None, None, 0.3, 0.3)

cv2.imwrite('data/stripes/real0_21/19.png', stripe)
cv2.imshow('stripe', stripe)
# cv2.imshow('img', img)
# cv2.imshow('canvas', img_canny)
cv2.waitKey()
# [[0, 0], \
# [0, dst_height], \
# [dst_width, 0], \
# [dst_width, dst_height]])
# print(src_anchor)
# print(dst_anchor)

# mat = cv2.getPerspectiveTransform(src_anchor, dst_anchor)
# print(mat)
# stripe = cv2.warpPerspective(img, mat, (dst_width, dst_height))

stripe = img[:, x_left:x_right]
stripe = cv2.resize(stripe, (dst_width, dst_height))

return stripe

if __name__ == '__main__':
calibrate_imgs()

test_case = 'real1_31/'
img_num = 31
in_folder = 'data/real_test/' + test_case
out_folder = 'data/stripes/' + test_case
if not os.path.isdir(out_folder):
os.mkdir(out_folder)

order_path = out_folder + 'order.txt'
order_file = open(order_path, 'w')
for img_id in range(img_num):
order_file.write(str(img_id) + '\n')
order_file.close()

for img_id in range(img_num):

print('current img:', img_id)

img_path = in_folder + str(img_id+1) + '.XSM/' + '00000001.jpg'
img = cv2.imread(img_path)
stripe = calibrate_imgs(img, crop_flag=True)
cv2.imwrite(out_folder + str(img_id) + '.png', stripe)
Binary file added data/real_test/real1_31/1.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/1.XSM/1.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/1.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/1.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Binary file added data/real_test/real1_31/10.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/10.XSM/10.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/10.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/10.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
Binary file added data/real_test/real1_31/11.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/11.XSM/11.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/11.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/11.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
Binary file added data/real_test/real1_31/12.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/12.XSM/12.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/12.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/12.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
Binary file added data/real_test/real1_31/13.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/13.XSM/13.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/13.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/13.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13
Binary file added data/real_test/real1_31/14.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/14.XSM/14.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/14.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/14.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14
Binary file added data/real_test/real1_31/15.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/15.XSM/15.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/15.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/15.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15
Binary file added data/real_test/real1_31/16.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/16.XSM/16.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/16.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/16.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
Binary file added data/real_test/real1_31/17.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/17.XSM/17.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/17.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/17.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
Binary file added data/real_test/real1_31/18.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/18.XSM/18.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/18.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/18.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
Binary file added data/real_test/real1_31/19.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/19.XSM/19.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/19.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/19.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19
Binary file added data/real_test/real1_31/2.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/2.XSM/2.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/2.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/2.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
Binary file added data/real_test/real1_31/20.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/20.XSM/20.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/20.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/20.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
Binary file added data/real_test/real1_31/21.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/21.XSM/21.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/21.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/21.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21
Binary file added data/real_test/real1_31/22.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/22.XSM/22.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/22.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/22.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
Binary file added data/real_test/real1_31/23.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/23.XSM/23.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/23.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/23.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
23
Binary file added data/real_test/real1_31/24.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/24.XSM/24.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/24.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/24.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
Binary file added data/real_test/real1_31/25.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/25.XSM/25.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/25.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/25.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25
Binary file added data/real_test/real1_31/26.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/26.XSM/26.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/26.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/26.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26
Binary file added data/real_test/real1_31/27.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/27.XSM/27.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/27.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/27.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
27
Binary file added data/real_test/real1_31/28.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/28.XSM/28.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/28.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/28.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
28
Binary file added data/real_test/real1_31/29.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/29.XSM/29.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/29.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/29.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
29
Binary file added data/real_test/real1_31/3.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/3.XSM/3.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/3.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/3.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Binary file added data/real_test/real1_31/30.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/30.XSM/30.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/30.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/30.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
30
Binary file added data/real_test/real1_31/31.XSM/00000001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/real_test/real1_31/31.XSM/31.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/31.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/31.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
31
Binary file added data/real_test/real1_31/4.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/4.XSM/4.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/4.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/4.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
Binary file added data/real_test/real1_31/5.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/5.XSM/5.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/5.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/5.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
Binary file added data/real_test/real1_31/6.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/6.XSM/6.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/6.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/6.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6
Binary file added data/real_test/real1_31/7.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/7.XSM/7.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/7.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/7.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
Binary file added data/real_test/real1_31/8.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/8.XSM/8.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/8.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/8.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
Binary file added data/real_test/real1_31/9.XSM/00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/9.XSM/9.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000001.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/9.XSM/NEXTNAME.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00000002.jpg
1 change: 1 addition & 0 deletions data/real_test/real1_31/9.XSM/XSMDESC.DAT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
18 changes: 14 additions & 4 deletions include/stripes_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class StripesSolver {
GREEDY,
GCOM,
GREEDY_GCOM,
GT,
};

const string puzzle_folder;
Expand All @@ -52,7 +53,7 @@ class StripesSolver {
// Path
PathManager path_manager;

StripesSolver(const string & _puzzle_foler, int _stripes_n, int _samples_n);
StripesSolver(const string & _puzzle_foler, int _stripes_n, int _samples_n, bool _real_flag);
~StripesSolver();

void m_metric();
Expand All @@ -61,13 +62,19 @@ class StripesSolver {
const string & case_name,
bool benchmark_flag);

cv::Mat compose_img(const vector<int> & composition_order);
cv::Mat add_seams(const cv::Mat & img, const vector<int> & composition_order);
cv::Mat compose_img(const vector<int> & composition_order,
bool shift_flag=false,
vector<int> * sol_x=nullptr);
cv::Mat add_seams( const cv::Mat & img,
const vector<int> & composition_order,
bool print_flag=true,
const vector<int> * sol_x=nullptr);

private:

Metric metric_mode;
Composition composition_mode;
bool real_flag;

vector<StripePair> stripe_pairs;
vector<StripePair> stripe_pairs_pixel;
Expand All @@ -93,6 +100,7 @@ class StripesSolver {
// Metric word-path
int sols_n {10};
int candidate_len {10};
const int candidate_factor {5};
vector< vector<double> > pixel_graph;
vector< vector<double> > pixel_graph2;

Expand All @@ -104,7 +112,9 @@ class StripesSolver {
void reassemble_GCOM();

void stochastic_search( vector<int> & sol, const vector< vector<StripePair> > & compose_next);
cv::Mat word_detection( const cv::Mat & img, const vector<int> & sol);
cv::Mat word_detection( const cv::Mat & img,
const vector<int> & sol,
vector<int> & sol_x);
void merge_single_sol(vector< vector<int> > & fragments);
void finetune_sols(const vector< vector<int> > & fragments);

Expand Down
Loading

0 comments on commit 5e56f47

Please sign in to comment.