Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# delphi grachics, problem of the eye

Posted on 2010-11-30
Medium Priority
403 Views
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26642735.html
This code I follow, but problem, it can't point the right position, try it.

The image that I'm testing;(it takes an 8click before it gets there, but position is still not correct.

A fix from the code will do, please.
0
Question by:systan
• 12
• 5
• 2

LVL 13

Expert Comment

ID: 34240089
Systan... I have no idea what you are asking.
You asked how to draw a line between two colours
Now you are showing us eyes.
Do you want to draw a line between two eyes?
0

LVL 14

Author Comment

ID: 34240113
yes, I use the code of ThievingSix, but didn't fix it.
0

LVL 13

Expert Comment

ID: 34240201
As ThievingSix explained, his code is for connecting 2 exact colours in an image.
Two eyes are a different problem.

Will you always be using a black and white image?
Is it possible for a single eye to show up as 2x objects?

I had an algorithm that scans a black and white image from left to right and counts the number of black images in each COLUMN and then stores them in an array of SmallInt, so you might have something like this:
00000220000000022000000

Then another algorithm will go through this array and detect the eyes by looking for the columns with the highest values. So what if you had something like this
00000123200000002310000
it would connect3 to 3
but you could also tell it to ignore consecutive values etc.

So what would separate one eye from another eye?
Well if it sees more than 2x 0's between sections of noise.
but then if your scan looks like this it would fail:
0000023002200000000000230000
0

LVL 25

Expert Comment

ID: 34240235
for those who want to know where that comes from :

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26646496.html

Finding the eyes is going to be a much tougher problem, starting from the 2 top images

I'll think tomorrow about this. I have a question though, about how you get the original image (greyscale) from any color picture, say from a webcam ? Have you Delphi code for that, or do you use some image tools application (PaintShop, PhotoShop...) ?
0

LVL 25

Assisted Solution

epasquier earned 200 total points
ID: 34240294
rfwoolf, I think you are close to what I did to detect the head frame on the other question.
The 2 images I generated are something like your array, but with greater precision, and 2D. Both approach have the same goal : try to simplify the image information, reduce the noise impact, up to a point where we can devise an algorithm to detect objects within the image.

One will have to think about this question : What makes some pixels area being recognized as "The Eyes" ?
0

LVL 14

Author Comment

ID: 34240900
I base the gray-scale on this link;
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26646496.html#34239337
and this;
ShowImage.ZIP
edge.zip

Now, we don't have to develop from c to delphi of opencv, we have experts here, that can turn the turtle to fly, lol

Ok;
Listening...

Thanks
0

LVL 13

Expert Comment

ID: 34240973
We need to cover some other ground first...
What exactly are you trying to do here?
What is the project goal?
Can we assume that the person will always have their head in the correct frame of the screen?
How intelligent does the software have to be? For example, you could have a user who puts his head far away from the camera, where his eyes will be 1 pixel each. Then you could have a user that puts their head close to the camera, then his eyes are 9 pixels each (for example). We could have an algorithm that scans through the image looking for white objects with pixels < 9 and > 2 pixels. if it finds more than 2 objects it can then have some intelligence such as looking for the 2 objects with the most similar sizes, or the 2 objects closest to the centre of the frame, or it could take an average of the size of the objects and take the 2 objects that are closest to the average etc.
You could run some tests - count the number of white pixels per eye, relative to the dimensions of the head frame.
For example, if the user is close to the camera, his/her head will be 400x 400pixels (for example) and his eyes will be 9 pixels each.
If the user is further away, and the frame is 200 x 200 pixels and you see the eyes are 4 pixels each etc...

This may be something you will have to develop by yourself, but we can provide some of the functions to read the images, and you will have to build in the intelligence.
0

LVL 13

Accepted Solution

rfwoolf earned 800 total points
ID: 34241109
Here is some thinking out loud about how to do this...

To take a black and white image and build an array of every 'white' object (ArrayWhiteObjects), every object will be an array of pixel co-ordinates.
We would start scanning the black and white image from the top left corner, and when we encounter a white pixel, we start another procedure which:
1: adds a new 'white object' to the ArrayWhiteObjects
2: Change the pixel in the black and white image to black so that it doesn't get read again.
3: 'Bleed' out from the white pixel in all 8 directions detecting another white pixel - if one is found, goto "2"
4: Finished adding a new 'white' object.

Now that we have our 'array' of white objects, we can start to detect which white objects are eyes.

Then based on the research of "EyeSize" relative to "Head-Size" we can filter out objects that are too big or to small to be eyes. In this example we will say i the frame size is 400 x 400 pixels, then the eyes should be no bigger than 9 pixels and no smaller than 2 pixels...
BiggestEyeSize := 9;
SmallestEyeSize := 2;

Now we itereate through ArrayWhiteObjects and add any matching objects to yet another array:
``````var
ArrayPotentialEyes : array of tWhiteObjects;
For i := 0 to length(ArrayWhiteObjects) do
begin
if (length(ArrayWhiteObjects[i]) < BiggestEyeSize)) and (length(ArrayWhiteObjects[i]) > SmallestEyeSize)) then
begin
Setlength(ArrayPotentialEyes, Length(ArrayPotentialEyes) + 1);
High(ArrayPotentialEyes) := ArrayWhiteObjects[i];
end;
end;
``````

Now that we have our array of potential eyes, we try to pick out the 2 objects that are most likely to be the eyes...
0

LVL 14

Author Comment

ID: 34241315
>>What is the project goal?

First, this is not a project, this is just some test, studies as a student developer
The goal here is to get the eye value or position from x and y
because if we get the x position and y position, we can balance the frame if x1<>x2 or y1<>y2

0

LVL 13

Expert Comment

ID: 34241331
So have you found a way to automatically remove the hair and end up with only the eyes like you have in these shots?
In these shots the eyes are 4 pixels each, will they always be 4 pixels each?
0

LVL 14

Author Comment

ID: 34241342
http://mc-computing.com/languages/delphi/images.html
I refer to that link, but I can't do it alone, my bad

Ok, I hope you guys understand the goal of this post.

Thanks
0

LVL 14

Author Comment

ID: 34241396
>>So have you found a way to automatically remove the hair and end up with only the eyes like you have in these shots?
NO, I haven't found the way, I just jump on this area, because when I see epasquiers answer to my other post, I think a jump on this, because if we get this method, we can go back to the result of that 4 white pixels,  the important thing is we got it working on this procedure. (if really work)
0

LVL 14

Author Comment

ID: 34241413
>>In these shots the eyes are 4 pixels each, will they always be 4 pixels each?
I don't know, its epasquiers call to answer that, seems his the master mind of that image procedure of how it got there.
0

LVL 14

Author Comment

ID: 34241444
epasquier?
>>One will have to think about this question : What makes some pixels area being recognized as "The Eyes" ?
Ok, it is recognize because they are separated in a form of 4 pixels and they are in the center.

0

LVL 14

Author Comment

ID: 34245603
Ok;
The procedure to get the eye is to get the face.!? right.
Assuming that face is colored then invert it to a film scale
Then in a film scale picture, transform it into a black and white seen, from that we can see the eye is white with 4+pixels grouped.

It's hard to explain, but, I'll try another words to define it well.  I'm not an excellent English talker.
0

LVL 14

Author Comment

ID: 34245726
http://gidesa.altervista.org/camshiftdemo.php
Delphi Rocks!

But well build our own procedure here, with the participation of Ex-Ex Delphi Experts.
0

LVL 14

Author Comment

ID: 34258055
hey guys, where are you, are we finished here?
0

LVL 14

Author Comment

ID: 34259701
We need to cover some other ground first...
What exactly are you trying to do here?
What is the project goal?
Can we assume that the person will always have their head in the correct frame of the screen?
How intelligent does the software have to be? For example, you could have a user who puts his head far away from the camera, where his eyes will be 1 pixel each. Then you could have a user that puts their head close to the camera, then his eyes are 9 pixels each (for example). We could have an algorithm that scans through the image looking for white objects with pixels < 9 and > 2 pixels. if it finds more than 2 objects it can then have some intelligence such as looking for the 2 objects with the most similar sizes, or the 2 objects closest to the centre of the frame, or it could take an average of the size of the objects and take the 2 objects that are closest to the average etc.
You could run some tests - count the number of white pixels per eye, relative to the dimensions of the head frame.
For example, if the user is close to the camera, his/her head will be 400x 400pixels (for example) and his eyes will be 9 pixels each.
If the user is further away, and the frame is 200 x 200 pixels and you see the eyes are 4 pixels each etc...

This may be something you will have to develop by yourself, but we can provide some of the functions to read the images, and you will have to build in the intelligence.

Ok;
I've read it, I'll open another post for this continuation.
As I've research so far, we have to detect the white circle  in film scale.
0

LVL 14

Author Closing Comment

ID: 34259747
Thanks

I'm only concerned about 1 persons image in the picture.
So the white circle could be detected.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the inâ€¦
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usuaâ€¦
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. â€¦
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calculâ€¦
###### Suggested Courses
Course of the Month10 days, 21 hours left to enroll