ScanCutout Class
class ScanCutout : ScanningSdkLibrary.Instance, Parcelable
The outline of a document within a page: the corner points that say which part of the image is the sheet of paper.
The points are held in clockwise order — four of them for a rectangular document, though the shape is not limited to four. A cutout starts out expressed in the image’s native pixel origin, with no rotation applied, and can be transformed for display and converted back again.
You get one from ScanPicture.detectCutout or build one by hand when the user adjusts the crop, then pass it to ScanPicture.refine to straighten and crop the page.
Holds its geometry in native memory. Call close — or use Kotlin’s use { } — when done to release it immediately; an unclosed instance is only reclaimed when garbage collection happens to run. Confine an instance to one thread, as with every SDK native handle.
See also
Constructors
ScanCutout
constructor(source: ScanCutout)
Creates an independent copy of another outline, sharing no native state with it.
constructor(bounds: SizeF, points: Array<PointF>, transform: Matrix)
Creates an outline from explicit corner points.
@JvmOverloads constructor(points: Array<Point>, orientation: Int, bounds: Point, asOrigin: Boolean = true)
Creates an outline from integer corner points, for code holding corners rather than a ScanCutout.
constructor(bytes: ByteArray)
Restores an outline previously serialised by writeBytes.
Properties
bounds
val bounds: RectF
The smallest rectangle containing the outline, after any transform is applied.
intPoints
val intPoints: Array<Point>
The corner points rounded to whole pixels, in the same order as points.
isDefined
val isDefined: Boolean
Whether a document was actually found.
isValid
val isValid: Boolean
Whether the corners still form a usable shape.
origin
var origin: SizeF
The size of the image these corners are expressed in.
points
var points: Array<PointF>
The corner points, in clockwise order.
transform
var transform: Matrix
The transform currently applied to the outline for display.
Functions
close
@Synchronized open override fun close()
Releases the native memory held by this instance immediately instead of waiting for the garbage collector.
copy
fun ScanCutout?.copy(): ScanCutout?
Safe copy cutout.
describeContents
open override fun describeContents(): Int
No special parcelling behaviour is needed.
equals
open operator override fun equals(other: Any?): Boolean
Two outlines are equal when their corner points and bounds match.
expand
external fun expand()
Expands the outline to cover the whole image.
hashCode
open override fun hashCode(): Int
Consistent with equals.
rectify
fun ScanCutout?.rectify(): RefineFeature
Chooses the right crop mode for a cutout that may be absent: crop to it when there is one, and leave the page uncropped when there is not.
toString
open external override fun toString(): String
A readable form of the corner points, for logging.
transform
external fun transform(orientation: ScanOrientation)
Applies an orientation to the outline, so it lines up with a rotated page.
writeBytes
external fun writeBytes(packed: Boolean): ByteArray
Serialises this outline so it can be stored or passed between processes.
writeToParcel
open override fun writeToParcel(dest: Parcel, flags: Int)
Writes this ScanCutout into a parcel.