interactive_shape_recognition 1.2.2 copy "interactive_shape_recognition: ^1.2.2" to clipboard
interactive_shape_recognition: ^1.2.2 copied to clipboard

Dart port of inkandswitch/interactive-shape-recognition, an implementation of "A Simple Approach to Recognise Geometric Shapes Interactively".

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:interactive_shape_recognition/interactive_shape_recognition.dart';
import 'package:interactive_shape_recognition_example/canvas_draw.dart';

final detectedShape = ValueNotifier<DetectedShape?>(null);
Timer? pointDebounce;

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Interactive Shape Recognition Demo',
      theme: ThemeData(
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: ValueListenableBuilder(
            valueListenable: detectedShape,
            builder: (context, detectedShape, child) {
              return Text(
                detectedShape == null
                    ? 'Draw below to detect a shape'
                    : 'Detected shape: ${detectedShape.shape}',
              );
            },
          ),
        ),
        body: SizedBox.expand(
          child: CanvasDraw(
            detectedShape: detectedShape,
            onDraw: (points) {
              if (pointDebounce == null || !pointDebounce!.isActive) {
                pointDebounce = Timer(const Duration(milliseconds: 100), () {
                  detectedShape.value = detectShape(points);
                });
              }
            },
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
31
downloads

Publisher

verified publisheradil.hanney.org

Weekly Downloads

Dart port of inkandswitch/interactive-shape-recognition, an implementation of "A Simple Approach to Recognise Geometric Shapes Interactively".

Homepage
Repository (GitHub)
View/report issues

Topics

#math #shape-recognition #polygons #js-port

Documentation

API reference

License

MIT (license)

Dependencies

area_polygon, convex_hull, flutter

More

Packages that depend on interactive_shape_recognition