# OCR Support

Before viewing this document, it is recommended to read[Mini Program plug-in documentation](https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using .html) Experience Tool Mini Program The plug-in is implemented entirely with this plug-in. The plug-in supports ID card identification, driving license identification and bank card identification. Mini Program code

# Request permission

  • Please search for this plug-in in the Mini Program background (AppID =wx4418e3e031e551be) Settings - Third Party Services - Add Plugins

# Invocation limitation

  • comeOpen CommunityPurchase, appid amount in plugin, API, service market is universal

# Calling mode

app.jsonAdd a declaration to introduce a plug-in versionChoose the latest

  "pages": [],
  "plugins": {
    "ocr-plugin": {
      "version": "3.0.2",
      "provider": "wx4418e3e031e551be"
    }
  }
}

The json of the page also adds a declaration

{
  "usingComponents": {
    "ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
  }
}

# assembly

External exposure of custom components, UI carrier on (style can be customized) Encapsulated

# parameter

Attribute name type Default values Required Required Introductions
onSuccess HandleEvent yes Interface calls the successful callback function
certificateType String idCard no There are four types of certificates ID card: id card, driving license: bankcard, business license: business license

Returns the image in the result_path Is the temporary address of user ID photos, developers can use image_Path gets user identification photos

The use of the four types of documents is specified below

# 1. Identity card

certificateType=&#39idCard&#39 or There is no certificateType parameter

Attribute name type Default values Required Required Introductions
onSuccess HandleEvent yes Interface calls the successful callback function
certificateType String idCard no There are four types of certificates ID card: id card, driving license: bankcard, business license: business license
opposite Boolean true no Whether to display the reverse side of the id card, default is True Display Reverse

# onSuccess

parameter and.detail

Reference[ID return result instance](#ID return result instance)

# Sample code 1

    <ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{false}}">
      <button type="primary">Positive identification of identity card</button>
    </ocr-navigator>
    <ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{true}}">
      <button type="primary">ID card reverse identification</button>
    </ocr-navigator>
/** wxss **/
/*Custom on styles*/
.ocr-wrapper {
  margin: 40rpx car
  width: 375rpx
}
.intro {
  margin: 40rpx
}

# ID return result instance

{"type":0,"name":{"text":"张三","pos":{"left_top":{"x":98.7780914307,"y":40.9823074341},"right_top":{"x":172.311325073,"y":41.2864379883},"right_bottom":{"x":172.190856934,"y":64.9047088623},"left_bottom":{"x":98.6072158813,"y":64.5630187988}},"label":[]},"gender":{"text":"男","pos":{"left_top":{"x":101.035919189,"y":80.7537384033},"right_top":{"x":121.421043396,"y":80.7818603516},"right_bottom":{"x":121.264938354,"y":101.272567749},"left_bottom":{"x":100.882026672,"y":101.244766235}},"label":[]},"nationality":{"text":"汉","pos":{"left_top":{"x":201.881393433,"y":81.7225189209},"right_top":{"x":222.004470825,"y":81.6959762573},"right_bottom":{"x":221.899169922,"y":101.255821228},"left_bottom":{"x":201.765304565,"y":101.291915894}},"label":[]}, "address": {"text": "No. 483 Wushan Road, Tianhe District, Guangzhou xxxxxxx," "pos":} "left_top":{"x":95.5787811279,"y":150.794250488},"right_top":{"x":310.358947754,"y":151.617507935},"right_bottom":{"x":310.004699707,"y":220.222885132},"left_bottom":{"x":95.1295013428,"y":219.552230835}},"label":[]},"id":{"text":"4452xxxxxxxxxxxx","pos":{"left_top":{"x":176.158676147,"y":244.072860718},"right_top":{"x":453.888336182,"y":244.978515625},"right_bottom":{"x":453.874603271,"y":266.313659668},"left_bottom":{"x":176.066543579,"y":265.342407227}},"label":[]},"card_position":{"pos":{"left_top":{"x":1085.625,"y":621.75},"right_top":{"x":338.125,"y":594.75},"right_bottom":{"x":303.625,"y":99.75},"left_bottom":{"x":1189.125,"y":126.75}},"label":[]},"image_width":1280,"image_height":960,"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}

# 2. Bank cards

certificateType=&#39bankCard&#39

Attribute name type Default values Required Required Introductions
onSuccess HandleEvent yes Interface calls the successful callback function
certificateType String Bankcard yes There are four types of certificates ID card: id card, driving license: bankcard, business license: business license

# onSuccess

parameter and.detail

Reference[Bank card return result example](#Bank card return result example)

# Sample code 1

<ocr-navigator bind:onSuccess="blankSuccess"  certificateType="bankCard">
  <button type="primary">Bank card identification</button>
</ocr-navigator>
/** wxss **/
/*Custom on styles*/
.ocr-wrapper {
  margin: 40rpx car
  width: 375rpx
}
.intro {
  margin: 40rpx
}

# Bank card return result example

{"number":{"text":"6225xxxxxxxxxxxx","label":[]},"card_position":{"pos":{"left_top":{"x":2.19140625,"y":227.6171875},"right_top":{"x":729.50390625,"y":206.0546875},"right_bottom":{"x":769.91015625,"y":658.8671875},"left_bottom":{"x":-11.27734375,"y":680.4296875}},"label":[]},"image_width":762,"image_height":1280,"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}

# Bank card return result

Bank card only support horizontal version savings card, credit card, and can only identify the bank card number, if need bank card name, expiration time need user manual input

# 3. Driving License

certificateType='drivingLicense'

Attribute name type Default values Required Required Introductions
onSuccess HandleEvent yes Interface calls the successful callback function
certificateType String drivingLicense yes There are four types of certificates ID card: id card, driving license: bankcard, business license: business license

# onSuccess

parameter and.detail

Reference[Driving License Return Result Example](#Driving License Return Result Example)

# Sample code 1

<ocr-navigator bind:onSuccess="driverSuccess" certificateType="drivingLicense" selectedOptions="{{['plateNum','vehicleType','owner']}}">
  <button type="primary">Driving license recognition</button>
</ocr-navigator>
/** wxss **/
/*Custom on styles*/
.ocr-wrapper {
  margin: 40rpx car
  width: 375rpx
}
.intro {
  margin: 40rpx
}

# Driving License Return Result Example

{"plate_num":{"text":"粤KDxxxx","label":[]},"vehicle_"type": {"text": "small car," "label":[]},"owner":{"text":"周xx","label":[]}, "addr": {"text": "Guangdong xxxxxxxx", "label":[]},"use_"character": {"text": "non-operating," "label":[]}, "model": {"text": "Dongfeng Nissan xxxxx," "label":[]},"vin":{"text":"LGBH52Exxxxxx","label":[]},"engine_num":{"text":"873073Y","label":[]},"register_date":{"text":"2017-11-13","label":[]},"issue_date":{"text":"2017-11-13","label":[]},"plate_A_b":{"text":"粤R82xxxx","label":[]},"record":{"text":"4418005xxxx","label":[]},"passengers_num":{"text":"26人","label":[]},"total_quality":{"text":"6900kg","label":[]},"prepare_quality":{"text":"4480kg","label":[]},"load_quality":{"text":"","label":[]},"lead_quality":{"text":"","label":[]},"overall_size":{"text":"7725x205xxxx","label":[]},"type":2,"card_position":[{"pos":{"left_top":{"x":454.0625,"y":17.34375},"right_top":{"x":987.8125,"y":11.71875},"right_bottom":{"x":987.8125,"y":562.96875},"left_bottom":{"x":471.5625,"y":546.09375}},"label":[]},{"pos":{"left_top":{"x":-0.9375,"y":28.59375},"right_top":{"x":445.3125,"y":22.96875},"right_bottom":{"x":445.3125,"y":551.71875},"left_bottom":{"x":-0.9375,"y":546.09375}},"label":[]}],"card_position_front":{"pos":{"left_top":{"x":454.0625,"y":17.34375},"right_top":{"x":987.8125,"y":11.71875},"right_bottom":{"x":987.8125,"y":562.96875},"left_bottom":{"x":471.5625,"y":546.09375}},"label":[]},"card_position_back":{"pos":{"left_top":{"x":-0.9375,"y":28.59375},"right_top":{"x":445.3125,"y":22.96875},"right_bottom":{"x":445.3125,"y":551.71875},"left_bottom":{"x":-0.9375,"y":546.09375}},"label":[]},"image_width":1000,"image_height":600,"img_size":{"w":1000,"h":600},"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}

# Driving License Return Result

Driving license support front and back page in a picture

# 4. Business License

certificateType='businessLicense'

Attribute name type Default values Required Required Introductions
onSuccess HandleEvent yes Interface calls the successful callback function
certificateType String businessLicense yes There are four types of certificates ID card: id card, driving license: bankcard, business license: business license

# onSuccess

parameter and.detail

Reference[Business License Return Result Example](#Business License Return Result Example)

# Sample code 1

<ocr-navigator bind:onSuccess="businessSuccess"   certificateType="businessLicense">
  <button type="primary">Business license identification</button>
</ocr-navigator>
/** wxss **/
/*Custom on styles*/
.ocr-wrapper {
  margin: 40rpx car
  width: 375rpx
}
.intro {
  margin: 40rpx
}

# Business License Return Result Example

{"reg_num":{"text":"371400228016303","label":[]},"legal_representative":{"text":"xxxx","label":[]},"enterprise_Name ": {" text ":" xxxxx Limited, "" label ":[]},"address":{"text":"xxx省 xxx 市xxx","label":[]},"type_of_Enterprise ": {" text ":" limited liability company(Investment or holding by natural persons)","label":[]},"business_scope":{"text":"xxxxxxxxxxxx","label":[]},"registered_Capital ": {" text ":" three million, "" label ":[]},"valid_Period ": {" text ":" April 12, 2008 to April, 2008, "" label ":[]},"registered_date":{"text":"April 12, 2008,"label":[]},"" true_position":{"pos":{"left_top":{"x":65.4609375,"y":115.640625},"right_top":{"x":567.4921875,"y":123.828125},"right_bottom":{"x":567.4921875,"y":811.578125},"left_bottom":{"x":65.4609375,"y":819.765625}},"label":[]},"img_size":{"w":630,"h":874},"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}

# Introductions

This document fits in3.0.2And the above plug-ins, and debug the base library in the2.4.0And above to use