edge_detector

Edge detector plugin based on google ml kit object detection. Allows basic edge detection for given image file.

:bulb: Please note that this package is just for edge detection. :bulb:

Check other packages for cropping tools:

  1. auto_crop - available for Android & iOS only.
  2. custom_cropper

Preview

Example usage

Basic usage

Future<void> _detectEdges() async {
    final imageFile = File('path/to/image');
    // Edges that are respective for the original image size.
    final originalImageEdges = await EdgeDetector().detectEdges(imageFile);
    if (originalImageEdges == null) return;

    final topLeft = originalImageEdges.topLeft; // Offset(x,y).
    final topRight = originalImageEdges.topRight; // Offset(x,y).
    final bottomRight = originalImageEdges.bottomRight; // Offset(x,y).
    final bottomLeft = originalImageEdges.bottomLeft; // Offset(x,y).
    final all = originalImageEdges.values; // [topLeft, topRight, bottomRight, bottomLeft].

    // Edges that are respective for the rendered image widget size.
    final widgetEdges = await originalImageEdges.toWidgetEdges(
      imageKey: _imageKey,
      originalImageFile: imageFile,
    );
}

Full example

Full example showing how to set up and use EdgeDetector. Source code