-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,462 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.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 | ||
local.properties |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
namespace 'com.zebra.freeformocrsample1' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.zebra.freeformocrsample1" | ||
minSdk 30 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.9.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
} |
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
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 |
26 changes: 26 additions & 0 deletions
26
...ample1/app/src/androidTest/java/com/zebra/freeformocrsample1/ExampleInstrumentedTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.zebra.freeformocrsample1; | ||
|
||
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.zebra.freeformocrsample1", appContext.getPackageName()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="com.symbol.datawedge.permission.contentprovider" /> | ||
<queries> | ||
<package android:name="com.symbol.datawedge" /> | ||
</queries> | ||
|
||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.FreeFormOCRSample1" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="" /> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
87 changes: 87 additions & 0 deletions
87
FreeFormOCRSample1/app/src/main/java/com/zebra/freeformocrsample1/ImageProcessing.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (C) 2018-2023 Zebra Technologies Corp | ||
* All rights reserved. | ||
*/ | ||
package com.zebra.freeformocrsample1; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.graphics.ImageFormat; | ||
import android.graphics.Matrix; | ||
import android.graphics.Rect; | ||
import android.graphics.YuvImage; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
public class ImageProcessing { | ||
|
||
private final String IMG_FORMAT_YUV = "YUV"; | ||
private final String IMG_FORMAT_Y8 = "Y8"; | ||
|
||
private static ImageProcessing instance = null; | ||
|
||
public static ImageProcessing getInstance() { | ||
|
||
if (instance == null) { | ||
instance = new ImageProcessing(); | ||
} | ||
return instance; | ||
} | ||
|
||
private ImageProcessing() { | ||
//Private Constructor | ||
} | ||
|
||
public Bitmap getBitmap(byte[] data, String imageFormat, int orientation, int stride, int width, int height) | ||
{ | ||
if(imageFormat.equalsIgnoreCase(IMG_FORMAT_YUV)) | ||
{ | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, new int[]{stride, stride}); | ||
yuvImage.compressToJpeg(new Rect(0, 0, stride, height), 100, out); | ||
yuvImage.getYuvData(); | ||
byte[] imageBytes = out.toByteArray(); | ||
if(orientation != 0) | ||
{ | ||
Matrix matrix = new Matrix(); | ||
matrix.postRotate(orientation); | ||
Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); | ||
return Bitmap.createBitmap(bitmap, 0 , 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | ||
} | ||
else | ||
{ | ||
return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); | ||
} | ||
} | ||
else if(imageFormat.equalsIgnoreCase(IMG_FORMAT_Y8)) | ||
{ | ||
return convertYtoJPG_CPU(data, orientation, stride, height); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
|
||
private Bitmap convertYtoJPG_CPU(byte[] data, int orientation, int stride, int height) | ||
{ | ||
int mLength = data.length; | ||
int [] pixels = new int[mLength]; | ||
for(int i = 0; i < mLength; i++) | ||
{ | ||
int p = data[i] & 0xFF; | ||
pixels[i] = 0xff000000 | p << 16 | p << 8 | p; | ||
} | ||
if(orientation != 0) | ||
{ | ||
Matrix matrix = new Matrix(); | ||
matrix.postRotate(orientation); | ||
Bitmap bitmap = Bitmap.createBitmap(pixels, stride, height, Bitmap.Config.ARGB_8888); | ||
return Bitmap.createBitmap(bitmap, 0 , 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | ||
} | ||
else | ||
{ | ||
return Bitmap.createBitmap(pixels, stride, height, Bitmap.Config.ARGB_8888); | ||
} | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
FreeFormOCRSample1/app/src/main/java/com/zebra/freeformocrsample1/IntentKeys.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2018-2023 Zebra Technologies Corp | ||
* All rights reserved. | ||
*/ | ||
package com.zebra.freeformocrsample1; | ||
|
||
public class IntentKeys { | ||
|
||
public static final String DATA_NEXT_URI = "next_data_uri"; | ||
public static final String STRIDE = "stride"; | ||
public static final String RAW_DATA = "raw_data"; | ||
public static final String ORIENTATION = "orientation"; | ||
public static final String IMAGE_FORMAT = "imageformat"; | ||
public static final String IMAGE_WIDTH = "width"; | ||
public static final String IMAGE_HEIGHT = "height"; | ||
|
||
public static final String COMMAND_IDENTIFIER_CREATE_PROFILE = "CREATE_PROFILE"; | ||
public static final String COMMAND_IDENTIFIER_EXTRA = "COMMAND_IDENTIFIER"; | ||
public static final String RESULT_ACTION = "com.symbol.datawedge.api.RESULT_ACTION"; | ||
|
||
public static final String DATA_TAG = "com.symbol.datawedge.data"; | ||
|
||
public static final String REGISTER_NOTIFICATION = "com.symbol.datawedge.api.REGISTER_FOR_NOTIFICATION"; | ||
public static final String UNREGISTER_NOTIFICATION = "com.symbol.datawedge.api.UNREGISTER_FOR_NOTIFICATION"; | ||
|
||
public static final String STRING_DATA_KEY = "string_data"; | ||
public static final String DATAWEDGE_API_NAME = "com.symbol.datawedge.api.APPLICATION_NAME"; | ||
public static final String NOTIFICATION_TYPE = "com.symbol.datawedge.api.NOTIFICATION_TYPE"; | ||
public static final String NOTIFICATION = "com.symbol.datawedge.api.NOTIFICATION"; | ||
|
||
|
||
public static final String EXTRA_GET_PROFILES_LIST = "com.symbol.datawedge.api.GET_PROFILES_LIST"; | ||
public static final String EXTRA_DELETE_PROFILE = "com.symbol.datawedge.api.DELETE_PROFILE"; | ||
|
||
public static final String SET_CONFIG = "com.symbol.datawedge.api.SET_CONFIG"; | ||
|
||
public static final String PROFILE_NAME = "FreeFormScanningProfile"; | ||
public static final String DATAWEDGE_API_ACTION = "com.symbol.datawedge.api.ACTION"; | ||
public static final String INTENT_OUTPUT_ACTION = "com.zebra.id_scanning.ACTION"; | ||
public static final String SELECTED_WORKFLOW = "free_form_ocr"; | ||
public static final String NOTIFICATION_ACTION = "com.symbol.datawedge.api.NOTIFICATION_ACTION"; | ||
public static final String NOTIFICATION_TYPE_WORKFLOW_STATUS = "WORKFLOW_STATUS"; | ||
public static final String KEY_STRING_DATA = "string_data"; | ||
public static final String KEY_BLOCK_LABEL = "block_label"; | ||
public static final String JSON_IMAGE_FORMAT = "imageformat"; | ||
public static final String KEY_GROUP_ID = "group_id"; | ||
|
||
public static final String EXTRA_RESULT_GET_PROFILES_LIST = "com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST"; | ||
public static final String DATAWEDGE_PACKAGE = "com.symbol.datawedge"; | ||
|
||
public static final String EXTRA_SOFT_SCAN_TRIGGER = "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER"; | ||
public static final String INTENT_RESULT_CODE_FAILURE = "FAILURE"; | ||
|
||
|
||
} |
Oops, something went wrong.