Package org.opencv.objdetect

## Class BarcodeDetector

- java.lang.Object
- - org.opencv.objdetect.GraphicalCodeDetector
  - - org.opencv.objdetect.BarcodeDetector

-     public class BarcodeDetector
      extends GraphicalCodeDetector

- - ### Field Summary

    - ### Fields inherited from class org.opencv.objdetect.GraphicalCodeDetector

      `nativeObj`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `BarcodeDetector()` | Initialize the BarcodeDetector.
    `protected` | `BarcodeDetector​(long addr)` |
    `` | `BarcodeDetector​(java.lang.String prototxt_path, java.lang.String model_path)` | Initialize the BarcodeDetector.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static BarcodeDetector` | `__fromPtr__​(long addr)` |
    `boolean` | `decodeWithType​(Mat img, Mat points, java.util.List<java.lang.String> decoded_info, java.util.List<java.lang.String> decoded_type)` | Decodes barcode in image once it's found by the detect() method.
    `boolean` | `detectAndDecodeWithType​(Mat img, java.util.List<java.lang.String> decoded_info, java.util.List<java.lang.String> decoded_type)` | Both detects and decodes barcode
    `boolean` | `detectAndDecodeWithType​(Mat img, java.util.List<java.lang.String> decoded_info, java.util.List<java.lang.String> decoded_type, Mat points)` | Both detects and decodes barcode
    `protected void` | `finalize()` |
    `void` | `getDetectorScales​(MatOfFloat sizes)` | Returns detector box filter sizes.
    `double` | `getDownsamplingThreshold()` | Get detector downsampling threshold.
    `double` | `getGradientThreshold()` | Get detector gradient magnitude threshold.
    `BarcodeDetector` | `setDetectorScales​(MatOfFloat sizes)` | Set detector box filter sizes.
    `BarcodeDetector` | `setDownsamplingThreshold​(double thresh)` | Set detector downsampling threshold.
    `BarcodeDetector` | `setGradientThreshold​(double thresh)` | Set detector gradient magnitude threshold.

    - ### Methods inherited from class org.opencv.objdetect.GraphicalCodeDetector

      `decode, decode, decodeMulti, decodeMulti, detect, detectAndDecode, detectAndDecode, detectAndDecode, detectAndDecodeMulti, detectAndDecodeMulti, detectAndDecodeMulti, detectMulti, getNativeObjAddr`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BarcodeDetector

          protected BarcodeDetector​(long addr)

    - #### BarcodeDetector

          public BarcodeDetector()

      Initialize the BarcodeDetector.

    - #### BarcodeDetector

          public BarcodeDetector​(java.lang.String prototxt_path,
                                 java.lang.String model_path)

      Initialize the BarcodeDetector. Parameters allow to load _optional_ Super Resolution DNN model for better quality.
      Parameters:
        `prototxt_path` - prototxt file path for the super resolution model
        `model_path` - model file path for the super resolution model

  - ### Method Detail

    - #### __fromPtr__

          public static BarcodeDetector __fromPtr__​(long addr)

    - #### decodeWithType

          public boolean decodeWithType​(Mat img,
                                        Mat points,
                                        java.util.List<java.lang.String> decoded_info,
                                        java.util.List<java.lang.String> decoded_type)

      Decodes barcode in image once it's found by the detect() method.
      Parameters:
        `img` - grayscale or color (BGR) image containing bar code.
        `points` - vector of rotated rectangle vertices found by detect() method (or some other algorithm). For N detected barcodes, the dimensions of this array should be [N][4]. Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
        `decoded_info` - UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
        `decoded_type` - vector strings, specifies the type of these barcodes
      Returns:
        true if at least one valid barcode have been found

    - #### detectAndDecodeWithType

          public boolean detectAndDecodeWithType​(Mat img,
                                                 java.util.List<java.lang.String> decoded_info,
                                                 java.util.List<java.lang.String> decoded_type,
                                                 Mat points)

      Both detects and decodes barcode
      Parameters:
        `img` - grayscale or color (BGR) image containing barcode.
        `decoded_info` - UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
        `decoded_type` - vector of strings, specifies the type of these barcodes
        `points` - optional output vector of vertices of the found barcode rectangle. Will be empty if not found.
      Returns:
        true if at least one valid barcode have been found

    - #### detectAndDecodeWithType

          public boolean detectAndDecodeWithType​(Mat img,
                                                 java.util.List<java.lang.String> decoded_info,
                                                 java.util.List<java.lang.String> decoded_type)

      Both detects and decodes barcode
      Parameters:
        `img` - grayscale or color (BGR) image containing barcode.
        `decoded_info` - UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
        `decoded_type` - vector of strings, specifies the type of these barcodes
      Returns:
        true if at least one valid barcode have been found

    - #### getDownsamplingThreshold

          public double getDownsamplingThreshold()

      Get detector downsampling threshold.
      Returns:
        detector downsampling threshold

    - #### setDownsamplingThreshold

          public BarcodeDetector setDownsamplingThreshold​(double thresh)

      Set detector downsampling threshold. By default, the detect method resizes the input image to this limit if the smallest image size is is greater than the threshold. Increasing this value can improve detection accuracy and the number of results at the expense of performance. Correlates with detector scales. Setting this to a large value will disable downsampling.
      Parameters:
        `thresh` - downsampling limit to apply (default 512) SEE: setDetectorScales
      Returns:
        automatically generated

    - #### getDetectorScales

          public void getDetectorScales​(MatOfFloat sizes)

      Returns detector box filter sizes.
      Parameters:
        `sizes` - output parameter for returning the sizes.

    - #### setDetectorScales

          public BarcodeDetector setDetectorScales​(MatOfFloat sizes)

      Set detector box filter sizes. Adjusts the value and the number of box filters used in the detect step. The filter sizes directly correlate with the expected line widths for a barcode. Corresponds to expected barcode distance. If the downsampling limit is increased, filter sizes need to be adjusted in an inversely proportional way.
      Parameters:
        `sizes` - box filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08])
      Returns:
        automatically generated

    - #### getGradientThreshold

          public double getGradientThreshold()

      Get detector gradient magnitude threshold.
      Returns:
        detector gradient magnitude threshold.

    - #### setGradientThreshold

          public BarcodeDetector setGradientThreshold​(double thresh)

      Set detector gradient magnitude threshold. Sets the coherence threshold for detected bounding boxes. Increasing this value will generate a closer fitted bounding box width and can reduce false-positives. Values between 16 and 1024 generally work, while too high of a value will remove valid detections.
      Parameters:
        `thresh` - gradient magnitude threshold (default 64).
      Returns:
        automatically generated

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `GraphicalCodeDetector`
      Throws:
        `java.lang.Throwable`