Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
garg-lucifer committed Jul 26, 2021
0 parents commit 455bf33
Show file tree
Hide file tree
Showing 389 changed files with 43,011 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
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
134 changes: 134 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions AndroidDocumentScannerAndFilter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions AndroidDocumentScannerAndFilter/build.gradle
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'

}
Empty file.
21 changes: 21 additions & 0 deletions AndroidDocumentScannerAndFilter/proguard-rules.pro
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());
}
}
5 changes: 5 additions & 0 deletions AndroidDocumentScannerAndFilter/src/main/AndroidManifest.xml
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;
}
}
Loading

0 comments on commit 455bf33

Please sign in to comment.