Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
67fa8fd
Add a placeholder for the live preview screen.
dustin-graham Jul 7, 2018
c864974
WIP. basic barcode detection impl.
dustin-graham Jul 7, 2018
73f4fe2
WIP.
dustin-graham Jul 7, 2018
04395d8
rotate image on Android prior to creating the FirebaseVisionImage
dustin-graham Jul 9, 2018
cb953e7
Add a basic camera preview implementation
dustin-graham Jul 9, 2018
973b32c
resume camera preview
dustin-graham Jul 9, 2018
8689993
strip out picture taking and video recording from Android camera impl
dustin-graham Jul 9, 2018
beaaa5f
android: insert per-frame handling of preview images
dustin-graham Jul 9, 2018
1ad5ae7
android: pipe image frames to MLKit Barcode detector
dustin-graham Jul 9, 2018
76930fc
android: send count of recognized barcodes
dustin-graham Jul 10, 2018
a0a1b62
android: get barcode bounding boxes displaying in Flutter
dustin-graham Jul 10, 2018
56272e4
ios: Add basic barcode scanning.
dustin-graham Jul 10, 2018
4e10f44
ios: Add live view barcode scanning
dustin-graham Jul 11, 2018
1313564
WIP: live text detection
dustin-graham Jul 13, 2018
99196c3
WIP: android live text detection.
dustin-graham Jul 14, 2018
dacaccf
WIP: Android legacy camera detector impl. Min SDK on this lib is 16.
dustin-graham Jul 19, 2018
6054f37
Android: allow detector and resolution to be set
dustin-graham Jul 19, 2018
de93bc7
Working live detection implementation for Android and iOS
dustin-graham Jul 20, 2018
7c8cca4
Merge remote-tracking branch 'upstream/master' into live_preview
dustin-graham Jul 20, 2018
4c5bf21
update Android with latest from upstream.
dustin-graham Jul 20, 2018
2219e8e
update both Android and iOS live view to work with new detectors.
dustin-graham Jul 20, 2018
8477cf9
Merge remote-tracking branch 'upstream/master' into live_preview
dustin-graham Jul 20, 2018
d1d24e7
remove unused ExifInterface dependency
dustin-graham Jul 21, 2018
b85bdb8
resolve dart analysis warnings.
dustin-graham Jul 21, 2018
a86fe62
reformat code.
dustin-graham Jul 21, 2018
e688aef
fix barcode test
dustin-graham Jul 21, 2018
762b04b
revert accidental camera plugin changes
dustin-graham Jul 21, 2018
8190bff
clang-format iOS files
dustin-graham Jul 21, 2018
f98ce94
Clean up LiveView implementation and fix formatting issues.
dustin-graham Jul 26, 2018
9fdee7c
Merge remote-tracking branch 'upstream/master' into live_preview
dustin-graham Jul 26, 2018
d7e6b32
update to support new LabelDetector.
dustin-graham Jul 26, 2018
776294d
undo inadvertent formatting changes outside firebase_ml_vision.
dustin-graham Jul 26, 2018
ef72e0a
add camera plugin as a dependency to firebase_ml_vision
dustin-graham Jul 27, 2018
543b6d7
wIP: send detected data back to flutter from live feed.
dustin-graham Jul 27, 2018
22e10c2
fix formatting issues.
dustin-graham Jul 27, 2018
858b2aa
restore normal camera functionality.
dustin-graham Jul 27, 2018
5bbbcbc
Merge remote-tracking branch 'upstream/master' into live_preview_came…
dustin-graham Aug 9, 2018
e91181f
present detection boundaries in Flutter from camera plugin integration
dustin-graham Aug 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resume camera preview
make stream handling more appealing
  • Loading branch information
dustin-graham committed Jul 9, 2018
commit 973b32c40ab76f7ccdacb7106d1ff8f63d4c449d
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ public void onActivityResumed(Activity activity) {
camera.setRequestingPermission(false);
return;
}
// TODO: figure out how to open camera iff the app is presenting a live preview
// if (activity == FirebaseMlVisionPlugin.this.activity) {
// if (camera != null) {
// camera.open(null);
// }
// }
if (activity == FirebaseMlVisionPlugin.this.activity) {
if (camera != null) {
camera.open(null);
}
}
}

@Override
Expand Down Expand Up @@ -137,6 +136,7 @@ public void onMethodCall(MethodCall call, Result result) {
case "dispose": {
if (camera != null) {
camera.dispose();
camera = null;
}
result.success(null);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private void prepareMediaRecorder(String outputFilePath) throws IOException {
mediaRecorder.prepare();
}

private void open(@Nullable final MethodChannel.Result result) {
public void open(@Nullable final MethodChannel.Result result) {
if (!hasCameraPermission()) {
if (result != null) result.error("cameraPermission", "Camera permission not granted", null);
} else {
Expand Down
79 changes: 30 additions & 49 deletions packages/firebase_ml_vision/example/lib/live_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LivePreviewState extends State<LivePreview> {
await controller.initialize();
yield new LiveViewCameraLoadStateReady(controller);
} on LiveViewCameraException catch (e) {
print("got an error: $e");
yield new LiveViewCameraLoadStateFailed(
"error initializing camera controller: ${e.toString()}");
}
Expand All @@ -50,58 +51,38 @@ class LivePreviewState extends State<LivePreview> {

@override
Widget build(BuildContext context) {
if (_isShowingPreview) {
return new StreamBuilder(
stream: _prepareCameraPreview(),
builder: (BuildContext context,
AsyncSnapshot<LiveViewCameraLoadState> snapshot) {
print("snapshot data: ${snapshot.data}");
final loadState = snapshot.data;
if (loadState != null) {
if (loadState is LiveViewCameraLoadStateLoading) {
return const Text("loading camera preview…");
} else if (loadState is LiveViewCameraLoadStateLoaded) {
// get rid of previous controller if there is one
return new Text("loaded camera name: ${loadState
.cameraDescription
.name}");
} else if (loadState is LiveViewCameraLoadStateReady) {
////// BINGO!!!, the camera is ready to present
if (_readyLoadState != loadState) {
_readyLoadState?.dispose();
_readyLoadState = loadState;
}
return new AspectRatio(
aspectRatio: _readyLoadState.controller.value.aspectRatio,
child: new LiveView(_readyLoadState.controller),
);
} else if (loadState is LiveViewCameraLoadStateFailed) {
return new Text("error loading camera ${loadState
.errorMessage}");
} else {
return const Text("Unknown Camera error");
return new StreamBuilder<LiveViewCameraLoadState>(
stream: _prepareCameraPreview(),
initialData: new LiveViewCameraLoadStateLoading(),
builder: (BuildContext context,
AsyncSnapshot<LiveViewCameraLoadState> snapshot) {
final loadState = snapshot.data;
if (loadState != null) {
if (loadState is LiveViewCameraLoadStateLoading ||
loadState is LiveViewCameraLoadStateLoaded) {
return const Text("loading camera preview…");
}
if (loadState is LiveViewCameraLoadStateReady) {
////// BINGO!!!, the camera is ready to present
if (_readyLoadState != loadState) {
_readyLoadState?.dispose();
_readyLoadState = loadState;
}
return new AspectRatio(
aspectRatio: _readyLoadState.controller.value.aspectRatio,
child: new LiveView(_readyLoadState.controller),
);
} else if (loadState is LiveViewCameraLoadStateFailed) {
return new Text("error loading camera ${loadState
.errorMessage}");
} else {
return new Text("Camera error: ${snapshot.error.toString()}");
return const Text("Unknown Camera error");
}
},
);
} else {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Current detector: ${widget.detector}"),
RaisedButton(
onPressed: () {
setState(() {
_isShowingPreview = true;
});
},
child: new Text("Start Live View"),
),
],
);
}
} else {
return new Text("Camera error: ${snapshot.error.toString()}");
}
},
);
}
}

Expand Down