This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onClick(v: View) { | |
cameraView.captureImage { cameraKitImage -> | |
// Get the Bitmap from the captured shot | |
getQRCodeDetails(cameraKitImage.bitmap) | |
} | |
} | |
private fun getQRCodeDetails(bitmap: Bitmap) { | |
val options = FirebaseVisionBarcodeDetectorOptions.Builder() | |
.setBarcodeFormats( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (page in firebaseVisionCloudText.getPages()) { | |
val languages = page.getTextProperty().getDetectedLanguages() | |
val height = page.getHeight() | |
val width = page.getWidth() | |
val confidence = page.getConfidence() | |
for (block in page.getBlocks()) { | |
val boundingBox : Rect = block.getBoundingBox() | |
val blockLanguages = block.getTextProperty().getDetectedLanguages() | |
val blockConfidence = block.getConfidence() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fab_take_photo.setOnClickListener { | |
// cameraView is a custom View which provides camera preview | |
cameraView.captureImage { cameraKitImage -> | |
// Get the Bitmap from the captured shot and use it to make the API call | |
getCardDetails(cameraKitImage.bitmap) | |
} | |
} | |
private fun getCardDetails(bitmap: Bitmap) { | |
val image = FirebaseVisionImage.fromBitmap(bitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation 'com.google.firebase:firebase-ml-vision:16.0.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getLabelsFromDevice(bitmap: Bitmap) { | |
... | |
val detector : FirebaseVisionCloudLabelDetector = FirebaseVision.getInstance().visionCloudLabelDetector | |
detector.detectInImage(image) | |
.addOnSuccessListener { | |
for(firebaseVision : FirebaseVisionCloudLabel in it){ | |
... | |
} | |
} | |
.addOnFailureListener { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fab_take_photo.setOnClickListener { | |
// cameraView is a custom View which provides camera preview | |
cameraView.captureImage { cameraKitImage -> | |
// Get the Bitmap from the captured shot and use it to make the API call | |
getLabelsFromDevice(cameraKitImage.bitmap) | |
} | |
} | |
private fun getLabelsFromDevice(bitmap: Bitmap) { | |
val image : FirebaseVisionImage = FirebaseVisionImage.fromBitmap(bitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.google.firebase:firebase-ml-vision:15.0.0' | |
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
.... | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text(widget.title), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => new _MyHomePageState(); | |
} | |
.... |