Hi,I am able to draw rectangles on the picture but I am not able to capture the co-ordinates of the picture box instead it capture the screen coordinates.So the rectangle that I draw on the picture box doesn't appear on the position that I desire.
// Convert and normalize the points and draw the reversible frame.
private void MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();
// Convert the points to screen coordinates.
p1 = this.pictureBox1.PointToScreen (p1);
p2 = this.pictureBox1.PointToScreen (p2);
// Normalize the rectangle.
if (p1.X < p2.X)
{
rc.X = p1.X;
rc.Width = p2.X - p1.X;
}
else
{
rc.X = p2.X;
rc.Width = p1.X - p2.X;
}
if (p1.Y < p2.Y)
{
rc.Y = p1.Y;
rc.Height = p2.Y - p1.Y;
}
else
{
rc.Y = p2.Y;
rc.Height = p1.Y - p2.Y;
}
textBox1.Text = Convert.ToString(rc.X);
textBox2.Text = Convert.ToString(rc.Y);
textBox3.Text = Convert.ToString(rc.Width);
textBox4.Text = Convert.ToString(rc.Height);
// Draw the reversible frame.
ControlPaint.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Thick);
}
private void button1_Click(object sender, EventArgs e)
{
motionDetector = new MotionDetector(simpleBackgroundModeling, blobCounting);
//string[] s = File.ReadAllLines("MotionZone.txt");
int x = Convert.ToInt32 (textBox1.Text);
int y = Convert.ToInt32(textBox2.Text);
int width = Convert.ToInt32(textBox3.Text);
int height = Convert.ToInt32(textBox4.Text);
bflag = true;
// btnVideoStop.Enabled = true;
// btnPlay.Enabled = false;
rectangle[1] = new Rectangle(x, y, width, height);