valetudo-map-parser 0.1.9b20__py3-none-any.whl → 0.1.9b22__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- valetudo_map_parser/config/utils.py +16 -9
- valetudo_map_parser/hypfer_handler.py +2 -10
- valetudo_map_parser/rand25_handler.py +2 -10
- {valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/METADATA +1 -1
- {valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/RECORD +8 -8
- {valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/LICENSE +0 -0
- {valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/NOTICE.txt +0 -0
- {valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/WHEEL +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
"""Utility code for the valetudo map parser."""
|
2
2
|
|
3
|
-
from dataclasses import dataclass
|
4
3
|
import hashlib
|
5
4
|
import json
|
5
|
+
from dataclasses import dataclass
|
6
6
|
from logging import getLogger
|
7
7
|
|
8
|
-
from PIL import
|
8
|
+
from PIL import Image, ImageOps
|
9
9
|
|
10
10
|
from .types import ChargerPosition, ImageSize, NumpyArray, RobotPosition
|
11
11
|
|
@@ -500,14 +500,21 @@ async def async_resize_image(params: ResizeParams):
|
|
500
500
|
)
|
501
501
|
|
502
502
|
if params.crop_size is not None:
|
503
|
-
|
504
|
-
|
505
|
-
hsf=hsf,
|
506
|
-
width=new_width,
|
507
|
-
height=new_height,
|
508
|
-
rand256=params.is_rand,
|
509
|
-
)
|
503
|
+
offset = OffsetParams(wsf, hsf, new_width, new_height, params.is_rand)
|
504
|
+
params.crop_size[0], params.crop_size[1] = await params.offset_func(offset)
|
510
505
|
|
511
506
|
return ImageOps.pad(params.pil_img, (new_width, new_height))
|
512
507
|
|
513
508
|
return ImageOps.pad(params.pil_img, (params.width, params.height))
|
509
|
+
|
510
|
+
def prepare_resize_params(handler, pil_img, rand):
|
511
|
+
"""Prepare resize parameters for image resizing."""
|
512
|
+
return ResizeParams(
|
513
|
+
pil_img=pil_img,
|
514
|
+
width=handler.shared.image_ref_width,
|
515
|
+
height=handler.shared.image_ref_height,
|
516
|
+
aspect_ratio=handler.shared.image_aspect_ratio,
|
517
|
+
crop_size=handler.crop_img_size,
|
518
|
+
offset_func=handler.async_map_coordinates_offset,
|
519
|
+
is_rand=rand
|
520
|
+
)
|
@@ -16,7 +16,7 @@ from .config.auto_crop import AutoCrop
|
|
16
16
|
from .config.drawable import Drawable
|
17
17
|
from .config.shared import CameraShared
|
18
18
|
from .config.types import COLORS, CalibrationPoints, Colors, RoomsProperties
|
19
|
-
from .config.utils import BaseHandler,
|
19
|
+
from .config.utils import BaseHandler, prepare_resize_params
|
20
20
|
from .hypfer_draw import ImageDraw as ImDraw
|
21
21
|
from .map_data import ImageData
|
22
22
|
|
@@ -247,15 +247,7 @@ class HypferMapImageHandler(BaseHandler):
|
|
247
247
|
del img_np_array
|
248
248
|
# reduce the image size if the zoomed image is bigger then the original.
|
249
249
|
if self.check_zoom_and_aspect_ratio():
|
250
|
-
resize_params =
|
251
|
-
pil_img=pil_img,
|
252
|
-
width=self.shared.image_ref_width,
|
253
|
-
height=self.shared.image_ref_height,
|
254
|
-
aspect_ratio=self.shared.image_aspect_ratio,
|
255
|
-
crop_size=self.crop_img_size,
|
256
|
-
offset_func=self.async_map_coordinates_offset,
|
257
|
-
is_rand=False,
|
258
|
-
)
|
250
|
+
resize_params = prepare_resize_params(self, pil_img, False)
|
259
251
|
resized_image = await self.async_resize_images(resize_params)
|
260
252
|
return resized_image
|
261
253
|
_LOGGER.debug("%s: Frame Completed.", self.file_name)
|
@@ -24,7 +24,7 @@ from .config.types import (
|
|
24
24
|
RobotPosition,
|
25
25
|
RoomsProperties,
|
26
26
|
)
|
27
|
-
from .config.utils import BaseHandler,
|
27
|
+
from .config.utils import BaseHandler, prepare_resize_params
|
28
28
|
from .map_data import RandImageData
|
29
29
|
from .reimg_draw import ImageDraw
|
30
30
|
|
@@ -257,15 +257,7 @@ class ReImageHandler(BaseHandler):
|
|
257
257
|
|
258
258
|
async def _finalize_image(self, pil_img):
|
259
259
|
if self.check_zoom_and_aspect_ratio():
|
260
|
-
resize_params =
|
261
|
-
pil_img=pil_img,
|
262
|
-
width=self.shared.image_ref_width,
|
263
|
-
height=self.shared.image_ref_height,
|
264
|
-
aspect_ratio=self.shared.image_aspect_ratio,
|
265
|
-
crop_size=self.crop_img_size,
|
266
|
-
offset_func=self.async_map_coordinates_offset,
|
267
|
-
is_rand=True,
|
268
|
-
)
|
260
|
+
resize_params = prepare_resize_params(self, pil_img, True)
|
269
261
|
pil_img = await self.async_resize_images(resize_params)
|
270
262
|
_LOGGER.debug("%s: Frame Completed.", self.file_name)
|
271
263
|
return pil_img
|
@@ -6,15 +6,15 @@ valetudo_map_parser/config/drawable.py,sha256=hsrEJCMVOrjs5sJfr26SeqJD0VNlYWwxcV
|
|
6
6
|
valetudo_map_parser/config/rand25_parser.py,sha256=fehyF18hRWRWbXbojocQCIaIch21Lbh1wtl2XdKRSl0,16447
|
7
7
|
valetudo_map_parser/config/shared.py,sha256=LQV5K8tbVhEKUkby9ssjEmh_T4Ai-Euzsbag_HWYVRc,9448
|
8
8
|
valetudo_map_parser/config/types.py,sha256=sdjqhcxpRSxNFLVHIyCg-RDL9JIjtQHoR2C2WpocWBc,16107
|
9
|
-
valetudo_map_parser/config/utils.py,sha256=
|
9
|
+
valetudo_map_parser/config/utils.py,sha256=QHF0rx72TS0Kpt2iTqqFwr6MlV0TJXK6-_008wDg8nU,18573
|
10
10
|
valetudo_map_parser/hypfer_draw.py,sha256=s58ak9IBYLjJyoddfDC99PfQ12HTjkSfJYXqCi4vZKs,14931
|
11
|
-
valetudo_map_parser/hypfer_handler.py,sha256=
|
11
|
+
valetudo_map_parser/hypfer_handler.py,sha256=8uAPum9JK_JDDSEoD_gLGxMRvdOg4oAABqc3PvW-GTs,13515
|
12
12
|
valetudo_map_parser/map_data.py,sha256=6FbQfgxFB6E4kcOWokReJOVSekVaE1kStyhTQhAhiOg,19469
|
13
13
|
valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
valetudo_map_parser/rand25_handler.py,sha256=
|
14
|
+
valetudo_map_parser/rand25_handler.py,sha256=iGWxNgLzl-4btakBGKEbLqKOp7j2gDD6bmSAp4YGjkY,15317
|
15
15
|
valetudo_map_parser/reimg_draw.py,sha256=dtdbYKKxmQnbOaHBHayWEF07OdSnTKo2CPSOW0qpgH0,12506
|
16
|
-
valetudo_map_parser-0.1.
|
17
|
-
valetudo_map_parser-0.1.
|
18
|
-
valetudo_map_parser-0.1.
|
19
|
-
valetudo_map_parser-0.1.
|
20
|
-
valetudo_map_parser-0.1.
|
16
|
+
valetudo_map_parser-0.1.9b22.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
|
17
|
+
valetudo_map_parser-0.1.9b22.dist-info/METADATA,sha256=B6EqNlL0I8Pmt-hy_nvT8HA9EdUTOb-_-X6dDAmowpo,1029
|
18
|
+
valetudo_map_parser-0.1.9b22.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
|
19
|
+
valetudo_map_parser-0.1.9b22.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
20
|
+
valetudo_map_parser-0.1.9b22.dist-info/RECORD,,
|
File without changes
|
{valetudo_map_parser-0.1.9b20.dist-info → valetudo_map_parser-0.1.9b22.dist-info}/NOTICE.txt
RENAMED
File without changes
|
File without changes
|