Пример #1
0
 /// <summary>
 ///     将抓拍图像提交分析
 /// </summary>
 /// <param name="data"></param>
 public void AddSnapImage(SnapVideoImage data)
 {
     if (_alive)
     {
         if (data != null && data.Img != null)
         {
             SnapImageQueue.AddToQueue(data);
         }
     }
     else
     {
         if (data != null && data.Img != null)
         {
             data.Img.Dispose();
             data = null;
         }
     }
 }
Пример #2
0
 /// <summary>
 ///     分析抓拍任务数量
 /// </summary>
 /// <param name="data"></param>
 public bool IsFull(int data)
 {
     return(SnapImageQueue.IsFull(data));
 }
Пример #3
0
        private void DataSenderTask()
        {
            Thread.Sleep(500);
            while (_alive)
            {
                try
                {
                    SnapVideoImage snapimg = SnapImageQueue.GetFromQueue();
                    if (snapimg == null)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }
                    else
                    {
                        if (snapimg.Img == null)
                        {
                            continue;
                        }

                        List <HitAlertInfoDetail> compresult;
                        byte[] bytSrc = ImageHelper.ImageToBytes(snapimg.Img);

                        bool lbRet = _faceVerify.CompareByFace(bytSrc, out compresult);
                        if (lbRet && (compresult != null) && (compresult.Count > 0) && (NoticeAlertEvent != null))
                        {
                            byte[] srcImgData = ObjectCopier.Clone(bytSrc);

                            HitAlertInfo alert = new HitAlertInfo(snapimg.SourceId, snapimg.CreateTime, srcImgData);
                            alert.Detail = new List <HitAlertInfoDetail>();
                            foreach (HitAlertInfoDetail detail in compresult)
                            {
                                if (detail.Score >= _AlertScore)
                                {
                                    alert.Detail.Add(detail);
                                }
                            }

                            // 存在符合分值的数据
                            if (alert.Detail.Count > 0)
                            {
                                // 判断是否报警
                                bool lbCheck = CheckExistAlarm(snapimg.CreateTime, alert.Detail[0].PersonId);
                                if (!lbCheck)
                                {
                                    long          timestamp     = ConvertHelper.DateTimeToStamp();
                                    HitPersonInfo hitpersoninfo = new HitPersonInfo(snapimg.CreateTime, alert.Detail[0].PersonId);

                                    _cache.Add <HitPersonInfo>(timestamp.ToString(), hitpersoninfo);

                                    NoticeAlertEvent(alert);
                                }
                                else
                                {
                                    alert = null;
                                }
                            }
                            else
                            {
                                alert = null;
                            }
                        }

                        // 销毁旧对象
                        if (snapimg != null && snapimg.Img != null)
                        {
                            snapimg.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Instance.Error("从队列接收数据错误:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                }
                Thread.Sleep(1000);
            }
        }
Пример #4
0
 public int GetCount()
 {
     return(SnapImageQueue.GetCount());
 }