public person_dataset ToDataAngineModel() { person_dataset d = new person_dataset(); d.id = this.ID; d.name = this.Name; d.source = this.Source; d.create_time = Convert.ToDateTime(this.CreateTime); d.type = this.Type; d.remark = this.Remark; return(d); }
public static PersonDataSet CreateInstanceFromDataAngineModel(person_dataset dt) { if (null == dt) { return(null); } PersonDataSet d = new PersonDataSet(); d.ID = dt.id; d.Name = dt.name; d.Source = dt.source; if (dt.create_time != null) { d.CreateTime = dt.create_time.ToString(); } d.Type = dt.type; d.Remark = dt.remark; return(d); }
public override void OnPost(HttpRequest request, HttpResponse response) { hitalert bll = new hitalert(); person_dataset person_datasetbll = new person_dataset(); if (request.RestConvention != null)//根据ID获得数据库 { Log.Debug(string.Format("请求地址无效", request.RestConvention)); //int id = -1; //try //{ // id = Convert.ToInt32(request.RestConvention); //} //catch //{ //} //SearchInfo searchinfo = SearchInfo.CreateInstanceFromJSON(request.PostParams); //if (searchinfo != null) //{ // DataAngineSet.Model.person_dataset ds = new DataAngineSet.Model.person_dataset(); // ds = person_datasetbll.GetModel(id); // //int num = bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString()).Tables[0].Rows.Count; // HitAlertData[] ha = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime(searchinfo.StartTime, searchinfo.EndTime, searchinfo.StartIndex, searchinfo.PageSize, ds.id.ToString())); // HitAlertData[] haALL = HitAlertData.CreateInstanceFromDataAngineDataSet(bll.GetListByTime_TaskId(searchinfo.StartTime, searchinfo.EndTime, ds.id.ToString())); // JObject jo = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha)))); // response.SetContent(JsonConvert.SerializeObject(jo)); //} } else { Log.Debug("根据图片的轨迹查询"); string result = Base64Decode(request.PostParams); //string result = request.PostParams; Trajectory_Search_ByImg trajectory_search = Trajectory_Search_ByImg.CreateInstanceFromJSON(result); if (trajectory_search != null) { InitFRS(); fa.LoadData(); fa.ScoreThresh = (float)0.5; Log.Debug(string.Format("阈值:{0}", fa.ScoreThresh)); Log.Debug(string.Format("top值:{0}", fa.TopK)); FRS.HitAlert[] hits; if (trajectory_search.PicSrc != null) { Bitmap Bitmapsrc = Base64ToImage(trajectory_search.PicSrc); Bitmap bmpsrc = new Bitmap(Bitmapsrc.Width, Bitmapsrc.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics.FromImage(bmpsrc).DrawImage(Bitmapsrc, new Rectangle(0, 0, bmpsrc.Width, bmpsrc.Height)); hits = fa.Search(bmpsrc); bmpsrc.Dispose(); } else { //Image src = Image.FromFile(trajectory_search.PicSrc_Path); Image src = Get_UrlImage(trajectory_search.PicSrc_Path); hits = fa.Search(src); } if (hits == null) { Log.Debug("该图没有人脸"); JObject jo = new JObject(new JProperty("num", 0), new JProperty("pageData", null)); response.SetContent(JsonConvert.SerializeObject(jo)); } else { if (hits[0].Details.Length == 0) { Log.Debug("没有找到该图像对应的人脸"); JObject jo = new JObject(new JProperty("num", 0), new JProperty("pageData", null)); response.SetContent(JsonConvert.SerializeObject(jo)); } else { int UserId = (int)hits[0].Details[0].UserId; Console.WriteLine(UserId); Log.Debug(string.Format("{0}, {1}, {2}, {3}", trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize)); System.Data.DataSet a = bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize); Console.WriteLine(a.Tables); HitAlertData_Trajectory_Search[] ha = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime, trajectory_search.StartIndex, trajectory_search.PageSize)); HitAlertData_Trajectory_Search[] haALL = HitAlertData_Trajectory_Search.CreateInstanceFromDataAngineDataSet(bll.GetListById(UserId, trajectory_search.StartTime, trajectory_search.EndTime)); JObject jo = new JObject(new JProperty("num", haALL.Length), new JProperty("pageData", JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ha)))); response.SetContent(JsonConvert.SerializeObject(jo)); } } } } response.Send(); }