| | |
| | | } |
| | | export function checkUploadFile(params: Object) { |
| | | return request({ |
| | | url: `${confingInfoStore().confingInfo.faceApi}/check-face`, |
| | | url: `${confingInfoStore().confingInfo.faceApi}/test/identifyFace`, |
| | | method: 'post', |
| | | data: params, |
| | | }) |
| | |
| | | let blobFile = new File([data], 'name.png', {type:"image/png"}) |
| | | console.log(blobFile) |
| | | const formData = new FormData() // 下面有备注 |
| | | formData.append('file', blobFile) |
| | | formData.append('image', blobFile) |
| | | checkUploadFile(formData).then(re=>{ |
| | | console.log('-----',re) |
| | | if(re.code===200&&re?.result?.length>0){ |
| | | const result=re.result[0] |
| | | const entityId=result._label |
| | | const distance=result._distance |
| | | if(re.code===200&&re?.data?.data.result.length>0&&re?.data?.data.result[0]){ |
| | | const result=re?.data?.data.result[0] |
| | | const entityId=result.user_id |
| | | const distance=result.score |
| | | console.log(`entityId=`+entityId+','+'distance='+distance) |
| | | // 设置识别的的两 要大于多少 |
| | | if(entityId!=='unknown'&&distance<=faceScore){ |
| | | if(entityId!=='unknown'&&distance>=faceScore){ |
| | | console.log(entityId,'得到了人脸识别id,存患者code到vuex') |
| | | // console.log(entityId,'得到了人脸识别id,存患者code到vuex') |
| | | console.log(entityId,'得到了人脸识别id,存患者code到vuex') |
| | | sockteStore().setfaceSockte({ |
| | | type: "人脸识别", |
| | | deviceName: "人脸识别", |
| | |
| | | state:2, |
| | | }) |
| | | } |
| | | |
| | | // |
| | | }else{ |
| | | console.log('本地没识别') |
| | | } |
| | |
| | | canvas.height = video.videoHeight |
| | | // 参数:图片,裁剪开始x坐标,裁剪开始y坐标,裁剪宽度,裁剪高度,目标x坐标,目标y坐标,目标宽度,目标高度 |
| | | // context.drawImage(image, 100, 100, 200, 200, 0, 0, 200, 200); |
| | | canvas.getContext('2d')?.drawImage(video, startPoint.x-10,startPoint.y-10,width+20,height+20,0,0,width+10,height+10) |
| | | canvas.getContext('2d')?.drawImage(video, startPoint.x-20,startPoint.y-20,width+60,height+60,20,20,width+60,height+60) |
| | | const imgSrc = canvas?.toDataURL('image/png'); |
| | | |
| | | return imgSrc |