|
1 | 1 | # coding: utf-8 |
2 | 2 |
|
3 | | -""" |
4 | | -
|
5 | | - Copyright (c) 2024 Aspose.BarCode for Cloud |
6 | | -
|
7 | | - Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | | - of this software and associated documentation files (the "Software"), to deal |
9 | | - in the Software without restriction, including without limitation the rights |
10 | | - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | | - copies of the Software, and to permit persons to whom the Software is |
12 | | - furnished to do so, subject to the following conditions: |
13 | | -
|
14 | | - The above copyright notice and this permission notice shall be included in all |
15 | | - copies or substantial portions of the Software. |
16 | | -
|
17 | | - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | | - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | | - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | | - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | | - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | | - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23 | | - SOFTWARE. |
24 | | -
|
25 | | -""" |
26 | | - |
27 | 3 | from __future__ import absolute_import, division |
28 | 4 |
|
29 | 5 | import re # noqa: F401 |
@@ -489,7 +465,7 @@ def get_barcode_recognize( |
489 | 465 | :param bool allow_additional_restorations: Allows engine using additional image restorations to recognize corrupted barcodes. At this time, it is used only in MicroPdf417 barcode type. Default value: False. # noqa: E501 |
490 | 466 | :param float region_likelihood_threshold_percent: Sets threshold for detected regions that may contain barcodes. Value 0.7 means that bottom 70% of possible regions are filtered out and not processed further. Region likelihood threshold must be between [0.05, 0.9] Use high values for clear images with few barcodes. Use low values for images with many barcodes or for noisy images. Low value may lead to a bigger recognition time. # noqa: E501 |
491 | 467 | :param list[int] scan_window_sizes: Scan window sizes in pixels. Allowed sizes are 10, 15, 20, 25, 30. Scanning with small window size takes more time and provides more accuracy but may fail in detecting very big barcodes. Combining of several window sizes can improve detection quality. # noqa: E501 |
492 | | - :param float similarity: Similarity coefficient depends on how homogeneous barcodes are. Use high value for for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] # noqa: E501 |
| 468 | + :param float similarity: Similarity coefficient depends on how homogeneous barcodes are. Use high value for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] # noqa: E501 |
493 | 469 | :param bool skip_diagonal_search: Allows detector to skip search for diagonal barcodes. Setting it to false will increase detection time but allow to find diagonal barcodes that can be missed otherwise. Enabling of diagonal search leads to a bigger detection time. # noqa: E501 |
494 | 470 | :param bool read_tiny_barcodes: Allows engine to recognize tiny barcodes on large images. Ignored if AllowIncorrectBarcodes is set to True. Default value: False. # noqa: E501 |
495 | 471 | :param str australian_post_encoding_table: Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other. # noqa: E501 |
@@ -865,7 +841,7 @@ def post_barcode_recognize_from_url_or_content( |
865 | 841 | :param bool allow_additional_restorations: Allows engine using additional image restorations to recognize corrupted barcodes. At this time, it is used only in MicroPdf417 barcode type. Default value: False. # noqa: E501 |
866 | 842 | :param float region_likelihood_threshold_percent: Sets threshold for detected regions that may contain barcodes. Value 0.7 means that bottom 70% of possible regions are filtered out and not processed further. Region likelihood threshold must be between [0.05, 0.9] Use high values for clear images with few barcodes. Use low values for images with many barcodes or for noisy images. Low value may lead to a bigger recognition time. # noqa: E501 |
867 | 843 | :param list[int] scan_window_sizes: Scan window sizes in pixels. Allowed sizes are 10, 15, 20, 25, 30. Scanning with small window size takes more time and provides more accuracy but may fail in detecting very big barcodes. Combining of several window sizes can improve detection quality. # noqa: E501 |
868 | | - :param float similarity: Similarity coefficient depends on how homogeneous barcodes are. Use high value for for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] # noqa: E501 |
| 844 | + :param float similarity: Similarity coefficient depends on how homogeneous barcodes are. Use high value for clear barcodes. Use low values to detect barcodes that ara partly damaged or not lighten evenly. Similarity coefficient must be between [0.5, 0.9] # noqa: E501 |
869 | 845 | :param bool skip_diagonal_search: Allows detector to skip search for diagonal barcodes. Setting it to false will increase detection time but allow to find diagonal barcodes that can be missed otherwise. Enabling of diagonal search leads to a bigger detection time. # noqa: E501 |
870 | 846 | :param bool read_tiny_barcodes: Allows engine to recognize tiny barcodes on large images. Ignored if AllowIncorrectBarcodes is set to True. Default value: False. # noqa: E501 |
871 | 847 | :param str australian_post_encoding_table: Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other. # noqa: E501 |
@@ -1885,3 +1861,105 @@ def put_generate_multiple_with_http_info(self, name, generator_params_list, **kw |
1885 | 1861 | _request_timeout=params.get("_request_timeout"), |
1886 | 1862 | collection_formats=collection_formats, |
1887 | 1863 | ) |
| 1864 | + |
| 1865 | + def scan_barcode(self, image_file, decode_types=None, timeout=None, async_req=False, **kwargs): |
| 1866 | + """Quickly scan a barcode from an image. |
| 1867 | +
|
| 1868 | + This method makes a synchronous HTTP request by default. To make an |
| 1869 | + asynchronous HTTP request, please pass async_req=True |
| 1870 | + >>> thread = BarcodeApi().scan_barcode(image_file, async_req=True) |
| 1871 | + >>> result = thread.get() |
| 1872 | +
|
| 1873 | + :param file image_file: Image as file # noqa: E501 |
| 1874 | + :param list[DecodeBarcodeType] decode_types: Types of barcode to recognize # noqa: E501 |
| 1875 | + :param int timeout: Timeout of recognition process in milliseconds. Default value is 15_000 (15 seconds). Maximum value is 30_000 (1/2 minute). In case of a timeout RequestTimeout (408) status will be returned. Try reducing the image size to avoid timeout. # noqa: E501 |
| 1876 | + :param async_req bool |
| 1877 | + :return: BarcodeResponseList |
| 1878 | + If the method is called asynchronously, |
| 1879 | + returns the request thread. |
| 1880 | + """ |
| 1881 | + kwargs["_return_http_data_only"] = True |
| 1882 | + if async_req: |
| 1883 | + return self.scan_barcode_with_http_info(image_file, decode_types=decode_types, timeout=timeout, **kwargs) |
| 1884 | + else: |
| 1885 | + (data) = self.scan_barcode_with_http_info(image_file, decode_types=decode_types, timeout=timeout, **kwargs) |
| 1886 | + return data |
| 1887 | + |
| 1888 | + def scan_barcode_with_http_info(self, image_file, **kwargs): |
| 1889 | + """Quickly scan a barcode from an image. |
| 1890 | +
|
| 1891 | + This method makes a synchronous HTTP request by default. To make an |
| 1892 | + asynchronous HTTP request, please pass async_req=True |
| 1893 | + >>> thread = BarcodeApi().scan_barcode_with_http_info(image_file, async_req=True) |
| 1894 | + >>> result = thread.get() |
| 1895 | +
|
| 1896 | + :param file image_file: Image as file # noqa: E501 |
| 1897 | + :return: BarcodeResponseList |
| 1898 | + If the method is called asynchronously, |
| 1899 | + returns the request thread. |
| 1900 | + """ |
| 1901 | + |
| 1902 | + all_params = {"image_file", "decode_types", "timeout"} |
| 1903 | + all_params.add("async_req") |
| 1904 | + all_params.add("_return_http_data_only") |
| 1905 | + all_params.add("_preload_content") |
| 1906 | + all_params.add("_request_timeout") |
| 1907 | + |
| 1908 | + params = locals() |
| 1909 | + for key, val in six.iteritems(params["kwargs"]): |
| 1910 | + if key not in all_params: |
| 1911 | + raise TypeError("Got an unexpected keyword argument '%s'" " to method scan_barcode" % key) |
| 1912 | + if val is None: |
| 1913 | + continue |
| 1914 | + |
| 1915 | + params[key] = val |
| 1916 | + del params["kwargs"] |
| 1917 | + # verify the required parameter "image_file" is set |
| 1918 | + if "image_file" not in params or params["image_file"] is None: |
| 1919 | + raise ValueError("Missing the required parameter 'image_file' when calling 'scan_barcode'") |
| 1920 | + |
| 1921 | + collection_formats = {} |
| 1922 | + |
| 1923 | + path_params = {} |
| 1924 | + |
| 1925 | + query_params = [] |
| 1926 | + |
| 1927 | + header_params = {} |
| 1928 | + |
| 1929 | + form_params = [] |
| 1930 | + local_var_files = {} |
| 1931 | + if "image_file" in params: |
| 1932 | + local_var_files["imageFile"] = params["image_file"] |
| 1933 | + if "decode_types" in params: |
| 1934 | + form_params.append(("decodeTypes", params["decode_types"])) |
| 1935 | + collection_formats["decodeTypes"] = "multi" |
| 1936 | + if "timeout" in params: |
| 1937 | + form_params.append(("timeout", params["timeout"])) |
| 1938 | + |
| 1939 | + body_params = None |
| 1940 | + # HTTP header "Accept" |
| 1941 | + header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) |
| 1942 | + |
| 1943 | + # HTTP header "Content-Type" |
| 1944 | + header_params["Content-Type"] = self.api_client.select_header_content_type(["multipart/form-data"]) |
| 1945 | + |
| 1946 | + # Authentication setting |
| 1947 | + auth_settings = ["JWT"] |
| 1948 | + |
| 1949 | + return self.api_client.call_api( |
| 1950 | + "/barcode/scan", |
| 1951 | + "POST", |
| 1952 | + path_params, |
| 1953 | + query_params, |
| 1954 | + header_params, |
| 1955 | + body=body_params, |
| 1956 | + post_params=form_params, |
| 1957 | + files=local_var_files, |
| 1958 | + response_type="BarcodeResponseList", |
| 1959 | + auth_settings=auth_settings, |
| 1960 | + async_req=params.get("async_req"), |
| 1961 | + _return_http_data_only=params.get("_return_http_data_only"), |
| 1962 | + _preload_content=params.get("_preload_content", True), |
| 1963 | + _request_timeout=params.get("_request_timeout"), |
| 1964 | + collection_formats=collection_formats, |
| 1965 | + ) |
0 commit comments