Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
hello there. this question is simple and straight forward,does anyone know how to write code that generates a 3d photo realistic avatar from a 2d photograph(s) provided by the user(just like the concept in virtual relay,where such an avatar is generated from photographs provided by the user)?source code for this would be awesome.thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 1-Apr-12 14:41pm    
This is not a simple question. However, this is an excellent, very interesting question, so I voted 5 (I really rarely do that). Is it your own idea?

However, I would say, the answer cannot be easy. I have a couple of more or less obvious ideas, I'll share them as soon as I find appropriate references and some time to post the answer. You should not help for a ready to use source code. At best, you will need to find and use some known techniques, hopefully from available libraries, but for acceptable results, some research and development will be needed -- again, at best.

--SA
Maximilien 1-Apr-12 16:47pm    
look/google for "3d reconstruction from 2D images".

It's not an easy topic.
Sergey Alexandrovich Kryukov 2-Apr-12 19:28pm    
Of course not. I think we can only talk about 2D avatars. For 3D, there is no enough information.
Even in computer tomography, which is based on multiple images taken at many different angles, the problem is classified as ill-posed (in the sense of Tikhonov), please see:
http://en.wikipedia.org/wiki/Ill-posed_problem

--SA
Member 8547508 6-Apr-12 9:05am    
i see,but what about software like faceworx?and what about virtual relay?how do they work then?also EAsports have a feature tha enables you to create such an avatar to play with in FIFA 2012.how is the problem ill posed if working solutions already exist?i just wanted some more light shed on the subject,especially in terms of source code.thanks for taking time to read the question though.
Sergey Alexandrovich Kryukov 8-Apr-12 0:48am    
Never tried, but in what sense are they 3D? Anyway, it's possible to have some simple model of a typical human head or a body and slightly adjust it according to the photograph, but you cannot consider it as a realistic model. It could work for avatars. Just one of the ideas. The others are about 2D processing... but I guess you are not interesting in those...
--SA

1 solution

I already explained in my comments to the question that there is no enough information to build a 3D model, ill-posed problem like in tomography, etc. Even a human eye do not really reconstruct such mode. You would rather have a set of photographs at different angles. In 1999, I learned from some MetaCreation's people about their camera which used only two shorts, but one of them was made using specially structured lighting. Similar structured-lighting approach is used in some pseudo-3D detectors used to build a 3D profile of the Printed Circuit Board in electronic industry. Sorry I cannot give much more detail, but those approaches are very interesting and require very special hardware. This is an interesting article about building 3D models from photos:
http://www.pcworld.com/article/11311/build_3d_models_from_photos.html[^].

My little 2D ideas are rather trivial but seem realistic to me. First, I would recommend you to load and use Inkspace:
http://en.wikipedia.org/wiki/Inkscape[^],
http://inkscape.org/[^].

Please run it and play with it. It could be recommended as a primary tool for developing all kind of graphics for software, but not just for software. There are many different effects supplied with this wonderful vector editing tool, but I would like to bring your attention to two of them: [Main Menu] => Path => Trace Bitmap and [Main Menu] => Path => Simplify. These two effects can help to vectorize the photograph and morph it give it some cartoonish look. Note, that simplify actually enriches the image, "simplification" simply means the process reduces the number if curve's nodes, but it gives it more sophisticated look. You also can search for effects of "posterization" (elsewhere, please see http://en.wikipedia.org/wiki/Posterization[^]). As Inkscape is Open-Source software, you can locate the source code of the effects and learn how to implement them.

My other more advanced but more fuzzy idea is the generalization of posterization. In principle, it's possible to decompose an image into a set of areas characterized with some "dominating gradient". The gradient withing each area can be reconstructed by interpolation and added to the model. So, the final model of the image should present a set of areas bounded by Bezier curves with gradient fill in each of them. Some problem could be smooth stitching them on their boundaries. I feel that the most adequate approach would be… ignoring this problem. Depending on how decomposition into areas is done, this effect can create visible color boundaries between the areas, like in classical posterization. It could support cartoonish look of the image and look natural enough.

After all, the whole field of painting including portrait painting is about the play with human perception. In most graphical styles, a human head is depicting with the use of some strokes on the face, curved lines with some thickness. There are no such line in real life! Nevertheless, the artistic styles of drawing often show the lines; and human perception reconstructs 3D image of a human head from this non-existent-in-nature images.

—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Apr-12 2:08am    
By the way, sorry for a long delay in reply to comments to the question. I bookmarked this page to discuss things later and finally did it.
--SA
Member 8547508 23-Apr-12 3:47am    
thank you for the long analysis,but you're not getting my point. you should read the paper: "a morphable model for synthesis of 3d faces" by volker blanz and thomas vetter of the max planck institute. afterwards download the software called faceworx and play around with it. all you need are TWO pictures to generate the model.the 3D MODEL.seriuosly, just do it and see for yourself,do it as soon as you read this to see what i'm trying to tell you.thank you.
Sergey Alexandrovich Kryukov 23-Apr-12 11:34am    
I can believe that, in principle. Sorry I was not familiar with this work, thank you for pointing it out.
--SA
Sergey Alexandrovich Kryukov 23-Apr-12 12:12pm    
And -- any reference? This article is often quoted, but is it publicly available? If you have read this article, do you consider implementation of the model synthesis feasible following the approach of the authors?
--SA
Member 8547508 25-Apr-12 3:23am    
like i said, the article is available publicly,just google it and you'll find it online.afterwards, download the software faceworx(it's free) and use it. the software is based on the principles described in the paper.afterwards, you'll understand my question.i don't want to know whether or not it is possible to do since,as shown by the existence of the algorithms that have been proven to be feasible,it is, i wanted to know if anyone had generated any "independent" code on how to do it, with an accompanying explanation on how to go about it.yes, i do believe that their approach is feasible,their methods are needed in a much larger project and without any "original" code, the project is at a standstill.if you'll go through it and find it possible to help in doing this in any way then it would be appreciated.thank you.(i could email you the paper if you can't find it online.)

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