private void NoticeFaceEvent(SnapVideoImage videoImg) { BeginInvoke((MethodInvoker) delegate() { if (videoImg != null && videoImg.Img != null) { for (int ie = _listboxcontrolCnt + _changecontrolCnt - 1; ie >= 1; ie--) { PictureBox pbctrl = (PictureBox)this.listBox1.Controls[ie - 1]; PictureBox pbnextctrl = (PictureBox)this.listBox1.Controls[ie]; if ((pbctrl != null) && (pbnextctrl != null) && (pbctrl.Image != null)) { if (ie == _listboxcontrolCnt + _changecontrolCnt - 1 && pbnextctrl.Image != null) { pbnextctrl.Image.Dispose(); } pbnextctrl.Image = pbctrl.Image; } } Bitmap newImage = new Bitmap(videoImg.Img, new Size(_pictureboxWidth, _pictureboxHeight)); PictureBox firstctrl = (PictureBox)this.listBox1.Controls[0]; if (firstctrl != null) { firstctrl.Image = newImage; } videoImg.Img.Dispose(); } }); }
private void api_FaceEvent(int frameId, Bitmap image, int faceId, int faceSerial, double score) { if (image == null) { return; } if (score > _traceFaceScore && faceSerial == 3) { /////////////////////////////////// // 增加发送到Kafka try { string outputfile = score.ToString() + "_" + faceId.ToString() + ".jpg"; string filedir = _faceFilePath + DateTime.Today.ToString("yyyy-M-d") + "\\"; if (!Directory.Exists(filedir)) { Directory.CreateDirectory(filedir); } image.Save(filedir + outputfile, ImageFormat.Jpeg); Log4NetHelper.Instance.Info("图像存储文件:" + outputfile); // 将数据进行组合后重新发送 string serveroutputPath = GetResultImageServerPath(filedir + outputfile); var resultkafka = new FaceImg4kafka(); resultkafka.ImgNum = frameId.ToString(); resultkafka.PassTime = DateTime.Now.ToString("yyyyMMddHHmmss"); resultkafka.CameraIp = "127.0.0.1"; resultkafka.FaceUrl = serveroutputPath; string resultjson = Newtonsoft.Json.JsonConvert.SerializeObject(resultkafka); _imgkafkaActor.Send2Quere(resultjson); } catch (Exception ex) { Log4NetHelper.Instance.Error("FaceEvent生成Kakfa数据出现错误:" + ex.Message); } /////////////////////////////////// if (NoticeFaceEvent != null) { Image faceImg = ObjectCopier.Clone(image); SnapVideoImage videoImg = new SnapVideoImage(_videoSrcUrl, frameId.ToString(), faceId, DateTime.Now, faceImg); NoticeFaceEvent(videoImg); } image.Dispose(); } else { image.Dispose(); } }
private void NoticeFaceEvent(SnapVideoImage videoImg) { BeginInvoke((MethodInvoker) delegate() { if (videoImg != null && videoImg.Img != null) { for (int ie = _listboxcontrolCnt + _chanegelistboxcontrolCnt - 1; ie >= 1; ie--) { UcSnapImage pbctrl = null; UcSnapImage pbnextctrl = null; if (this.plNewSnap.Controls[ie - 1] is UcSnapImage) { pbctrl = (UcSnapImage)this.plNewSnap.Controls[ie - 1]; } if (this.plNewSnap.Controls[ie] is UcSnapImage) { pbnextctrl = (UcSnapImage)this.plNewSnap.Controls[ie]; } if ((pbctrl != null) && (pbnextctrl != null)) { if (ie == _listboxcontrolCnt + _chanegelistboxcontrolCnt + 1 && pbnextctrl.pbImage.Image != null) { pbnextctrl.Dispose(); } if (pbctrl.pbImage.Image != null) { pbnextctrl.pbImage.Image = pbctrl.pbImage.Image; } } } Bitmap newImage = new Bitmap(videoImg.Img, new Size(_pictureboxWidth, _pictureboxHeight)); if (this.plNewSnap.Controls[0] is UcSnapImage) { UcSnapImage firstctrl = (UcSnapImage)this.plNewSnap.Controls[0]; if (firstctrl != null) { firstctrl.pbImage.Image = newImage; } } // log var currentCount = _verifyTask.GetCount(); Log4NetHelper.Instance.Info("等待进行比对的数量:" + currentCount.ToString()); _verifyTask.AddSnapImage(videoImg); } }); }
private void watcher_FaceEvent(FileFaceImage faceimage) { if (faceimage == null || string.IsNullOrEmpty(faceimage.ImgFilePath)) { return; } /////////////////////////////////// // 增加发送到Kafka try { string outputfile = Guid.NewGuid().ToString().Replace("-", "") + ".jpg"; string filedir = _faceFilePath + DateTime.Today.ToString("yyyy-M-d") + "\\"; if (!Directory.Exists(filedir)) { Directory.CreateDirectory(filedir); } File.Copy(faceimage.ImgFilePath, filedir + outputfile); Log4NetHelper.Instance.Info("图像存储文件:" + outputfile); // 将数据进行组合后重新发送 string serveroutputPath = GetResultImageServerPath(filedir + outputfile); var resultkafka = new FaceImg4kafka(); resultkafka.ImgNum = ConvertHelper.DateTimeToStamp().ToString(); resultkafka.PassTime = faceimage.TimeStamp; resultkafka.CameraIp = faceimage.CameraIp; resultkafka.FaceUrl = serveroutputPath; string resultjson = Newtonsoft.Json.JsonConvert.SerializeObject(resultkafka); _imgkafkaActor.Send2Quere(resultjson); } catch (Exception ex) { Log4NetHelper.Instance.Error("FaceEvent生成Kakfa数据出现错误:" + ex.Message); } /////////////////////////////////// if (NoticeFaceEvent != null) { Image faceImg = new Bitmap(faceimage.ImgFilePath); string frameid = ObjectCopier.Clone(faceimage.TimeStamp); DateTime createDate = faceimage.CreateTime; SnapVideoImage videoImg = new SnapVideoImage(_videoSrcUrl, frameid, 1, createDate, faceImg); NoticeFaceEvent(videoImg); } }
private void hikvison_FaceEvent(string strSnapTime, string strDevIP, string strFilePath, Rectangle rectFace) { if (string.IsNullOrEmpty(strFilePath)) { return; } /////////////////////////////////// // 增加发送到Kafka try { // 将数据进行组合后重新发送 string serveroutputPath = GetResultImageServerPath(strFilePath); var resultkafka = new FaceImg4kafka(); resultkafka.ImgNum = ConvertHelper.DateTimeToStamp().ToString(); resultkafka.PassTime = strSnapTime; resultkafka.CameraIp = strDevIP; resultkafka.FaceUrl = serveroutputPath; string resultjson = Newtonsoft.Json.JsonConvert.SerializeObject(resultkafka); _imgkafkaActor.Send2Quere(resultjson); } catch (Exception ex) { Log4NetHelper.Instance.Error("FaceEvent生成Kakfa数据出现错误:" + ex.Message); } /////////////////////////////////// if (NoticeFaceEvent != null) { Image faceImg = new Bitmap(strFilePath); string frameid = Path.GetFileNameWithoutExtension(strFilePath); DateTime createDate = Convert.ToDateTime(strSnapTime); SnapVideoImage videoImg = new SnapVideoImage(_videoSrcUrl, frameid, 1, createDate, faceImg); NoticeFaceEvent(videoImg); } }