Skip to main content

Scanning a Specific Area

You can crop and scan an arbitrary area of the image using CropRect in ScanOptions.

CropRect Parameters​

Specifying the crop area
ParameterDescription
cropWidthWidth to crop (0.0 to 1.0, where 1 represents the full width of the input image)
heightHeight to crop (0.0 to 1.0, where 1 represents the full height of the input image)
horizontalBiasHorizontal position (0.0 = left edge, 0.5 = center, 1.0 = right edge)
verticalBiasVertical position (0.0 = top edge, 0.5 = center, 1.0 = bottom edge)
Crop area example

Implementation​

Specify CropRect in ScanOptions and pass it to the scan method.

scanResult = try edgeOCR.scan(
sampleBuffer,
scanOption: scanOption,
viewBounds: viewBounds)

For example, to divide the screen into a 3x3 grid and crop only the bottom-center cell, configure as follows.

scanOptions = ScanOptions(
scanMode: ScanOptions.ScanMode.Default,
cropRect: CropRect(
horizontalBias: 0.5,
verticalBias: 1.0,
cropWidth: 0.33,
height: 0.33))