Solved

delphi grachics, problem of the eye

Posted on 2010-11-30
19
387 Views
Last Modified: 2012-06-27
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.
 listofimagebyepasquier
The image that I'm testing;(it takes an 8click before it gets there, but position is still not correct.
 imagetest
A fix from the code will do, please.
0
Comment
Question by:systan
  • 12
  • 5
  • 2
19 Comments
 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
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

by:systan
Comment Utility
yes, I use the code of ThievingSix, but didn't fix it.
0
 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
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?
Will your input image always have only the eyes? What about your hair?
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

by:epasquier
Comment Utility
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

by:epasquier
epasquier earned 50 total points
Comment Utility
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

by:systan
Comment Utility
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

by:rfwoolf
Comment Utility
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

by:
rfwoolf earned 200 total points
Comment Utility
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;

Open in new window


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

by:systan
Comment Utility
>>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
 x
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 13

Expert Comment

by:rfwoolf
Comment Utility
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

by:systan
Comment Utility
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

by:systan
Comment Utility
>>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

by:systan
Comment Utility
>>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

by:systan
Comment Utility
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

by:systan
Comment Utility
Ok;
The procedure to get the eye is to get the face.!? right.
assuming_colored_faceAssuming that face is colored then invert it to a film scale
filmfaceThen 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

by:systan
Comment Utility
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

by:systan
Comment Utility
hey guys, where are you, are we finished here?
0
 
LVL 14

Author Comment

by:systan
Comment Utility
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

by:systan
Comment Utility
Thanks

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now