Scan region
A region is expressed in normalized coordinates - 0 to 1 across and down the frame - so it
survives whatever resolution the browser negotiates. Cropping happens before any pixel is
touched, which makes every later stage cheaper in proportion to the area removed. The reticle
frames the region and ShowMask dims the rest; still images are always searched in full.
Frame diagnostics
Presets
Full frame is BbScanRegion.Full, the default. Centred square
is BbScanRegion.CenteredSquare(0.7), the usual aiming box. Linear band,
a wide strip across the middle, suits a one dimensional barcode held level; Right half
shows that a region need not be centred. Watch Decoded size and the frame time in
the diagnostics under the scanner shrink with the region.
Custom
new BbScanRegion(x, y, width, height), each a fraction of the frame. The same
fraction of a wide frame's width and height are different numbers of pixels, so a square in
fractions is a rectangle on screen; KeepSquare narrows it along the longer axis
to the largest square it holds. CenteredSquare sets it: on a 1280×720 frame,
CenteredSquare(0.7) searches 504×504 pixels. ForFrame gives the
region as it applies to a frame of a given size.
Result positions
Corner points are always reported in the coordinates of the frame the camera
produced, not of the cropped region, so an overlay drawn from them lines up with
what the user sees. A matrix code reports its four outer corners, clockwise from the
symbol's own top-left whichever way up it is held; a linear code reports the two ends
of the line that read it. BoundingBox is the upright box round them.
In code
@* An aiming square, 70 % of the shorter edge, square on any camera *@ <BbScanner Region="BbScanRegion.CenteredSquare(0.7)" /> @* A band across the middle for a one dimensional barcode: x, y, width, height *@ <BbScanner Region="new BbScanRegion(0.05, 0.35, 0.9, 0.3)" />
Region can change while the camera runs; the next frame is searched with the new one. Values
outside 0 to 1 are clamped by Normalized(). IsFull says whether a region
covers the whole frame.