Click here to Skip to main content
16,017,922 members
Please Sign up or sign in to vote.
3.20/5 (3 votes)
See more:
Really hoping you can help me, I'm really stuck.

I've been a C# business apps developer for 10 years, I thought I'd have a go at some image detection as it's something that really interests me.

Basic outline of my project it to measure an object from a photo. I have an A4 sheet of paper on the floor, on which I'll put a foot, hand, a pen - apple.. whatever... and the app will measure it.

So, I've tried the following filters in order so far..

1) Grayscaled image,
2) CannyEdgeDetector filter,
3) Added Binary Filter

I then...

Process the Blobs in the image,
Draw rectangles around the blobs and store the rectangle dimensions in an array.

Image Here : Clicky[^]

(That's my foot)

I try to detect the sheet of paper (I know the dimensions are 210mm x 294mm So I do some simple maths to work out the scale.

I then try and find the object rectangle and return the size of it in millimetres (Using the A4 as a point of reference)

My question is this:

1) Am I using the correct filters - is there a better set of filters I can use to make the image easier to detect shapes on?
2) Am I using the correct method? Is there another class/set of procedures I should be exploring?
3) Should I give up?

Thanks,
Lee
Posted
Comments
Sergey Alexandrovich Kryukov 9-Sep-13 14:07pm    
The questions make little to no sense unless you well describe the purpose of your recognition. There is no such thing as recognition in general. What is "object rectangle"? Of which object, exactly?
Look at the concept of "convex hull". Is that what you need. By the way, in your case block recognition should be very easy, but you did not try blob recognition.
Do you show processed image or original one?
—SA
CodusIT 9-Sep-13 15:29pm    
The objective of the application is to measure the size of the object using an A4 sheet of paper as a point of reference. (I thought I'd made that clear, apologies if not)

The picture attached is the image of my foot on the paper once I have applied filters and detected the objects in it (I have the application draw rectangles around each, using the size of the rectangles to get a reference to the size.

I will look into block recognition, thank you.

Convex hull doesn't work (well I couldn't get it to work) as the different conditions photos are taken in cause the filters to vary quite considerably. I find that using convex hull can work in one image but not another.. Saying that though if I can get some advice on the best way to apply filters to give the best block image.. That would help.

1 solution

Your problem is not just image filtering but also transforming the coordinates of expected space to real space. You say you have a piece of paper that measures 210mm x 294mm, however the image captured is not for multiple reasons.

First, it is in pixels. You will need to determine what a pixel to a mm is. This of course depends on the distance of the camera from the object. If you need this to be dynamic, it gets even more complicated. For the sake of simplicity lets say you place the camera and the piece of paper at a fixed location. This allows you to say 1 pixel equals XXmm.

This is however only optimally true. The truth is the lens is for all purposes a "point" while the paper is a plane. Meaning that some areas have 1 pixel to XXmm, but as you observe further from those locations the error and distortion will grow.

This "error" must be determined and then applied to the other object. It comes from the fact that each point on the plane is a different distance from the camera involving all 3 coordinates X,Y, and Z (keep in mind the lens may have the slightest tilt in relation to the surface). In order to calculate this error you must find known areas on the piece of paper. For example you know the corners are right angles. You could use those to calculate the distortion of the paper. However, as move away from those points the distortion would grow. This means the more points the better.
For example, say instead you used graphing paper. Now your image has captured a sheet that should have numerous squares all over. Since you know these squares are exactly 1cm (or whatever) and have perfect angles you could calculate the distortion more accurately through out the plane.

Once you have the real values you can use them with the expected values to calculate the objects dimensions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900