Example #1
0
        /// <summary>
        /// Computes the pf image from histogram. Used for visualization.
        /// </summary>
        public void ComputePfImageFromHistogram()
        {
            float pf = 0;

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    int   idx   = i * Width + j;
                    Color pixel = ColorTexture.GetPixel(j, i);
                    pf = GetPf(pixel);
                    if (pf > 0.8f)
                    {
                        if (!ColorTextureVisual.GetPixel(j, i).Equals(Color.blue))   //&& Mask[idx] == defines.HIST_FG_PIXEL)
                        {
                            ColorTextureVisual.SetPixel(j, i, Color.Lerp(pixel, Color.green, 0.5f));

                            if (Mask[idx] == defines.HIST_FG_PIXEL)
                            {
                                ColorTextureVisual.SetPixel(j, i, Color.Lerp(pixel, Color.cyan, 0.5f));
                            }
                        }
                    }
                    else if (pf == 0.3f)
                    {
                        if (!ColorTextureVisual.GetPixel(j, i).Equals(Color.blue))
                        {
                            //ColorTextureVisual.SetPixel( j, i, Color.Lerp( pixel, Color.yellow, 0.2f ) );
                        }
                    }
                }
            }
            ColorTextureVisual.Apply();
        }
Example #2
0
        /// <summary>
        /// Gets 3D points [units = meters] and calculated pf vector
        /// </summary>
        /// <param name="state">State.</param>
        private void PreparePointCloud(HoloProxies.Engine.trackerState state)
        {
            boundingbox = findBoundingBoxFromCurrentState(state);

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    int idx = i * Width + j;

                    // if point is not in the bounding box
                    if (j < boundingbox.x || j >= boundingbox.z || i < boundingbox.y || i >= boundingbox.w)
                    {
                        // mark as not useful
                        Camera3DPoints[idx].X = 0;
                        Camera3DPoints[idx].Y = 0;
                        Camera3DPoints[idx].Z = 0;
                        PfVec[idx]            = defines.OUTSIDE_BB;
                    }
                    else // if it's inside the box
                    {
                        Color pixel = ColorTexture.GetPixel(j, i);
                        PfVec[idx] = GetPf(pixel);
                        // Draw the bounding box region
                        if (drawBox && OnBoxEdge(j, i))
                        {
                            //ColorTextureVisual.SetPixel( j, i, Color.blue );
                            ColorTextureVisual.SetPixel(j, i, Color.Lerp(pixel, Color.blue, 0.3f));
                        }
                    }
                }
            } //end for
        }