Best Practice|Using Tencent Cloud Intelligent Text Recognition to Realize Online Car Hailing Information Management

According to statistics from the online car-hailing regulatory information exchange platform, as of July 31, 2022, a total of 279 online car-hailing platform companies across the country have obtained online car-hailing platform operating licenses, and a total of 4.60 million online car-hailing driver licenses, vehicle transportation licenses, and vehicle transportation licenses have been issued across the country. 1.882 million certificates have been issued, and a total of 695 million orders have been received as of July. The collection and management of online ride-hailing driver’s identity, driver’s license, driving license, and vehicle information is a very arduous task. Safe and compliant collection and management of online ride-hailing information can effectively protect the safety of passengers and strengthen driver supervision. review to improve travel safety.

So, how does AI technology empower online ride-hailing platform companies to improve quality and efficiency?

Below, we will introduce in detail the implementation process of how to use Tencent Cloud intelligent text recognition to collect information related to online ride-hailing.

1. Preparation work

In order to use Tencent Cloud's automotive-related recognition capabilities, you need to do the following preparations.

1.1. Free experience of car-related identification

Before using Tencent Cloud car-related identification , experience car-related identification services through the Tencent Cloud official website.

 

Tencent Cloud Intelligent Text Recognition provides free resource packages, including monthly free resource packages for driving license/driving license recognition, vehicle vin code recognition and license plate recognition, each with a monthly free resource package of 1,000 free quotas. You can view the resources on the resource package management page Package usage.

 

1.2. Console monitoring information

After using it, I learned that the usage information of all text recognition services can be viewed in the console . You can see the statistics of the current month's calls, billing, number of successes, success rate, etc. from the figure below.

 

2. Operation process

Through the following steps, you can use the car-related identification function of Tencent Cloud Intelligent Text Recognition to collect online ride-hailing driver information.

  • Get personal key

  • View API documentation related to car recognition

  • Use Tencent Cloud’s intelligent text recognition car-related recognition function to collect online ride-hailing driver information

2.1. Obtain personal key

On the API key management page of Tencent Cloud Access Management , we create a new personal key.

 

2.2. View API documents related to car recognition

Online ride-hailing driver's license recognition API interface, driving license recognition API interface, license plate recognition API interface

 

2.3. Use the car-related recognition function of Tencent Cloud AI text recognition to collect information from online ride-hailing companies.

The process of collecting information from online ride-hailing companies is mainly divided into the following steps:

  • Install the SDK that the environment depends on and call the car-related identification interface

  • Experience the effect of information collection by online ride-hailing companies

2.3.1 Install environment-dependent SDKs and call car-related identification interfaces

package test

import (
	"encoding/base64"
	"encoding/csv"
	"encoding/json"
	"fmt"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
	ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119"
	"io"
	"io/ioutil"
	"log"
	"os"
)

//Resp 	响应体
type Resp struct {
	Response map[string]string
}

//RespFrontInfo 	响应体
type RespFrontInfo struct {
	Response FrontMsg
}
//FrontMsg 行驶证识别正面
type FrontMsg struct {
	FrontInfo map[string]string
}

//ImageCarIdentify 网约车公司信息收集入口函数
func ImageCarIdentify(path string, fileName string, infoType int64) (string, error) {
	// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
	// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
	credential := common.NewCredential(
		"secretId",
		"secretKey",
	)
	// 实例化一个client选项,可选的,没有特殊需求可以跳过
	cpf := profile.NewClientProfile()
	cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
	// 实例化要请求产品的client对象,clientProfile是可选的
	client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
	//读取图片base64
	toBase64Str, err := imageToBase64(path + fileName)
	resp := ""
	if infoType == 1 {
		resp, err = imageType1(*client, toBase64Str)
		WriteOnlineCarDriverToCsv(resp)
	}
	if infoType == 2 {
		resp, err = imageType2(*client, toBase64Str)
		WriteOnlineCarDrivingToCsv(resp)
	}
	if infoType == 3 {
		resp, err = imageType3(*client, toBase64Str)
		WriteLicensePlateToCsv(resp)
	}
	if err != nil {
		return "", err
	}
	fmt.Println(resp)
	return resp, nil
}

//imageType1 网约车驾驶证识别
func imageType1(client ocr.Client, toBase64Str string) (string, error) {
	// 实例化一个请求对象,每个接口都会对应一个request对象
	request := ocr.NewRideHailingDriverLicenseOCRRequest()
	request.ImageBase64 = common.StringPtr(toBase64Str)
	// 返回的resp是一个ImageEnhancementResponse的实例,与请求对象对应
	response, err := client.RideHailingDriverLicenseOCR(request)
	if _, ok := err.(*errors.TencentCloudSDKError); ok {
		fmt.Printf("An API error has returned: %s", err)
		return "", err
	}
	if err != nil {
		return "", err
	}
	return response.ToJsonString(), nil
}

//imageType2 行驶证识别
func imageType2(client ocr.Client, toBase64Str string) (string, error) {
	// 实例化一个请求对象,每个接口都会对应一个request对象
	request := ocr.NewVehicleLicenseOCRRequest()
	request.ImageBase64 = common.StringPtr(toBase64Str)
	request.CardSide = common.StringPtr("FRONT")
	// 返回的resp是一个ImageEnhancementResponse的实例,与请求对象对应
	response, err := client.VehicleLicenseOCR(request)
	if _, ok := err.(*errors.TencentCloudSDKError); ok {
		fmt.Printf("An API error has returned: %s", err)
		return "", err
	}
	if err != nil {
		return "", err
	}
	return response.ToJsonString(), nil
}

//imageType3 车牌识别
func imageType3(client ocr.Client, toBase64Str string) (string, error) {
	// 实例化一个请求对象,每个接口都会对应一个request对象
	request := ocr.NewLicensePlateOCRRequest()
	request.ImageBase64 = common.StringPtr(toBase64Str)
	// 返回的resp是一个ImageEnhancementResponse的实例,与请求对象对应
	response, err := client.LicensePlateOCR(request)
	if _, ok := err.(*errors.TencentCloudSDKError); ok {
		fmt.Printf("An API error has returned: %s", err)
		return "", err
	}
	if err != nil {
		return "", err
	}
	return response.ToJsonString(), nil
}

//WriteOnlineCarDriverToCsv 网约车驾驶证写入csv
func WriteOnlineCarDriverToCsv(str string) {
	jsondata := Resp{}
	err := json.Unmarshal([]byte(str), &jsondata)
	if err != nil {
		fmt.Println(err)
	}
	nfs, err := os.OpenFile("./data.csv", os.O_RDWR|os.O_CREATE, 0666)
	if err != nil {
		log.Fatalf("can not create file, err is %+v", err)
	}
	defer nfs.Close()
	nfs.Seek(0, io.SeekEnd)
	writer := csv.NewWriter(nfs)
	writer.Write([]string{"姓名", "从业资格证号", "发证日期"})
	var record []string
	record = append(record, jsondata.Response["Name"])
	record = append(record, jsondata.Response["LicenseNumber"])
	record = append(record, jsondata.Response["ReleaseDate"])
	writer.Write(record)
	writer.Flush() //将内存中的数据刷回到硬盘保存
}

//WriteLicensePlateToCsv 车牌写入csv
func WriteLicensePlateToCsv(str string) {
	jsondata := Resp{}
	err := json.Unmarshal([]byte(str), &jsondata)
	if err != nil {
		fmt.Println(err)
	}
	nfs, err := os.OpenFile("./data.csv", os.O_RDWR|os.O_CREATE, 0666)
	if err != nil {
		log.Fatalf("can not create file, err is %+v", err)
	}
	defer nfs.Close()
	nfs.Seek(0, io.SeekEnd)
	writer := csv.NewWriter(nfs)
	writer.Write([]string{"车牌号", "车牌颜色"})
	var record []string
	record = append(record, jsondata.Response["Number"])
	record = append(record, jsondata.Response["Color"])
	writer.Write(record)
	writer.Flush() //将内存中的数据刷回到硬盘保存
}

//WriteOnlineCarDrivingToCsv 网约车行驶证写入csv
func WriteOnlineCarDrivingToCsv(str string) {
	jsondata := RespFrontInfo{}
	err := json.Unmarshal([]byte(str), &jsondata)
	if err != nil {
		fmt.Println(err)
	}
	nfs, err := os.OpenFile("./data.csv", os.O_RDWR|os.O_CREATE, 0666)
	if err != nil {
		log.Fatalf("can not create file, err is %+v", err)
	}
	defer nfs.Close()
	nfs.Seek(0, io.SeekEnd)
	writer := csv.NewWriter(nfs)
	writer.Write([]string{"号牌号码", "车辆类型", "所有人", "地址", "使用性质", "品牌型号", "车辆识别代号", "发动机编号", "注册日期", "发证单位"})
	var record []string
	record = append(record, jsondata.Response.FrontInfo["PlateNo"])
	record = append(record, jsondata.Response.FrontInfo["VehicleType"])
	record = append(record, jsondata.Response.FrontInfo["Owner"])
	record = append(record, jsondata.Response.FrontInfo["Address"])
	record = append(record, jsondata.Response.FrontInfo["UseCharacter"])
	record = append(record, jsondata.Response.FrontInfo["Model"])
	record = append(record, jsondata.Response.FrontInfo["Vin"])
	record = append(record, jsondata.Response.FrontInfo["EngineNo"])
	record = append(record, jsondata.Response.FrontInfo["RegisterDate"])
	record = append(record, jsondata.Response.FrontInfo["Seal"])
	writer.Write(record)
	writer.Flush() //将内存中的数据刷回到硬盘保存
}

//imageToBase64 img转base64
func imageToBase64(filePath string) (string, error) {
	srcByte, err := ioutil.ReadFile(filePath)
	if err != nil {
		return "", err
	}
	res := base64.StdEncoding.EncodeToString(srcByte)
	return res, nil
}

2.3.2 Experience the effect of information collection by online ride-hailing companies

The online car-hailing driver's license information, driving license information, and vehicle information are imported in batches. The online car-hailing driver's license recognition capability can identify the name, license number, start date, expiration date, issuance date, etc.; the driver's license recognition capability can Automatically locate and identify all fields on the main page and sub-pages of the driver's license. The main page identification fields include license number, name, gender, nationality, address, date of birth, date of initial license collection, permitted driving type, validity period, issuing unit, deputy Page recognition fields include license number, name, file number, and record; the license plate recognition capability can automatically locate and identify motor vehicle license plates in mainland China, return regional number, license plate number, and license plate color information, and finally summarize the output results into a csv file . By comparing the results with actual pictures, the car-related recognition function using Tencent Cloud's intelligent text recognition can accurately and efficiently collect information about online ride-hailing companies.

1) Group 1

 

 

 

The recognition results are exported in csv mode:

 

2) The second group

 

 

Recognition results, exported in csv format:

 

2.3.3 Summary

Online ride-hailing is different from other service models. During the entire journey, the driver and the passenger coexist in a small closed space for a long time. The two parties have direct face-to-face close contact. Safety issues, especially personal safety, are of great concern to both the driver and the passenger. issues of greatest concern. Using the car-related identification function of Tencent Cloud's intelligent text recognition, you can quickly and efficiently collect online ride-hailing driver information and verify the identity of online ride-hailing drivers, effectively ensuring the safety of passengers, strengthening the review of drivers, and improving travel safety.

Learn more product information: https://cloud.tencent.com/product/vehicleocr

Guess you like

Origin blog.csdn.net/tencentAI/article/details/129196223