Skip to content

Commit 89e6b24

Browse files
test
1 parent e31b372 commit 89e6b24

40 files changed

+1056
-378
lines changed

dynamsoft_barcode_reader_bundle/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.0.10.7771"
1+
__version__ = "4.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from . import _DynamsoftCore

dynamsoft_barcode_reader_bundle/cvr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.0.10.7771"
1+
__version__ = "3.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from .core import *

dynamsoft_barcode_reader_bundle/dbr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "11.0.10.7771"
1+
__version__ = "11.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from .core import *

dynamsoft_barcode_reader_bundle/dip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.0.10.7771"
1+
__version__ = "3.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from . import _DynamsoftImageProcessing

dynamsoft_barcode_reader_bundle/license.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.0.10.7771"
1+
__version__ = "4.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from . import _DynamsoftLicense

dynamsoft_barcode_reader_bundle/utility.py

Lines changed: 175 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.0.10.7771"
1+
__version__ = "2.0.10.7798"
22

33
if __package__ or "." in __name__:
44
from .cvr import *
@@ -18,7 +18,12 @@
1818

1919
from abc import ABC, abstractmethod
2020
from typing import List, Tuple, Union
21+
from enum import IntEnum
2122

23+
class FilterType(IntEnum):
24+
FT_HIGH_PASS = _DynamsoftUtility.FT_HIGH_PASS
25+
FT_SHARPEN = _DynamsoftUtility.FT_SHARPEN
26+
FT_SMOOTH = _DynamsoftUtility.FT_SMOOTH
2227

2328
class UtilityModule:
2429
"""
@@ -212,7 +217,7 @@ def is_latest_overlapping_enabled(self, type: int) -> bool:
212217
return _DynamsoftUtility.CMultiFrameResultCrossFilter_IsLatestOverlappingEnabled(
213218
self, type
214219
)
215-
220+
216221
_DynamsoftUtility.CMultiFrameResultCrossFilter_register(MultiFrameResultCrossFilter)
217222

218223
class ProactiveImageSourceAdapter(ImageSourceAdapter, ABC):
@@ -248,7 +253,7 @@ def _fetch_image():
248253
def has_next_image_to_fetch(self) -> bool:
249254
"""
250255
Determines whether there are more images left to fetch.
251-
256+
252257
Returns:
253258
True if there are more images left to fetch, false otherwise.
254259
"""
@@ -322,7 +327,7 @@ def set_directory(self, *args) -> Tuple[int, str]:
322327
path (str): The path of the directory to search.
323328
filter (str, optional): A string that specifies file extensions. For example: "*.BMP;*.JPG;*.GIF", or "*.*", etc. The default value is "*.bmp;*.jpg;*.jpeg;*.tif;*.png;*.tiff;*.gif;*.pdf".
324329
recursive (bool, optional): Specifies whether to load files recursively. The default value is False.
325-
330+
326331
Returns:
327332
A tuple containing following elements:
328333
- error_code <int>: The error code indicating the status of the operation.
@@ -459,22 +464,26 @@ def set_pages(self, pages: List[int]) -> Tuple[int, str]:
459464
_DynamsoftUtility.CFileFetcher_register(FileFetcher)
460465

461466

462-
class ImageManager:
467+
class ImageIO:
463468
"""
464-
The ImageManager class is a utility class for managing and manipulating images. It provides functionality for saving images to files and drawing various shapes on images.
469+
The ImageIO class is a utility class for reading and writing images.
465470
466471
Methods:
467472
save_to_file(self, image_data: ImageData, path: str, overwrite: bool = True) -> Tuple[int, str]: Saves an image to a file.
468-
draw_on_image(self, *args) -> Tuple[int, str]: Draws an image on an image.
473+
read_from_file(self, file_path: str) -> Tuple[int, ImageData]: Reads an image from a file.
474+
read_from_memory(self, image_file_bytes: bytes) -> Tuple[int, ImageData]: Reads an image from a file in memory.
475+
save_to_memory(self, image_data: ImageData,image_format: EnumImageFileFormat) -> Tuple[int, bytes]: Saves an image to memory in the specified format.
476+
read_from_numpy(self, image: "np.ndarray", image_pixel_format: EnumImagePixelFormat) -> Tuple[int, str, ImageData]: Reads an image from a numpy array.
477+
save_to_numpy(self, image_data: ImageData) -> Tuple[int, str, "np.ndarray"]: Saves an image to a numpy array.
469478
"""
470479

471480
_thisown = property(
472481
lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag"
473482
)
474-
483+
475484
def __init__(self):
476485
_DynamsoftUtility.Class_init(
477-
self, _DynamsoftUtility.new_CImageManager()
486+
self, _DynamsoftUtility.new_CImageIO()
478487
)
479488
def save_to_file(
480489
self, image_data: ImageData, path: str, overwrite: bool = True
@@ -492,16 +501,10 @@ def save_to_file(
492501
- error_code <int>: The error code indicating the status of the operation.
493502
- error_message <str>: A descriptive message explaining the error.
494503
"""
495-
return _DynamsoftUtility.CImageManager_SaveToFile(
504+
return _DynamsoftUtility.CImageIO_SaveToFile(
496505
self, image_data, path, overwrite
497506
)
498507

499-
def draw_on_image(self, *args):
500-
"""
501-
Draws an image on an image.
502-
"""
503-
return _DynamsoftUtility.CImageManager_DrawOnImage(self, *args)
504-
505508
def read_from_file(self, file_path: str) -> Tuple[int, ImageData]:
506509
"""
507510
Reads an image from a file.
@@ -516,8 +519,39 @@ def read_from_file(self, file_path: str) -> Tuple[int, ImageData]:
516519
- error_code <int>: The error code indicating the status of the operation.
517520
- image_data (ImageData): An ImageData object representing the image if succeeds, None otherwise.
518521
"""
519-
return _DynamsoftUtility.CImageManager_ReadFromFile(self, file_path)
520-
522+
return _DynamsoftUtility.CImageIO_ReadFromFile(self, file_path)
523+
524+
def read_from_memory(self, image_file_bytes: bytes) -> Tuple[int, ImageData]:
525+
"""
526+
Reads an image from a file in memory.
527+
If the file format is gif, pdf or tiff, we read the first page of the image file.
528+
The caller is responsible for freeing the memory allocated for the image.
529+
530+
Args:
531+
image_file_bytes (bytes): A bytes representing the image file in memory.
532+
533+
Returns:
534+
A tuple containing following elements:
535+
- error_code <int>: The error code indicating the status of the operation.
536+
- image_data (ImageData): An ImageData object representing the image if succeeds, None otherwise.
537+
"""
538+
return _DynamsoftUtility.CImageIO_ReadFromMemory(self, image_file_bytes)
539+
540+
def save_to_memory(self, image_data: ImageData,image_format: EnumImageFileFormat) -> Tuple[int, bytes]:
541+
"""
542+
Saves an image to memory in the specified format.
543+
544+
Args:
545+
image_data (ImageData): The image data to be saved.
546+
image_format (EnumImageFileFormat): The desired image format.
547+
548+
Returns:
549+
A tuple containing following elements:
550+
- error_code <int>: The error code indicating the status of the operation.
551+
- image_file_bytes (bytes): The byte array representing the saved image file if succeeds, None otherwise.
552+
"""
553+
return _DynamsoftUtility.CImageIO_SaveToMemory(self, image_data, image_format)
554+
521555
def read_from_numpy(self, image: "numpy.ndarray", image_pixel_format: EnumImagePixelFormat) -> Tuple[int, str, ImageData]:
522556
"""
523557
Reads an image from a numpy array.
@@ -533,7 +567,7 @@ def read_from_numpy(self, image: "numpy.ndarray", image_pixel_format: EnumImageP
533567
- image_data (ImageData): An ImageData object representing the image if succeeds, None otherwise.
534568
"""
535569
return 0, "Success.", ImageData(image.tobytes(),image.shape[1],image.shape[0],image.strides[0], image_pixel_format)
536-
570+
537571
def save_to_numpy(self, image_data: ImageData) -> Tuple[int, str, "numpy.ndarray"]:
538572
"""
539573
Saves an image to a numpy array.
@@ -568,38 +602,41 @@ def save_to_numpy(self, image_data: ImageData) -> Tuple[int, str, "numpy.ndarray
568602
err_str = _DynamsoftCore.DC_GetErrorString()
569603
arr = None
570604
return err, err_str, arr
571-
572-
def read_from_memory(self, image_file_bytes: bytes) -> Tuple[int, ImageData]:
573-
"""
574-
Reads an image from a file in memory.
575-
If the file format is gif, pdf or tiff, we read the first page of the image file.
576-
The caller is responsible for freeing the memory allocated for the image.
577605

578-
Args:
579-
image_file_bytes (bytes): A bytes representing the image file in memory.
606+
__destroy__ = _DynamsoftUtility.delete_CImageIO
580607

581-
Returns:
582-
A tuple containing following elements:
583-
- error_code <int>: The error code indicating the status of the operation.
584-
- image_data (ImageData): An ImageData object representing the image if succeeds, None otherwise.
608+
_DynamsoftUtility.CImageIO_register(ImageIO)
609+
610+
class ImageDrawer:
611+
_thisown = property(
612+
lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag"
613+
)
614+
615+
def __init__(self):
616+
_DynamsoftUtility.Class_init(
617+
self, _DynamsoftUtility.new_CImageDrawer()
618+
)
619+
620+
def draw_on_image(self, *args):
585621
"""
586-
return _DynamsoftUtility.CImageManager_ReadFromMemory(self, image_file_bytes)
587-
588-
def save_to_memory(self, image_data: ImageData,image_format: EnumImageFileFormat) -> Tuple[int, bytes]:
622+
Draws an image on an image.
589623
"""
590-
Saves an image to memory in the specified format.
624+
return _DynamsoftUtility.CImageDrawer_DrawOnImage(self, *args)
591625

592-
Args:
593-
image_data (ImageData): The image data to be saved.
594-
image_format (EnumImageFileFormat): The desired image format.
626+
__destroy__ = _DynamsoftUtility.delete_CImageDrawer
627+
628+
_DynamsoftUtility.CImageDrawer_register(ImageIO)
629+
630+
class ImageProcessor:
631+
_thisown = property(
632+
lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag"
633+
)
634+
635+
def __init__(self):
636+
_DynamsoftUtility.Class_init(
637+
self, _DynamsoftUtility.new_CImageProcessor()
638+
)
595639

596-
Returns:
597-
A tuple containing following elements:
598-
- error_code <int>: The error code indicating the status of the operation.
599-
- image_file_bytes (bytes): The byte array representing the saved image file if succeeds, None otherwise.
600-
"""
601-
return _DynamsoftUtility.CImageManager_SaveToMemory(self, image_data, image_format)
602-
603640
def crop_image(self, image_data:ImageData, crop_form: Union[Rect,Quadrilateral]) -> Tuple[int, ImageData]:
604641
"""
605642
Crops an image.
@@ -613,16 +650,104 @@ def crop_image(self, image_data:ImageData, crop_form: Union[Rect,Quadrilateral])
613650
Returns:
614651
A tuple containing following elements:
615652
- error_code <int>: The error code indicating the status of the operation.
616-
- cropped_image_data (ImageData): A ImageData object representing the cropped image if succeeds, None otherwise.
653+
- cropped_image_data (ImageData): An ImageData object representing the cropped image if succeeds, None otherwise.
617654
"""
618655
if isinstance(crop_form, Rect):
619-
return _DynamsoftUtility.CImageManager_CropImageWithRect(self, image_data, crop_form)
656+
return _DynamsoftUtility.CImageProcessor_CropImageWithRect(self, image_data, crop_form)
620657
elif isinstance(crop_form, Quadrilateral):
621-
return _DynamsoftUtility.CImageManager_CropImageWithQuadrilateral(self, image_data, crop_form)
658+
return _DynamsoftUtility.CImageProcessor_CropImageWithQuadrilateral(self, image_data, crop_form)
622659
else:
623660
raise TypeError("Unsupported crop form type")
661+
def adjust_brightness(self, image_data: ImageData, brightness: int) -> ImageData:
662+
"""
663+
Adjusts the brightness of the image.
664+
665+
Args:
666+
image_data (ImageData): The image data to be adjusted.
667+
brightness (int): The brightness adjustment value (positive values increase brightness, negative values decrease brightness).
668+
669+
Returns:
670+
An ImageData object after brightness adjustment.
671+
"""
672+
return _DynamsoftUtility.CImageProcessor_AdjustBrightness(self, image_data, brightness)
673+
674+
def adjust_contrast(self, image_data: ImageData, contrast: int) -> ImageData:
675+
"""
676+
Adjusts the contrast of the image.
677+
678+
Args:
679+
image_data (ImageData): The image data to be adjusted.
680+
contrast (int): The contrast adjustment value (positive values enhance, negative values reduce contrast).
681+
682+
Returns:
683+
An ImageData object after contrast adjustment.
684+
"""
685+
return _DynamsoftUtility.CImageProcessor_AdjustContrast(self, image_data, contrast)
686+
687+
def filter_image(self, image_data: ImageData, filter_type: FilterType) -> ImageData:
688+
"""
689+
Applies a specified image filter to an input image and returns the filtered result.
690+
691+
Args:
692+
image_data (ImageData): The image data to be filtered.
693+
filter_type (FilterType): Specifies the type of filter to apply to the input image.
694+
695+
Returns:
696+
An ImageData object after filtering operation.
697+
"""
698+
return _DynamsoftUtility.CImageProcessor_FilterImage(self, image_data, filter_type)
699+
700+
def convert_to_gray(self, image_data: ImageData, r: float = 0.3, g: float = 0.59, b: float = 0.11) -> ImageData:
701+
"""
702+
Converts a colour image to grayscale using the given weights.
703+
704+
Args:
705+
image_data (ImageData): The image data to be converted.
706+
r (float): Weight for red channel (default value: 0.3).
707+
g (float): Weight for green channel (default value: 0.59).
708+
b (float): Weight for blue channel (default value: 0.11).
709+
710+
Returns:
711+
An ImageData object after grayscale conversion.
712+
"""
713+
return _DynamsoftUtility.CImageProcessor_ConvertToGray(self, image_data, r, g, b)
714+
715+
def convert_to_binary_global(self, image_data: ImageData, threshold: int = -1, invert: bool = False) -> ImageData:
716+
"""
717+
Converts a grayscale image to binary image using a global threshold.
718+
719+
Args:
720+
image_data (ImageData): The image data to be converted.
721+
threshold (int): Global threshold for binarization (default is -1, automatic calculate the threshold).
722+
invert (bool): If true, invert the binary image (black becomes white and white becomes black).
723+
724+
Returns:
725+
An ImageData object after binary conversion.
726+
"""
727+
return _DynamsoftUtility.CImageProcessor_ConvertToBinaryGlobal(self, image_data, threshold, invert)
624728

625-
__destroy__ = _DynamsoftUtility.delete_CImageManager
729+
# * Converts the grayscale image to binary image using local (adaptive) binarization.
730+
# * @param pImageData: Input image in grayscale.
731+
# * @param blockSize: Size of the block for local binarization(default is 0).
732+
# * @param compensation: Adjustment value to modify the threshold (default is 0).
733+
# * @param invert: If true, invert the binary image (black becomes white and white becomes black).
734+
# * @return: Image after binarization.
735+
736+
def convert_to_binary_local(self, image_data: ImageData, block_size: int = 0, compensation: int = 0, invert: bool = False) ->ImageData:
737+
"""
738+
Converts a grayscale image to binary image using local (adaptive) binarization.
739+
740+
Args:
741+
image_data (ImageData): The image data to be converted.
742+
block_size (int): Size of the block for local binarization (default is 0).
743+
compensation (int): Adjustment value to modify the threshold (default is 0).
744+
invert (bool): If true, invert the binary image (black becomes white and white becomes black).
745+
746+
Returns:
747+
An ImageData object after binary conversion.
748+
"""
749+
return _DynamsoftUtility.CImageProcessor_ConvertToBinaryLocal(self, image_data, block_size, compensation, invert)
750+
__destroy__ = _DynamsoftUtility.delete_CImageProcessor
626751

627752

628-
_DynamsoftUtility.CImageManager_register(ImageManager)
753+
_DynamsoftUtility.CImageProcessor_register(ImageProcessor)

include/DynamsoftBarcodeReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef void* HANDLE;
2424
#endif
2525
#include "DynamsoftCore.h"
2626

27-
#define DBR_VERSION "11.0.10.3775"
27+
#define DBR_VERSION "11.0.10.3788"
2828

2929
/**Enumeration section*/
3030

include/DynamsoftCaptureVisionRouter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "DynamsoftCodeParser.h"
2626
#include "DynamsoftLicense.h"
2727

28-
#define DCV_VERSION "3.0.10.3775"
28+
#define DCV_VERSION "3.0.10.3788"
2929

3030
/**Enumeration section*/
3131

include/DynamsoftCodeParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#endif
1616
#include "DynamsoftCore.h"
1717

18-
#define DCP_VERSION "3.0.10.3775"
18+
#define DCP_VERSION "3.0.10.3788"
1919
/**
2020
* @enum MappingStatus
2121
*

include/DynamsoftCore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#define DYNAMSOFT_CORE_VERSION "4.0.10.3775"
2+
#define DYNAMSOFT_CORE_VERSION "4.0.10.3788"
33

44
/**Enumeration section*/
55

0 commit comments

Comments
 (0)