4 changed files with 166 additions and 0 deletions
@ -0,0 +1,146 @@ |
|||
import { v4 as uuidv4 } from 'uuid' |
|||
/** |
|||
* autoRestart 如果该字段为true,那么如果相机已启动,调用此接口,会自动重启相机。如果该字段为false,那么如果相机已启动,调用此接口,相机将继续工作,同时返回错误。 |
|||
* need_receipt 如果为false,则不返回回执。 |
|||
*/ |
|||
|
|||
const transformToString = data => { |
|||
return JSON.stringify(data) |
|||
} |
|||
|
|||
// 启动相机
|
|||
export const startCapture = transformToString({ |
|||
command: 'startCapture', |
|||
autoRestart: true, |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 停止相机
|
|||
export const stopCapture = transformToString({ |
|||
command: 'stopCapture', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 获取相机状态
|
|||
export const getCameraState = transformToString({ |
|||
command: 'getCameraState', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
/** |
|||
* 拍照 |
|||
* 1. 图片拍照需要启动相机后才能拍照。 |
|||
* 2. 拍照时间并非完全等于指令下发时间,而是取后台程序上一张实时获取的照片。 |
|||
* 3. 后台自动拍照间隙目前设置为300ms |
|||
*/ |
|||
export const takePhoto = transformToString({ |
|||
command: 'takePhoto', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
/** |
|||
* 拍照并保存 |
|||
* filePrefix 图片保存前缀,最终保存的图片格式为filePrefix+2022-07-26-12-51-46.tiff |
|||
*/ |
|||
export const takeAndSavePhoto = transformToString({ |
|||
command: 'takeAndSavePhoto', |
|||
filePrefix: 'exprose1000/phto', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 加载相机配置
|
|||
// 该指令只加载配置,不保存配置
|
|||
export const loadCameraConfig = transformToString({ |
|||
command: 'loadCameraConfig', |
|||
data: 'data:application/octet-stream;base64,IyB7MDVEOEMyOTQtRjI5NS00ZGZiLTlEMDEtMDk2QkQwNDA0OUY0fQojIEdlbkFwaSBwZXJzaXN0ZW5jZSBmaWxlICh2ZXJzaW9uIDMuMS4wKQojIERldmljZSA9IEJhc2xlcjo6R2lnRUNhbWVyYSAtLSBCYXNsZXIgZ2VuZXJpYyBHaWdFVmlzaW9uIGNhbWVyYSBpbnRlcmZhY2UgLS0gRGV2aWNlIHZlcnNpb24gPSAzLjguMCAtLSBQcm9kdWN0IEdVSUQg=', |
|||
messageId: uuidv4(), |
|||
filename: 'acA4112-8gm_40185942.pfs', |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 保存相机配置
|
|||
export const saveCameraConfig = transformToString({ |
|||
command: 'saveCameraConfig', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 启动相机识别
|
|||
export const startCharacterRecognition = transformToString({ |
|||
command: 'startCharacterRecognition', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 停止相机识别
|
|||
export const stopCharacterRecognition = transformToString({ |
|||
command: 'stopCharacterRecognition', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 获取识别结果
|
|||
export const getCharacterRecognitionResult = transformToString({ |
|||
command: 'getCharacterRecognitionResult', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 获取识别结果simple
|
|||
export const getCharacterRecognitionResultSimple = transformToString({ |
|||
command: 'getCharacterRecognitionResultSimple', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 机械臂控制接口 获取机械臂 连接信息 x y 位置
|
|||
export const getMechanicalArmState = transformToString({ |
|||
command: 'getMechanicalArmState', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
/** |
|||
* 通道1亮度 = 模拟通道亮度*数字通道1亮度 |
|||
* 通道2亮度 = 模拟通道亮度*数字通道1亮度 |
|||
* 通道3亮度 = 模拟通道亮度*数字通道1亮度 |
|||
* 通道4亮度 = 模拟通道亮度*数字通道1亮度 |
|||
*/ |
|||
|
|||
//设置模拟通道亮度
|
|||
export const setFlashBrightnessAnalog = transformToString({ |
|||
command: 'setFlashBrightnessAnalog', |
|||
brightness: 49282, |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 设置数字通道亮度
|
|||
export const setFlashBrightnessDigital = channel => { |
|||
return transformToString({ |
|||
command: 'setFlashBrightnessDigital', |
|||
channel, |
|||
brightness: 45497, |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
} |
|||
|
|||
// 打开闪光灯
|
|||
export const openFlashLight = transformToString({ |
|||
command: 'openFlashLight', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
|||
|
|||
// 关闭闪光灯
|
|||
export const closeFlashLight = transformToString({ |
|||
command: 'CloseFlashLight', |
|||
messageId: uuidv4(), |
|||
need_receipt: true, |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue