Android Question Can anybody help complite B4A lib for me

Discussion in 'Android Questions' started by laomms, Jul 14, 2018 at 3:37 AM.

  1. laomms

    laomms Member Licensed User

    Code:
    package CamOcr;

    import anywheresoftware.b4a.AbsObjectWrapper;

    import anywheresoftware.b4a.BA;
    import anywheresoftware.b4a.BA.Author;
    import anywheresoftware.b4a.BA.Hide;
    import anywheresoftware.b4a.BA.Pixel;
    import anywheresoftware.b4a.BA.ShortName;
    import anywheresoftware.b4a.BA.Version;
    import anywheresoftware.b4a.BALayout;
    import anywheresoftware.b4a.BA.DependsOn;
    import anywheresoftware.b4a.keywords.Common.DesignerCustomView;
    import anywheresoftware.b4a.objects.LabelWrapper;
    import anywheresoftware.b4a.objects.PanelWrapper;
    import anywheresoftware.b4a.objects.ViewWrapper;
    import anywheresoftware.b4a.BA.ActivityObject;
    import anywheresoftware.b4a.BA.Events;
    import anywheresoftware.b4a.IOnActivityResult;
    import anywheresoftware.b4a.BA.Permissions;

    import android.content.Intent;
    import android.os.Bundle;
    import android.app.Activity;
    import android.util.Log;
    import android.view.View;
    import android.widget.CompoundButton;
    import android.widget.TextView;
    import android.graphics.Color;





    @ActivityObject
    @DependsOn(values={
    "android-support-v7-appcompat""android-support-v4""com.google.android.gms:play-services-vision",
                       
    "com.google.android.gms:play-services-base""com.google.android.gms:play-services-basement"})
    @Permissions(values={"android.permission.CAMERA"})
    //"com.android.support:design", "google-play-services", "android-support-design",


    public class CamOcr extends Activity {
      SurfaceView cameraPreview;
     
      private void createCameraSource()
      {
        TextRecognizer localTextRecognizer = new TextRecognizer.Builder(this).build();
        final CameraSource localCameraSource = new CameraSource.Builder(this, localTextRecognizer).setAutoFocusEnabled(true).setRequestedPreviewSize(1600, 1024).build();
        this.cameraPreview.getHolder().addCallback(new SurfaceHolder.Callback()
        {
          public void surfaceChanged(SurfaceHolder paramAnonymousSurfaceHolder, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {}
     
          public void surfaceCreated(SurfaceHolder paramAnonymousSurfaceHolder)
          {
            if (ActivityCompat.checkSelfPermission(ScanTextActivity.this, "android.permission.CAMERA") != 0) {}
            for (;;)
            {
              return;
              try
              {
                localCameraSource.start(ScanTextActivity.this.cameraPreview.getHolder());
              }
              catch (IOException localIOException)
              {
                localIOException.printStackTrace();
              }
            }
          }
     
          public void surfaceDestroyed(SurfaceHolder paramAnonymousSurfaceHolder)
          {
            localCameraSource.stop();
          }
        });
        localTextRecognizer.setProcessor(new Detector.Processor()
        {
          public void receiveDetections(Detector.Detections<TextBlock> paramAnonymousDetections)
          {
            SparseArray localSparseArray = paramAnonymousDetections.getDetectedItems();
            for (int i = 0;; i++) {
              if ((i < localSparseArray.size()) && (i < 10))
              {
                String str = ((TextBlock)localSparseArray.valueAt(i)).getValue().replaceAll("[^0-9]", "");
                Log.d("tag", "Value: " + str);
                if ((str.length() == 54) || (str.length() == 63))
                {
                  Log.d("tag", "Value: " + str);
                  MicrosoftWebPage.insertExt = str;
                  MainActivity.insertExt = str;
                  Intent localIntent = new Intent();
                  localIntent.putExtra("textblock_result", str);
                  ScanTextActivity.this.setResult(0, localIntent);
                  localSparseArray.clear();
                  ScanTextActivity.this.finish();
                }
              }
              else
              {
                return;
              }
            }
          }
     
          public void release() {}
        });
      }
     
      protected void onCreate(Bundle paramBundle)
      {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_main);
        this.mSurfaceView = (SurfaceView) findViewById(R.id.SurfaceViewPreview);
        createCameraSource();
      }
    }
     

    Attached Files:

    • abc.png
      abc.png
      File size:
      15.6 KB
      Views:
      13
    • src.zip
      File size:
      44 KB
      Views:
      0
    Last edited: Jul 18, 2018 at 3:47 PM
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice