Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write C# Windows Form App code to determine the central position of the video in the picturebox to find if the red object lies to

Write C# Windows Form App code to determine the central position of the video in the picturebox to find if the red object lies to the left or right of the video in the camera.

I have detected the red object using following code. I would like to determine the "pixel location" of the red object and check if it lies to the "left of the central position in the video" or to the right.

ColorFiltering colorfilter = new ColorFiltering(); colorfilter.Red = new IntRange(Red, (int)numericUpDownRed.Value); colorfilter.Green = new IntRange(Green, (int)numericUpDownGreen.Value); colorfilter.Blue = new IntRange(Blue, (int)numericUpDownBlue.Value); colorfilter.ApplyInPlace(video2);

//BlobCounter BlobCounter blobcounter = new BlobCounter(); blobcounter.MinHeight = 20; blobcounter.MinWidth = 20; blobcounter.ObjectsOrder = ObjectsOrder.Size; blobcounter.ProcessImage(video2); Rectangle[] rect = blobcounter.GetObjectsRectangles(); if (rect.Length > 0) { Rectangle target = rect[0]; Graphics graphic = Graphics.FromImage(video2); // To apply Grapghics on video2, that is, pictureBox2.

g = Graphics.FromImage(video2); using (Pen pen = new Pen(Color.White, 3)) {

graphic.DrawRectangle(pen, target);

g.DrawString("Target Located !", new Font("Arial", 20), new SolidBrush(Color.White), new PointF(2, 2)); // to demonstrate 'recognition' of target. g.Dispose(); } graphic.Dispose(); } pictureBox2.Image = video2; } pictureBox1.Image = video;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

What is a stockout cost and why is it important?

Answered: 1 week ago