/// <summary>
        /// 映美金相机触发出图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void icImagingControl_ImageAvailable(object sender, TIS.Imaging.ICImagingControl.ImageAvailableEventArgs e)
        {
            TIS.Imaging.ImageBuffer CurrentBuffer = icImagingControl.ImageBuffers[e.bufferIndex];
            Image <Gray, byte>      grayImage     = new Image <Gray, byte>(CurrentBuffer.Bitmap);

            YMJcamera.GetCamParams();//获取内参
            //校正畸变
            CvInvoke.InitUndistortRectifyMap(TisCamera.cameraMatrix, TisCamera.distCoeffs, null, TisCamera.cameraMatrix,
                                             TisCamera.imageSize, DepthType.Cv32F, TisCamera.mapx, TisCamera.mapy);
            CvInvoke.Remap(grayImage, grayImage, TisCamera.mapx, TisCamera.mapy, Inter.Linear, BorderType.Constant, new MCvScalar(0));
            for (int i = 0; i < TisCamera.height; i++)
            {
                for (int j = 0; j < TisCamera.width; j++)
                {
                    TisCamera.YMJImage.Data[i, j, 2] = grayImage.Data[i, j, 0];
                    TisCamera.YMJImage.Data[i, j, 1] = grayImage.Data[i, j, 0];
                    TisCamera.YMJImage.Data[i, j, 0] = grayImage.Data[i, j, 0];
                }
            }
            if (GLB.Camera_index == 1)
            {
                DealWithImage.getContoursForYMJ(grayImage, ptbDisplay);
                ptbDisplay.Image = TisCamera.YMJImage.ToBitmap();//显示映美金图像
            }
        }
        /// <summary>
        /// 显示真三维图像:
        /// </summary>
        /// <param name="cameraIndex"></param>
        /// <param name="point_3d"></param>
        /// <param name="ptb"></param>
        public static void display_point_3d_1(int cameraIndex, float[] point_3d, PictureBox ptb)
        {
            float ff;
            float visibaleDistance = 0;//可视距离

            if (cameraIndex == 0)
            {
                visibaleDistance = 2600;                  //2300
            }
            else if (cameraIndex == 1)
            {
                visibaleDistance = 3750;
            }
            for (int i = 0; i < GLB.BUFH; i++)
            {
                for (int j = 0; j < GLB.BUFW; j++)
                {
                    ff = (float)(point_3d[(i * GLB.BUFW + j) * 3 + 2]);
                    if (ff < visibaleDistance && ff > 2000)
                    {
                        //伪彩色表示深度:
                        GLB.MyFrame.Data[i, j, 0] = (byte)(128 + 127 * Math.Cos(ff / 13f));
                        GLB.MyFrame.Data[i, j, 1] = (byte)(127 - 127 * Math.Sin(ff / 17f));
                        GLB.MyFrame.Data[i, j, 2] = (byte)(128 + 127 * Math.Sin(ff / 23f));
                        //GLB.MyFrame.Data[i, j, 0] = 255;
                        //GLB.MyFrame.Data[i, j, 1] = 255;
                        //GLB.MyFrame.Data[i, j, 2] = 255;
                    }
                    else
                    {
                        GLB.MyFrame.Data[i, j, 0] = 0;
                        GLB.MyFrame.Data[i, j, 1] = 0;
                        GLB.MyFrame.Data[i, j, 2] = 0;
                    }
                }
            }
            DealWithImage.getContours(point_3d);
            ptb.Image = GLB.MyFrame.ToBitmap();

            //###########################测试###############################
            //GLB.MyFrame = GLB.MyFrame.SmoothBlur(GLB.BUFW, GLB.BUFH);//全屏模糊
            //src = src.SmoothGaussian(25);//25*25区块,高斯模糊
            //GLB.MyFrame = GLB.MyFrame.SmoothMedian(17);//17*17区块,均值模糊化
            //var gray = GLB.MyFrame.Convert<Gray, Byte>(); //灰度化
            //CvInvoke.AdaptiveThreshold(gray, gray, 255, AdaptiveThresholdType.MeanC, ThresholdType.Binary, 27, 1);
            //ptb.Image = gray.ToBitmap();
        }
        /// <summary>
        /// 显示三维数据
        /// </summary>
        /// <param name="cameraIndex"></param>
        /// <param name="myp3d"></param>
        /// <param name="ptb"></param>
        public static void display_point_3d(int cameraIndex, float[] myp3d, PictureBox ptb)
        {
            GLB.TitleStr = "";
            float visibaleDistance = 0;//可视距离
            float dis_temp         = 0;
            int   d = 2;

            if (cameraIndex == 0)
            {
                visibaleDistance = 2436;
            }
            //else if (cameraIndex == 1) visibaleDistance = 2600;
            for (int i = d; i < GLB.BUFH - d; i += d)
            {
                for (int j = d; j < GLB.BUFW - d; j += d)
                {
                    float z_center = myp3d[(i * GLB.BUFW + j) * 3 + 2];
                    if (z_center > 0 && z_center < visibaleDistance)//小于托盘的深度
                    {
                        float v1 = myp3d[3 * ((i - d) * GLB.BUFW + j - d) + 2];
                        float v2 = myp3d[3 * ((i - d) * GLB.BUFW + j) + 2];
                        float v3 = myp3d[3 * ((i - d) * GLB.BUFW + j + d) + 2];
                        float v4 = myp3d[3 * (i * GLB.BUFW + j - d) + 2];

                        float v6 = myp3d[3 * (i * GLB.BUFW + j + d) + 2];
                        float v7 = myp3d[3 * ((i + d) * GLB.BUFW + j - d) + 2];
                        float v8 = myp3d[3 * ((i + d) * GLB.BUFW + j) + 2];
                        float v9 = myp3d[3 * ((i + d) * GLB.BUFW + j + d) + 2];

                        if (double.IsNaN(v1) || double.IsNaN(v2) || double.IsNaN(v3) || double.IsNaN(v4) ||
                            double.IsNaN(v6) || double.IsNaN(v7) || double.IsNaN(v8) || double.IsNaN(v9))
                        {
                            dis_temp = 0;
                        }


                        dis_temp = Math.Abs(v1 - z_center) + Math.Abs(v2 - z_center) + Math.Abs(v3 - z_center) + Math.Abs(v4 - z_center)
                                   + Math.Abs(v6 - z_center) + Math.Abs(v7 - z_center) + Math.Abs(v8 - z_center) + Math.Abs(v9 - z_center);//双线斜率绝对值之和
                        dis_temp = dis_temp < 15 ? z_center : 0;
                    }
                    else
                    {
                        dis_temp = 0;
                    }
                    //伪彩色效果:
                    for (int dy = -d / 2; dy < d / 2; dy++)
                    {
                        for (int dx = -d / 2; dx < d / 2; dx++)
                        {
                            if (dis_temp == 0)
                            {
                                GLB.MyFrame.Data[i + dx, j + dy, 0] = (byte)(dis_temp);   //B
                                GLB.MyFrame.Data[i + dx, j + dy, 1] = (byte)(dis_temp);   //G
                                GLB.MyFrame.Data[i + dx, j + dy, 2] = (byte)(dis_temp);   //R
                            }
                            else
                            {
                                GLB.MyFrame.Data[i + dx, j + dy, 0] = (byte)(128 + 127 * Math.Cos(dis_temp / 13f));
                                GLB.MyFrame.Data[i + dx, j + dy, 1] = (byte)(127 - 127 * Math.Sin(dis_temp / 17f));
                                GLB.MyFrame.Data[i + dx, j + dy, 2] = (byte)(128 + 127 * Math.Sin(dis_temp / 23f));
                            }
                        }
                    }
                }
            }
            DealWithImage.getContours(myp3d);

            //RotatedRect myrect = new RotatedRect(new PointF((float)GLB.BUFW / 2, (float)GLB.BUFH / 2), new Size(8, 8), 0);
            //CvInvoke.Ellipse(GLB.frame, myrect, new MCvScalar(255, 0, 0), 5);//在角上一个小圆
            if (GLB.MyFrame.Data != null)
            {
                ptb.Image = GLB.MyFrame.ToBitmap();
            }
        }