Skip to content

Commit

Permalink
Release 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed May 4, 2018
1 parent ea487a8 commit 5f7d80b
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 25 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Liked? :star: Star the repo to support the project!
* [x] Scan multiple barcodes.
* [x] Barcode coordinates.
* [x] Show barcode text.
* [ ] Standard code.
* [x] Recognize Text
* [x] Simple OCR.
* [x] Toggle torch.
Expand All @@ -31,13 +32,18 @@ Liked? :star: Star the repo to support the project!
* [x] Text language.
* [x] Text coordinates.
* [x] Hide recognized text.
* [ ] Standard code.
* [ ] Detect Faces
* [x] Simple detection.
* [x] Toggle torch.
* [x] Toggle auto focus.
* [x] Multiple detection.
* [ ] Face coordinates.
* [ ] Hide detection information.
* [x] Face coordinates.
* [x] Hide detection information.
* [ ] Standard code.
* [ ] Generalization of capture activities.
* [ ] Choose between back and front camera.
* [ ] Control camera FPS.

* [ ] iOS
* [ ] Barcode Scan
Expand All @@ -47,8 +53,10 @@ Liked? :star: Star the repo to support the project!
* [ ] Detect Faces
* [ ] _Future Tasks_

### Your feature isn't listed? Open a issue right now!

## Screenshots
<img src="docs/flutter_01.png" height="300em"/> <img src="docs/flutter_02.png" height="300em"/> <img src="docs/flutter_03.png" height="300em"/> <img src="docs/flutter_04.png" height="300em"/> <img src="docs/flutter_06.png" height="300em"/>
<img src="docs/flutter_01.png" height="300em"/> <img src="docs/flutter_02.png" height="300em"/> <img src="docs/flutter_03.png" height="300em"/> <img src="docs/flutter_04.png" height="300em"/> <img src="docs/flutter_05.png" height="300em"/> <img src="docs/flutter_06.png" height="300em"/> <img src="docs/flutter_07.png" height="300em"/> <img src="docs/flutter_08.png" height="300em"/>

## Usage

Expand All @@ -62,7 +70,7 @@ To use this plugin :
dependencies:
flutter:
sdk: flutter
flutter_mobile_vision: ^0.0.3
flutter_mobile_vision: ^0.0.4
```
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ public void onMethodCall(MethodCall call, Result result) {
autoFocus = (boolean) arguments.get("autoFocus");
}

if (arguments.containsKey("multiple")) {
multiple = (boolean) arguments.get("multiple");
}

if (arguments.containsKey("showText")) {
showText = (boolean) arguments.get("showText");
}

int rc = ActivityCompat.checkSelfPermission(activity, Manifest.permission.CAMERA);
if (rc != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void createCameraSource() throws MobileVisionException {
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();

FaceTrackerFactory faceTrackerFactory = new FaceTrackerFactory(graphicOverlay);
FaceTrackerFactory faceTrackerFactory = new FaceTrackerFactory(graphicOverlay, showText);

faceDetector.setProcessor(
new MultiProcessor.Builder<>(faceTrackerFactory).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,24 @@ class FaceGraphic extends GraphicOverlay.Graphic {
Color.WHITE,
Color.YELLOW
};
private static int currentColorIndex = 0;
private static int currentColorIndex;

static {
currentColorIndex = 0;
}

private Paint facePositionPaint;
private Paint idPaint;
private Paint boxPaint;

private boolean showText;
private volatile Face face;

FaceGraphic(GraphicOverlay overlay) {
FaceGraphic(GraphicOverlay overlay, boolean showText) {
super(overlay);

this.showText = showText;

currentColorIndex = (currentColorIndex + 1) % COLOR_CHOICES.length;
final int selectedColor = COLOR_CHOICES[currentColorIndex];

Expand Down Expand Up @@ -113,18 +120,20 @@ public void draw(Canvas canvas) {
float x = translateX(face.getPosition().x + face.getWidth() / 2);
float y = translateY(face.getPosition().y + face.getHeight() / 2);

canvas.drawCircle(x, y, FACE_POSITION_RADIUS, facePositionPaint);
if (showText) {
canvas.drawCircle(x, y, FACE_POSITION_RADIUS, facePositionPaint);

canvas.drawText("id: " + getId(), x + ID_X_OFFSET, y + ID_Y_OFFSET, idPaint);
canvas.drawText("id: " + getId(), x + ID_X_OFFSET, y + ID_Y_OFFSET, idPaint);

canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()),
x - ID_X_OFFSET, y - ID_Y_OFFSET, idPaint);
canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()),
x - ID_X_OFFSET, y - ID_Y_OFFSET, idPaint);

canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()),
x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, idPaint);
canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()),
x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, idPaint);

canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()),
x - ID_X_OFFSET * 2, y - ID_Y_OFFSET * 2, idPaint);
canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()),
x - ID_X_OFFSET * 2, y - ID_Y_OFFSET * 2, idPaint);
}

// Draws a bounding box around the face.
canvas.drawRect(getBoundingBox(), boxPaint);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.edufolly.fluttermobilevision.face;

import android.content.Context;
import android.util.Log;

import com.google.android.gms.vision.MultiProcessor;
Expand All @@ -11,13 +10,15 @@

public class FaceTrackerFactory implements MultiProcessor.Factory<Face> {
private GraphicOverlay<FaceGraphic> graphicOverlay;
private boolean showText;

public FaceTrackerFactory(GraphicOverlay<FaceGraphic> graphicOverlay) {
public FaceTrackerFactory(GraphicOverlay<FaceGraphic> graphicOverlay, boolean showText) {
this.graphicOverlay = graphicOverlay;
this.showText = showText;
}

public Tracker<Face> create(Face face) {
FaceGraphic graphic = new FaceGraphic(graphicOverlay);
FaceGraphic graphic = new FaceGraphic(graphicOverlay, showText);
try {
return new FaceGraphicTracker(graphicOverlay, graphic);
} catch (Exception ex) {
Expand Down
Binary file added docs/flutter_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/flutter_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/flutter_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/flutter_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions example/lib/face_details.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';

class FaceDetails extends StatefulWidget {
final Face face;

FaceDetails(this.face);

@override
_FaceDetailsState createState() => new _FaceDetailsState();
}

class _FaceDetailsState extends State<FaceDetails> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Face Details'),
),
body: new ListView(
children: <Widget>[
new ListTile(
title: new Text(widget.face.id.toString()),
subtitle: const Text('Id'),
),
new ListTile(
title: new Text(widget.face.eulerY.toString()),
subtitle: const Text('Euler Y'),
),
new ListTile(
title: new Text(widget.face.eulerZ.toString()),
subtitle: const Text('Euler Z'),
),
new ListTile(
title: new Text(widget.face.leftEyeOpenProbability.toString()),
subtitle: const Text('Left Eye Open Probability'),
),
new ListTile(
title: new Text(widget.face.rightEyeOpenProbability.toString()),
subtitle: const Text('Right Eye Open Probability'),
),
new ListTile(
title: new Text(widget.face.smilingProbability.toString()),
subtitle: const Text('Smiling Probability'),
),
new ListTile(
title: new Text(widget.face.top.toString()),
subtitle: const Text('Top'),
),
new ListTile(
title: new Text(widget.face.bottom.toString()),
subtitle: const Text('Bottom'),
),
new ListTile(
title: new Text(widget.face.left.toString()),
subtitle: const Text('Left'),
),
new ListTile(
title: new Text(widget.face.right.toString()),
subtitle: const Text('Right'),
),
],
),
);
}
}
13 changes: 7 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';
import 'package:flutter_mobile_vision_example/barcode_details.dart';
import 'package:flutter_mobile_vision_example/face_details.dart';
import 'package:flutter_mobile_vision_example/ocr_text_details.dart';

void main() => runApp(new MyApp());
Expand Down Expand Up @@ -439,12 +440,12 @@ class FaceWidget extends StatelessWidget {
return new ListTile(
leading: const Icon(Icons.face),
title: new Text(face.id.toString()),
// trailing: const Icon(Icons.arrow_forward),
// onTap: () => Navigator.of(context).push(
// new MaterialPageRoute(
// builder: (context) => new OcrTextDetails(ocrText),
// ),
// ),
trailing: const Icon(Icons.arrow_forward),
onTap: () => Navigator.of(context).push(
new MaterialPageRoute(
builder: (context) => new FaceDetails(face),
),
),
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_mobile_vision
description: Flutter implementation for Google Mobile Vision. Scan Barcodes, Recognize Text and Detect Faces.
version: 0.0.3
version: 0.0.4
author: Eduardo Folly <[email protected]>
homepage: https://github.com/edufolly/flutter_mobile_vision

Expand Down

0 comments on commit 5f7d80b

Please sign in to comment.