xvision 0.0.2 copy "xvision: ^0.0.2" to clipboard
xvision: ^0.0.2 copied to clipboard

A pure Dart computer vision and image processing library for real-time pixel manipulation, convolutions, and ML pre-processing.

example/lib/main.dart

// example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:xvision/xvision.dart';

void main() {
  // 1. Initialize a 128x128 RGBA image.
  final XVImage image = XVImage(128, 128, PixelFormat.rgba8888);
  debugPrint('Initialized a blank ${image.width}x${image.height} RGBA image.');

  // 2. Fill it with a dark slate background.
  image.fill(const XVColor(15, 23, 42));

  // 3. Draw a custom geometric pattern.
  // Draw a grid of lines.
  for (int i = 0; i < 128; i += 32) {
    image.drawLine(XVPoint(i, 0), XVPoint(i, 127), const XVColor(50, 50, 50));
    image.drawLine(XVPoint(0, i), XVPoint(127, i), const XVColor(50, 50, 50));
  }

  // Draw a filled circle.
  image.drawCircle(const XVPoint(64, 64), 40, XVColor.white, fill: true);
  // Draw a red bounding rect.
  image.drawRect(const XVRect(20, 20, 88, 88), XVColor.red, fill: false);
  debugPrint('Drew geometric grid, a white circle, and a red bounding rectangle.');

  // 4. Perform an image transform (Crop a region of interest).
  final XVImage cropped = image.crop(const XVRect(10, 10, 108, 108));
  debugPrint('Cropped a Region of Interest (ROI) of size ${cropped.width}x${cropped.height}.');

  // 5. Apply image filters (Gaussian blur).
  final XVImage blurred = cropped.gaussianBlur(1.5, kernelSize: 5);
  debugPrint('Applied Gaussian blur filter (sigma=1.5, kernelSize=5).');

  // 6. Convert color space (Grayscale conversion).
  final XVImage gray = blurred.convert(PixelFormat.gray8);
  debugPrint('Converted the blurred ROI to Grayscale (gray8 format).');

  // 7. Binarize using Otsu automatic thresholding.
  final XVImage thresholded = gray.otsuThreshold(maxVal: 255.0);
  debugPrint('Applied Otsu automatic thresholding to obtain binary mask.');

  // 8. Encode to PNG bytes.
  final Uint8List pngBytes = thresholded.toPng();
  debugPrint('Encoded processed image to PNG successfully (${pngBytes.length} bytes).');
}
1
likes
160
points
160
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A pure Dart computer vision and image processing library for real-time pixel manipulation, convolutions, and ML pre-processing.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

equatable

More

Packages that depend on xvision