New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rnkit-excard

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rnkit-excard

易道博识-图像识别 for ReactNative

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

npm react-native MIT bitHound Score Downloads

易道博识-图像识别 for React Native.

Support me with a Follow

Getting Started

First, cd to your RN project directory, and install RNMK through rnpm . If you don't have rnpm, you can install RNMK from npm with the command npm i -S rnkit-excard and link it manually (see below).

iOS

  • React Native < 0.29 (Using rnpm)

    rnpm install rnkit-excard

  • React Native >= 0.29

    $npm install -S rnkit-excard

    $react-native link rnkit-excard

Manually

  • Add node_modules/rnkit-excard/ios/RNKitExcard.xcodeproj to your xcode project, usually under the Libraries group
  • Add libRNKitExcard.a (from Products under RNKitExcard.xcodeproj) to build target's Linked Frameworks and Libraries list
  • Add ocr framework to $(PROJECT_DIR)/Frameworks.

Android

  • React Native < 0.29 (Using rnpm)

    rnpm install rnkit-excard

  • React Native >= 0.29

    $npm install -S rnkit-excard

    $react-native link rnkit-excard

Manually

  • JDK 7+ is required
  • Add the following snippet to your android/settings.gradle:
include ':rnkit-excard'
project(':rnkit-excard').projectDir = new File(rootProject.projectDir, '../node_modules/rnkit-excard/android/app')
  • Declare the dependency in your android/app/build.gradle
dependencies {
    ...
    compile project(':rnkit-excard')
}
  • Import import io.rnkit.excard.EXOCRPackage; and register it in your MainActivity (or equivalent, RN >= 0.32 MainApplication.java):
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new EXOCRPackage()
    );
}
  • Add Module ExBankCardSDK And ExCardSDK In Your Main Project.

Finally, you're good to go, feel free to require rnkit-excard in your JS files.

Have fun! :metal:

Basic Usage

Import library

import RNKitExcard from 'rnkit-excard';

Init

RNKitExcard.config({
  DisplayLogo: false
  ....
})

Init Params

KeyTypeDefaultDescription
OrientationMaskstring'MaskAll'方向设置,设置扫描页面支持的识别方向
ByPresentBOOLNO扫描页面调用方式设置,是否以present方式调用,默认为NO,YES-以present方式调用,NO-以sdk默认方式调用(push或present)
NumberOfSpaceBOOLYES结果设置,银行卡号是否包含空格
DisplayLogoBOOLYES是否显示logo
EnablePhotoRecBOOLYESEnablePhotoRec
FrameColorint扫描框颜色, 必须与FrameAlpha共同设置
FrameAlphafloat扫描框透明度, 必须与FrameColor共同设置
ScanTextColorint扫描字体颜色
IDCardScanNormalTextColorint正常状态扫描字体颜色 (身份证)
IDCardScanErrorTextColorint错误状态扫描字体颜色 (身份证)
BankScanTipsstring银行卡扫描提示文字
DRCardScanTipsstring驾驶证扫描提示文字
VECardScanTipsstring行驶证扫描提示文字
BankScanTipsstring银行卡扫描提示文字
IDCardScanFrontNormalTipsstring身份证正常状态正面扫描提示文字
IDCardScanFrontErrorTipsstring身份证错误状态正面扫描提示文字
IDCardScanBackNormalTipsstring身份证正常状态背面扫描提示文字
IDCardScanBackErrorTipsstring身份证错误状态背面扫描提示文字
fontNamestring扫描提示文字字体名称
ScanTipsFontSizefloat扫描提示文字字体大小
IDCardNormalFontNamestring正常状态扫描提示文字字体名称
IDCardNormalFontSizefloat正常状态扫描提示文字字体大小
IDCardErrorFontNamestring错误状态扫描提示文字字体名称
IDCardErrorFontSizefloat错误状态扫描提示文字字体大小
qualityfloat图片清晰度, 范围(0-1)
OrientationMask
  • Portrait
  • LandscapeLeft
  • LandscapeRight
  • PortraitUpsideDown
  • Landscape
  • MaskAll
  • AllButUpsideDown

一、银行卡识别

1. 使用摄像头、相册识别

try {
	const result = await RNKitExcard.recoBankFromStream();
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

2. 使用远程或本地图片识别

try {
	const imagePath = '...';
	const result = await RNKitExcard.recoBankFromStillImage(imagePath);
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

返回值

KeyTypeDefaultDescription
bankNamestring银行名称
cardNamestring卡名称
cardTypestring卡类型
cardNumstring卡号
validDatestring有限期
fullImgPathstring银行卡全图
cardNumImgPathstring银行卡号截图

二、驾驶证识别

1. 使用摄像头、相册识别

try {
	const result = await RNKitExcard.recoDRCardFromStream();
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

2. 使用远程或本地图片识别

try {
	const imagePath = '...';
	const result = await RNKitExcard.recoDRCardFromStillImage(imagePath);
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

返回值

KeyTypeDefaultDescription
namestring姓名
sexstring性别
nationstring国籍
cardIdstring身份证号码
addressstring住址
birthstring出生日期
issueDatestring初次领证时间
driveTypestring准驾车型
validDatestring有效期至日期
fullImgPathstring驾驶证全图

三、行驶证识别

1. 使用摄像头、相册识别

try {
	const result = await RNKitExcard.recoVECardFromStream();
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

2. 使用远程或本地图片识别

try {
	const imagePath = '...';
	const result = await RNKitExcard.recoVECardFromStillImage(imagePath);
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

返回值

KeyTypeDefaultDescription
plateNostring号牌号码
vehicleTypestring车辆类型
ownerstring所有人
addressstring住址
modelstring品牌型号
useCharacterstring使用性质
engineNostring发动机号
VINstring车辆识别代码
registerDatestring注册日期
issueDatestring发证日期
fullImgPathstring行驶证全图

四、身份证识别

1. 使用摄像头、相册识别

try {
	const bFront = true  // 身份证方向,true-正面,false-背面
	const result = await RNKitExcard.recoIDCardFromStreamWithSide(bFront);
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

2. 使用远程或本地图片识别

try {
	const imagePath = '...';
	const result = await RNKitExcard.recoIDCardFromStillImage(imagePath);
} catch (error) {
	if (error.code === -1) {
		console.log('on cancel')
	} else {
		console.log(error)
	}
}

返回值

KeyTypeDefaultDescription
typeint1:正面 2:反面
namestring姓名
genderstring性别
nationstring名族
birthstring出生
addressstring地址
codestring身份证
issuestring签发机关
validstring有效期
frontShadowint1:正面图像有遮挡 0:正面图像无遮挡
backShadowint1:背面图像有遮挡 0:背面图像无遮挡
faceImgPathstring人脸截图
frontFullImgPathstring身份证正面全图
backFullImgPathstring身份证背面全图

五、常量

const sdkVersion = RNKitExcard.sdkVersion;
const kernelVersion = RNKitExcard.kernelVersion;
KeyTypeDefaultDescription
sdkVersionstringsdk版本号
kernelVersionstring识别核心版本号

六、clean 清理图片临时目录

try {
	const result = await RNKitExcard.clean();
} catch (error) {
	console.log(error)
}

Contribution

Questions

Feel free to contact me or create an issue

made with ♥

Keywords

react

FAQs

Package last updated on 21 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts