Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gemilepus committed Jan 5, 2022
1 parent e3b8584 commit 63287c5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-- /tessdata must be copied to the Android device in a subdirectory named tessdata.
<img src="https://github.com/gemilepus/Android-Camera-OCR/blob/master/Screenshot_20200924-111840798.jpg" width="300" />
<img src="https://github.com/gemilepus/Android-Camera-OCR/blob/master/Screenshot_20200924-111902185.jpg" width="300" />
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

package com.example.user.tesseracttess_twoocr.Camera2API;

import static org.opencv.imgproc.Imgproc.MORPH_ELLIPSE;
import static org.opencv.imgproc.Imgproc.MORPH_OPEN;
import static org.opencv.imgproc.Imgproc.THRESH_BINARY;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ImageFormat;
import android.graphics.Matrix;
import android.graphics.Point;
Expand Down Expand Up @@ -57,6 +59,8 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.Size;
import android.util.SparseIntArray;
Expand All @@ -73,9 +77,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.example.user.tesseracttess_twoocr.Camera2API.MessageView;
import com.example.user.tesseracttess_twoocr.R;

import com.example.user.tesseracttess_twoocr.VariableEditor;
import com.googlecode.tesseract.android.TessBaseAPI;
import com.otaliastudios.cameraview.AspectRatio;
Expand Down Expand Up @@ -103,14 +105,6 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

import static org.opencv.imgproc.Imgproc.MORPH_CLOSE;
import static org.opencv.imgproc.Imgproc.MORPH_ELLIPSE;
import static org.opencv.imgproc.Imgproc.MORPH_GRADIENT;
import static org.opencv.imgproc.Imgproc.MORPH_OPEN;
import static org.opencv.imgproc.Imgproc.THRESH_BINARY;
import static org.opencv.imgproc.Imgproc.THRESH_OTSU;
import static org.opencv.photo.Photo.INPAINT_NS;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class Camera2BasicFragment extends Fragment implements View.OnClickListener, ActivityCompat.OnRequestPermissionsResultCallback , View.OnTouchListener {

Expand Down Expand Up @@ -517,7 +511,7 @@ public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull C
* @param text The message to show
*/
private void showToast(final String text) {
final Activity activity = getActivity();
final Activity activity = this.getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
Expand Down Expand Up @@ -708,8 +702,9 @@ public void onClick(View view) {
}
case R.id.picture: {

takePicture();
Click_takepicture = true;
takePicture();


final ImageButton imageButton = getActivity().findViewById(R.id.picture);
imageButton.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
Expand Down Expand Up @@ -49,6 +48,8 @@
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.Size;
import android.util.SparseIntArray;
Expand All @@ -65,7 +66,6 @@
import android.widget.Toast;
import android.widget.VideoView;

import com.example.user.tesseracttess_twoocr.Camera2API.MessageView;
import com.example.user.tesseracttess_twoocr.R;

import java.io.File;
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/res/layout/fragment_camera2_basic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down Expand Up @@ -71,7 +72,7 @@

android:background="@drawable/badge_circle_gray"

android:src="@android:drawable/ic_menu_camera" />
app:srcCompat="@android:drawable/ic_menu_camera" />


<ImageButton
Expand All @@ -83,7 +84,7 @@
android:layout_marginLeft="40dp"
android:background="@drawable/badge_circle_gray"

android:src="@android:drawable/radiobutton_off_background" />
app:srcCompat="@android:drawable/radiobutton_off_background" />

<ImageButton
android:id="@+id/info"
Expand All @@ -95,7 +96,7 @@

android:background="@drawable/button_border"

android:src="@android:drawable/ic_menu_gallery" />
app:srcCompat="@android:drawable/ic_menu_gallery" />

</FrameLayout>

Expand All @@ -107,7 +108,8 @@
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:layout_marginEnd="0dp"
android:text="TEST" />
android:text="TEST"
android:visibility="invisible" />

<TextView
android:id="@+id/text_room"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_camera2_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down Expand Up @@ -63,7 +64,7 @@

android:background="@drawable/badge_circle_gray"

android:src="@android:drawable/ic_menu_camera" />
app:srcCompat="@android:drawable/ic_menu_camera" />


<ImageButton
Expand All @@ -74,7 +75,7 @@
android:layout_marginRight="20dp"
android:background="#00FFFFFF"

android:src="@android:drawable/ic_menu_gallery" />
app:srcCompat="@android:drawable/ic_menu_gallery" />

</FrameLayout>

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:7.0.4'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
4 changes: 4 additions & 0 deletions openCVLibrary342/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ android {
}
}
}

dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package org.opencv.android;

import java.util.List;

import org.opencv.BuildConfig;
import org.opencv.R;
import org.opencv.core.Mat;
import org.opencv.core.Size;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
Expand All @@ -20,6 +13,13 @@
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import org.opencv.BuildConfig;
import org.opencv.R;
import org.opencv.core.Mat;
import org.opencv.core.Size;

import java.util.List;

/**
* This is a basic class, implementing the interaction with Camera and OpenCV library.
* The main responsibility of it - is to control when camera can be enabled, process the frame,
Expand Down

0 comments on commit 63287c5

Please sign in to comment.