public void butUpdate_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.tBoxFilename.Text.Trim())) { return; } byte[] tempBytes; //图片字节数组 using (FileStream fs = new FileStream(this.tBoxFilename.Text.Trim(), FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(fs)) { tempBytes = br.ReadBytes((int)fs.Length); } } //bas64编码 string base64txt = Convert.ToBase64String(tempBytes); UploadFaceInfo uploadFaceInfo = new UploadFaceInfo() { type = this.checkBoxType.Checked ? "white" : "black", serialnumber = this.tBoxSerialnumber.Text.Trim(), name = this.tBoxName.Text.Trim(), sex = this.checkBoxSex.Checked ? "男" : "女", idnumber = this.tBoxIdnumber.Text.Trim(), filename = Path.GetFileName(this.tBoxFilename.Text.Trim()), imagebytes = base64txt }; string jsonStr = JsonConvert.SerializeObject(uploadFaceInfo); byte[] bytes = Encoding.UTF8.GetBytes(jsonStr); RobotClientControl.GetInstance().SendMsg(CODE_UPDATE, bytes); }
/// <summary> /// 处理算法端消息 /// </summary> /// <param name="code"></param> /// <param name="bytes"></param> public async void DealAlgorithmMsg(byte code, byte[] bytes) { await Task.Factory.StartNew(() => { //bas64解码 string unBase64txt = Encoding.UTF8.GetString(bytes); byte[] unBase64Bytes = Convert.FromBase64String(unBase64txt); RobotClientControl.GetInstance().ReceiveMsg(code, unBase64Bytes); }); }
private void butUpConfig_Click(object sender, EventArgs e) { PedestriansConfig pedestriansConfig = new PedestriansConfig() { type = 1, X1 = 100, Y1 = 100, X2 = 200, Y2 = 200 }; string jsonStr = JsonConvert.SerializeObject(pedestriansConfig); byte[] bytes = Encoding.UTF8.GetBytes(jsonStr); RobotClientControl.GetInstance().SendMsg(CODE_UPDATECONFIG, bytes); }
public void butDeleteBlack_Click(object sender, EventArgs e) { List <SelectFaceInfo> tempList = faceList.Where(p => p.type.Equals("black")).ToList(); int num = int.Parse(this.tBoxBlackNum.Text.Trim()); if (num > tempList.Count - 1) { return; } DeleteFaceInfo deleteFaceInfo = new DeleteFaceInfo() { type = tempList[num].type, serialnumber = tempList[num].serialnumber }; string jsonStr = JsonConvert.SerializeObject(deleteFaceInfo); byte[] bytes = Encoding.UTF8.GetBytes(jsonStr); RobotClientControl.GetInstance().SendMsg(CODE_DELETE, bytes); }
private void JavaClientControl_DataReceived(short code, byte[] bytes) { try { WriteLogRealize.GetInstance().WriteTo_rTxtJavaCode(false, code, bytes); switch (code) { case SELECTFACE: //查询人脸名单 var str01 = Encoding.UTF8.GetString(bytes); byte byte01 = (byte)int.Parse(str01); byte selectCode = 0x05; RobotClientControl.GetInstance().SendMsg(selectCode, new byte[] { byte01 }); ////模拟数据返回 //List<SelectFaceInfo> tempList = new List<SelectFaceInfo>() //{ // new SelectFaceInfo() // { // type = "white", // filename = "123.jpg", // idnumber = "10011", // index = 1, // name = "张山", // serialnumber = "1", // sex = "男", // toal = 2 // }, // new SelectFaceInfo() // { // type = "black", // filename = "234.jpg", // idnumber = "10021", // index = 2, // name = "李四", // serialnumber = "2", // sex = "男", // toal = 2 // } //}; //string jsonStr1 = UtilityJson.SerializeObject(tempList); //byte[] bytes1 = Encoding.UTF8.GetBytes(jsonStr1); //SendDataToJava(SELECTFACE, bytes1).Employ(); break; case UPDATEFACE: //上传人脸名单 byte updateCode = 0x04; RobotClientControl.GetInstance().SendMsg(updateCode, bytes); //模拟数据返回 //SendDataToJava(UPDATEFACE, Encoding.UTF8.GetBytes("0x1F")).Employ(); break; case DELETEFACE: //删除人脸名单 byte deleteCode = 0x06; //var str02 = Encoding.UTF8.GetString(bytes); //byte byte02 = (byte)int.Parse(str02); RobotClientControl.GetInstance().SendMsg(deleteCode, bytes); //模拟数据返回 //SendDataToJava(DELETEFACE, Encoding.UTF8.GetBytes("0x1F")).Employ(); break; case CLEARFACE: //清空人脸名单 byte clearCode = 0x07; RobotClientControl.GetInstance().SendMsg(clearCode, bytes); //模拟数据返回 //SendDataToJava(CLEARFACE, Encoding.UTF8.GetBytes("0x1F")).Employ(); break; case IDENTIFYFACE: //人脸识别 byte identifyCode = 0x03; RobotClientControl.GetInstance().SendMsg(identifyCode, bytes); //模拟数据返回 //SendDataToJava(IDENTIFYFACE, Encoding.UTF8.GetBytes("0x1F")).Employ(); //short tempshort1 = 0x08; //报警 //string filename = @"C:\Users\Administrator\Desktop\20180811113140.jpg"; //byte[] tempBytes = File.ReadAllBytes(filename); ////bas64编码 //string base64txt = Convert.ToBase64String(tempBytes); //AlarmFaceInfo alarmFaceInfo = new AlarmFaceInfo() //{ // name = "夏六马", // robotnumber = 1, // serialnumber = "1", // type = "white", // imagebytes = base64txt //}; //string jsonStr2 = UtilityJson.SerializeObject(alarmFaceInfo); //byte[] bytes2 = Encoding.UTF8.GetBytes(jsonStr2); //SendDataToJava(tempshort1, bytes2).Employ(); break; case REGIONDETECTION: //区域监测 byte detectionCode = 0x20; RobotClientControl.GetInstance().SendMsg(detectionCode, bytes); break; case UPLOADCONFIG: //上传人脸名单 byte uploadconfigCode = 0x21; RobotClientControl.GetInstance().SendMsg(uploadconfigCode, bytes); break; } } catch (Exception ex) { WriteLogRealize.GetInstance().WriteTo_rTxtLog("解析Java数据异常:" + ex.ToString()); } }
private void butGetConfig_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_DETECTION, new byte[] { 0x5E }); }
private void butStopDetection_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_DETECTION, new byte[] { 0x3E }); }
public void butStopIdentify_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_IDENTIFY, new byte[] { 0x3E }); }
public void butClearAll_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_CLEAR, new byte[] { 0x3E }); }
public void butSelectAll_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_SELECT, new byte[] { 0x3E }); }
/// <summary> /// 关闭跟随 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void butStopFollow_Click(object sender, EventArgs e) { RobotClientControl.GetInstance().SendMsg(CODE_FOLLOW, new byte[] { 0x3E }); }