Skip to content

Commit

Permalink
Updated projects
Browse files Browse the repository at this point in the history
  • Loading branch information
ci-bot committed May 25, 2023
1 parent 10d2fa9 commit 8a4649c
Show file tree
Hide file tree
Showing 481 changed files with 299 additions and 133 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@

*.apk
Samples/DocumentReader-sample/app/ocrandmrz/release/output.json
.idea/
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ dependencies {
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.regula.btdevice:api:1.0+@aar'
implementation 'com.regula.documentreader.core:fullauthrfid:6.7.+@aar'
implementation('com.regula.documentreader:api:6.7.+@aar') {
implementation 'com.regula.btdevice:api:1.0.+@aar'
implementation 'com.regula.documentreader.core:fullauthrfid:6.8.+@aar'
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"

implementation 'com.regula.btdevice:api:1.0+@aar'
implementation 'com.regula.btdevice:api:1.0.+@aar'
//noinspection GradleDynamicVersion
implementation 'com.regula.documentreader.core:fullrfid:6.7.+@aar'
implementation 'com.regula.documentreader.core:fullrfid:6.8.+@aar'
//noinspection GradleDynamicVersion
implementation('com.regula.documentreader:api:6.7.+@aar') {
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ class MainActivity : FragmentActivity(), Serializable {
Toast.LENGTH_SHORT
).show()
}

Instance().setLocalizationCallback { stringId ->
if(stringId == "strLookingDocument")
return@setLocalizationCallback SettingsActivity.customString;
return@setLocalizationCallback null;
}
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.regula.documentreader.Helpers.Companion.setProcessParams
import com.regula.documentreader.Helpers.Companion.toIntArray
import com.regula.documentreader.Helpers.Companion.toMutableListString
import com.regula.documentreader.Scan.Companion.ACTION_TYPE_CUSTOM
import com.regula.documentreader.SettingsActivity.Companion.customString
import com.regula.documentreader.SettingsActivity.Companion.functionality
import com.regula.documentreader.SettingsActivity.Companion.isDataEncryptionEnabled
import com.regula.documentreader.api.DocumentReader.Instance
Expand Down Expand Up @@ -107,6 +108,8 @@ class SettingsActivity : FragmentActivity() {
if (selectedTabIndex == 0) {
isRfidEnabled = false
isDataEncryptionEnabled = false
customString = null

val adapter =
applicationSettingsFragment.binding.recyclerView.adapter as CommonRecyclerAdapter
adapter.notifyItemRangeChanged(0, adapter.itemCount)
Expand All @@ -125,6 +128,7 @@ class SettingsActivity : FragmentActivity() {
var isRfidEnabled = false
var functionality = Functionality()
var isDataEncryptionEnabled = false
var customString:String? = null
}
}

Expand All @@ -149,6 +153,17 @@ class ApplicationSettingsFragment : Fragment() {
{ isDataEncryptionEnabled },
{ isDataEncryptionEnabled = it })
)
sectionsData.add(Section("Custom localization"))
sectionsData.add (
InputString(
"Searching for document custom string",
{
customString?:""
},
{
customString = if(it == "") null else it
})
)
binding.recyclerView.layoutManager = LinearLayoutManager(activity)
binding.recyclerView.adapter = CommonRecyclerAdapter(sectionsData)
binding.recyclerView.addItemDecoration(DividerItemDecoration(activity, 1))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
2. Download or clone the current repository using the command `git clone https://github.com/regulaforensics/DocumentReader-Android.git`.
3. Open the `Basic/DocumentReader-sample_java` project in an IDE.
4. Copy the license file to the project: `Basic/DocumentReader-sample_java/app/src/main/res/raw/`.
5. Change the application ID to the one you have specified during the registration at [client.regulaforensics.com](https://client.regulaforensics.com).
5. Change the application ID to the one you have specified during the registration at [licensing.regulaforensics.com](https://licensing.regulaforensics.com).
6. Run the project.
Note: Android Gradle plugin requires Java 11 to run

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ dependencies {
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.regula.documentreader.core:fullrfid:6.7.+@aar' // use fullauthrfid core for 7310
implementation('com.regula.documentreader:api:6.7.+@aar') {

implementation 'com.regula.documentreader.core:fullrfid:6.8.+@aar' // use fullauthrfid core for 7310
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

<application
android:allowBackup="true"
android:icon="@drawable/r_icon"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ dependencies {
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.regula.documentreader.core:fullrfid:6.7.+@aar'
implementation('com.regula.documentreader:api:6.7.+@aar') {

implementation 'com.regula.documentreader.core:fullrfid:6.8.+@aar'
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true;
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ dependencies {
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.regula.btdevice:api:1.0+@aar'
implementation 'com.regula.documentreader.core:fullauthrfid:6.7.+@aar'
implementation('com.regula.documentreader:api:6.7.+@aar') {
implementation 'com.regula.btdevice:api:1.0.+@aar'
implementation 'com.regula.documentreader.core:fullauthrfid:6.8.+@aar'
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.06827586"
android:scaleY="0.06827586"
android:translateX="33.244137"
android:translateY="29.25">
<path
android:pathData="M471.17,470.8C536.53,431.54 582.73,353.76 582.73,268.28C582.73,106.02 452.34,0 288.71,0C125.07,0 0,105.99 0,289.22V426.63H119.74V289.22C119.74,179.28 195.57,117.78 288.71,117.78C381.84,117.78 448.35,180.59 448.35,268.28C448.35,355.98 376.5,426.63 283.39,426.63H119.76V725H239.49V531.32H286.05C403.13,531.32 480.29,620.32 482.95,725H608C605.79,621.38 555.4,516.84 471.17,470.8V470.8Z"
android:fillColor="#663399"/>
</group>
</vector>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions CustomCamera/CustomCamera-Kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
File renamed without changes.
1 change: 1 addition & 0 deletions CustomCamera/CustomCamera-Kotlin/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.regula.documentreader.core:mrzrfid:6.7.+@aar'
implementation('com.regula.documentreader:api:6.7.+@aar') {
implementation 'com.regula.documentreader.core:mrzrfid:6.8.+@aar'
implementation('com.regula.documentreader:api:6.8.+@aar') {
transitive = true;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.regula.customcamera_kotlin.custom

import android.Manifest
import android.app.AlertDialog
import android.content.DialogInterface
import android.content.pm.PackageManager
import android.graphics.ImageFormat
import android.hardware.camera2.CameraAccessException
import android.hardware.camera2.CameraManager
import android.media.ImageReader
Expand All @@ -13,28 +13,37 @@ import android.util.Size
import android.view.Surface
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.regula.common.utils.Camera2Image
import com.regula.common.utils.CameraUtil
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.regula.customcamera_kotlin.R

import com.regula.documentreader.api.DocumentReader
import com.regula.documentreader.api.completions.IDocumentReaderCompletion
import com.regula.documentreader.api.enums.DocReaderAction
import com.regula.documentreader.api.enums.eVisualFieldType
import com.regula.documentreader.api.errors.DocumentReaderException
import com.regula.documentreader.api.internal.params.ImageInputParam
import com.regula.documentreader.api.results.DocumentReaderResults

open class Camera2Activity : AppCompatActivity(), OnImageAvailableListener {
private var isProcessingFrame = false
private var recognitionFinished = false
private var postInferenceCallback: Runnable? = null
private var sensorOrientation = 0
var previewHeight = 0
var previewWidth = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_camera2)
setFragment()
if ((ContextCompat.checkSelfPermission(this@Camera2Activity, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED)
) {
ActivityCompat.requestPermissions(
this@Camera2Activity,
arrayOf(Manifest.permission.CAMERA),
PERMISSIONS_CAMERA
)
} else {
setFragment()
}
}

override fun onRequestPermissionsResult(
Expand Down Expand Up @@ -82,61 +91,48 @@ open class Camera2Activity : AppCompatActivity(), OnImageAvailableListener {
if (previewWidth == 0 || previewHeight == 0) {
return
}
try {
val image = reader.acquireLatestImage() ?: return
if (!isProcessingFrame && !recognitionFinished) {
val data = CameraUtil.convertYUV420888ToNV21(Camera2Image.createFrame(image))
val params = ImageInputParam(
previewWidth,
previewHeight,
ImageFormat.NV21

val image = reader.acquireLatestImage() ?: return
if (!isProcessingFrame && !recognitionFinished) {
isProcessingFrame = true
DocumentReader.Instance().recognizeImage(image, completion)
}
image.close()
}

private val completion = IDocumentReaderCompletion { i: Int, documentReaderResults: DocumentReaderResults?, throwable: DocumentReaderException? ->
when (i) {
DocReaderAction.COMPLETE -> {
if (documentReaderResults != null
&& documentReaderResults.morePagesAvailable == 0
)
isProcessingFrame = true
DocumentReader.Instance().recognizeVideoFrame(
data, params
) { i: Int, documentReaderResults: DocumentReaderResults?, throwable: DocumentReaderException? ->
when (i) {
DocReaderAction.COMPLETE -> {
if (documentReaderResults != null
&& documentReaderResults.morePagesAvailable == 0)
recognitionFinished = true
recognitionFinished = true

if (documentReaderResults != null) {
if (documentReaderResults.morePagesAvailable != 0) { //more pages are available for this document
Toast.makeText(
this@Camera2Activity,
"Page ready, flip",
Toast.LENGTH_LONG
).show()
//letting API know, that all frames will be from different page of the same document, merge same field types
DocumentReader.Instance().startNewPage()
} else { //no more pages available
startDialog(documentReaderResults)
}
}
}
DocReaderAction.ERROR -> {
recognitionFinished = false
Toast.makeText(
this@Camera2Activity,
"Error: " + if (throwable != null) throwable.message else "",
Toast.LENGTH_LONG
).show()
}
DocReaderAction.CANCEL -> {}
if (documentReaderResults != null) {
if (documentReaderResults.morePagesAvailable != 0) { //more pages are available for this document
Toast.makeText(
this@Camera2Activity,
"Page ready, flip",
Toast.LENGTH_LONG
).show()
//letting API know, that all frames will be from different page of the same document, merge same field types
DocumentReader.Instance().startNewPage()
} else { //no more pages available
startDialog(documentReaderResults)
}
isProcessingFrame = false
}
}
postInferenceCallback = Runnable { image.close() }
processImage()
} catch (e: Exception) {
e.printStackTrace()
DocReaderAction.ERROR -> {
recognitionFinished = false
Toast.makeText(
this@Camera2Activity,
"Error: " + if (throwable != null) throwable.message else "",
Toast.LENGTH_LONG
).show()
}
DocReaderAction.CANCEL -> {}
}
}

private fun processImage() {
postInferenceCallback!!.run()
isProcessingFrame = false
}

private val screenOrientation: Int
Expand All @@ -159,4 +155,8 @@ open class Camera2Activity : AppCompatActivity(), OnImageAvailableListener {
builder.setMessage(documentReaderResults.getTextFieldValueByType(eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES))
builder.show()
}

companion object {
private const val PERMISSIONS_CAMERA: Int = 1100
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,38 @@ import com.regula.documentreader.api.errors.DocumentReaderException
import com.regula.documentreader.api.internal.params.ImageInputParam
import com.regula.documentreader.api.results.DocumentReaderResults

/**
* Created by Sergey Yakimchik on 19.01.22.
* Copyright (c) 2022 Regula. All rights reserved.
*/
class CustomRegActivity : CaptureActivity3(), CameraCallbacks {
private var orientationEventListener: OrientationEventListener? = null
private var mCurrentDegrees = 0
private var recognitionFinished = true
private var isPauseRecognize = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

var isScenarioExist = false
for (scenario in DocumentReader.Instance().availableScenarios) {
if (scenario.name.equals(DocumentReader.Instance().processParams().scenario)) {
isScenarioExist = true
break
}
}
if (!isScenarioExist) {
Log.e(DEBUG, "Scenario: ${DocumentReader.Instance().processParams().scenario} doesn't exist")
finish()
return
}

if (ContextCompat.checkSelfPermission(this@CustomRegActivity, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED
) {
Log.d(DEBUG, "OnResume: Asking permissions")
Log.d(DEBUG, "onCreate: Asking permissions")
ActivityCompat.requestPermissions(
this@CustomRegActivity,
arrayOf(Manifest.permission.CAMERA),
PERMISSIONS_CAMERA
)
} else {
Log.d(DEBUG, "OnResume: Permissions granted")
Log.d(DEBUG, "onCreate: Permissions granted")
safeCameraOpenInView()
}
DocumentReader.Instance().startNewSession()
Expand Down
File renamed without changes.
Loading

0 comments on commit 8a4649c

Please sign in to comment.