Сначала мобильное зрение показывает только камеру предварительного просмотра, а после многих попыток получить В результате я увидел, что тексты распознаются, но в одном устройстве работает, а в другом нет.
Что делать?
Например, в одном устройстве isOperational() возвращает false и переходит к readstate(), а после этого переходит к loer() и остается на нем!
на другом устройстве он возвращает только false и не переходит в циклический цикл.
Я хочу задать еще вопросы по этому поводу:
- Мой первый вопрос: как работает isOperational()? Я не могу этого понять.
- Может быть, он обращается к луперу, чтобы загрузить собственную библиотеку в очередь, и после многих попыток, наконец, загрузка завершается и работает. Может ли это быть правильно? Или это просто баг, что он уходит в лупер? Где угодно, что мне делать?
- Могу ли я работать над этим, если на одном устройстве, которое я пробовал, оно работает, а на другом нет? Или он должен работать на каждом устройстве, чтобы я мог на нем работать? И я получаю .apk из проекта, но его не удается установить на устройства. Почему?
- Должен ли он проверять наличие сети?
- Нужно ли проверять доступ к памяти?
Код: Выделить всё
TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
textRecognizer.setProcessor(new OcrDetectorProcessor(graphicOverlay));
if (!textRecognizer.**isOperational**()) {
// Note: The first time that an app using a Vision API is installed on a
// device, GMS will download a native libraries to the device in order to do detection.
// Usually this completes before the app is run for the first time. But if that
// download has not yet completed, then the above call will not detect any text,
// barcodes, or faces.
//
// isOperational() can be used to check if the required native libraries are currently
// available. The detectors will automatically become operational once the library
// downloads complete on device.
Log.w(TAG, "Detector dependencies are not yet available.");
// Check for low storage. If there is low storage, the native library will not be
// downloaded, so detection will not become operational.*
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
if (hasLowStorage) {
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
Log.w(TAG, getString(R.string.low_storage_error));
}
}
*// Creates and starts the camera. Note that this uses a higher resolution in comparison
// to other detection examples to enable the text recognizer to detect small pieces of text.*
cameraSource =
new CameraSource.Builder(getApplicationContext(), textRecognizer)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1280, 1024)
.setRequestedFps(2.0f)
.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO : null)
.build();
}
Подробнее здесь: https://stackoverflow.com/questions/571 ... n-true-and