public void UnInit() { this.pictureBox1.Image = null; m_SearchResultRecord = null; MyLog4Net.Container.Instance.Log.DebugFormat("ucSearchResultItem disposed: ", this.GetHashCode()); this.GiveFeedback -= new System.Windows.Forms.GiveFeedbackEventHandler(this.pictureBox1_GiveFeedback); this.pictureBox1.Click -= new System.EventHandler(this.pictureBox1_Click); this.pictureBox1.GiveFeedback -= new System.Windows.Forms.GiveFeedbackEventHandler(this.pictureBox1_GiveFeedback); this.pictureBox1.DoubleClick -= new System.EventHandler(this.pictureBox1_DoubleClick); this.pictureBox1.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); this.pictureBox1.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); this.pictureBox1.MouseUp -= new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp); this.PreviewKeyDown -= new System.Windows.Forms.PreviewKeyDownEventHandler(this.ucSearchResultItem_PreviewKeyDown); this.Resize -= new System.EventHandler(this.ucSearchResultItem_Resize); this.Controls.Clear(); labelControl1.Dispose(); labelControl1 = null; labelControl2.Dispose(); labelControl2 = null; this.pictureBox1.Dispose(); this.pictureBox1 = null; }
public void Show(SearchResultRecord item) { m_SearchResultRecord = item; this.pictureBox1.Image = item.ThumbNailPic; this.labelControl1.Text = string.Format("目标类型 {0}", Common.Utils.GetSearchObjectTypeName(item.ObjectType)); this.labelControl2.Text = item.TargetTs.ToString(DataModel.Constant.DATETIME_FORMAT); }
private void AddRow(SearchResultRecord info) { m_allResultList.Rows.Add(info.ID, info.TaskUnitID, info.CameraID, info.FrameSeq, info.TimeStamp, info.TargetAppearTs, info.TargetDisappearTs, info.TargetDisappearTs, info.Distance, info.ThumbPicPath, info.OrgPicPath, info.ObjectRect, info.ObjectType, info.CardNum, info.CarType, info.CarLogo, info.CarStruct, info.CarColor1, info.CarColor2, info.CarColor3, info.CardColor, info); }
public void StartRequestImage(uint searchSessionID, SearchResultRecord item, bool isOriginalImage) { System.Diagnostics.Trace.WriteLine(string.Format("StartRequestImage searchSessionID:{0},taskUnitID:{1},objID:{2},imageType:{3}" , searchSessionID, item.TaskUnitID, item.ID, isOriginalImage)); string url = isOriginalImage? item.OrgPicPath : item.ThumbPicPath; Framework.Container.Instance.IVXProtocol.StartGetImage(searchSessionID, item.CameraID, item.TaskUnitID, item.ID, url); }
public void SearchResoultPlayBack() { SearchResultRecord record = m_SelectedResultRecord; if (record != null) { Framework.Container.Instance.EvtAggregator.GetEvent <SearchResoultPlaybackRequestEvent>().Publish( new Tuple <SearchResultRecord, SearchType> (record, m_SearchSession.SearchPara.SearchType)); } }
/// <summary> /// Logic for searching for existing records /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, RoutedEventArgs e) { if (validDateRanges && validAmountRanges) { if (typeOfRecordSearched.Equals("e")) { UpdateModifiedExpenseList(); } else if (typeOfRecordSearched.Equals("i")) { UpdateModifiedIncomeList(); } if ((bool)radioExpense.IsChecked) { var results = SearchResults.GetExpenseSearchResults(currentUser.ExistingUserExpenses, currentUser.NewUserExpenses, currentUser.ModifiedExpenseRecords, cmbCategory, txtMin, txtMax, dteStart, dteEnd); Results = new ObservableCollection <SearchResultRecord>( SearchResultRecord.GetExpenseResults( results.Item1, results.Item2, results.Item3).OrderByDescending(x => x.Date).ToList()); lstSearchResults.ItemsSource = Results; if (Results.Count == 0) { MessageBox.Show("No results found!", "No Results", MessageBoxButton.OK); } typeOfRecordSearched = "e"; } else if ((bool)radioIncome.IsChecked) { var results = SearchResults.GetIncomeSearchResults(currentUser.ExistingUserIncome, currentUser.NewUserIncome, currentUser.ModifiedIncomeRecords, cmbCategory, txtMin, txtMax, dteStart, dteEnd); Results = new ObservableCollection <SearchResultRecord>( SearchResultRecord.GetIncomeResults( results.Item1, results.Item2, results.Item3).OrderByDescending(x => x.Date).ToList()); lstSearchResults.ItemsSource = Results; if (Results.Count == 0) { MessageBox.Show("No results found!", "No Results", MessageBoxButton.OK); } typeOfRecordSearched = "i"; } else { MessageBox.Show("Please select the type of record you wish to search.", "Error"); } return; } MessageBox.Show("Invalid input ranges! Please check that any range entered\n" + "does not have the minimum greater than the specified maximum and vice versa.", "Error"); }
public void StartRequestImage(SearchResultRecord item, bool isOriginalImage) { try { Framework.Container.Instance.VideoSearchService.StartRequestImage(m_searchSessionID, item, isOriginalImage); } catch (SDKCallException ex) { string operation = isOriginalImage ? "请求原始图" : "请求缩略图"; Common.SDKCallExceptionHandler.Handle(ex, operation); } }
public void ShowOriginalImage() { int index = 0; SearchResultRecord record = SelectedResultRecord; if (record != null) { index = m_ResultSummary.SearchResultList.IndexOf(record); } DetailViewPageInfo.Index = index; // 用using 在Clear的时候m_EditImageForm 为null m_EditImageForm = new EditImageForm(this); m_EditImageForm.FormClosed += new FormClosedEventHandler(EditImageForm_FormClosed); m_EditImageForm.ShowDialog(); }
public void ExportVideo() { SearchResultRecord record = m_SelectedResultRecord; try { FormVideoEdit edit = new FormVideoEdit(Framework.Container.Instance.TaskManagerService.GetTaskUnitById(record.TaskUnitID) , record.TargetAppearTs , record.TargetDisappearTs); edit.ShowDialog(); } catch (Exception ex) { SDKCallExceptionHandler.Handle(ex, "导出视频", true); } }
/// <summary> /// logic for double clicking on a search result to display the window to edit it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstSearchResults_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (lstSearchResults.SelectedItem != null) { selectedRecord = lstSearchResults.SelectedItem as SearchResultRecord; colors[0] = currentUser.Color1; colors[1] = currentUser.Color2; colors[2] = currentUser.Color3; colors[3] = currentUser.Color4; RecordViewWindow editWindow = new RecordViewWindow(ref selectedRecord, typeOfRecordSearched, currentUser); editWindow.Owner = this; IsEnabled = false; editWindow.IsEnabled = true; editWindow.Visibility = Visibility.Visible; } }
private List <Tuple <PropertyInfo, string> > GetProperties(SearchResultRecord record) { List <Tuple <PropertyInfo, string> > psRet = new List <Tuple <PropertyInfo, string> >(); PropertyInfo[] properties = record.GetType().GetProperties(); if (properties != null && properties.Length > 0) { string description; SearchResultPropertyAttribute attr; foreach (PropertyInfo p in properties) { object[] objs = p.GetCustomAttributes(typeof(SearchResultPropertyAttribute), false); if (objs != null && objs.Length > 0) { attr = (SearchResultPropertyAttribute)objs[0]; if (record.IsVehicleSearchResult) { if (attr.AvailableMode == AvailableMode.NonVehicle) { continue; } } else { if (attr.AvailableMode == AvailableMode.Vehicle) { continue; } } description = ((SearchResultPropertyAttribute)objs[0]).DisplayName; if (string.CompareOrdinal(description, "相似度") == 0 && !m_resultSummary.IsSimilaritySearch) { continue; } psRet.Add(new Tuple <PropertyInfo, string>(p, description)); } } } return(psRet); }
public void PlayVideo(SearchResultRecord record) { try { TaskUnitInfo taskUnit = Framework.Container.Instance.TaskManagerService.GetTaskUnitById(record.TaskUnitID); CurrFile = taskUnit; DateTime dtStart = record.TargetAppearTs.AddSeconds(-5); DateTime dtEnd = record.TargetDisappearTs.AddSeconds(10); //if (dtStart < taskUnit.StartTime) //{ // dtStart = taskUnit.StartTime; //} PlayVideo(dtStart, /*record.TargetDisappearTs*/ dtEnd); // TODO: 因为不知道TaskUnitInfo的结束时间, 加5秒无法判断是否越界。暂时不加5 } catch (SDKCallException ex) { Common.SDKCallExceptionHandler.Handle(ex, "获取任务单元"); } }
/// <summary> /// Constructor for the RecordViewWindow /// </summary> /// <param name="selected"></param> public RecordViewWindow(ref SearchResultRecord selected, string typeLastSearched, User current) { InitializeComponent(); //colorscheme = colors; currentUser = current; DataContext = currentUser; selectedRecord = selected; txtAmount.Text = selectedRecord.Amount.ToString(); txtDescription.Text = selectedRecord.Description.ToString(); cmbCategory.Text = selectedRecord.Category; dteDate.SelectedDate = selectedRecord.Date; if (typeLastSearched.Equals("e")) { foreach (string item in Categories.GetExpenseCategories()) { cmbCategory.Items.Add(item); } } else { foreach (string item in Categories.GetIncomeCategories()) { cmbCategory.Items.Add(item); } } if (selected.Status.Equals("--")) { btnDelete.Visibility = Visibility.Hidden; btnDelete.IsEnabled = false; chkHasBeenDeleted.Visibility = Visibility.Visible; chkHasBeenDeleted.IsEnabled = true; chkHasBeenDeleted.IsChecked = true; } }
/// <summary> /// 同步等到获取到图片后返回 /// </summary> /// <param name="item"></param> /// <param name="isOriginalImage"></param> /// <returns></returns> public Image RequestImage(uint searchSessionID, SearchResultRecord item, bool isOriginalImage, int timeout = 5 *1000) { Image imgRet = null; lock (m_MRERequestImage) { m_SyncRequsestImageRecord = new Tuple <SearchResultRecord, bool>(item, isOriginalImage); StartRequestImage(searchSessionID, item, isOriginalImage); } bool succeed = m_MRERequestImage.WaitOne(timeout); if (succeed) { lock (m_MRERequestImage) { imgRet = isOriginalImage ? m_SyncRequsestImageRecord.Item1.OriginalPic : m_SyncRequsestImageRecord.Item1.ThumbNailPic; m_MRERequestImage.Reset(); m_SyncRequsestImageRecord = null; } } return(imgRet); }
public async Task <SearchResult <ResultT> > Query <T, ResultT>( SearchRequest searchRequest, bool track = false ) where T : class where ResultT : class { var indexClient = GetIndexForModel <T>(); if (indexClient == null) { throw new Exception("Failed to get indexClient. Make sure index exists."); } var facetProperties = SearchableModelAttribute.GetFacetableProperties <T>(); List <string> facets = new List <string>(); if (searchRequest.FacetInfoToReturn != null && searchRequest.FacetInfoToReturn.Count > 0) { foreach (FacetInfoRequest f in searchRequest.FacetInfoToReturn) { var facetDefinition = GetPropertyName(f.FacetName); if (f.Values != null && f.Values.Count() > 0) { facetDefinition += $",values:{string.Join("|", f.Values)}"; } else { facetDefinition += $",count:{f.Count},sort:{f.Sort}"; } facets.Add(facetDefinition); } } Type resultType = typeof(ResultT); MemberInfo[] props = resultType.GetMembers(); List <string> propertiesToSelect = props .Where(p => (p.MemberType == MemberTypes.Field || p.MemberType == MemberTypes.Property) && p.GetCustomAttributes(typeof(IgnorePropertyAttribute), true).Length == 0 ) .Select(p => p.Name) .ToList(); SearchParameters sp = new SearchParameters() { Select = propertiesToSelect, SearchMode = searchRequest.SearchMode == "All" ? SearchMode.All : SearchMode.Any, QueryType = QueryType.Full, Top = searchRequest.Limit, Skip = searchRequest.Offset, // Add count IncludeTotalResultCount = true, // Add search highlights HighlightFields = searchRequest.FieldsToHighlight.Select(f => GetPropertyName(f)).ToList(), HighlightPreTag = HighlightTagStart, HighlightPostTag = HighlightTagEnd, // Add facets Facets = facets, }; if (!string.IsNullOrEmpty(searchRequest.ScoringProfile)) { sp.ScoringProfile = searchRequest.ScoringProfile; } if (searchRequest.OrderBy.Count > 0) { var orderByFields = new List <string>(); foreach (var orderBy in searchRequest.OrderBy) { var orderByPropertyName = GetPropertyName(orderBy.Key); orderByFields.Add($"{orderByPropertyName} {orderBy.Value}"); } sp.OrderBy = orderByFields; } if (searchRequest.Filters != null && searchRequest.Filters.Count > 0) { List <string> filterStrings = new List <string>(); foreach (var f in searchRequest.Filters) { filterStrings.Add($"({ConstructConditionFilter<T>(f)})"); } sp.Filter = string.Join(" and ", filterStrings); } string searchText = searchRequest.SearchText; var headers = new Dictionary <string, List <string> >() { { "x-ms-azs-return-searchid", new List <string>() { "true" } } }; var azureSearchResults = await indexClient.Documents.SearchWithHttpMessagesAsync(searchText, sp, customHeaders : headers); IEnumerable <string> headerValues; string searchId = string.Empty; if (azureSearchResults.Response.Headers.TryGetValues("x-ms-azs-searchid", out headerValues)) { searchId = headerValues.FirstOrDefault(); } if (track) { var properties = new Dictionary <string, string> { { "SearchServiceName", _searchClient.SearchServiceName }, { "SearchId", searchId }, { "IndexName", indexClient.IndexName }, { "QueryTerms", searchText }, { "ResultCount", azureSearchResults.Body.Count.ToString() }, { "ScoringProfile", sp.ScoringProfile } }; _telemetryClient.TrackEvent("Search", properties); } SearchResult <ResultT> results = new SearchResult <ResultT>(); results.SearchId = searchId; results.IndexName = indexClient.IndexName; results.TotalRecordsFound = azureSearchResults.Body.Count; if (azureSearchResults.Body.Facets != null) { foreach (var facetProp in facetProperties) { if (azureSearchResults.Body.Facets.ContainsKey(facetProp.Key.Name)) { var facetValues = new List <FacetStats>(); foreach (var facetStat in azureSearchResults.Body.Facets[facetProp.Key.Name]) { facetValues.Add(new FacetStats() { Value = facetStat.Value, Count = facetStat.Count, From = (double?)facetStat.From, To = (double?)facetStat.To }); } results.FacetsStats.Add(facetProp.Key.Name, facetValues); } } } foreach (var record in azureSearchResults.Body.Results) { try { JObject obj = JObject.FromObject(record.Document); var resultRecord = new SearchResultRecord <ResultT>(); resultRecord.Record = obj.ToObject <ResultT>(); resultRecord.Score = record.Score; if (record.Highlights != null) { foreach (var highlight in record.Highlights) { var sourceFieldValue = obj.GetValue(highlight.Key).ToString(); foreach (var h in highlight.Value.ToList()) { sourceFieldValue = sourceFieldValue.Replace(h.Replace(HighlightTagStart, String.Empty).Replace(HighlightTagEnd, String.Empty), h); } resultRecord.Highlights.Add(highlight.Key, new List <string>() { sourceFieldValue }); } } results.Records.Add(resultRecord); } catch (Exception ex) { var a = ex; } } return(results); }
//void OnSearchBegin(SearchSession session) //{ // m_searchSessionID = session.SearchId; // //m_currSearchItem = summary.SearchPara.CurrentSearchItem; //} void OnSearchItemImageReceived(SearchImageInfo info) { string key = GetRecordKey(info.dwCameraID, info.dwTaskUnitID, info.dwMoveObjID); if (m_DTKey2Record.ContainsKey(key)) { SearchResultRecord record = m_DTKey2Record[key]; if (string.Compare(record.ThumbPicPath, info.ImageURL, true) == 0) { MyLog4Net.Container.Instance.Log.DebugFormat("### OnSearchItemImageReceived, taskunitname: {0}, taskUnitID: {1}", Title, m_currSearchItem.TaskUnitId); if (record.ThumbNailPic == null) { record.ThumbNailPic = info.Image; DataRow dataRow = this.m_ResultSummary.AllSearchResultList.Rows.Find(info.dwMoveObjID); if (dataRow != null) { dataRow["ThumbNailPic"] = info.Image; } if (ThumbNailImageRetrieved != null) { ThumbNailImageRetrieved(record); } } } else { int result = string.Compare(record.OrgPicPath, info.ImageURL, true); // Debug.Assert(result == 0); if (result == 0) { if (record.OriginalPic == null) { record.OriginalPic = info.Image; Framework.Container.Instance.CacheMgr.Register(record); if (OriginalImageRetrieved != null) { if (record.ObjectRect != Rectangle.Empty) { // 先提取目标图 Image img = new Bitmap(record.ObjectRect.Width, record.ObjectRect.Height); Graphics g = Graphics.FromImage(img); g.DrawImage(record.OriginalPic, new Rectangle(0, 0, record.ObjectRect.Width, record.ObjectRect.Height), record.ObjectRect, GraphicsUnit.Pixel); record.ObjectPic = img; g.Dispose(); // 再在原图上画目标框 g = Graphics.FromImage(record.OriginalPic); g.DrawRectangle(new Pen(new SolidBrush(Color.Red), 2), record.ObjectRect); g.Dispose(); } OriginalImageRetrieved(record); } } } } } //if (ImageDownloaded != null) //{ // ImageDownloaded(m_searchSessionID, info.dwCameraID, info.dwTaskUnitID, (int)info.dwMoveObjID, info.ptImageData); //} }
public void ExportPic(bool originalPic) { SearchResultRecord record = m_SelectedResultRecord; if (record == null) { return; } string resourcename = GetResourceNameByTaskUnitID(record.TaskUnitID); string type = (originalPic) ? "原始图" : "缩略图"; string fileName = resourcename.Replace(".", "_") + type + record.ID.ToString() + ".jpg"; bool needdSave = true; SaveFileDialog sfd = new SaveFileDialog(); sfd.RestoreDirectory = true; sfd.Filter = "JPG文件|*.jpg"; sfd.FileName = fileName; sfd.InitialDirectory = Framework.Environment.PictureSavePath; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = sfd.FileName; } else { needdSave = false; } if (needdSave) { // 保存文件 Trace.WriteLine("btnSave_Click, FileName:" + fileName); Image srcpic = null; if (originalPic) { if (record.OriginalPic == null) { try { record.OriginalPic = Framework.Container.Instance.VideoSearchService.RequestImage(m_searchSessionID, record, originalPic); } catch (SDKCallException ex) { Common.SDKCallExceptionHandler.Handle(ex, "获取原始图"); } } srcpic = record.OriginalPic; } else { if (record.ThumbNailPic == null) { try { record.ThumbNailPic = Framework.Container.Instance.VideoSearchService.RequestImage(m_searchSessionID, record, originalPic); } catch (SDKCallException ex) { Common.SDKCallExceptionHandler.Handle(ex, "获取缩略图"); } } srcpic = record.ThumbNailPic; } if (srcpic != null) { using (Image imgTmp = new Bitmap(srcpic)) { imgTmp.Save(fileName, ImageFormat.Jpeg); } } } }
public void GoToCompareSearch() { SearchResultRecord record = SelectedSingleViewModel.SelectedResultRecord; Image image = record.ThumbNailPic; Image fullimage = record.OriginalPic; Rectangle rect = record.ObjectRect; if (image == null) { try { image = Framework.Container.Instance.VideoSearchService.RequestImage(m_searchSession.SearchId, record, false); record.ThumbNailPic = image; } catch (SDKCallException ex) { Common.SDKCallExceptionHandler.Handle(ex, "获取缩略图"); } } if (fullimage == null) { try { fullimage = Framework.Container.Instance.VideoSearchService.RequestImage(m_searchSession.SearchId, record, true); record.OriginalPic = fullimage; } catch (SDKCallException ex) { Common.SDKCallExceptionHandler.Handle(ex, "获取原始图"); } if (fullimage == null) { MyLog4Net.Container.Instance.Log.Warn("GoToCompareSearch: No original image retrieved, cannot go to compare search"); return; } } DataModel.ImageType it = ImageType.Common; if (record.ObjectType == SearchResultObjectType.CAR) { it = ImageType.Car; } else if (record.ObjectType == SearchResultObjectType.FACE) { it = ImageType.Face; } else { it = ImageType.Object; } if (image != null) { // 需要复制一份Image image = new Bitmap(image); fullimage = new Bitmap(fullimage); Framework.Container.Instance.EvtAggregator.GetEvent <GotoCompareSearchEvent>().Publish(""); CompareImageInfo info = new CompareImageInfo { Image = fullimage, RegionImage = image, ImageRectangle = rect, ImageType = it, }; if (!Framework.Container.Instance.CacheMgr.HasItem(record)) { record.Clear(); } Framework.Container.Instance.EvtAggregator.GetEvent <SetCompareImageInfoEvent>().Publish(info); } }
private string GetRecordKey(SearchResultRecord record) { return(GetRecordKey(record.CameraID, record.TaskUnitID, record.ID)); }
//private void ShowCirularProgress(bool show) //{ // //ShowCirularProgress(circularProgress1, picEditOriginal, show); // //ShowCirularProgress(circularProgress2, picEditThumb, show); //} //private void UpdateCircularPosition(CircularProgress circular) //{ // //int x = circular.Parent.Width / 2; // //int y = circular.Parent.Height / 2; // //circular.Location = new System.Drawing.Point(x - circular.Width / 2, y - circular.Height / 2); //} #endregion #region Internal helper functions internal void SwitchRecord(SearchResultSingleSummary summary, SearchResultRecord record) { m_resultSummary = summary; Record = record; }