Ejemplo n.º 1
0
        // calibrate the xyz
        private void CalibrateXYZ()
        {
            List <double[]> xyzList = new List <double[]>();

            this.ReadRGBConfig();
            fixture.RotateOn(); // ready ca310

            foreach (int[] rgb in this.rgbList)
            {
                double[] xyz = new double[3];

                if (rgb.Length == 3)
                {
                    if (dut.ChangePanelColor(rgb[0], rgb[1], rgb[2]))
                    {
                        System.Threading.Thread.Sleep(1000);
                        CIE1931Value cie = ca310Pipe.GetCa310Data();
                        xyz[0] = cie.x; xyz[1] = cie.y; xyz[2] = cie.Y;
                        xyzList.Add(xyz);
                    }
                    else
                    {
                        xyz[0] = 0; xyz[1] = 0; xyz[2] = 0;
                        xyzList.Add(xyz);
                    }
                }
            }

            fixture.RotateOff();
            this.WriteMatrixData(xyzList, "xyz");
        }
Ejemplo n.º 2
0
        public override void Calibration(float exposure = 0)
        {
            double flexPixel    = 0;
            double maxFlexPixel = 0;

            System.Drawing.Color pixel;
            StringBuilder        matrixStr = new StringBuilder();

            System.Threading.Thread.Sleep(3000);

            foreach (int[] item in rgbList)
            {
                List <AForge.IntPoint> cors = null;

                if (dut.ChangePanelColor(item[0], item[1], item[2]))
                {
                    System.Threading.Thread.Sleep(5000);
                    matrixStr.Clear();

                    camera.ExposureTime = this.CalExposureTime(exposure, item);
                    System.Drawing.Bitmap bitmap = camera.GrabImage();
                    if (this.videoCavaus != null)
                    {
                        this.videoCavaus.Image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap());
                    }
                    //Process Image to 1bpp to increase SNR
                    Bitmap m_orig = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
                    // only support the 32bppArgb for Aforge Blob Counter
                    Bitmap processbmp = m_orig.Clone(new Rectangle(0, 0, m_orig.Width, m_orig.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    pipe.GetDisplayCornerfrombmp(processbmp, out cors);

                    Bitmap cropimg = null;

                    if (cors != null)
                    {
                        cropimg = pipe.croppedimage(bitmap, cors, dut.ui_width, dut.ui_height);
                        if (this.videoCavaus != null)
                        {
                            this.videoCavaus.Image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap());
                        }
                    }

                    double[,] matrix = new double[cropimg.Width, cropimg.Height];

                    for (int i = 0; i < cropimg.Height; i++)
                    {
                        for (int j = 0; j < cropimg.Width; j++)
                        {
                            pixel        = cropimg.GetPixel(i, j);
                            flexPixel    = redWeight * pixel.R + greenWeight * pixel.G + blueWeight * pixel.B;
                            matrix[i, j] = flexPixel;

                            if (flexPixel > maxFlexPixel)
                            {
                                maxFlexPixel = flexPixel;
                            }
                        }
                    }

                    for (int i = 0; i < cropimg.Height; i++)
                    {
                        for (int j = 0; j < cropimg.Width; j++)
                        {
                            if (matrix[i, j] != 0)
                            {
                                matrix[i, j] = maxFlexPixel / matrix[i, j];
                            }

                            matrixStr.Append(matrix[i, j]);

                            if (j != cropimg.Width - 1)
                            {
                                matrixStr.Append(", ");
                            }
                        }
                        matrixStr.AppendLine();
                    }

                    string fullname = string.Format("{0}{1}_{2:000}{3:000}{4:000}_Flex.csv", PATH, serialNumber, item[0], item[1], item[2]);
                    using (StreamWriter sw = new StreamWriter(fullname, true))
                    {
                        sw.Write(matrixStr.ToString());
                        sw.Flush();
                        sw.Close();
                    }
                }
            }
        }