bluemellophone commited on
Commit
45c1d77
·
unverified ·
1 Parent(s): 3072e1b
examples/0d4e4df2-7b69-91b1-1985-c8421f2f3253.jpg ADDED

Git LFS Details

  • SHA256: 5f9a38aae3d865efaae06710f447816e99b259d1ddab1b4a3fbd24865d16776e
  • Pointer size: 132 Bytes
  • Size of remote file: 3.39 MB
examples/18cef191-74ed-2b5e-55a5-f58bd3d483ff.jpg ADDED

Git LFS Details

  • SHA256: a27074eeb8aa90926fbfae1d5ca3a5d0a6da1f20888197052a20423c9562e34d
  • Pointer size: 131 Bytes
  • Size of remote file: 886 kB
examples/1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg ADDED

Git LFS Details

  • SHA256: 786a940b062a90961f409539292f09144c3dbdbc6b6faa64c3e764d63d55c988
  • Pointer size: 132 Bytes
  • Size of remote file: 2 MB
examples/1d3c85e9-ee24-f290-e7e1-6e338f2eaebb.jpg ADDED

Git LFS Details

  • SHA256: ce2e4a0b76f6c35b2e2b49e96e0214d8b96568b70997bb963a9f38fecf23c24a
  • Pointer size: 132 Bytes
  • Size of remote file: 2.03 MB
examples/3e043302-af1c-75a7-4057-3a2f25c123bf.jpg ADDED

Git LFS Details

  • SHA256: fbf4dba2b0e216538590d68c2ad2fddaec6df750a3c20583ef7a8320b2c8b937
  • Pointer size: 131 Bytes
  • Size of remote file: 744 kB
examples/43ecc08d-502a-7a51-9d68-3e40a76439a2.jpg ADDED

Git LFS Details

  • SHA256: eddbccfa609459b39c4c2c44a2b38d944a3b8d2f119fbc1ea7fca26f5c71949e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.96 MB
examples/479058af-e774-e6aa-a2b0-9a42dd6ff8b1.jpg ADDED

Git LFS Details

  • SHA256: 95d661cbaaac7310d1240d5a1507667a2697b1fdc23b0ba1b2f7ef7c36a5726d
  • Pointer size: 132 Bytes
  • Size of remote file: 2.35 MB
examples/7c910b87-ae3a-f580-d431-03cd89793803.jpg ADDED

Git LFS Details

  • SHA256: 96b0b442cc48c47a3997984b2d07ea26e22bc05f078ed72a35f1c4d4a099da0b
  • Pointer size: 132 Bytes
  • Size of remote file: 1.3 MB
examples/8fa04489-cd94-7d8f-7e2e-5f0fe2f7ae76.jpg ADDED

Git LFS Details

  • SHA256: e602b820cf66a527f775c605f782e7d078af4b5d9ccc7891877a7f110ac61c43
  • Pointer size: 132 Bytes
  • Size of remote file: 2.86 MB
examples/bb7b4345-b98a-c727-4c94-6090f0aa4355.jpg ADDED

Git LFS Details

  • SHA256: fa17a3d3dce7867343b8a178197e1cc4dcf28e86f776f30067a48772051f6262
  • Pointer size: 131 Bytes
  • Size of remote file: 970 kB
tests/test_tile.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ from os.path import abspath, exists, join, relpath
3
+
4
+ import cv2
5
+ import numpy as np
6
+ import utool as ut
7
+
8
+
9
+ def test_tile_grid():
10
+ from scoutbot.tile import TILE_WIDTH, tile_grid
11
+
12
+ img_filepath = abspath(join('examples', '1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'))
13
+ assert exists(img_filepath)
14
+ img = cv2.imread(img_filepath)
15
+
16
+ assert img.shape == (4000, 6016, 3)
17
+
18
+ grid1 = tile_grid(img.shape)
19
+ grid2 = tile_grid(img.shape, offset=TILE_WIDTH // 2, borders=False)
20
+ grid = grid1 + grid2
21
+
22
+ assert len(grid1) == 682
23
+ assert len(grid2) == 570
24
+ assert len(set(map(str, grid))) == len(grid)
25
+
26
+ assert grid1[0] == {'x': 0, 'y': 0, 'w': 256, 'h': 256, 'b': True}
27
+ assert grid2[0] == {'x': 128, 'y': 176, 'w': 256, 'h': 256, 'b': False}
28
+
29
+
30
+ def test_tile_filepath():
31
+ from scoutbot.tile import tile_filepath
32
+
33
+ img_filepath = abspath(join('examples', '1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'))
34
+ assert exists(img_filepath)
35
+
36
+ grid = {'x': 0, 'y': 0, 'w': 256, 'h': 256, 'b': True}
37
+
38
+ filepath = tile_filepath(img_filepath, grid)
39
+ filepath = relpath(filepath)
40
+ assert filepath == join(
41
+ 'examples', '1be4d40a-6fd0-42ce-da6c-294e45781f41_x_0_y_0_w_256_h_256.jpg'
42
+ )
43
+
44
+ if exists(filepath):
45
+ ut.delete(filepath, verbose=False)
46
+
47
+
48
+ def test_tile_write():
49
+ from scoutbot.tile import tile_filepath, tile_write
50
+
51
+ img_filepath = abspath(join('examples', '1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'))
52
+ assert exists(img_filepath)
53
+ img = cv2.imread(img_filepath)
54
+
55
+ grid = {'x': 0, 'y': 0, 'w': 256, 'h': 256, 'b': True}
56
+ filepath = tile_filepath(img_filepath, grid, ext='.png') # Use lossless here
57
+ assert tile_write(img, grid, filepath)
58
+
59
+ assert exists(filepath)
60
+ tile_img = cv2.imread(filepath)
61
+
62
+ x0 = grid.get('x')
63
+ y0 = grid.get('y')
64
+ w = grid.get('w')
65
+ h = grid.get('h')
66
+ y1 = y0 + h
67
+ x1 = x0 + w
68
+ tile = img[y0:y1, x0:x1]
69
+
70
+ assert tile_img.shape == (256, 256, 3)
71
+ assert tile.shape == (256, 256, 3)
72
+
73
+ tile = tile.astype(np.float32)
74
+ tile_img = tile_img.astype(np.float32)
75
+
76
+ assert np.all(np.abs(tile - tile_img) <= 0)
77
+ ut.delete(filepath, verbose=False)
78
+
79
+
80
+ def test_tile_compute():
81
+ from scoutbot.tile import compute
82
+
83
+ img_filepath = abspath(join('examples', '1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'))
84
+ filepaths = compute(img_filepath)
85
+
86
+ assert len(filepaths) == 1252
87
+ for filepath in filepaths:
88
+ assert exists(filepath)
89
+ ut.delete(filepath, verbose=False)