Eine Linie zeichnen auf eine bitmap

Ich machte ein Gesicht dector in matlab, und ich bin das übersetzen in c# - code, habe ich alles moslty getan. In der Hauptsache benutze ich

 System.Drawing.Bitmap b = new
        System.Drawing.Bitmap("C:*Location of file on computer*");

zu initilly erreichen der Bild, und in den letzten Schritten habe ich diesen code

public static void ratio(System.Drawing.Bitmap b, Dictionary<int, List<int>> map)
    {
        double height=0;
        double width=0;


        foreach (KeyValuePair<int, List<int>> place in map)
        {
            height = place.Value[2] - place.Value[3];
            width = place.Value[0] - place.Value[1];

            if( ((height/width) >= 1) && ((height/width) <=  2 ) )
                draw(b, place, map);
        }
    }

    public static void draw(System.Drawing.Bitmap bmp, KeyValuePair<int, List<int>> place, Dictionary<int, List<int>> map)
    {
        //Create pen.
        Pen blackPen = new Pen(Color.Black, 3);
        //Create coordinates of points that define line.

        int x1 = place.Value[1];   //topleft to topright
        int y1 = place.Value[3];
        int x2 = place.Value[0];
        int y2 = place.Value[3];

        int x3 = place.Value[0];   //topright to bottomright
        int y3 = place.Value[3];
        int x4 = place.Value[0];
        int y4 = place.Value[2];

        int x5 = place.Value[0];   //bottomright to bottomleft
        int y5 = place.Value[2];
        int x6 = place.Value[1];
        int y6 = place.Value[2];

        int x7 = place.Value[1];   //bottomleft to topleft
        int y7 = place.Value[2];
        int x8 = place.Value[1];
        int y8 = place.Value[3];

        //Draw line to screen.
        using (var graphics = Graphics.FromImage(bmp))
        {
            graphics.DrawLine(blackPen, x1, y1, x2, y2);
        }

        using (var graphics = Graphics.FromImage(bmp))
        {
            graphics.DrawLine(blackPen, x3, y3, x4, y4);
        }

        using (var graphics = Graphics.FromImage(bmp))
        {
            graphics.DrawLine(blackPen, x5, y5, x6, y6);
        }

        using (var graphics = Graphics.FromImage(bmp))
        {
            graphics.DrawLine(blackPen, x7, y7, x8, y8);
        }

    }

zeichnen Sie einen Rahmen um das Gesicht. Verhältnis verwendet den Grenzen von labels bezogen, die connected component labeling, zu finden, das richtige Verhältnis für ein menschliches Gesicht (meine zahlen sind nur ausgedacht) Karte Wörterbuch enthält die label-Nummer, zusammen mit dem xmax, xmin, ymax und ymin als Werte. Alles kompiliert ohne Fehler, aber, was ich versuche zu tun, ist jetzt die Anzeige des Sprach-Bild mit den eingezeichneten Kästchen um das Gesicht und ich bin unsicher, wie das zu tun,

InformationsquelleAutor DSP_Student | 2013-07-09
Schreibe einen Kommentar