@@ -204,7 +204,7 @@ async def wrapper(context: process_utils.Context) -> None:
204
204
context .image = new_image
205
205
elapsed_time = time .perf_counter () - start_time
206
206
if os .environ .get ("TIME" , "FALSE" ) == "TRUE" :
207
- print (f"Elapsed time in { self .name } : { int ( round (elapsed_time ) )} s." )
207
+ print (f"Elapsed time in { self .name } : { round (elapsed_time )} s." )
208
208
209
209
if self .progress :
210
210
context .save_progress_images (self .name )
@@ -340,8 +340,8 @@ async def _histogram(
340
340
points .append (("max_level" , max_ , histogram_max / 10 ))
341
341
342
342
for label , value , pos in points :
343
- if int ( round (value ) ) < len (histogram_data ):
344
- hist_value = histogram_data [int ( round (value ) )]
343
+ if round (value ) < len (histogram_data ):
344
+ hist_value = histogram_data [round (value )]
345
345
axes .annotate (
346
346
label ,
347
347
xy = (value , hist_value ),
@@ -507,7 +507,7 @@ async def docrop(context: process_utils.Context) -> None:
507
507
margin_vertical = context .get_px_value (
508
508
crop_config .setdefault ("margin_vertical" , schema .MARGIN_VERTICAL_DEFAULT ),
509
509
)
510
- crop (context , int ( round (margin_horizontal )), int ( round (margin_vertical ) ))
510
+ crop (context , round (margin_horizontal ), round (margin_vertical ))
511
511
512
512
513
513
@Process ("sharpen" )
@@ -616,10 +616,10 @@ def draw_rectangle(image: NpNdarrayInt, contour: tuple[int, int, int, int], bord
616
616
color = (0 , 255 , 0 )
617
617
opacity = 0.1
618
618
x , y , width , height = contour
619
- x = int ( round (x ) )
620
- y = int ( round (y ) )
621
- width = int ( round (width ) )
622
- height = int ( round (height ) )
619
+ x = round (x )
620
+ y = round (y )
621
+ width = round (width )
622
+ height = round (height )
623
623
624
624
sub_img = image [y : y + height , x : x + width ]
625
625
mask_image = np .zeros (sub_img .shape , dtype = np .uint8 )
@@ -689,20 +689,18 @@ def find_limit_contour(
689
689
values = np .zeros (image_size )
690
690
if vertical :
691
691
for x , _ , width , height in contours :
692
- x_int = int ( round (x ) )
692
+ x_int = round (x )
693
693
for value in range (x_int , min (x_int + width , image_size )):
694
694
values [value ] += height
695
695
else :
696
696
for _ , y , width , height in contours :
697
- y_int = int ( round (y ) )
697
+ y_int = round (y )
698
698
for value in range (y_int , min (y_int + height , image_size )):
699
699
values [value ] += width
700
700
701
701
ranges = zero_ranges (values )
702
702
703
- return [
704
- int (round (sum (ranges_ ) / 2 )) for ranges_ in ranges if ranges_ [0 ] != 0 and ranges_ [1 ] != image_size
705
- ]
703
+ return [round (sum (ranges_ ) / 2 ) for ranges_ in ranges if ranges_ [0 ] != 0 and ranges_ [1 ] != image_size ]
706
704
707
705
708
706
def find_limits (
@@ -813,7 +811,7 @@ def _find_contours_thresh(
813
811
config .setdefault ("contour_kernel_size" , schema .CONTOUR_KERNEL_SIZE_DEFAULT ),
814
812
)
815
813
816
- kernel_size = int ( round (kernel_size / 2 ) )
814
+ kernel_size = round (kernel_size / 2 )
817
815
818
816
# Assign a rectangle kernel size
819
817
kernel : NpNdarrayInt = np .ones ((kernel_size , kernel_size ), "uint8" )
@@ -1722,7 +1720,7 @@ async def split(
1722
1720
)
1723
1721
context .image = cv2 .imread (process_file .name )
1724
1722
if crop_config .setdefault ("enabled" , schema .CROP_ENABLED_DEFAULT ):
1725
- crop (context , int ( round (margin_horizontal )), int ( round (margin_vertical ) ))
1723
+ crop (context , round (margin_horizontal ), round (margin_vertical ))
1726
1724
process_file = tempfile .NamedTemporaryFile ( # pylint: disable=consider-using-with
1727
1725
suffix = ".png" ,
1728
1726
)
@@ -1959,12 +1957,12 @@ async def _process_code(name: str) -> bool:
1959
1957
await add_code .add_codes (
1960
1958
pdf_filename ,
1961
1959
destination_filename ,
1962
- dpi = float (os .environ .get ("SCAN_CODES_DPI" , 200 )),
1963
- pdf_dpi = float (os .environ .get ("SCAN_CODES_PDF_DPI" , 72 )),
1960
+ dpi = float (os .environ .get ("SCAN_CODES_DPI" , " 200" )),
1961
+ pdf_dpi = float (os .environ .get ("SCAN_CODES_PDF_DPI" , "72" )),
1964
1962
font_name = os .environ .get ("SCAN_CODES_FONT_NAME" , "Helvetica-Bold" ),
1965
- font_size = float (os .environ .get ("SCAN_CODES_FONT_SIZE" , 16 )),
1966
- margin_top = float (os .environ .get ("SCAN_CODES_MARGIN_TOP" , 0 )),
1967
- margin_left = float (os .environ .get ("SCAN_CODES_MARGIN_LEFT" , 2 )),
1963
+ font_size = float (os .environ .get ("SCAN_CODES_FONT_SIZE" , "16" )),
1964
+ margin_top = float (os .environ .get ("SCAN_CODES_MARGIN_TOP" , "0" )),
1965
+ margin_left = float (os .environ .get ("SCAN_CODES_MARGIN_LEFT" , "2" )),
1968
1966
)
1969
1967
if destination_filename .exists ():
1970
1968
# Remove the source file on success
0 commit comments