fasdfsa commited on
Commit
1a6fe57
·
1 Parent(s): 5138f76

分行成功

Browse files
Files changed (1) hide show
  1. lines.py +22 -0
lines.py CHANGED
@@ -24,6 +24,10 @@ if __name__ == '__main__':
24
 
25
  boxs = glob.glob(f"{out2}/*.boxs", recursive=False)
26
 
 
 
 
 
27
  for j, pt in enumerate(boxs):
28
  with open(pt, "r", encoding='UTF-8') as fp:
29
  box = json.load(fp)
@@ -38,6 +42,24 @@ if __name__ == '__main__':
38
  height = max( ld[1], rd[1] ) - min(lu[1], ru[1])
39
  points = np.array([lu, ru, rd, ld])
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  print(f"{box} {j+1} / {len(boxs)}")
42
 
43
  print(f"{chapter} {i+1} / {len(pths)}")
 
24
 
25
  boxs = glob.glob(f"{out2}/*.boxs", recursive=False)
26
 
27
+ last_x = -1
28
+ new_line = False
29
+ lines = []
30
+ line = []
31
  for j, pt in enumerate(boxs):
32
  with open(pt, "r", encoding='UTF-8') as fp:
33
  box = json.load(fp)
 
42
  height = max( ld[1], rd[1] ) - min(lu[1], ru[1])
43
  points = np.array([lu, ru, rd, ld])
44
 
45
+ if last_x == -1:
46
+ last_x = lu[0]
47
+ else:
48
+ x_diff = abs(lu[0] - last_x)
49
+ if x_diff > int(width / 2):
50
+ new_line = True
51
+
52
+ if new_line:
53
+ lines.append(line)
54
+ line = []
55
+ new_line = False
56
+
57
+ line.append(bx)
58
+
59
+
60
+ last_x = lu[0]
61
+
62
+
63
  print(f"{box} {j+1} / {len(boxs)}")
64
 
65
  print(f"{chapter} {i+1} / {len(pths)}")