Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active November 25, 2021 01:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kenwebb/a2fbbbff6710fa8e411b to your computer and use it in GitHub Desktop.
Save kenwebb/a2fbbbff6710fa8e411b to your computer and use it in GitHub Desktop.
Human Face Generator
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Fri Jan 27 2017 10:35:21 GMT-0500 (EST)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Human Face Generator
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: a2fbbbff6710fa8e411b
Keywords:
My Notes
--------
This workbook explores software that can generate human faces.
I'd like to be able to use it for faces in my Singing Competitions workbook, and elsewhere.
Ideally, the software will be written in JavaScript, or can be converted to JavaScript (Java, C/C++).
Ideally, it will generate SVG images at runtime.
I've spent a few hours searching for possible software.
Initially I'll try facesjs[3], written in JavaScript and able to generate SVG at runtime in a browser.
References
----------
(1) google "random faces SVG", "random face generation", "cartoon face generator"
(2) http://savannah.nongnu.org/projects/doodlehash
"This is doodlehash, a C library that makes random faces from a given item of text. Do you want to make an avatar from an email address? doodlehash is for you. Doodlehash uses specially annotated SVG files as input. Eyes, ears, nose, mouth, hair, etc are randomly chosen and coloured to make a unique face."
License: GNU Affero General Public License v3 or later
(3) http://dumbmatter.com/facesjs/
) https://github.com/dumbmatter/facesjs
"A JavaScript library for generating vector-based cartoon faces"
MIT License
"Faces are drawn as scalable vector graphics (SVG). Each face can also be represented by a small JavaScript object, which allows you to store that object and then draw the same face again later. As you can probably tell, the number of options for each facial feature (eyes, nose, mouth, etc.) is fairly limited, and some of the current options are fairly crude. So fork it on GitHub and add some new options!"
(4) http://www.morphases.com/
"Morphases is an online next generation software in face manipulation. It allows user to modify and create human faces from different elements in real time with almost an unlimited power. All elements are divided individually and stored into genebank."
has a Flash editor, images can't be saved, bitmap image based
(5) http://bl.ocks.org/enjalot/1282943
"Chernoff Smileys"
uses D3 library, generates SVG, D3 code is on the web page
(6) http://selfiecity.net/
a research project
(7) http://svgavatars.com/
"jQuery script for creating hi-res avatars on your site by your visitors"
commercial software ($17), SVG, JavaScript and PHP
the demo is impressive
(8) http://www.makehuman.org/
"MakeHuman is the free and open source software to create realistic 3d humans"
(9) http://www.neatorama.com/2011/07/05/chernoff-and-the-face-value-of-numbers/
"A smiley-face is very expressive, statistically. By tweaking the eyes, mouth and other bits, you can literally put a meaningful face on any jumble of numbers. Herman Chernoff pointed this out in 1973 in the Journal of the American Statistical Association, in a monograph called “The Use of Faces to Represent Points in K-Dimensional Space Graphically.” Most people, when shown some statistics, sigh and get boggled. But Herman Chernoff realized that almost everyone is good at reading faces. So he devised recipes to convert any set of statistics into an equivalent bunch of smiley-face drawings."
lists various face parameters
(10) http://people.cs.nctu.edu.tw/~whtsai/Conference_Papers_PDF/Chen_Tsai_CORCE_2005.pdf
"Automatic comic face generation from human face pictures" by Yen-Lin Chen and Wen-Hsiang Tsai
"A system for automatic generation of comic faces by face image analysis is proposed. A face model of 72 facial feature points is first proposed for personal comic face drawi8ng and modification."
generates SVG
(11) https://www.khanacademy.org/cs/random-face-generator/6612995667394560
JavaScript, generates a canvas image, uses ProcessingJS
"All code is owned by its respective author and made available under an MIT license."
(12) http://en.wikipedia.org/wiki/OpenCV
"OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision, developed by Intel Russia research center in Nizhny Novgorod, and now supported by Willow Garage and Itseez. It is free for use under the open source BSD license. The library is cross-platform. It focuses mainly on real-time image processing."
C/C++
(13) http://avachara.com/avatar/
a commercial avatar generator, with lots of face and body features; generates a bitmap
(14) https://www.udemy.com/blog/cartoon-making-software/
Cartoon Making Software: Top 13 Cartoon Making Software Programs, June 11, 2014 by Florence Ng
(15) http://en.wikipedia.org/wiki/Active_shape_model
"Active shape models (ASMs) are statistical models of the shape of objects which iteratively deform to fit to an example of the object in a new image, developed by Tim Cootes and Chris Taylor in 1995. The shapes are constrained by the PDM (point distribution model) Statistical Shape Model to vary only in ways seen in a training set of labelled examples. The shape of an object is represented by a set of points (controlled by the shape model). The ASM algorithm aims to match the model to a new image."
there's open source code in C/C++
(16) http://www.mrl.nyu.edu/~perlin/facedemo/
Java
(17) http://www.cs.cmu.edu/afs/cs/project/face/www/facs.htm
FACS - Facial Action Coding System (Ekman and Friesen 1978)
64 AUs (Action Units) with associated muscle names; photo of a human face for each AU
(18) http://face-and-emotion.com/dataface/facs/new_version.jsp
"The new (2002) Facial Action Coding System (FACS) by Paul Ekman, Wallace V. Friesen, and Joseph C. Hager"
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<Block/>
</_-.XholonClass>
<xholonClassDetails>
</xholonClassDetails>
<PhysicalSystem>
<Block/>
</PhysicalSystem>
<Blockbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, face, eyeId, numFaces, displaySvg, returnSvgStr, beh = {
postConfigure: function() {
me = this.cnode.parent();
face = [];
eyeId = [];
numFaces = 4;
displaySvg = true;
returnSvgStr = true;
$wnd.xh.param("TimeStepInterval", "200");
$wnd.xh.require("faces");
var rootEle = $doc.querySelector("#xhsvg");
var group = "";
for (var i = 0; i < numFaces; i++) {
group = group + '<div id="xhsvg' + i + '" style="height: 200px; width: 200px; display: inline-block;"></div>';
}
rootEle.innerHTML = group;
},
act: function() {
if ($wnd.faces) {
if (face.length == 0) {
this.generateFaces();
}
else {
this.animateFaces();
}
this.displayFaces();
}
},
generateFaces: function() {
for (var i = 0; i < numFaces; i++) {
var f = $wnd.faces.generate();
$wnd.console.log(f);
var iid = f.eyes[0].id;
if (iid == 0) { iid = 1;}
$wnd.console.log(iid);
face.push(f);
eyeId.push(iid);
}
},
animateFaces: function() {
for (var i = 0; i < numFaces; i++) {
if (face[i].eyes[0].id == 0) {
face[i].eyes[0].id = eyeId[i];
face[i].eyes[1].id = eyeId[i];
}
else if (Math.random() < 0.1) {
face[i].eyes[0].id = 0;
face[i].eyes[1].id = 0;
}
}
},
displayFaces: function() {
for (var i = 0; i < numFaces; i++) {
if (returnSvgStr) {
var svgStr = $wnd.faces.display("xhsvg" + i, face[i], displaySvg, returnSvgStr);
// allow this to work as part of XholonFountain options
// replace " with ' replace < with &lt;
svgStr = svgStr.replace(/"/g, "'").replace(/</g, "&lt;");
svgStr = "data:image/svg+xml," + svgStr;
$wnd.console.log(svgStr);
}
else {
$wnd.faces.display("xhsvg" + i, face[i], displaySvg, returnSvgStr);
}
}
returnSvgStr = false; // only return and log the svgStr strings once
}
}
//# sourceURL=Blockbehavior.js
]]></Blockbehavior>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment