arcore_plugin 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

arcore_plugin #

A Flutter plugin for Android allowing to recongize images via ARCore

  • USES ARCore version 1.8.0

Features #

[x] Displaying live ARCamera Feed

[x] Recognizing images via ARCore (for more information see: https://developers.google.com/ar/develop/c/augmented-images/)

[ ] Placing Objects

[ ] In-App training of the imgdb file

Installation #

Android #

  • For Setup make sure you migrated your App to AndroidX
  • in app/build.gradle set minSdkVersion to 24 and compileSdkVersion 28
 defaultConfig {
        ...     
        minSdkVersion 24
        ...
    }
and
android {
    compileSdkVersion 28
    ...
}

Very important! #

* AS FOR NOW THE PLUGIN DOES NOT SUPPORT IN APP TRAINING OF THE IMGDB FILE
* The IMGDB File has to be PRETRAINED and saved in a Temp Directory before the ArCoreView is created 
* The IMGDB File name hast to be image_database.imgdb
 * you can find a pretained imgdb file under example/assets. The images that the imgdb file is trained with are found under example/assets/tester_images
* for more info about ARCore imgdb files see : https://developers.google.com/ar/develop/c/augmented-images/arcoreimg

Getting Started #

  • For the given Example you have to have a pretrained imgdb saved in your assets folder and added as an asset in your pubspec.yaml file !
import 'dart:io';
import 'package:flutter/services.dart' show rootBundle;
import 'package:arcore_plugin/arcore_plugin.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';


void main() async {
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitDown,
    DeviceOrientation.portraitUp,
  ]);
  final Directory systemTempDir = Directory.systemTemp;
  final File tempFile = File('${systemTempDir.path}/image_database.imgdb');

  // create tempfile
  await tempFile.create();

  rootBundle.load("assets/image_database.imgdb").then((data) {
    tempFile.writeAsBytesSync(
        data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));

    runApp(MaterialApp(home: TextViewExample()));
  }).catchError((error) {
    throw Exception(error);
  });
}

class TextViewExample extends StatefulWidget {
  @override
  _TextViewExampleState createState() => _TextViewExampleState();
}

class _TextViewExampleState extends State<TextViewExample> {
  String recongizedImage;
  ArCoreViewController arCoreViewController;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Size screenSize = MediaQuery.of(context).size;
    return Scaffold(
        backgroundColor: Colors.blue,
        appBar: AppBar(
          title: const Text('ArCoreViewExample'),
          backgroundColor: Colors.black,
          centerTitle: true,
        ),
        body: Center(
            child: ArCoreView(
          focusBox: Container(
            width: screenSize.width * 0.5,
            height: screenSize.width * 0.5,
            decoration: BoxDecoration(
                border: Border.all(width: 1, style: BorderStyle.solid)),
          ),
          width: screenSize.width,
          height: screenSize.height,
          onImageRecognized: _onImageRecognized,
          onArCoreViewCreated: _onTextViewCreated,
        )));
  }

  void _onTextViewCreated(ArCoreViewController controller) {
    arCoreViewController = controller;
    controller.getArCoreView();
  }

  void _onImageRecognized(String recImgName) {
    print("image recongized: $recImgName");

    // you can pause the image recognition via arCoreViewController.pauseImageRecognition();
    // resume it via arCoreViewController.resumeImageRecognition();
  }
}


Note: This plugin is still under development, and some APIs might not be available yet. Feedback welcome and Pull Requests are most welcome!

0.0.1 #

  • First Release

0.0.1+1 #

  • Added more information in README file

0.0.1+2 #

  • Added better control over Image Recognition. User can pause and resume image recognition via ArCoreViewController
  • Added example on how to save the imgdb file in the App --> see main function in example
  • Added pretrained imgdb file and tester images as asset for example
  • updated README.md

0.1.0 #

  • ArCore is now optional not required.

0.1.1 #

  • upgrade to ARCore version 1.8.0

0.1.2 #

  • added width, height, focusBox parameters (all optional)
  • width : width of arcore view (Default value 300)
  • height: height of arcore view (Default value 300)

0.1.4 #

  • Fixed image db file path
  • Fixed main thread issue in FlutterArcoreView
  • Toast message for recognized image BIG THANKS to Ilya Bershadskyi for contributing!

example/README.md

arcore_plugin_example #

Demonstrates how to use the arcore_plugin plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  arcore_plugin: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:arcore_plugin/arcore_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.2

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
pedantic ^1.4.0 1.9.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8