Ejemplo n.º 1
0
        private void OnImageWindowImageChanged(object sender)
        {
            HalconWindowControl window = sender as HalconWindowControl;

            UpdatePointAndGrayValLabels(window as HalconWindowControl, oldRow, oldCol);
            RefreshRegionsInHalconWindow(window);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Refreshes the regions in halcon window.
 /// </summary>
 /// <param name="window">The window.</param>
 private void RefreshRegionsInHalconWindow(HalconWindowControl window)
 {
     if (window != null)
     {
         window.HalconWindow.SetColor("green");
         window.HalconWindow.SetLineWidth(2);
         window.HalconWindow.SetDraw("margin");
         window.HalconWindow.DispRectangle1(0.0, this.cameraAcq.CurrentCameraProperties.NumberOfPixelsToBeClippedAtLeft, this.cameraAcq.CurrentImageHeight, this.cameraAcq.CurrentImageWidth - this.cameraAcq.CurrentCameraProperties.NumberOfPixelsToBeClippedAtRight);
         window.HalconWindow.SetColor("cyan");
         window.HalconWindow.SetLineWidth(2);
         window.HalconWindow.DispRectangle1(0.0, this.cameraAcq.CurrentCameraProperties.CameraHeightReferenceLowerLimit, this.cameraAcq.CurrentImageHeight, this.cameraAcq.CurrentCameraProperties.CameraHeightReferenceUpperLimit);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the coordinate and gray value labels according to the mouse movement
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="row">The row.</param>
        /// <param name="column">The column.</param>
        private void UpdatePointAndGrayValLabels(HalconWindowControl window, double row, double column)
        {
            if (this.InvokeRequired)
            {
                Action <HalconWindowControl, double, double> a = new Action <HalconWindowControl, double, double>(UpdatePointAndGrayValLabels);
                this.BeginInvoke(a, window, row, column);
            }
            else
            {
                if (window == null)
                {
                    return;
                }
                lblRowColData.Text = Convert.ToInt32(row) + @"," + Convert.ToInt32(column);
                oldRow             = row;
                oldCol             = column;
                try
                {
                    if (window.ImageData == null || column < 0 || row < 0 || window.ImageWidth < column || window.ImageHeight < row)
                    {
                        lblRowColData.Text = "0,0";
                        lblColorValue.Text = "0,0,0";
                        return;
                    }
                    string pixelString = "";
                    HTuple pixelVal    = window.ImageData.GetGrayval((int)row, (int)column);
                    if (pixelVal.Length > 1)
                    {
                        for (int i = 0; i < pixelVal.Length; i++)
                        {
                            pixelString = pixelString + pixelVal[i].D;
                            if (i != pixelVal.Length - 1)
                            {
                                pixelString = pixelString + ",";
                            }
                        }
                    }
                    else
                    {
                        int channels = window.ImageData.CountChannels();
                        if (channels == 1)
                        {
                            HTuple pixelVals = window.ImageData.GetGrayval((int)row, (int)column);
                            pixelString = Convert.ToInt32(pixelVals.D).ToString();
                        }
                        else if (channels == 3)
                        {
                            HImage r, g, b;
                            r = window.ImageData.Decompose3(out g, out b);
                            HTuple pixelVals = r.GetGrayval((int)row, (int)column);
                            pixelString = Convert.ToInt32(pixelVals.D).ToString();
                            pixelVals   = g.GetGrayval((int)row, (int)column);
                            pixelString = pixelString + "," + Convert.ToInt32(pixelVals.D);
                            pixelVals   = b.GetGrayval((int)row, (int)column);
                            pixelString = pixelString + "," + Convert.ToInt32(pixelVals.D);
                        }
                    }

                    lblColorValue.Text = pixelString;
                }
                catch
                { }
            }
        }
Ejemplo n.º 4
0
        private void OnImageWindowRepainted(object sender)
        {
            HalconWindowControl window = sender as HalconWindowControl;

            RefreshRegionsInHalconWindow(window);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the "Mouse Move" event in the Image Window
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="HalconDotNet.HMouseEventArgs"/> instance containing the event data.</param>
        private void OnImageWindowMouseMove(object sender, HMouseEventArgs e)
        {
            HalconWindowControl window = sender as HalconWindowControl;

            UpdatePointAndGrayValLabels(window, e.Y, e.X);
        }