MATLAB Answers


Square object detection using webcam

Asked by mona
on 10 Feb 2013

Hello experts,

I have this code which works so perfect while detecting square objects from images which are downloaded from internet. However, when I am taking the image of a square object from my webcam and processing, its not turning out to be as expected. I am suspecting, the reason could be due to the green and pink hues which are dominantly captured from webcam. The actual output which is being obtained is that there are squares distributed at random places. What do you all suggest?


2 Answers

Answer by Image Analyst
on 10 Feb 2013

I suggest you upload an image: It's always easier to discuss image image processing advice if you have an image to see, don't you think?


I don't see any square objects in that image.

on 13 Feb 2013

I am sorry, I meant circular and not square. I am really sorry for this mistake.

You can edit your post to correct it. Have you tried imfindcircle()?

Answer by mona
on 13 Feb 2013

Yes, yes I did. I could send you the code through private message if you agree on thta.


  1. This should have been a comment, not an answer.
  2. Your main problem is poor lighting.
  3. Also, findcircle may not work on ellipses.
  4. You may also need to adjust some parameters in imfindcircle. I haven't experimented around with it a lot.
on 13 Feb 2013

I have actually tried everything with the code along with the parameters of imfindcircle and I am completely confident that everything is perfect. However, I would only agree with one of your point which is poor lighting.

I don't know why you don't agree with the other 3 points, but whatever...

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!