Ejemplo n.º 1
0
        void AVLGraphics(bool graphicsSwitch)
        {
            if (graphicsSwitch)
            {
                displayImageTop    = new AvlNet.Image(TopIntensityImage.CreateBitmap());
                displayImageBottom = new AvlNet.Image(BottomIntensityImage.CreateBitmap());
                //Match Edges
                //foreach (var item in outMatchEdges)
                //{
                //    AVL.DrawPath(ref displayImageTop, item, Pixel.Green, new DrawingStyle(DrawingMode.Fast, 1, 1, false, PointShape.Circle, 2));
                //}
                //Match Point
                //AVL.DrawPoint(ref displayImageTop, outMatchPoint.Value, Pixel.Green, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 60));
                // Intersection Point 1
                // AVL.DrawPoint(ref displayImageTop, outIntersectionPoint01.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120));
                // Intersection Point 2
                // AVL.DrawPoint(ref displayImageTop, outIntersectionPoint02.Value, Pixel.Purple, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120));
                //Fit line
                //AVL.DrawLine(ref displayImageTop, outLine01.Value, Pixel.Yellow, new DrawingStyle(DrawingMode.Fast, 1, 2, false, PointShape.Circle, 2));
                //AVL.DrawLine(ref displayImageTop, outLine02.Value, Pixel.Yellow, new DrawingStyle(DrawingMode.Fast, 1, 1, false, PointShape.Circle, 2));
                //AVL.DrawLine(ref displayImageTop, outLineMid.Value, new Pixel(LineColor), new DrawingStyle(DrawingMode.Fast, 1, 2, false, PointShape.Circle, 2));
                //AVL.DrawPoint(ref displayImageTop, MidPoint01.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120));
                // AVL.DrawPoint(ref displayImageTop, MidPoint02.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120));
                //displayImageTop.Save($@"{ConfigPath.ImageDataPathTop}{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.png");

                ImageSourceTop    = ImageConvert.BitmapToImageSource(displayImageTop.CreateBitmap());
                ImageSourceBottom = ImageConvert.BitmapToImageSource(displayImageBottom.CreateBitmap());
            }
        }
Ejemplo n.º 2
0
        void AVLRun(Surface topSurface, Surface bottomSurface, AvlNet.Image topDepthImage, AvlNet.Image bottomDepthImage, AvlNet.Image topIntensityImage, AvlNet.Image bottomIntensityImage)
        {
            double dis01 = -1000;
            double dis02 = -1000;

            macros.TopPoint(topIntensityImage, topDepthImage, out TopPointValue, out TopPoint);

            macros.BottomPoint(topDepthImage, topIntensityImage, out BottomPointValue, out BottomPoint);

            macros.TopRef(bottomIntensityImage, bottomDepthImage, out TopRefValue);
            macros.BottomRef(bottomIntensityImage, bottomDepthImage, out BottomRefValue);

            Point3D topPoint = ImageConvert.TransPoint3DToRealWorld(new Point3D(TopPoint.Value.X, TopPoint.Value.Y, TopPointValue.Value), gocator.mContextTop);

            Point3D bottomPoint = ImageConvert.TransPoint3DToRealWorld(new Point3D(BottomPoint.Value.X, BottomPoint.Value.Y, BottomPointValue.Value), gocator.mContextTop);

            Point3D topRefPoint = ImageConvert.TransPoint3DToRealWorld(new Point3D(0, 0, TopRefValue.Value), gocator.mContextBottom);

            Point3D bottomRefPoint = ImageConvert.TransPoint3DToRealWorld(new Point3D(0, 0, BottomRefValue.Value), gocator.mContextBottom);

            dis01 = ImageConvert.CalcZGap(topPoint, topRefPoint, gocator.mContextTop);
            dis02 = ImageConvert.CalcZGap(bottomPoint, bottomRefPoint, gocator.mContextTop);


            string P1Msg = $"P1,{ImageConvert.Point3DToString(topPoint)},Distance,{dis01},Ref,{TopRefValue.Value}";
            string P2Msg = $"P2,{ImageConvert.Point3DToString(bottomPoint)},Distance,{dis02},Ref,{ BottomRefValue.Value}";

            File.AppendAllText($"{ConfigPath.TestResultPath}result01.csv", P1Msg + Environment.NewLine);
            File.AppendAllText($"{ConfigPath.TestResultPath}result02.csv", P2Msg + Environment.NewLine);
            Logger(P1Msg);
            Logger(P2Msg);
            _context.Post(new SendOrPostCallback((e) =>
            {
                AVLGraphics(true);
            }), new object());
        }
Ejemplo n.º 3
0
        private void Gocator_OnDataReceivedEvent(object sender, object e)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            List <TopBottomSurface> rawDataSet = (List <TopBottomSurface>)e;

            foreach (var item in rawDataSet)
            {
                //save to surface
                Surface topSurface = new Surface(gocator.mContextTop.Width, gocator.mContextTop.Height, item.TopSurfaceData);
                SurfaceConvert.ScaleSurface(ref topSurface, gocator.mContextTop);
                Surface bottomSurface = new Surface(gocator.mContextBottom.Width, gocator.mContextBottom.Height, item.BottomSurfaceData);
                SurfaceConvert.ScaleSurface(ref bottomSurface, gocator.mContextBottom);
                TopDepthImage        = ImageConvert.ZValueToDepthImage(item.TopSurfaceData, gocator.mContextTop);
                BottomDepthImage     = ImageConvert.ZValueToDepthImage(item.BottomSurfaceData, gocator.mContextBottom);
                TopIntensityImage    = ImageConvert.ByteToIntensityBitmap(item.TopSurfaceIntensityData, gocator.mContextTop);
                BottomIntensityImage = ImageConvert.ByteToIntensityBitmap(item.BottomSurfaceIntensityData, gocator.mContextBottom);

                AVLRun(topSurface, bottomSurface, TopDepthImage, BottomDepthImage, TopIntensityImage, BottomIntensityImage);

                server.SendAll("-1000");
                sw.Stop();
                Logger($"{sw.ElapsedMilliseconds}");
                Logger("Send Data to Client -1000");

                string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string generateSurfaceTopName = $"{ConfigPath.ImageDataPathTop}TopSurface{timeStamp}.avdata";
                AVL.SaveSurface(topSurface, generateSurfaceTopName);
                string generateSurfaceBottomName = $"{ConfigPath.ImageDataPathBottom}BottomSurface{timeStamp}.avdata";
                AVL.SaveSurface(bottomSurface, generateSurfaceBottomName);
            }
            Logger("Surface data saved");

            //gocator.StartAcq();
        }