Real-time Shape Identification

asked 2018-01-21 01:06:56 -0500

whiskeyz gravatar image

updated 2018-01-21 01:50:13 -0500

Dear all,

I'm embarking on a project which requires detection of landmarks through 2D logos (shapes).

I'm working on OpenCV 3.2.0 with Python and ROS.

For example, a wall may have such a blue-coloured shape on it (

I'd need to first detect the shape via a live video stream through a camera and report it as it is.

I have tried to train a HAAR-cascade for it but have gotten lots of false positives.

This is my method of training the cascade:
1) Get one positive picture of the desired object (as above).
2) Get 3000 negatives.
3) Use opencv_createsamples to create 3000 positive samples using the positive picture and negatives.
4) Use 1000 of the positive samples to create my .vec
5) Use 1000 negatives and the positive vector to train the cascade.
I usually only get 3 to 4 features per stage and at around stage 6 or 7 the false alarm rate would be reached - although I read that usually 30~60 features per stage and full completion is the norm.

Any suggestion on possible reasons for the above would be appreciated.

I'd like to also seek opinions on alternative methods to go about achieving my goal, i.e. are there other alternatives to HAAR for real-time shape recognition & tracking? I have tried OpenCV's template matching but it is scale/skew/rotation sensitive and hence limited in functionality.

Thank you very much.

edit retag flag offensive close merge delete


forget about training cascades for this, it likely won't work.

do you have to use those markers ? why not use aruco ones instead ?

berak gravatar imageberak ( 2018-01-21 02:21:26 -0500 )edit

@berak Thanks for the clarification that cascades would not work well. However I do have to use those markers as a prerequisite for my mission, which is part of the reason I am having trouble finding a good algorithm for it in Python.

whiskeyz gravatar imagewhiskeyz ( 2018-01-21 02:31:15 -0500 )edit

Will the markers have little deformation? If so, multi scale template matching could basically help you find the markers.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-01-21 09:15:31 -0500 )edit

@StevenPuttemans Yes and thank you - as I am streaming the input from video capture, a scale/skew invariant approach would definitely help. However, the simplicity of my markers seem to render feature based algorithms ineffective. Are there any particular approach you might suggest for a scale invariant template matching?

whiskeyz gravatar imagewhiskeyz ( 2018-01-21 09:45:21 -0500 )edit