Camera capture Pixelnetica™ Document Scanning SDK for Apple iOS
Capturing a document means showing a camera preview, detecting the page’s edges in real time, and taking the shot when the framing is good. DSSDK offers this as a ready-to-use screen, or as an engine you drive from your own camera UI.
Ready-to-use: the camera screen
The fastest path is PxUiCameraScreen (presented via the SwiftUI PxUiCameraScreenView). It runs the live preview, edge-detection overlay, optional auto-shot, and torch control for you, and returns the captured page plus its detected corners.
import DocScanningSDK_UI
PxUiCameraScreenView(configuration: PxUiCameraScreenConfiguration()) { result in
switch result {
case .success(let image, let cutout):
// `image` = the captured page; `cutout` = the detected document quad.
break
case .cancelled, .failure:
break
@unknown default:
break
}
}
Configure behaviour (edge detection, auto-shot, torch) through PxUiCameraScreenConfiguration, and re-localise the on-screen guidance through the strings table. See Quick Start for the full presentation.
Engine: drive detection yourself
If you build your own camera UI, feed each preview frame to a PxFrameObserver and use what it reports to draw your overlay:
observe(_:)(orobserve(_:roi:)) takes a frame and returns status flags describing the current detection (for example whether a stable document quad is defined).checkedFullnessandcheckedDistortiontell you whether the document fills enough of the frame and how skewed it is — the signals behind “move closer” / “hold steady” guidance.- When the quad is stable, capture a full-resolution still and pass it on to cropping.
The full PxFrameObserver surface (flags, averaging, region of interest) is in the API reference.
Tips
- Live capture needs a real device; add
NSCameraUsageDescriptiontoInfo.plist. - Detection runs on a downscaled working image, so a high-resolution preview does not improve detection — capture the full-resolution still only when you take the shot.
See also
- Edge detection & cropping — refine the corners after capture.
- Process an existing image — the no-camera path (and how to test on the Simulator).