-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.2" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
implementation 'androidx.appcompat:appcompat:1.3.0' | ||
implementation project(path: ':java') | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.namangarg.androiddocumentscannerandfilter; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.namangarg.androiddocumentscannerandfilter.test", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.namangarg.androiddocumentscannerandfilter"> | ||
|
||
/ | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.namangarg.androiddocumentscannerandfilter; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import com.namangarg.androiddocumentscannerandfilter.Filters.BlackAndWhiteFilter; | ||
import com.namangarg.androiddocumentscannerandfilter.Filters.GreyScaleFilter; | ||
import com.namangarg.androiddocumentscannerandfilter.Filters.LightenFilter; | ||
import com.namangarg.androiddocumentscannerandfilter.Filters.MagicFilter; | ||
import com.namangarg.androiddocumentscannerandfilter.Filters.ShadowRemovelFilter; | ||
|
||
import org.opencv.android.OpenCVLoader; | ||
|
||
public class DocumentFilter { | ||
|
||
static { | ||
OpenCVLoader.initDebug(); | ||
} | ||
|
||
public static Bitmap getMagicFilter(Bitmap bitmap){ | ||
return MagicFilter.getMagicFilteredImage(bitmap); | ||
} | ||
|
||
public static Bitmap getShadowRemoval(Bitmap bitmap){ | ||
return ShadowRemovelFilter.getShadowFilteredImage(bitmap); | ||
} | ||
|
||
public static Bitmap getGreyScaleFilter(Bitmap bitmap){ | ||
return GreyScaleFilter.getGreyFilteredImage(bitmap); | ||
} | ||
|
||
public static Bitmap getLightenFilter(Bitmap bitmap){ | ||
return LightenFilter.getLightenFilteredImage(bitmap); | ||
} | ||
|
||
public static Bitmap getBlackAndWhiteFilter(Bitmap bitmap){ | ||
return BlackAndWhiteFilter.getBlackAndWhiteFilteredImage(bitmap); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.namangarg.androiddocumentscannerandfilter.Filters; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import org.opencv.android.Utils; | ||
import org.opencv.core.CvType; | ||
import org.opencv.core.Mat; | ||
import org.opencv.imgproc.Imgproc; | ||
|
||
public class BlackAndWhiteFilter { | ||
|
||
public static Bitmap getBlackAndWhiteFilteredImage(Bitmap bitmap){ | ||
// adaptive threshold with median blur | ||
// works best on text written on blank paper instead of ruled ones. | ||
Mat mat = new Mat(bitmap.getWidth(),bitmap.getHeight(), CvType.CV_8UC1); | ||
Utils.bitmapToMat(bitmap, mat); | ||
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY); | ||
Imgproc.medianBlur(mat,mat,5); | ||
Imgproc.adaptiveThreshold(mat, mat,255,Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY,11,3); | ||
Bitmap result = Bitmap.createBitmap(mat.cols(),mat.rows(),Bitmap.Config.ARGB_8888); | ||
Utils.matToBitmap(mat, result); | ||
mat.release(); | ||
return result; | ||
} | ||
} |