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
<!-- | |
<uses-permission android:name="android.permission.CAMERA" /> | |
Add the following two lines below the line above --> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<!-- ... --> |
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
// public class CameraActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener {... | |
// | |
// define a constant of the needed subfolder | |
public static final String TESS_DATA = "/tessdata"; | |
// | |
// private static final String TAG = "CameraActivity"; | |
//... | |
// protected void onCreate(Bundle savedInstanceState) {... | |
//... | |
// Call method in onCreate before you create a MyTessOCR instance |
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
//... | |
//... | |
//... | |
// Mat usedMat; | |
MyTessOCR mTessOCR; | |
Bitmap bitmap; | |
// | |
// BaseLoaderCallback mLoaderCallBack = new BaseLoaderCallback(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
package com.example.android.myapplication; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import com.googlecode.tesseract.android.TessBaseAPI; | |
import static com.googlecode.tesseract.android.TessBaseAPI.PageSegMode.PSM_AUTO; | |
public final class MyTessOCR { |
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
// ... | |
// ... | |
// JavaCameraView javaCameraView; | |
// Button makeNormal, makeGray, makeCanny, makeDilate, makeErode; | |
Button makeRead; | |
TextView readTextView; | |
Bitmap bitmap; | |
// Mat usedMat; |
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
// include your header file here! | |
#include <com_example_android_myapplication_OpenCvMaker.h> | |
// change the name of this according to the methods name in your header, mine looks like this: | |
JNIEXPORT jint JNICALL Java_com_example_android_myapplication_OpenCvMaker_makeGray | |
(JNIEnv *, jclass, jlong addrInput, jlong addrOutput){ | |
return (jint) toGray((*(Mat*) addrInput),(*(Mat*) addrOutput)); | |
} | |
int toGray(Mat img, Mat& gray) { |
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
//...#include <jni.h> | |
#include <opencv2/opencv.hpp> | |
#include <stdio.h> | |
using namespace cv; | |
using namespace std; | |
// ... | |
// extern "C" { | |
// #endif |
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
// change the package name to yours here | |
package com.example.android.opencvdemo; | |
public class OpenCvMaker { | |
private static boolean canny; | |
private static boolean dilate; | |
private static boolean erode; | |
private static boolean gray; | |
private static boolean normal; |
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
//... | |
// JavaCameraView javaCameraView; | |
// Mat usedMat; | |
Button makeNormal, makeGray, makeCanny, makeDilate, makeErode; | |
//... | |
// BaseLoaderCallback mLoaderCallBack = new BaseLoaderCallback(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
protected void deliverAndDrawFrame(CvCameraViewFrame frame) { | |
Mat modified; | |
if (mListener != null) { | |
modified = mListener.onCameraFrame(frame); | |
} else { | |
modified = frame.rgba(); | |
} |
NewerOlder