Skip to content

Commit

Permalink
Change deprecated TextRecognition#getClient() API in code snippets
Browse files Browse the repository at this point in the history
Change-Id: I0026160163cefe0f4a429e3c25ee29b5ed4db799
  • Loading branch information
Yun Liu committed May 19, 2021
1 parent 131b1e1 commit 26a3f10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.mlkit.vision.text.Text;
import com.google.mlkit.vision.text.TextRecognition;
import com.google.mlkit.vision.text.TextRecognizer;
import com.google.mlkit.vision.text.TextRecognizerOptions;

public class TextRecognitionActivity extends AppCompatActivity {

Expand All @@ -40,7 +41,7 @@ protected void onCreate(Bundle savedInstanceState) {
private void recognizeText(InputImage image) {

// [START get_detector_default]
TextRecognizer recognizer = TextRecognition.getClient();
TextRecognizer recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS);
// [END get_detector_default]

// [START run_detector]
Expand Down Expand Up @@ -102,7 +103,7 @@ private void processTextBlock(Text result) {

private TextRecognizer getTextRecognizer() {
// [START mlkit_local_doc_recognizer]
TextRecognizer detector = TextRecognition.getClient();
TextRecognizer detector = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS);
// [END mlkit_local_doc_recognizer]

return detector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.text.Text
import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.TextRecognizer
import com.google.mlkit.vision.text.TextRecognizerOptions

class TextRecognitionActivity : AppCompatActivity() {

private fun recognizeText(image: InputImage) {

// [START get_detector_default]
val recognizer = TextRecognition.getClient()
val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
// [END get_detector_default]

// [START run_detector]
Expand Down Expand Up @@ -81,7 +82,7 @@ class TextRecognitionActivity : AppCompatActivity() {

private fun getTextRecognizer(): TextRecognizer {
// [START mlkit_local_doc_recognizer]
return TextRecognition.getClient()
return TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
// [END mlkit_local_doc_recognizer]
}
}

0 comments on commit 26a3f10

Please sign in to comment.