detectQuad static method
Detect the document quad in a grayscale (luma) frame. Returns normalized corners or null when nothing convincing was found.
Implementation
static Quad? detectQuad(Uint8List gray, int width, int height, int stride) {
final input = calloc<Uint8>(gray.length);
final out = calloc<Float>(8);
try {
input.asTypedList(gray.length).setAll(0, gray);
final found = _detectQuad(input, width, height, stride, out);
if (found == 0) return null;
final c = out.asTypedList(8);
return Quad(
Offset(c[0], c[1]),
Offset(c[2], c[3]),
Offset(c[4], c[5]),
Offset(c[6], c[7]),
);
} finally {
calloc.free(input);
calloc.free(out);
}
}