Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C# Windows Form App to locate a red object through a camera mounted on the mobile robot using AForge Library using the resolution

Write a "C# Windows Form App" to "locate a red object through a camera" mounted on the mobile robot using AForge Library using the "resolution of the camera" and "pixel location of the red object" in the video.

So that when the robot moves around, the video from the camera can used to used to tell if the red object is in the middle of the video, have rectangle around it and if it is in central position show a message box displaying that the red object is recognised. So, if the pixel location of the red object is 200 then it is located to the left, if the pixel location is 400 then it is located in the middle, if it is 600 then it means the red object is in the right from the middle part of the video. Display a co-ordinate label in the form based on pixel location.

Note that the camera "only moves along x axis".

I have used EuclideanColorFiltering filter from AForge.Imaging.Filters Library to extract the red object from the image but the red object placed anywhere cannot be located yet for robot to move towards it.

if(radiobtnRed.Checked) { // create filter EuclideanColorFiltering filter = new EuclideanColorFiltering(); // set center colol and radius filter.CenterColor = new RGB (Color.FromArgb(215, 0, 0)); filter.Radius = 100; // apply the filter filter.ApplyInPlace(image1);

ProcessImg(image1); }

// define Process Image function public void ProcessImg(Bitmap image) { BlobCounter blobCounter = new BlobCounter(); blobCounter.MinWidth = 5; blobCounter.MinHeight = 5; blobCounter.FilterBlobs = true; blobCounter.ObjectsOrder = ObjectsOrder.Size;

BitmapData objectsData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, image.PixelFormat); //grayscaling Grayscale grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721); UnmanagedImage grayImage = grayscaleFilter.Apply(new UnmanagedImage(objectsData));

// unlock image image.UnlockBits(objectsData);

blobCounter.ProcessImage(image); Rectangle[ ] rects = blobCounter.GetObjectsRectangles(); Blob[ ] blobs = blobCounter.GetObjectsInformation(); pictureBox3.Image = image;

}

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

More Books

Students also viewed these Databases questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago