| class info |
| com.huawei.hms.mlplugin.card.gcr.MLGcrCapture |
| Represents the general card recognition class. |
| Method |
| public void captureImage(android.graphics.Bitmap bitmap, Object object, MLGcrCapture.Callback callback) |
| Enables the plug-in for recognizing static images of general cards. |
Parameters
| Parameter name | Parameter desc |
| bitmap | Static image. |
| object | Reserved. |
| callback | Recognition result callback. |
Sample Code
- // Create a general card recognition configurator.
- MLGcrCaptureConfig config = new MLGcrCaptureConfig.Factory().create();
- MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(config);
- ocrManager.captureImage(bitmap, object, callback);
Parameters
| Parameter name | Parameter desc |
| context | Activity or application context. |
| object | Reserved. |
| callback | Recognition result callback. |
Sample Code
- // Create a general card recognition configurator.
- MLGcrCaptureConfig cardConfig = new MLGcrCaptureConfig.Factory().create();
- // Create a general card recognition UI configurator.
- MLGcrCaptureUIConfig uiConfig = new MLGcrCaptureUIConfig.Factory()
- // Set the color of the scanning box.
- .setScanBoxCornerColor(Color.GREEN)
- // Set the tip text in the scanning box. It is recommended that the tip text contain fewer than 30 characters.
- .setTipText("Recognizing, align edges")
- // Set the screen orientation. Three modes are supported.
- // MLGcrCaptureUIConfig.ORIENTATION_AUTO: adaptive mode. The physical sensor decides the screen orientation.
- // MLGcrCaptureUIConfig.ORIENTATION_LANDSCAPE: landscape mode. The screen width is greater than the screen height.
- // MLGcrCaptureUIConfig.ORIENTATION_PORTRAIT: portrait mode. The screen height is greater than the screen width.
- .setOrientation(MLGcrCaptureUIConfig.ORIENTATION_AUTO)
- .create();
- // Method 1: Create a general card recognition processor based on the customized card recognition UI configurator.
- MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig, uiConfig);
- // Method 2: Create a general card recognition processor using the default UI.
- MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig);
- // Bind the general card recognizer and the recognition result callback method.
- ocrManager.capturePhoto(this, object, callback);
| Method |
| public void capturePreview(android.content.Context context, Object object, MLGcrCapture.Callback callback) |
| Enables the plug-in for recognizing general cards in camera streams. |
Parameters
| Parameter name | Parameter desc |
| context | Activity or application context. |
| object | Reserved. |
| callback | Recognition result callback. |
Sample Code
- // Create a general card recognition configurator.
- MLGcrCaptureConfig cardConfig = new MLGcrCaptureConfig.Factory().create();
- // Create a general card recognition UI configurator.
- MLGcrCaptureUIConfig uiConfig = new MLGcrCaptureUIConfig.Factory()
- // Set the color of the scanning box.
- .setScanBoxCornerColor(Color.GREEN)
- // Set the tip text in the scanning box. It is recommended that the tip text contain fewer than 30 characters.
- .setTipText("Recognizing, align edges")
- // Set the screen orientation. Three modes are supported.
- // MLGcrCaptureUIConfig.ORIENTATION_AUTO: adaptive mode. The physical sensor decides the screen orientation.
- // MLGcrCaptureUIConfig.ORIENTATION_LANDSCAPE: landscape mode. The screen width is greater than the screen height.
- // MLGcrCaptureUIConfig.ORIENTATION_PORTRAIT: portrait mode. The screen height is greater than the screen width.
- .setOrientation(MLGcrCaptureUIConfig.ORIENTATION_AUTO)
- .create();
- // Method 1: Create a general card recognizer based on the customized card recognition UI configurator.
- MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig, uiConfig);
- // Method 2: Create a general card recognizer using the default UI.
- MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig);
- // Bind the general card recognizer and the recognition result callback method.
- ocrManager.capturePreview(this, object, callback);