コード例 #1
0
        /// <summary>
        /// finds the absolute borders of a point cloud in terms of coordinates
        /// </summary>
        /// <param name="pInputCloud">the point cloud</param>
        /// <returns>a struct containing the borders</returns>
        public static PointCloudBorderPackage findBordersAbsolute(PointCloud pInputCloud)
        {
            PointCloudBorderPackage resPack = new PointCloudBorderPackage();

            foreach (Point p in pInputCloud.pointcloud_hs)
            {
                if (p.point.X < resPack.xmin)
                {
                    resPack.xmin = p.point.X;
                }
                if (p.point.X > resPack.xmax)
                {
                    resPack.xmax = p.point.X;
                }
                if (p.point.Y < resPack.ymin)
                {
                    resPack.ymin = p.point.Y;
                }
                if (p.point.Y > resPack.ymax)
                {
                    resPack.ymax = p.point.Y;
                }
                if (p.point.Z < resPack.zmin)
                {
                    resPack.zmin = p.point.Z;
                }
                if (p.point.Z > resPack.zmax)
                {
                    resPack.zmax = p.point.Z;
                }
            }
            return(resPack);
        }
コード例 #2
0
        /// <summary>
        /// creates three bitmaps based on a point cloud
        /// </summary>
        /// <param name="pInputCloud">the point cloud</param>
        /// <param name="pHeight">the height of the bitmap</param>
        /// <param name="pWidth">the width of the bitmap</param>
        /// <returns>the picture package containing top, bottom and front view</returns>
        public static PointCloudPicturePackage createPointCloudPicturePackageFromPointCloud(PointCloud pInputCloud, int pHeight, int pWidth)
        {
            //create data objects
            PointCloudPicturePackage resPack = new PointCloudPicturePackage();

            resPack.sideview   = new WriteableBitmap(pWidth, pHeight, 96.0, 96.0, System.Windows.Media.PixelFormats.Pbgra32, null);
            resPack.bottomview = new WriteableBitmap(pWidth, pHeight, 96.0, 96.0, System.Windows.Media.PixelFormats.Pbgra32, null);
            resPack.frontview  = new WriteableBitmap(pWidth, pHeight, 96.0, 96.0, System.Windows.Media.PixelFormats.Pbgra32, null);

            //clear bitmap and set initial color value
            resPack.sideview.Clear(System.Windows.Media.Colors.White);
            resPack.bottomview.Clear(System.Windows.Media.Colors.White);
            resPack.frontview.Clear(System.Windows.Media.Colors.White);

            //find absolute borders for point cloud
            PointCloudBorderPackage pcbp = findBordersAbsolute(pInputCloud);

            resPack.borders = pcbp;

            //draw stuff
            foreach (Point p in pInputCloud.pointcloud_hs)
            {
                //calculate relative location by norming: 0 <= x,y,z <= 1
                float x, y, z;
                x = (p.point.X + Math.Abs(pcbp.xmin)) / (Math.Abs(pcbp.xmax) + Math.Abs(pcbp.xmin));
                y = (p.point.Y + Math.Abs(pcbp.ymin)) / (Math.Abs(pcbp.ymax) + Math.Abs(pcbp.ymin));
                z = (p.point.Z + Math.Abs(pcbp.zmin)) / (Math.Abs(pcbp.zmax) + Math.Abs(pcbp.zmin));

                if (!(x >= 1 || y >= 1 || z >= 1))
                {
                    //draw picture: x,y for front; x,z for bottom; z,y for side;
                    resPack.frontview.SetPixel((int)(x * pWidth), (int)(y * pHeight), System.Windows.Media.Colors.DarkRed);
                    resPack.bottomview.SetPixel((int)(x * pWidth), (int)(z * pHeight), System.Windows.Media.Colors.DarkRed);
                    resPack.sideview.SetPixel((int)(z * pWidth), (int)(y * pHeight), System.Windows.Media.Colors.DarkRed);
                }
            }

            //return
            resPack.bottomview.Freeze(); resPack.frontview.Freeze(); resPack.sideview.Freeze();
            return(resPack);
        }