private void MenuItem_Zoom_Click(object sender, EventArgs e) { try { zoomOption = ZoomOption.MouseMove; if (sender == MenuItem_ZoomFitSize) { FitSize(true); } else if (sender == MenuItem_ZoomFullSize) { FullSize(true); } else { SetScrollBarLocationBeforeZoom(); string value_Str = ((ToolStripMenuItem)sender).Text; float zoomValue = float.Parse(Regex.Match(value_Str, @"\d+").Value); zoomValue = zoomValue / 100; SetZoom(zoomValue); } } catch (Exception ex) { VisionLogger.Log(WaftechLibraries.Log.LogType.Exception, sender.ToString(), ex); VisionNotifier.AddNotification(ex.Message); } }
private static void AcqFailureCallback(MC.SIGNALINFO signalInfo) { uint currentChannel = (uint)signalInfo.Context; try { isImageReady = false; } catch (System.Exception ex) { VisionLogger.Log(WaftechLibraries.Log.LogType.Exception, "E2VCameraHelper", ex); VisionNotifier.AddNotification("System Exception: " + ex.Message); errorMessage = ex.Message; } }
public static bool TeachTeacherROI( string RecipeName, EuresysDoublePatternMatcher PatternMatcher_, PatternMatcherParameters PatternMatcherParameters_, EROIBW8 eROIForPatternTeaching1_, EROIBW8 eROIForPatternTeaching2_, iEuresysROI MatcherEROI, PointF WaferCenterPoint, WaferOrientation patternOrientation) { string PatternFilePath_One = PatternMatcherParameterHelper.GetLeftPatternFilePath(RecipeName); string PatternFilePath_Two = PatternMatcherParameterHelper.GetRightPatternFilePath(RecipeName); string PatternImageFilePath_One = PatternMatcherParameterHelper.GetLeftPatternImageFilePath(RecipeName); string PatternImageFilePath_Two = PatternMatcherParameterHelper.GetRightPatternImageFilePath(RecipeName); PatternMatcher_.TeachAndSaveEMatcher( PatternMatcherParameters_, eROIForPatternTeaching1_, eROIForPatternTeaching2_, PatternFilePath_One, PatternFilePath_Two, PatternImageFilePath_One, PatternImageFilePath_Two); if (PatternMatcher_.Pattern1.IsVoid) { goto Fail; } if (PatternMatcher_.Pattern2.IsVoid) { goto Fail; } // Match EROIBW8 matcherROI = MatcherEROI.GetROI(0); PatternMatcher_.MatchPatterns(matcherROI); EMatcher eMatcher1 = PatternMatcher_.EMatcher1; EMatcher eMatcher2 = PatternMatcher_.EMatcher2; if (eMatcher1.NumPositions != 1) { string errorMessage = "Pattern 1: Number of patterns matched is not equal to one"; VisionLogger.Log(LogType.Exception, "PatternMatcherManager", errorMessage); VisionNotifier.AddNotification(errorMessage); goto Fail; } if (eMatcher2.NumPositions != 1) { string errorMessage = "Pattern 2: Number of patterns matched is not equal to one"; VisionLogger.Log(LogType.Exception, "PatternMatcherManager", errorMessage); VisionNotifier.AddNotification(errorMessage); goto Fail; } EROIBW8 matcherEROI_1 = MatcherEROI.GetROI(0); float OriginalXPos_pattern1 = eMatcher1.GetPosition(0).CenterX + (matcherEROI_1.OrgX); float OriginalYPos_pattern1 = eMatcher1.GetPosition(0).CenterY + (matcherEROI_1.OrgY); float OriginalXPos_pattern2 = eMatcher2.GetPosition(0).CenterX + (matcherEROI_1.OrgX); float OriginalYPos_pattern2 = eMatcher2.GetPosition(0).CenterY + (matcherEROI_1.OrgY); float WaferCenterXPos = WaferCenterPoint.X; float WaferCenterYPos = WaferCenterPoint.Y; PointF p1 = new PointF(OriginalXPos_pattern1, OriginalYPos_pattern1); PointF p2 = new PointF(OriginalXPos_pattern2, OriginalYPos_pattern2); float PatternDefaultAngleOffset = (float)CalculateAngleBetween3Points.Execute( p1, p2, WaferCenterPoint, 0, true, patternOrientation); // Replace value PatternMatcherParameters_.OriginalXPos_pattern1 = OriginalXPos_pattern1; PatternMatcherParameters_.OriginalYPos_pattern1 = OriginalYPos_pattern1; PatternMatcherParameters_.OriginalXPos_pattern2 = OriginalXPos_pattern2; PatternMatcherParameters_.OriginalYPos_pattern2 = OriginalYPos_pattern2; PatternMatcherParameters_.WaferCenterXPos = WaferCenterXPos; PatternMatcherParameters_.WaferCenterYPos = WaferCenterYPos; PatternMatcherParameters_.DefaultAngleOffset = PatternDefaultAngleOffset; return(true); Fail: return(false); }
private static void ProcessingCallback(MC.SIGNALINFO signalInfo) { isImageReady = false; UInt32 currentChannel = (UInt32)signalInfo.Context; currentSurface = signalInfo.SignalInfo; // + GrablinkSnapshotTrigger Sample Program try { // Update the image with the acquired image buffer data Int32 width, height, bufferPitch; IntPtr bufferAddress; MC.GetParam(currentChannel, "ImageSizeX", out width); MC.GetParam(currentChannel, "ImageSizeY", out height); MC.GetParam(currentChannel, "BufferPitch", out bufferPitch); MC.GetParam(currentSurface, "SurfaceAddr", out bufferAddress); try { imageMutex.WaitOne(); image = new System.Drawing.Bitmap(width, height, bufferPitch, PixelFormat.Format8bppIndexed, bufferAddress); imgpal = image.Palette; // Build bitmap palette Y8 for (uint i = 0; i < 256; i++) { imgpal.Entries[i] = Color.FromArgb( (byte)0xFF, (byte)i, (byte)i, (byte)i); } image.Palette = imgpal; string path_directory = @"D:\Waftech\BDMVision\Log\Temp\"; System.IO.Directory.CreateDirectory(path_directory); string fullPath = path_directory + "test.jpg"; image.Save(fullPath); eImage = new EImageBW8(); eImage.SetSize(image.Width, image.Height); eImage.Load(fullPath); } finally { imageMutex.ReleaseMutex(); } isImageReady = true; // Retrieve the frame rate double frameRate_Hz; MC.GetParam(channel, "PerSecond_Fr", out frameRate_Hz); // Retrieve the channel state string channelState; MC.GetParam(channel, "ChannelState", out channelState); // Log frame rate and channel state VisionLogger.Log(WaftechLibraries.Log.LogType.Log, "E2VCameraHelper", string.Format("Frame Rate: {0:f2}, Channel State: {1}", frameRate_Hz, channelState)); } catch (Euresys.MultiCamException ex) { VisionLogger.Log(WaftechLibraries.Log.LogType.Exception, "E2VCameraHelper", ex); VisionNotifier.AddNotification("MultiCam Exception: " + ex.Message); errorMessage = "MultiCam Exception: " + ex.Message; } catch (System.Exception ex) { VisionLogger.Log(WaftechLibraries.Log.LogType.Exception, "E2VCameraHelper", ex); VisionNotifier.AddNotification("System Exception: " + ex.Message); errorMessage = "System Exception: " + ex.Message; } }