2

Why isOperational() in mobile vision text recognizer returns false?

At first, mobile vision only show preview camera and after many tries to get the result, I saw that the texts recognized but in one device it works and in other device does not.

What should I do?

For example, in one device, isOperational() returns false, and it goes to readstate() and after that goes to looper() and stays on it!

in other device it only return false and doesn't go to looper.

I want ask other questions about it:

  1. My first question is: how does isOperational() work? I can't understand it.

  2. Maybe it goes to looper to download the native library in a queue and after many try, at last download completes and work. Can it be correct? Or is it just a bug that it goes to looper? Anywhere, what should I do?

  3. Can I work on this when it works in one device I tried and in other does not? Or it must work in every device to I can work on it? And I get .apk from project but it can't install in devices, why?

  4. Should it check for network?

  5. Should it check for access to the memory?

note: it works with camera API and its deprecated. maybe the problem is with this!

  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();
}

It doesn't produce any error and show preview camera but doesn't recognize texts in some devices.

Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
Arman00
  • 21
  • 2
  • Hi again, if my explain is unclear, please tell me to explain more. I work on this question more than 2 weeks and read a lot of stackoverflow questions but can't find the problem to solve it. – Arman00 Jul 24 '19 at 14:08
  • libocr.so library load status: false Request download for engine ocr is a no-op because rate limiting. (it shows in Run tab) but the internet isn't slow and limiting. – Arman00 Jul 24 '19 at 15:02
  • I checked that google play service is update but it can't help to download vision library :-( – Arman00 Jul 30 '19 at 13:08

0 Answers0