EDN Admin
Well-known member
Let say i have an image of a face. And i have detected the eyes with a rectangle around it, next i wish to save the eyes(only) that appear in the rectangle into a folder. How can i do it? Any suggestion?
This is the code where the eyes are detected and where the rectangles are drawn:
<font color="#0000ff" size=2><font color="#0000ff" size=2>
<font style="font-size:10px private</font></font></font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff void</font></font><font style="font-size:10px btnDetect_Click(</font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff object</font></font><font style="font-size:10px sender, </font><font style="font-size:10px" color="#2b91af <font style="font-size:10px" color="#2b91af EventArgs</font></font></font><font size=2><font style="font-size:10px e)</font>
<font style="font-size:10px {</font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff if</font></font><font style="font-size:10px (lastPic != </font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff null</font></font></font><font size=2><font style="font-size:10px )</font>
<font style="font-size:10px {</font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff int</font></font><font size=2><font style="font-size:10px faces = objFaceDetector.WrapDetectFaces(lastPic); </font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff this</font></font><font style="font-size:10px .Text = </font><font style="font-size:10px" color="#a31515 <font style="font-size:10px" color="#a31515 "Number of faces : "</font></font></font><font size=2><font style="font-size:10px + faces.ToString();</font>
</font><font color="#0000ff" size=2><font color="#0000ff" size=2><font style="font-size:10px unsafe</font> </font></font><font size=2>
<font style="font-size:10px {</font>
<font style="font-size:10px picGraphics = pictureBox1.CreateGraphics();</font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff int</font></font><font size=2><font style="font-size:10px lx, ly, rx, ry, res;</font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff for</font></font><font style="font-size:10px (</font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff int</font></font></font><font size=2><font style="font-size:10px f = 0; f < faces; f++)</font>
<font style="font-size:10px { </font>
<font style="font-size:10px objFaceDetector.WrapGetFaceCordinates(f, &lx, &ly, &rx, &ry);</font>
<font style="font-size:10px </font>
</font><font color="#008000" size=2><font color="#008000" size=2><font style="font-size:10px // picGraphics.DrawRectangle(myPen, lx, ly, rx, ry);</font> </font></font><font size=2>
<font style="font-size:10px </font>
<font style="font-size:10px res = objFaceDetector.WrapGetEyeCordinates(f, &lx, &ly, &rx, &ry);</font>
<font style="font-size:10px </font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff if</font></font><font size=2><font style="font-size:10px (res > -1)</font>
<font style="font-size:10px { </font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx-20, ly+14, lx+20, ly+14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx+19, ly-14, lx+19, ly+14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 20, ry + 14, rx + 20, ry + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx + 19, ry - 14, rx + 19, ry + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx - 20, ly - 14, lx + 20, ly - 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx - 19, ly - 14, lx - 19, ly + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 20, ry - 14, rx + 20, ry - 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 19, ry - 14, rx - 19, ry + 14);</font>
<font style="font-size:10px </font>
<font style="font-size:10px } </font>
<font style="font-size:10px }</font>
<font style="font-size:10px picGraphics.Save();</font>
<font style="font-size:10px picGraphics.Dispose();</font>
<font style="font-size:10px }</font>
<font style="font-size:10px }</font>
<font style="font-size:10px }
<font color="#0000ff" size=2><font color="#0000ff" size=2>
private</font></font> <font color="#0000ff" size=2><font color="#0000ff" size=2>void</font></font><font size=2> btnSave_Click(</font><font color="#0000ff" size=2><font color="#0000ff" size=2>object</font></font><font size=2> sender, </font><font color="#2b91af" size=2><font color="#2b91af" size=2>EventArgs</font></font><font size=2> e)
{
</font><font color="#008000" size=2><font color="#008000" size=2>// WHAT CAN I PUT HERE???</font></font><font size=2>
}
THANKS </font></font></font>
View the full article
This is the code where the eyes are detected and where the rectangles are drawn:
<font color="#0000ff" size=2><font color="#0000ff" size=2>
<font style="font-size:10px private</font></font></font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff void</font></font><font style="font-size:10px btnDetect_Click(</font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff object</font></font><font style="font-size:10px sender, </font><font style="font-size:10px" color="#2b91af <font style="font-size:10px" color="#2b91af EventArgs</font></font></font><font size=2><font style="font-size:10px e)</font>
<font style="font-size:10px {</font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff if</font></font><font style="font-size:10px (lastPic != </font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff null</font></font></font><font size=2><font style="font-size:10px )</font>
<font style="font-size:10px {</font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff int</font></font><font size=2><font style="font-size:10px faces = objFaceDetector.WrapDetectFaces(lastPic); </font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff this</font></font><font style="font-size:10px .Text = </font><font style="font-size:10px" color="#a31515 <font style="font-size:10px" color="#a31515 "Number of faces : "</font></font></font><font size=2><font style="font-size:10px + faces.ToString();</font>
</font><font color="#0000ff" size=2><font color="#0000ff" size=2><font style="font-size:10px unsafe</font> </font></font><font size=2>
<font style="font-size:10px {</font>
<font style="font-size:10px picGraphics = pictureBox1.CreateGraphics();</font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff int</font></font><font size=2><font style="font-size:10px lx, ly, rx, ry, res;</font>
</font><font style="font-size:10px <font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff for</font></font><font style="font-size:10px (</font><font style="font-size:10px" color="#0000ff <font style="font-size:10px" color="#0000ff int</font></font></font><font size=2><font style="font-size:10px f = 0; f < faces; f++)</font>
<font style="font-size:10px { </font>
<font style="font-size:10px objFaceDetector.WrapGetFaceCordinates(f, &lx, &ly, &rx, &ry);</font>
<font style="font-size:10px </font>
</font><font color="#008000" size=2><font color="#008000" size=2><font style="font-size:10px // picGraphics.DrawRectangle(myPen, lx, ly, rx, ry);</font> </font></font><font size=2>
<font style="font-size:10px </font>
<font style="font-size:10px res = objFaceDetector.WrapGetEyeCordinates(f, &lx, &ly, &rx, &ry);</font>
<font style="font-size:10px </font>
</font><font color="#0000ff" size=2><font style="font-size:10px" color="#0000ff if</font></font><font size=2><font style="font-size:10px (res > -1)</font>
<font style="font-size:10px { </font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx-20, ly+14, lx+20, ly+14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx+19, ly-14, lx+19, ly+14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 20, ry + 14, rx + 20, ry + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx + 19, ry - 14, rx + 19, ry + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx - 20, ly - 14, lx + 20, ly - 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, lx - 19, ly - 14, lx - 19, ly + 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 20, ry - 14, rx + 20, ry - 14);</font>
<font style="font-size:10px picGraphics.DrawLine(myPen, rx - 19, ry - 14, rx - 19, ry + 14);</font>
<font style="font-size:10px </font>
<font style="font-size:10px } </font>
<font style="font-size:10px }</font>
<font style="font-size:10px picGraphics.Save();</font>
<font style="font-size:10px picGraphics.Dispose();</font>
<font style="font-size:10px }</font>
<font style="font-size:10px }</font>
<font style="font-size:10px }
<font color="#0000ff" size=2><font color="#0000ff" size=2>
private</font></font> <font color="#0000ff" size=2><font color="#0000ff" size=2>void</font></font><font size=2> btnSave_Click(</font><font color="#0000ff" size=2><font color="#0000ff" size=2>object</font></font><font size=2> sender, </font><font color="#2b91af" size=2><font color="#2b91af" size=2>EventArgs</font></font><font size=2> e)
{
</font><font color="#008000" size=2><font color="#008000" size=2>// WHAT CAN I PUT HERE???</font></font><font size=2>
}
THANKS </font></font></font>
View the full article