static readonly CascadeClassifier cascadeClassifier = new CascadeClassifier("haarcascade_frontalface_alt_tree.xml");
void Device_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
Image<Bgr, byte> grayImage = new Image<Bgr, byte>(bitmap);
Rectangle[] rectangles = cascadeClassifier.DetectMultiScale(grayImage, 1.2, 1);
foreach (Rectangle rect in rectangles)
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
using (Pen pen = new Pen(Color.Red, 5))
{
graphics.DrawRectangle(pen, rect);
}
}
}
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
webcamDetection.Image = bitmap;
}
so this is the code i am using my question how do i get the x and y values of the red rectangle so i can send those values to an arduino and set servos as such. I can provide more information, hope someone can help me out.
If you know the rectangle you can check the documentation to see the available properties. You would typically use rect.X
, rect.Y
, rect.Width
, and rect.Height
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.