This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// Initialize the Mobile Ads SDK. | |
MobileAds.initialize(this,getString(R.string.admob_app_id)); | |
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this); | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
... | |
<string name="admob_app_id">ca-app-pub-3940256099942544~3347511713</string> | |
<string name="ad_unit_id">ca-app-pub-3940256099942544/5224354917</string> | |
... | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
compile 'com.google.firebase:firebase-ads:11.8.0' | |
... | |
} | |
//Dont forget to apply the plugin below | |
apply plugin: 'com.google.gms.google-services' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
... | |
classpath 'com.google.gms:google-services:3.0.0' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textRecognizer.setProcessor(new Detector.Processor<TextBlock>() { | |
@Override | |
public void release() { | |
} | |
/** | |
* Detect all the text from camera using TextBlock and the save values into a stringBuilder | |
* which will then be set to the textView. | |
* */ | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mCameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer) | |
.setFacing(CameraSource.CAMERA_FACING_BACK) | |
.setRequestedPreviewSize(1280, 1024) | |
.setAutoFocusEnabled(true) | |
.setRequestedFps(2.0f) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void startCameraSource() { | |
//Create the TextRecognizer | |
final TextRecognizer textRecognizer = new TextRecognizer.Builder(getApplicationContext()).build(); | |
if (!textRecognizer.isOperational()) { | |
Log.w(TAG, "Detector dependencies not loaded yet"); | |
} else { | |
//Initialize camerasource to use high resolution and set Autofocus on. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:weightSum="5" | |
tools:context="com.tuts.prakash.simpleocr.MainActivity"> | |
<SurfaceView | |
android:id="@+id/surfaceView" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.tuts.prakash.simpleocr"> | |
<uses-permission android:name="android.permission.CAMERA"/> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launcher_round" | |
android:supportsRtl="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
compile 'com.google.android.gms:play-services-vision:11.0.4' | |
... | |
} |