Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to detect red color ball with a if statement in MATLAB

Status
Not open for further replies.

umagon

Newbie level 3
Joined
Sep 23, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
as the title above, i wanted to write a code if red color ball was detected, the led will lit on (in MATLAB). how to write a IF statement to make sure the red ball was detected from the webcam? and how to determine the range of RGB value

let say i have a variable A = a ball bound in a box, then by using a IF, if the ball that bounded in the box (variable A) is red, then led will on

please help, thanks alot
 

Since you are using a webcam, not all adapter would give the same RGB result for a single color. They might be just the same but they may vary by a point or so which makes detection of color very difficult. Hereby you have to go for a check of the red color ball for its corresponding RGB value. You may say this as a training phase.

aqVideo = videoinput('winvideo', 1, 'RGB24_640x480');
preview(aqVideo);

In the preview screen, place the ball close to the camera with decent focus such that the major part of the picture is covered by the ball.

aqImage = getsnapshot(aqVideo); // This will acquire the image/snapshot.

Once done calculate the RGB values of the pixel which appears the most.

Regards,

Devilwar
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top