示例#1
0
 public static void AddToQueue(SnapVideoImage data)
 {
     lock (_datequeue)
     {
         _datequeue.Enqueue(data);
     }
 }
示例#2
0
        public static SnapVideoImage GetFromQueue()
        {
            SnapVideoImage date = null;

            lock (_datequeue)
            {
                if (_datequeue.Count >= 0)
                {
                    _datequeue.TryDequeue(out date); //从队列中取数据
                }
            }
            return(date);
        }
示例#3
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;
         }
     }
 }
示例#4
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);
            }
        }