lv #16
@ -32,8 +32,17 @@ export default class EntryAbility extends UIAbility {
|
|||||||
globalThis.judgeVersion = '2024.11.22.14'
|
globalThis.judgeVersion = '2024.11.22.14'
|
||||||
globalThis.videoVersion= '1.0'
|
globalThis.videoVersion= '1.0'
|
||||||
// globalThis.version = '2022.03.14.01'
|
// globalThis.version = '2022.03.14.01'
|
||||||
|
//视频遮挡
|
||||||
globalThis.context = this.context;
|
globalThis.spzd={
|
||||||
|
spzd1:false,
|
||||||
|
spzd2:false,
|
||||||
|
spzd3:false,
|
||||||
|
spzd4:false,
|
||||||
|
}
|
||||||
|
globalThis.singlePlay=false //单机模式
|
||||||
|
globalThis.signNum=0//心跳指令编号
|
||||||
|
globalThis.lsh='0000000000000'//学员流水号
|
||||||
|
globalThis.statue=1//考试状态
|
||||||
globalThis.pathDir = this.context.filesDir;
|
globalThis.pathDir = this.context.filesDir;
|
||||||
console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir);
|
console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir);
|
||||||
// this.requestPermission(this.context)
|
// this.requestPermission(this.context)
|
||||||
|
|||||||
@ -9,10 +9,14 @@ import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
|
|||||||
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
||||||
import { getTCP } from '../common/utils/GlobalTcp';
|
import { getTCP } from '../common/utils/GlobalTcp';
|
||||||
import testNapi from '@ohos.hiserialsdk';
|
import testNapi from '@ohos.hiserialsdk';
|
||||||
|
import {
|
||||||
|
getEsCarModel,
|
||||||
|
} from '../common/service/initable'
|
||||||
import {
|
import {
|
||||||
getDoubleCeneterTable,
|
getDoubleCeneterTable,
|
||||||
getliushuiNum,
|
getliushuiNum,
|
||||||
getSingleCenterTable,
|
getSingleCenterTable,
|
||||||
|
setliushuiNum,
|
||||||
takePhotoFn
|
takePhotoFn
|
||||||
} from '../common/service/indexService';
|
} from '../common/service/indexService';
|
||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||||
@ -31,6 +35,7 @@ struct Index {
|
|||||||
@State ratio: number = 1700 / 960
|
@State ratio: number = 1700 / 960
|
||||||
@State loading: boolean = true
|
@State loading: boolean = true
|
||||||
@State fd: number = -1;
|
@State fd: number = -1;
|
||||||
|
private interval=null;
|
||||||
private context = getContext(this) as common.UIAbilityContext;
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
fileHelper =null;
|
fileHelper =null;
|
||||||
build() {
|
build() {
|
||||||
@ -78,6 +83,7 @@ struct Index {
|
|||||||
if (globalThis.timeInfo?.mode == '3') {
|
if (globalThis.timeInfo?.mode == '3') {
|
||||||
await getDoubleCeneterTable()
|
await getDoubleCeneterTable()
|
||||||
} else if (globalThis.timeInfo?.mode == '1') {
|
} else if (globalThis.timeInfo?.mode == '1') {
|
||||||
|
//单中心
|
||||||
await getSingleCenterTable()
|
await getSingleCenterTable()
|
||||||
} else {
|
} else {
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
@ -135,8 +141,6 @@ struct Index {
|
|||||||
GestureGroup(GestureMode.Exclusive,
|
GestureGroup(GestureMode.Exclusive,
|
||||||
TapGesture({ count: 2 })
|
TapGesture({ count: 2 })
|
||||||
.onAction(() => {
|
.onAction(() => {
|
||||||
// takePhotoFn(this.context)
|
|
||||||
|
|
||||||
globalThis.singlePlay = !globalThis.singlePlay
|
globalThis.singlePlay = !globalThis.singlePlay
|
||||||
this.isSingle = globalThis.singlePlay
|
this.isSingle = globalThis.singlePlay
|
||||||
})
|
})
|
||||||
@ -201,7 +205,6 @@ struct Index {
|
|||||||
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
||||||
}
|
}
|
||||||
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId}
|
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId}
|
||||||
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
|
|
||||||
globalThis.udpClient2.sendMsg(param, this.context)
|
globalThis.udpClient2.sendMsg(param, this.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,11 +212,12 @@ struct Index {
|
|||||||
this.loading = false
|
this.loading = false
|
||||||
this.createAlbum()
|
this.createAlbum()
|
||||||
this.userAuth();
|
this.userAuth();
|
||||||
|
//plc
|
||||||
getUDP()
|
getUDP()
|
||||||
getUDP2()
|
getUDP2()
|
||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
this.interval=setInterval(() => {
|
this.interval=setInterval(() => {
|
||||||
setliushuiNum()
|
setliushuiNum(this.context)
|
||||||
getliushuiNum()
|
getliushuiNum()
|
||||||
this.heartMsg()
|
this.heartMsg()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@ -275,7 +279,6 @@ struct Index {
|
|||||||
// await this.getModel()
|
// await this.getModel()
|
||||||
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
||||||
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
|
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
|
||||||
console.info(testNapi)
|
|
||||||
}
|
}
|
||||||
async getModel() {
|
async getModel() {
|
||||||
const context = this.context;
|
const context = this.context;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import AccountTable from '../common/database/tables/AccountTable';
|
|||||||
import USER from '../common/constants/USER';
|
import USER from '../common/constants/USER';
|
||||||
import { dateFormat, getCurrentTime } from '../common/utils/tools';
|
import { dateFormat, getCurrentTime } from '../common/utils/tools';
|
||||||
import MA_SYSSET from '../common//constants/MA_SYSSET';
|
import MA_SYSSET from '../common//constants/MA_SYSSET';
|
||||||
import FaceCompare from './compontents/faceCompareByhaikang'
|
import FaceCompare from './compontents/FaceCompare'
|
||||||
// import { initJudgeUdp } from '../common/utils/UdpJudge'
|
// import { initJudgeUdp } from '../common/utils/UdpJudge'
|
||||||
import { writeObjectOut } from '../api/judge'
|
import { writeObjectOut } from '../api/judge'
|
||||||
import testNapi from "@ohos.idcard";
|
import testNapi from "@ohos.idcard";
|
||||||
|
|||||||
@ -1,38 +1,72 @@
|
|||||||
import camera from '@ohos.multimedia.camera';
|
//@ts-ignore
|
||||||
import { cameraService } from '../../common/service/cameraService';
|
|
||||||
import { voiceService } from '../../common/service/voiceService';
|
|
||||||
import { faceCompare } from '../../api/userInfo';
|
|
||||||
import prompt from '@ohos.prompt';
|
|
||||||
import grantPermission from '../../common/utils/PermissionUtils';
|
|
||||||
import CameraModel from '../../common/service/CameraModel';
|
|
||||||
|
|
||||||
let previewWidth;
|
import util from '@ohos.util';
|
||||||
let previewHeight;
|
|
||||||
|
|
||||||
const PERMISSIONS: Array<string> = [
|
import { voiceService } from '../../common/service/voiceService'
|
||||||
'ohos.permission.CAMERA']
|
import { faceCompare } from '../../api/userInfo'
|
||||||
|
import FileUtil from '../../common/utils/File'
|
||||||
|
import { VideoConfig } from '../interfaces'
|
||||||
|
import common from '@ohos.app.ability.common';
|
||||||
|
|
||||||
|
import { string2Bytes } from '../../common/utils/tools'
|
||||||
|
import { takePhoto } from '../../common/service/videoService'
|
||||||
|
import { GlobalConfig } from '../../config/index'
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default struct FaceCompare {
|
export default struct FaceCompare {
|
||||||
@State imageBase64: string = 'data:image/jpeg;base64,'
|
|
||||||
@Prop sfzh: string;
|
|
||||||
@Prop firstImage: string;
|
|
||||||
@Link showFaceCompare: boolean;
|
|
||||||
@Link faceCompareSucess: boolean;
|
|
||||||
@State imageThumbnail: string = '';
|
|
||||||
private mXComponentController: XComponentController = new XComponentController();
|
|
||||||
private cameraModel: CameraModel = new CameraModel();
|
|
||||||
private cameraObj = null;
|
|
||||||
private timer = null; //人脸比对执行任务定时器
|
|
||||||
private stopClose = false; // 阻止用户关闭此组件
|
|
||||||
private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发
|
|
||||||
private vocObj = null;
|
|
||||||
private surfaceId: string = '';
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@State imageBase64: string = 'data:image/jpeg;base64,'
|
||||||
|
@Prop sfzh: string;
|
||||||
|
@Prop lsh: string;
|
||||||
|
@Prop firstImage: string;
|
||||||
|
@Link faceCompareSucess: number;
|
||||||
|
@Link showFaceCompare: boolean;
|
||||||
|
@Link getqkFlag: boolean;
|
||||||
|
@Link faceCatchImg: string;
|
||||||
|
@State imageThumbnail: string = '';
|
||||||
|
private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发
|
||||||
|
private vocObj = null;
|
||||||
|
@State callBackFlag: boolean = false;
|
||||||
|
@State @Watch('clearIntervalFn') showFaceCompareFlag: Boolean = false;
|
||||||
|
@State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream'
|
||||||
|
@State previewUri: Resource = $r('app.media.2_nor')
|
||||||
|
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
|
||||||
|
@State showControls: boolean = false
|
||||||
|
private controller: VideoController = new VideoController()
|
||||||
|
@State isAutoPlay: boolean = true
|
||||||
|
@State signNum: number = 0;
|
||||||
|
private fileUtil: FileUtil
|
||||||
|
private interval: any
|
||||||
|
@State param: VideoConfig = {
|
||||||
|
spls: '',
|
||||||
|
videoNum: '1',
|
||||||
|
faceFlag: false,
|
||||||
|
pztd: '1',
|
||||||
|
ljlx: '',
|
||||||
|
ip: '192.168.7.112',
|
||||||
|
port: '554',
|
||||||
|
userName: 'admin',
|
||||||
|
pwd: '12345qwe',
|
||||||
|
td1: '1',
|
||||||
|
td2: '2',
|
||||||
|
td3: '3',
|
||||||
|
td4: '4',
|
||||||
|
videoRecord1: false,
|
||||||
|
videoRecord2: false,
|
||||||
|
videoRecord3: false,
|
||||||
|
videoRecord4: false,
|
||||||
|
rlls: '1',
|
||||||
|
spzd4:false,
|
||||||
|
spzd3:false,
|
||||||
|
spzd2:false,
|
||||||
|
spzd1:false,
|
||||||
|
zdyz:'500',
|
||||||
|
}
|
||||||
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
Column() {
|
Column() {
|
||||||
@ -44,29 +78,22 @@ export default struct FaceCompare {
|
|||||||
|
|
||||||
Row() {
|
Row() {
|
||||||
Row() {
|
Row() {
|
||||||
XComponent({
|
Video({
|
||||||
id: 'componentId',
|
src: this.showFaceCompare ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream` : '',
|
||||||
type: 'surface',
|
previewUri: this.previewUri,
|
||||||
controller: this.mXComponentController
|
currentProgressRate: PlaybackSpeed.Speed_Forward_1_00_X,
|
||||||
})
|
controller: this.controller,
|
||||||
.onLoad(() => {
|
|
||||||
// this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:640,surfaceHeight:480});
|
|
||||||
// let surfaceId = this.mXComponentController.getXComponentSurfaceId()
|
|
||||||
// console.log('jiangsong: xcomponentController this.surfaceId = ' + surfaceId)
|
|
||||||
this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 640, surfaceHeight: 480 });
|
|
||||||
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
|
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
|
|
||||||
this.readyToTakePhoto(this.surfaceId)
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
.muted(true)
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
.backgroundColor(Color.Black)
|
.autoPlay(this.isAutoPlay)
|
||||||
|
.controls(this.showControls)
|
||||||
}
|
}
|
||||||
.width('48%')
|
.width('48%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
|
|
||||||
|
|
||||||
Row() {
|
Row() {
|
||||||
Image(this.firstImage)
|
Image(this.firstImage)
|
||||||
.width('100%')
|
.width('100%')
|
||||||
@ -106,9 +133,7 @@ export default struct FaceCompare {
|
|||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
.backgroundImageSize({ width: '100%', height: '100%' })
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
this.times = 1;
|
this.times = 1;
|
||||||
// this.takePhoto('face_check.mp3');
|
|
||||||
this.readyToTakePhoto(this.surfaceId);
|
|
||||||
// await this.cameraObj.releaseSource()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.width('88.9%')
|
.width('88.9%')
|
||||||
@ -134,24 +159,14 @@ export default struct FaceCompare {
|
|||||||
.backgroundImage($r('app.media.close'))
|
.backgroundImage($r('app.media.close'))
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
.backgroundImageSize({ width: '100%', height: '100%' })
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
// prompt.showToast({
|
this.controller.stop()
|
||||||
// message: '人脸比对程序正在执行,请等待程序执行完毕。',
|
this.vocObj && this.vocObj.releasePlayer()
|
||||||
// duration: 3000
|
this.showFaceCompare = !this.showFaceCompare
|
||||||
// });
|
this.showFaceCompareFlag=!this.showFaceCompareFlag
|
||||||
this.showFaceCompare = false
|
this.faceCompareSucess = -1
|
||||||
this.faceCompareSucess = false
|
globalThis.statue = 2
|
||||||
return
|
|
||||||
console.log('jiangsong close the faceCompare componet');
|
|
||||||
if (!this.stopClose) {
|
|
||||||
this.showFaceCompare = false
|
|
||||||
|
|
||||||
} else {
|
|
||||||
prompt.showToast({
|
|
||||||
message: '人脸比对程序正在执行,请等待程序执行完毕。',
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
this.showFaceCompare = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
@ -161,178 +176,177 @@ export default struct FaceCompare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onPageShow() {
|
onPageShow() {
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
// this.cameraModel.initCamera(this.surfaceId);
|
const fileUtil = new FileUtil(this.context)
|
||||||
await grantPermission().then(res => {
|
this.fileUtil = fileUtil
|
||||||
if (this.surfaceId) {
|
this.getVideoConfig()
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
}
|
|
||||||
}).catch(rej => {
|
|
||||||
})
|
|
||||||
|
|
||||||
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
|
|
||||||
// this.cameraModel.setTakePictureHandleCallback(this.takePictureHandle.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// takePictureHandle = (thumbnail: string) => {
|
clearIntervalFn() {
|
||||||
// this.imageThumbnail = thumbnail;
|
this.callBackFlag = false
|
||||||
// };
|
clearInterval(this.interval)
|
||||||
|
this.vocObj && this.vocObj.releasePlayer()
|
||||||
async initCamera(surfaceId: string) {
|
|
||||||
//动态获取隐私权限
|
|
||||||
let context = getContext(this) as any
|
|
||||||
await context.requestPermissionsFromUser(PERMISSIONS)
|
|
||||||
console.log('grantPermission,requestPermissionsFromUser');
|
|
||||||
// 创建CameraManager对象
|
|
||||||
let cameraManager = await camera.getCameraManager(context)
|
|
||||||
if (!cameraManager) {
|
|
||||||
console.error('Failed to get the CameraManager instance');
|
|
||||||
}
|
|
||||||
// 获取相机列表
|
|
||||||
let cameraArray = await cameraManager.getSupportedCameras()
|
|
||||||
if (!cameraArray) {
|
|
||||||
console.error('Failed to get the cameras');
|
|
||||||
}
|
|
||||||
for (let index = 0; index < cameraArray.length; index++) {
|
|
||||||
console.log('cameraId : ' + cameraArray[index].cameraId) // 获取相机ID
|
|
||||||
console.log('cameraPosition : ' + cameraArray[index].cameraPosition) // 获取相机位置
|
|
||||||
console.log('cameraType : ' + cameraArray[index].cameraType) // 获取相机类型
|
|
||||||
console.log('connectionType : ' + cameraArray[index].connectionType) // 获取相机连接类型
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建相机输入流
|
getqkFn() {
|
||||||
let cameraInput = await cameraManager.createCameraInput(cameraArray[0])
|
let tmpList = [];
|
||||||
|
tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
|
||||||
// 打开相机
|
const param = {
|
||||||
await cameraInput.open().then(() => {
|
id: 41,
|
||||||
console.log('opencamera succ.');
|
list: tmpList,
|
||||||
}).catch(function (err) {
|
carNo: globalThis.carInfo.carNo,
|
||||||
console.log("opencamera failed with error:" + err);
|
placeId: globalThis.carInfo.examinationRoomId
|
||||||
});
|
}
|
||||||
|
globalThis.udpClient2.sendMsg(param, this.context)
|
||||||
// 获取相机设备支持的输出流能力
|
|
||||||
let cameraOutputCap = await cameraManager.getSupportedOutputCapability(cameraArray[0]);
|
|
||||||
if (!cameraOutputCap) {
|
|
||||||
console.error("outputCapability outputCapability == null || undefined")
|
|
||||||
} else {
|
|
||||||
console.log("outputCapability: " + JSON.stringify(cameraOutputCap));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取相机支持的输出能力--支持的预览配置信息
|
async faceComparFn() {
|
||||||
let previewProfilesArray = cameraOutputCap.previewProfiles;
|
console.log('mmmmm0',1)
|
||||||
if (!previewProfilesArray) {
|
|
||||||
console.error("createOutput previewProfilesArray == null || undefined")
|
|
||||||
} else {
|
|
||||||
console.log("previewProfiles:" + JSON.stringify(previewProfilesArray[0]))
|
|
||||||
previewWidth = previewProfilesArray[0].size.width;
|
|
||||||
previewHeight = previewProfilesArray[0].size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建预览输出流,其中参数 surfaceId 参考下面 XComponent 组件,预览流为XComponent组件提供的surface
|
takePhoto(this.param, this.context, 'jt/',0,({base64})=>{
|
||||||
let previewOutput = await cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId)
|
|
||||||
if (!previewOutput) {
|
|
||||||
console.error("Failed to create the PreviewOutput instance.")
|
|
||||||
} else {
|
|
||||||
console.log("create the PreviewOutput instance succ.")
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建会话
|
|
||||||
let captureSession = await cameraManager.createCaptureSession()
|
|
||||||
if (!captureSession) {
|
|
||||||
console.error('Failed to create the CaptureSession instance.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log('Callback returned with the CaptureSession instance.' + captureSession);
|
|
||||||
|
|
||||||
// 开始配置会话
|
|
||||||
await captureSession.beginConfig()
|
|
||||||
|
|
||||||
// 向会话中添加相机输入流
|
|
||||||
await captureSession.addInput(cameraInput)
|
|
||||||
|
|
||||||
// 向会话中添加预览输入流
|
|
||||||
await captureSession.addOutput(previewOutput)
|
|
||||||
|
|
||||||
// 提交会话配置
|
|
||||||
await captureSession.commitConfig()
|
|
||||||
// 启动会话
|
|
||||||
await captureSession.start().then(() => {
|
|
||||||
console.log('captureSession start success.');
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log("captureSession start failed with error:" + err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async aboutToDisappear() {
|
|
||||||
clearTimeout(this.timer)
|
|
||||||
this.vocObj.releasePlayer()
|
|
||||||
this.cameraObj.releaseSource()
|
|
||||||
}
|
|
||||||
|
|
||||||
async readyToTakePhoto(surfaceId) {
|
|
||||||
this.surfaceId = surfaceId;
|
|
||||||
this.cameraObj = new cameraService(surfaceId);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.showFaceCompare = false
|
|
||||||
this.faceCompareSucess = true;
|
|
||||||
}, 3000)
|
|
||||||
return
|
|
||||||
await this.cameraObj.initCamera((img) => {
|
|
||||||
console.log('jiangsong getPhoto res.' + img.slice(0, 100))
|
|
||||||
this.imageBase64 = 'data:image/jpeg;base64,' + img;
|
|
||||||
const firstImage = this.firstImage.substr(22)
|
|
||||||
faceCompare({
|
faceCompare({
|
||||||
sfzh: this.sfzh,
|
sfzh: this.sfzh,
|
||||||
firstImage: firstImage,
|
firstImage: this.firstImage.substr(22),
|
||||||
// sfzh: '321281198605076819',
|
secondImage: base64,
|
||||||
// firstImage: this.firstImage,
|
|
||||||
secondImage: img,
|
|
||||||
type: 2,
|
type: 2,
|
||||||
verifyType: 1
|
verifyType: 1
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
console.log('mmmmm8',res)
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
console.log('jiangsong face compare success' + JSON.stringify(res))
|
this.controller.stop()
|
||||||
this.showFaceCompare = false
|
this.showFaceCompare = !this.showFaceCompare
|
||||||
this.faceCompareSucess = true;
|
this.showFaceCompareFlag=!this.showFaceCompareFlag
|
||||||
} else {
|
this.faceCompareSucess = 1;
|
||||||
console.log('jiangsong face compare faild')
|
// this.faceCatchImg = result
|
||||||
//3s后开始语音提示
|
|
||||||
this.timer = setTimeout(() => {
|
|
||||||
this.takePhoto('face_fail.mp3');
|
|
||||||
}, 3000)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
this.vocObj = new voiceService(async (status) => {
|
|
||||||
console.log('jiangsong voiceService callback. status == ' + status)
|
|
||||||
if (status == 'completed') {
|
|
||||||
this.cameraObj.takePhoto();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//3s后开始语音提示
|
|
||||||
this.timer = setTimeout(() => {
|
|
||||||
this.takePhoto('face_check.mp3');
|
|
||||||
}, 3000)
|
|
||||||
}
|
|
||||||
|
|
||||||
takePhoto(name) {
|
|
||||||
this.stopClose = true;
|
|
||||||
if (this.times > 3) {
|
|
||||||
this.stopClose = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.times++;
|
|
||||||
|
|
||||||
this.vocObj.playAudio({
|
this.vocObj.playAudio({
|
||||||
type: 1,
|
type: 1,
|
||||||
name: name
|
name: 'yzcg.wav'
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
this.times++;
|
||||||
|
//3s后开始语音提示
|
||||||
|
this.vocObj.playAudio({
|
||||||
|
type: 1,
|
||||||
|
name: 'face_fail.mp3'
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
console.log('mmmmm8',9)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async heartMsg(context) {
|
||||||
|
let tmpList = []
|
||||||
|
const str = this.lsh
|
||||||
|
for (let i = 0;i < str.length; i++) {
|
||||||
|
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
||||||
|
}
|
||||||
|
const param = {
|
||||||
|
id: 46,
|
||||||
|
list: tmpList,
|
||||||
|
carNo: globalThis.carInfo.carNo,
|
||||||
|
placeId: globalThis.carInfo.examinationRoomId,
|
||||||
|
sendCallback: () => {
|
||||||
|
this.callBackFlag = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
|
||||||
|
clearInterval(this.interval)
|
||||||
|
this.interval = setInterval(() => {
|
||||||
|
if (this.callBackFlag) {
|
||||||
|
const param2 = {
|
||||||
|
id: 47,
|
||||||
|
list: tmpList,
|
||||||
|
carNo: globalThis.carInfo.carNo,
|
||||||
|
placeId: globalThis.carInfo.examinationRoomId,
|
||||||
|
}
|
||||||
|
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
globalThis.udpClient2.setMsgCallBack((val) => {
|
||||||
|
if (val.id == '48') {
|
||||||
|
if (val.body[13] == '1') {
|
||||||
|
this.showFaceCompareFlag=!this.showFaceCompareFlag
|
||||||
|
this.showFaceCompare = !this.showFaceCompare
|
||||||
|
this.vocObj && this.vocObj.releasePlayer()
|
||||||
|
this.faceCompareSucess = 1
|
||||||
|
clearInterval(this.interval)
|
||||||
|
} else if (val.body[13] == '0' && this.callBackFlag) {
|
||||||
|
globalThis.statue = 2
|
||||||
|
this.vocObj && this.vocObj.playAudio({
|
||||||
|
type: 1,
|
||||||
|
name: 'face_chekc_fail.wav'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async getVideoConfig() {
|
||||||
|
console.log('faceEnterIn')
|
||||||
|
this.vocObj = new voiceService(async (status, val, next) => {
|
||||||
|
if (status == 'idle') {
|
||||||
|
if (val == 'face_check.mp3' || val == 'face_fail.mp3') {
|
||||||
|
if (this.times >= 3) {
|
||||||
|
globalThis.statue = 3
|
||||||
|
this.faceCompareSucess = -1;
|
||||||
|
this.vocObj && this.vocObj.playAudio({
|
||||||
|
type: 1,
|
||||||
|
name: 'face_checking.wav'
|
||||||
|
})
|
||||||
|
this.heartMsg(this.context)
|
||||||
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.faceComparFn()
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
} else if (val == 'yzcg.wav') {
|
||||||
|
this.showFaceCompare = !this.showFaceCompare
|
||||||
|
this.showFaceCompareFlag=!this.showFaceCompareFlag
|
||||||
|
globalThis.statue = 4
|
||||||
|
this.faceCompareSucess = 1;
|
||||||
|
this.vocObj && this.vocObj.releasePlayer()
|
||||||
|
|
||||||
|
} else if (val == 'face_chekc_fail.wav') {
|
||||||
|
this.vocObj && this.vocObj.releasePlayer()
|
||||||
|
this.faceCompareSucess = -1
|
||||||
|
this.showFaceCompare = !this.showFaceCompare
|
||||||
|
this.showFaceCompareFlag=!this.showFaceCompareFlag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
|
||||||
|
console.log('faceEnterIn,data',data)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.vocObj && this.vocObj.playAudio({
|
||||||
|
type: 1,
|
||||||
|
name: 'face_check.mp3'
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
this.param = JSON.parse(data)
|
||||||
|
this.param.userName = JSON.parse(data).userName
|
||||||
|
this.param.ip = this.param.ip
|
||||||
|
this.param.pwd = this.param.pwd
|
||||||
|
this.param.port = this.param.port
|
||||||
|
this.param.rlls = this.param.rlls
|
||||||
|
this.controller.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async aboutToDisappear() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// export default FaceCompare
|
|
||||||
@ -6,7 +6,10 @@
|
|||||||
"mainElement": "EntryAbility",
|
"mainElement": "EntryAbility",
|
||||||
"deviceTypes": [
|
"deviceTypes": [
|
||||||
"default",
|
"default",
|
||||||
"tablet"
|
"tablet",
|
||||||
|
"pad",
|
||||||
|
"wearable",
|
||||||
|
"car",
|
||||||
],
|
],
|
||||||
"deliveryWithInstall": true,
|
"deliveryWithInstall": true,
|
||||||
"installationFree": false,
|
"installationFree": false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user