public void GetDefectCell(string productName, string batchName, string boardName, string sideName, string shotName, string defectName, out DefectCell defectCell) { defectCell = new DefectCell(); string defectPath = _dataDir + "\\" + productName + "\\" + batchName + "\\" + boardName + "\\" + sideName + "\\" + shotName; MachVisionFile machVisionFile = new MachVisionFile(defectPath, shotName); defectName = Regex.Replace(defectName, @"(.bmp)$", ""); machVisionFile.ReadRoiInTemplate(defectName, out var roi); machVisionFile.ReadDefectInfos(defectName, out var defectInfos); defectCell.RoiInTemplate = roi; defectCell.DefectInfos = defectInfos; string imageFile = defectPath + "\\" + defectName + ".bmp"; if (!File.Exists(imageFile)) { return; } defectCell.DefectImage = ImageOperateTools.GetImageFromFile(imageFile); Bitmap templateImage; if (TryGetTemplateImg(sideName, shotName, roi, out templateImage)) { defectCell.TemplateImage = templateImage; } else { defectCell.TemplateImage = null; } }
private void UpdateDataCells() { DefectCells = new List <DefectCell>(); if (_displayWindowNum <= 0) { return; } int head = -1; int end = -1; if (!DefectNameList.Contains(DefectName)) { int iter = _displayWindowNum; do { DefectCells.Add(new DefectCell()); } while (--iter > 0); return; } int indexOfGroup = DefectNameList.IndexOf(DefectName) / _displayWindowNum; head = indexOfGroup * _displayWindowNum; end = head + _displayWindowNum - 1; for (var iter = head; iter <= end; ++iter) { var defectCell = new DefectCell(); if (null == DefectNameList || 0 == DefectNameList.Count || iter >= DefectNameList.Count || iter < 0) { DefectCells.Add(new DefectCell()); } else { _device.GetDefectCell(ProductName, BatchName, BoardName, SideName, ShotName, DefectNameList[iter], out defectCell); defectCell.GenRegionFromRect(_dilationPixel); DefectCells.Add(defectCell); } } DisplayWindowIndex = DefectNameList.IndexOf(DefectName) - head; DefectRegionIndex = 0; return; }
public bool SetByDefectCell(DefectCell defectCell, int regionIndex, EMarkDataType markType) { if (defectCell == null || defectCell.DefectRegions == null || regionIndex < 0 || regionIndex >= defectCell.DefectRegions.Count || defectCell.DefectRegions[regionIndex] == null || defectCell.DefectRegions[regionIndex].DefectInfoIndexList == null || defectCell.DefectRegions[regionIndex].DefectInfoIndexList.Count <= 0 || defectCell.DefectInfos == null || defectCell.DefectInfos.Count <= 0) { return(false); } SingleDefectRegion defectRegion = defectCell.DefectRegions[regionIndex]; MarkRegionType = markType; SmallestRect = new Rectangle(defectRegion.SmallestRect.X, defectRegion.SmallestRect.Y, defectRegion.SmallestRect.Width, defectRegion.SmallestRect.Height); DefectInfos = new Dictionary <int, DefectInfo>(); foreach (var index in defectRegion.DefectInfoIndexList) { if (index < 0 || index >= defectCell.DefectInfos.Count) { return(false); } DefectInfo defectInfo = new DefectInfo(); defectInfo.CodeNum = defectCell.DefectInfos[index].CodeNum; Rectangle rect = defectCell.DefectInfos[index].DefectRect; defectInfo.DefectRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height); if (DefectInfos.ContainsKey(index)) { return(false); } else { DefectInfos.Add(index, defectInfo); } } return(true); }
public void SetDefectCell(DefectCell defectCell) { _defectCell = null == defectCell ? new DefectCell() : defectCell; return; }