Ejemplo n.º 1
0
 public void GetFaceTaskData()
 {
     mVehicleTaskList = VehicleMongoDAL.GetInstance().GetAllVehicleTask();
     try
     {
         this.Invoke(new DelegateBindHandler(BindDataSource));
     }
     catch
     { }
 }
Ejemplo n.º 2
0
        public void GetVehicleListData()
        {
            mVehicleObjList.Clear();
            mCardTargetList.Clear();
            mTargetQuery.PageNumber = 1;
            mTargetQuery.PageSize   = 30;
            mTargetQuery.PageNumber = pagerVehicle.CurrentPage;
            mTargetQuery.PageSize   = pagerVehicle.RecordsPerPage;
            //mVehicleCount = VehicleMongoDAL.GetInstance().GetVehicleCount();
            mVehicleCount = VehicleMongoDAL.GetInstance().GetVehicleCount(mTargetQuery);
            //mVehicleObjList = VehicleMongoDAL.GetInstance().GetVehicleList(pagerVehicle.CurrentPage, pagerVehicle.RecordsPerPage);
            mVehicleObjList = VehicleMongoDAL.GetInstance().GetVehicleList(mTargetQuery);
            int i = 0;

            foreach (var vehicleObj in mVehicleObjList)
            {
                CardTargetItem itemInfo = new CardTargetItem();
                //Image vehImage =Image.FromFile(vehicleObj.ImagePath);

                //itemInfo.ShowImage = vehImage;
                Cell cell = new Cell {
                    FieldName = "ShowImage", RowIndex = i++, FileName = vehicleObj.ImagePath, RectBody = vehicleObj.vehicle.Clwz
                };
                LoadImageAsync(cell);
                itemInfo.PassTime  = "时间:" + Convert.ToDateTime(vehicleObj.CreateTime.AsDateTime.AddHours(8)).ToString("yyyy-MM-dd HH:mm:ss");
                itemInfo.PlateNo   = "车牌:" + vehicleObj.vehicle.Hphm;
                itemInfo.CrossName = "车型:" + vehicleObj.vehicle.Clpp;
                foreach (var item in VehicleDictList.GetInstance().GetVehicleTypeList())
                {
                    if (item.SYSDICT_CODE == vehicleObj.vehicle.Cllx)
                    {
                        itemInfo.PlateNo += "    类型:" + item.SYSDICT_NAME + "  ";
                        break;
                    }
                }
                mCardTargetList.Add(itemInfo);
            }
            try
            {
                this.Invoke(new DelegateBindHandler(BindDataSource));
            }
            catch
            { }
        }
Ejemplo n.º 3
0
 private void simpleButtonAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textEdit1.Text))
     {
         mTaskPath = textEdit1.Text;
         VehicleTask vehicleTask = new VehicleTask();
         vehicleTask.CreateTime = new BsonDateTime(DateTime.Now);
         vehicleTask.TaskId     = DateTime.Now.ToString("yyyyMMddHHmmssfff");
         vehicleTask.TaskPath   = mTaskPath;
         vehicleTask.TaskState  = "0";
         vehicleTask.TaskCount  = "0";
         bool bResult = VehicleMongoDAL.GetInstance().AddVehicleTask(vehicleTask);
         if (bResult)
         {
             XtraMessageBox.Show("添加成功!");
             loadTaskData();
         }
     }
     else
     {
         XtraMessageBox.Show("先选择路径!");
     }
 }
Ejemplo n.º 4
0
        private void SearchFaceMongo()
        {
            mCardVehResultList.Clear();
            mSortedVehResult.Clear();
            mSortedVehResultList.Clear();
            HVehicleQuery vehicleQuery = new HVehicleQuery();

            vehicleQuery.timeStart = Convert.ToDateTime(dtpStrartTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            vehicleQuery.timeEnd   = Convert.ToDateTime(dtpEndTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            vehicleQuery.queryClpp = mQueryClpp;

            LogHelper.WriteLog(typeof(FrmVehSearchByPic), "count start");
            //int mTotalVehCount = Convert.ToInt32(VehicleMongoDAL.GetInstance().GetVehicleCount());
            int mTotalVehCount = Convert.ToInt32(VehicleMongoDAL.GetInstance().GetVehicleCount(vehicleQuery));

            LogHelper.WriteLog(typeof(FrmVehSearchByPic), "count end " + mTotalVehCount);
            int RecordsPerPage = 1000;
            int pageCount      = mTotalVehCount / RecordsPerPage;

            if (mTotalVehCount % RecordsPerPage == 0)
            {
                pageCount = mTotalVehCount / RecordsPerPage;
            }
            else
            {
                pageCount = mTotalVehCount / RecordsPerPage + 1;
            }
            vehicleQuery.PageSize = RecordsPerPage;

            LogHelper.WriteLog(typeof(FrmVehSearchByPic), "query start");
            //ObjectId fistId = VehicleMongoDAL.GetInstance().GetVehicleFirstId(vehicleQuery);
            for (int i = 1; i <= pageCount; i++)
            {
                LogHelper.WriteLog(typeof(FrmVehSearchByPic), "mongo start" + i);
                //List<FaceObject> TempFaceObjList = FaceMongoDAL.GetInstance().GetFaceList(i, RecordsPerPage);
                vehicleQuery.PageNumber = i;
                //List<VehicleObject> TempFaceObjList = VehicleMongoDAL.GetInstance().GetVehicleListGtId(fistId, vehicleQuery);
                List <VehicleObject> TempFaceObjList = VehicleMongoDAL.GetInstance().GetVehicleList(vehicleQuery);

                /*
                 * if (null != TempFaceObjList)
                 * {
                 *  if (TempFaceObjList.Count > 0)
                 *  {
                 *      fistId = TempFaceObjList[TempFaceObjList.Count - 1].Id;
                 *  }
                 * }*/
                LogHelper.WriteLog(typeof(FrmVehSearchByPic), "mongo end");

                double progress = (double)i / (double)pageCount * 100;
                try
                {
                    this.Invoke(new DelegateProgress(ShowProgress), Convert.ToInt32(progress));
                }
                catch
                {
                }

                foreach (var faceObj in TempFaceObjList)
                {
                    if (mVehSearchResult.Veh[nSelectedIndex].Cbdm != faceObj.vehicle.Cbdm)
                    {
                        continue;
                    }
                    VehicleCompareResult faceResult = new VehicleCompareResult();
                    float score = 0;// (float)VehSimCos.HCARREGSimCos(mSearchFaceBase64, faceObj.vehicle.Cltzxx);//Feature.Compare(mSearchFaceBase64, faceObj.FaceFeature);
                    faceResult.Score      = score;
                    faceResult.CreateTime = faceObj.CreateTime.AsDateTime.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss");
                    faceResult.ImagePath  = faceObj.ImagePath;
                    faceResult.Clpp       = faceObj.vehicle.Clpp;
                    faceResult.Clwz       = faceObj.vehicle.Clwz;
                    faceResult.Cphm       = faceObj.vehicle.Hphm;
                    mSortedVehResult.Add(faceResult);
                    if (mSortedVehResult.Count > 100)
                    {
                        mSortedVehResult.Remove(mSortedVehResult.Last());
                    }
                }
            }
            mSortedVehResultList = mSortedVehResult.ToList();
            LogHelper.WriteLog(typeof(FrmVehSearchByPic), "query end");

            try
            {
                this.Invoke(new DelegateBindHandler(BindDataSource));
            }
            catch
            { }
        }
Ejemplo n.º 5
0
        private void ReceiveMsg(Object threadContext)
        {
            ZError errors;
            int    threadIndex = (int)threadContext;

            Console.WriteLine("thread {0} ZmqFaceSink Start Receive Message !", threadIndex);
            while (receiving)
            {
                using (ZFrame frame = receiverSocketList[threadIndex].ReceiveFrame(ZSocketFlags.DontWait, out errors))
                {
                    if (null != frame)
                    {
                        // Process task
                        string        str           = System.Text.Encoding.UTF8.GetString(frame.Read());
                        List <string> mFileNameList = JsonConvert.DeserializeObject <List <string> >(str);
                        LogHelper.WriteLog(typeof(ZmqVehicleSink), "recv count " + mFileNameList.Count);
                        List <VehicleObject> mVehObjectList = new List <VehicleObject>();
                        foreach (var fileName in  mFileNameList)
                        {
                            using (var requester = new ZSocket(context, ZSocketType.REQ))
                            {
                                requester.Connect("tcp://127.0.0.1:50559");
                                string imagepath = fileName;
                                if (File.Exists(imagepath))
                                {
                                    Guid guid = Guid.NewGuid();
                                    DataTypes.VehicleInfo info = new DataTypes.VehicleInfo();
                                    info.Id        = "11111";
                                    info.Imagepath = (imagepath);
                                    info.Uuid      = guid.ToString().Replace("-", "");
                                    ZMessage zMsg = new ZMessage();
                                    zMsg.Add(new ZFrame(info.ToByteArray()));
                                    requester.Send(zMsg);
                                    using (ZFrame reply = requester.ReceiveFrame())
                                    {
                                        DataTypes.VehicleInfo msg2 = new DataTypes.VehicleInfo();
                                        msg2.MergeFrom(reply.Read());
                                        VehicleRecogResult vehicleResults = JsonConvert.DeserializeObject <VehicleRecogResult>(msg2.Jsonresult);
                                        if (null != vehicleResults.Veh)
                                        {
                                            foreach (var item in vehicleResults.Veh)
                                            {
                                                VehicleObject vehicleObj = new VehicleObject();
                                                string        FileName   = fileName;
                                                vehicleObj.ImagePath  = FileName;
                                                vehicleObj.TaskId     = "";
                                                vehicleObj.CreateTime = new BsonDateTime(DateTime.Now);
                                                vehicleObj.vehicle    = item;
                                                mVehObjectList.Add(vehicleObj);
                                            }
                                            //Console.WriteLine(" Received:  {0}!", msg2.Jsonresult);
                                        }
                                    }
                                }
                            }
                        }
                        if (mVehObjectList.Count > 0)
                        {
                            VehicleMongoDAL.GetInstance().AddVehicleObject(mVehObjectList);
                        }
                        Console.WriteLine("thread {0} receive count:{1}", threadIndex, mFileNameList.Count);
                    }
                    else
                    {
                        if (errors == ZError.ETERM)
                        {
                            return;     // Interrupted
                        }
                        if (errors != ZError.EAGAIN)
                        {
                            throw new ZException(errors);
                        }
                    }
                }
                Thread.Sleep(10);
            }
            Console.WriteLine("thread {0} ZmqVehicleSink End Receive Message !", threadIndex);
        }
Ejemplo n.º 6
0
        public void SavePicturesToDB()
        {
            mVehicleTaskList = VehicleMongoDAL.GetInstance().GetAllVehicleTask();
            if (null != mVehicleTaskList)
            {
                if (mVehicleTaskList.Count > 0)
                {
                    for (int i = 0; i < mVehicleTaskList.Count; i++)
                    {
                        if (mVehicleTaskList[i].TaskState == "0")
                        {
                            currentIndex = i;
                            break;
                        }
                        else
                        {
                            currentIndex = -1;
                        }
                    }

                    if (currentIndex >= 0)
                    {
                        foreach (FileData f in FastDirectoryEnumerator.EnumerateFiles(mVehicleTaskList[currentIndex].TaskPath, "*", System.IO.SearchOption.AllDirectories))
                        {
                            string filename     = f.Path.ToLower();
                            string FileFullName = f.Path;
                            if ((filename.Contains(".jpg") || filename.Contains(".bmp") || filename.Contains(".jpeg")))
                            {
                                m_listFilePath.Add(f.Path);
                                //InsertIntoMongo(filename);

                                mVehicleTaskList[currentIndex].TaskCount = mTaskCount++.ToString();
                            }
                            if (m_listFilePath.Count >= 100)
                            {
                                ZmqVehicleSink.GetInstance().SendVehicles(m_listFilePath);
                                try
                                {
                                    mVehicleTaskList[currentIndex].TaskCount = (Convert.ToInt32(mVehicleTaskList[currentIndex].TaskCount) + m_listFilePath.Count).ToString();
                                    VehicleMongoDAL.GetInstance().UpdateVehicleTask(mVehicleTaskList[currentIndex]);
                                    this.Invoke(new DelegateBindHandler(BindDataSource));
                                }
                                catch
                                { }
                                m_listFilePath.Clear();
                            }
                        }
                        if (m_listFilePath.Count > 0)
                        {
                            ZmqVehicleSink.GetInstance().SendVehicles(m_listFilePath);
                            try
                            {
                                mVehicleTaskList[currentIndex].TaskCount = (Convert.ToInt32(mVehicleTaskList[currentIndex].TaskCount) + m_listFilePath.Count).ToString();
                                VehicleMongoDAL.GetInstance().UpdateVehicleTask(mVehicleTaskList[currentIndex]);
                                this.Invoke(new DelegateBindHandler(BindDataSource));
                            }
                            catch
                            { }
                            m_listFilePath.Clear();
                        }
                        mVehicleTaskList[currentIndex].TaskState = "1";
                        VehicleMongoDAL.GetInstance().UpdateVehicleTask(mVehicleTaskList[currentIndex]);
                        loadTaskData();
                    }
                }
            }

            try
            {
                Thread.Sleep(1000);
                this.Invoke(new DelegateRestartTime(RestartTime));
            }
            catch { }
        }