Hi there fellow sketchware coders,
I know a lot of you’re engaged on some initiatives which requires ocr (optical persona recognition) But no longer getting success in ocr. So At the present time I’m here to fresh sketchware ocr project and tutorial.
Existing: All files and links are offered under this text.
Some examples of app the place it is possible you’ll per chance per chance expend ocr
• Questions search app
• Tanslator app
• Moreover it is possible you’ll per chance per chance regulate it for extracting text from photos
On this project only realtime ocr is made. In the event you would like text from photos ocr. Then comment under this publish.
To delivery out,
Make a project in sketchware
It goes to be important to assemble google vision library. In the event you haven’t got then please download it and if you happen to will gather gotten then enable it.
After that it is possible you’ll gather gotten to form your app gather
You are going to need
1. A linear for making of digicam layout
2. A textview for getting text.
Gaze at my example
On this instance linear1 is important layout. Linear2 is digicam layout. and textview1 is textview for getting text. Other linears are correct for other expend.
Turning on most important library
It goes to be important to steered Google procedure library ( no need of Google procedure api key.)
First with title locate_vrb
Second with title activity
In first moreblock locate_vrb add a asd with code
Code:-
}
com.google.android.gms.vision.CameraSource cameraSource;
SurfaceView cameraView;
{
In 2d moreblock activity add this asd code
com.google.android.gms.vision.text.TextRecognizer textRecognizer = new com.google.android.gms.vision.text.TextRecognizer.Builder(getApplicationContext()).fabricate();
if (!textRecognizer.isOperational()) {
android.util.Log.w(“MainActivity”, “Detector dependencies are no longer but available”);
} else {
cameraSource = new com.google.android.gms.vision.CameraSource.Builder(getApplicationContext(), textRecognizer)
.setFacing(com.google.android.gms.vision.CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1280, 1024)
.setRequestedFps(2.0f)
.setAutoFocusEnabled(exact)
.fabricate();
}
cameraView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
try {
cameraSource.delivery(cameraView.getHolder());
} purchase (java.io.IOException e) {
e.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
cameraSource.end();
}
});
textRecognizer.setProcessor(new com.google.android.gms.vision.Detector.Processor() {
@Override
public void open() {
}
@Override
public void receiveDetections(com.google.android.gms.vision.Detector.Detections detections) {
final SparseArray items = detections.getDetectedItems();
if(items.size() != 0)
{
textview1.publish(new Runnable() {
@Override
public void flee() {
StringBuilder stringBuilder = new StringBuilder();
for(int i =0;i
{
com.google.android.gms.vision.text.TextBlock item = items.valueAt(i);
stringBuilder.append(item.getValue());
stringBuilder.append(“n”);
}
textview1.setText(stringBuilder.toString());
}
});
}
}
});
//Commerce textview1 along with your TextView Id
In oncreate match add a asd code
cameraView = new SurfaceView(this);
linear2.addView(cameraView);
Right here linear2 is ogle containing digicam it is possible you’ll per chance per chance alternate it.
Moreover add activity moreblock in it.
Closing step:-
Add a digicam part for digicam permissions.
After that flee this project and now that it is possible you’ll gather gotten a working ocr app in sketchware.
In the event to receive any error, then comment under this publish. I’ll surely answer to comment.
No comments:
Post a Comment