Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DevLucem/Android-Text-Scanner

Repository files navigation

Text and Numbers Recognizer Lucem

This library is an easy to implement and use for scanning text and numbers using the camera (Optical Character Recognition) on android devices.

You can view my my app here where i use this library Scan Credo I appreciate your download and rating of this app.

Scan Sample

Implementation

Add jitpack to repositories in the root build.gradle file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add this dependency line in your build.gradle app level

dependencies {
	implementation 'com.github.Lucem-Anb:android-text-scanner:@Version'
}

πŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒπŸ˜ƒ

Usage

This library uses the SurfaceView to display the camera. Detected values are accessed using a listener. There are two ways of using this library, let's start with the simple one

Option 1

Create the ScannerView in your Activity or fragment

<com.lucem.anb.characterscanner.ScannerView
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:id="@+id/scanner"/>

Start the scan whenever you want

ScannerView scanner = findViewById(R.id.scanner);
scanner.setOnDetectedListener(this, new ScannerListener() {
 @Override
 public void onDetected(String detections) {
 Toast.makeText(MainActivity.this, detections, Toast.LENGTH_SHORT).show();
 }
 @Override
 public void onStateChanged(String state, int i) {
 Log.d("state", state);
 }
 });

Option 2

Create a surface view in your activity or fragment

<SurfaceView
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:id="@+id/surface"/>

Initialize your Scanner and pass your activity and surface view

SurfaceView surfaceView = findViewById(R.id.surface);
Scanner scanner = new Scanner(this, surfaceView, new ScannerListener() {
 @Override
 public void onDetected(String detections) {
 Toast.makeText(MainActivity.this, detections, Toast.LENGTH_SHORT).show();
 }
 @Override
 public void onStateChanged(String state, int i) {
 Log.d("state", state);
 }
 });
 

More Customization

showToasts(boolean); Enable or disable recognition engine alert

getState(); return a String of the current state

onStateChanged(); Called when the scanning state is changed

setScanning(boolean) Start or Stop scanning state

Latest Version: 0.1.0

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /