Various fixes and face outputs
This commit is contained in:
parent
1edc207e3c
commit
06b541ca1e
5 changed files with 502 additions and 1 deletions
|
@ -197,6 +197,18 @@ class Game
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value of originalGameAt.
|
||||
*
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getOriginalGameAt()
|
||||
{
|
||||
return $this->originalGameAt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ class Hit
|
|||
* @return string|null
|
||||
*/
|
||||
public function getFeatureImgAsString($feature) {
|
||||
$filename = $this->getFeatureFilename($feature);
|
||||
$filename = $this->getFeatureDirname($feature) .'/'.$this->getId().'.jpg';
|
||||
if(!file_exists($filename)) {
|
||||
return null;
|
||||
}
|
||||
|
|
BIN
www/brow_explain.png
Normal file
BIN
www/brow_explain.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
147
www/faces2.php
Normal file
147
www/faces2.php
Normal file
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', true);
|
||||
|
||||
$em = \EmotionHero\Application::getInstance()->getEm();
|
||||
/* @var $hitRepo EmotionHero\Models\HitRepository */
|
||||
$hitRepo = $em->getRepository(\EmotionHero\Models\Hit::class);
|
||||
|
||||
/* @var $currentHit \EmotionHero\Models\Hit */
|
||||
$currentHit = $hitRepo->findOneBy(['hasImage'=>true], ['id'=>'DESC']);
|
||||
|
||||
|
||||
$printEmoBlocks = function($emotion, $feature, $steps = 6) use($em) {
|
||||
$hits = $em->getRepository(EmotionHero\Models\Hit::class)->findBy(['hasImage'=>true],["emotions.$emotion" => 'ASC']);
|
||||
foreach($hits as $hit) {
|
||||
/* @var $hit EmotionHero\Models\Hit */
|
||||
$img = $hit->getFeatureImgAsString($feature);
|
||||
$score = $hit->getEmotions()->getEmotionScore($emotion);
|
||||
|
||||
$percentage = sprintf("%.7f %%",$score);
|
||||
echo <<< EOSNIPPET
|
||||
<div class="block">
|
||||
<img src="data:image/x-icon;base64,$img" title="{$hit->getId()}">
|
||||
|
||||
<span class="perc">$percentage</span>
|
||||
</div>
|
||||
EOSNIPPET;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Emotion Hero</title>
|
||||
</head>
|
||||
<style type="text/css">
|
||||
|
||||
body{
|
||||
background:black;
|
||||
font-family:"Unifont";
|
||||
font-weight:bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.block{
|
||||
/*width:14%;*/
|
||||
background: yellow;
|
||||
margin-bottom: 8%;
|
||||
}
|
||||
img{
|
||||
width:100%;
|
||||
filter:sepia(100%);
|
||||
/*mix-blend-mode: multiply;
|
||||
mix-blend-mode: exclusion;*/
|
||||
}
|
||||
|
||||
.nose .block{
|
||||
width:70px;
|
||||
}
|
||||
.perc{
|
||||
display:block;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
background: blue;
|
||||
color: white;
|
||||
font-size:67%;
|
||||
}
|
||||
|
||||
.emo-block{
|
||||
width:14%;
|
||||
float:left;
|
||||
margin-right:0.28%;
|
||||
text-align:center;
|
||||
|
||||
|
||||
}
|
||||
.emo-block-emos{
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.emo{
|
||||
text-align:center;
|
||||
float:left;
|
||||
|
||||
}
|
||||
.brows{
|
||||
width:100%;
|
||||
}
|
||||
.nose{
|
||||
width:240px;
|
||||
}
|
||||
|
||||
.current{
|
||||
/*width:200px;*/
|
||||
margin:0 auto;
|
||||
text-align:center;
|
||||
}
|
||||
.current img{
|
||||
width:200px;
|
||||
}
|
||||
dd, dt{
|
||||
float:left;width:80px;
|
||||
text-align:left;
|
||||
}
|
||||
img.curImg{
|
||||
position:absolute;
|
||||
left:0;
|
||||
/*mix-blend-mode:difference;*/
|
||||
}
|
||||
|
||||
svg{
|
||||
width:300px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.emo-name{
|
||||
position:fixed;
|
||||
background:#ffff00;
|
||||
z-index:9999;
|
||||
}
|
||||
h3 span{
|
||||
padding:0.2%;
|
||||
color:black;
|
||||
background:yellow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
echo "<div class='brows emo'><h3><span>eye brows</span></h3>";
|
||||
|
||||
|
||||
foreach(EmotionHero\Models\Emotions::$EMOTIONS as $emotion) {
|
||||
echo "<div class='emo-block'><div class='emo-name'>$emotion</div><div class='emo-block-emos'>";
|
||||
$printEmoBlocks($emotion, 'brows');
|
||||
echo "<img class='curImg' src=\"data:image/x-icon;base64,{$currentHit->getFeatureImgAsString("brows")}\" title=\"{$currentHit->getId()}\" style=\"top:{$currentHit->getEmotions()->getEmotionScore($emotion)}%\">";
|
||||
echo "</div></div>";
|
||||
}
|
||||
echo"</div>";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
342
www/faces3.php
Normal file
342
www/faces3.php
Normal file
|
@ -0,0 +1,342 @@
|
|||
<?php
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
error_reporting(E_ALL);ini_set('display_errors', true);
|
||||
|
||||
$em = \EmotionHero\Application::getInstance()->getEm();
|
||||
/* @var $hitRepo EmotionHero\Models\HitRepository */
|
||||
$hitRepo = $em->getRepository(\EmotionHero\Models\Hit::class);
|
||||
|
||||
/* @var $currentHit \EmotionHero\Models\Hit */
|
||||
$currentHit = $hitRepo->findOneBy(['hasImage'=>true], ['id'=>'DESC']);
|
||||
$betterHit = $hitRepo->getBetterHit($currentHit);
|
||||
|
||||
$printEmoBlocks = function($emotion, $feature, $steps = 6) use($em) {
|
||||
foreach(range(0, 100, 100/($steps-1)) as $i) {
|
||||
/* @var $hitRepo EmotionHero\Models\HitRepository */
|
||||
$hitRepo = $em->getRepository(EmotionHero\Models\Hit::class);
|
||||
if($feature == 'nose'){
|
||||
$items = [992, 1035, 701, 888, 671, 906, 693, 725, 762, 666, 751,992,728];
|
||||
$hit = $hitRepo->find($items[array_rand($items)]);
|
||||
} elseif($feature == 'mouth_left') {
|
||||
$items = [992, 1035, 1034, 888];
|
||||
$hit = $hitRepo->find($items[array_rand($items)]);
|
||||
} else{
|
||||
$hit = $hitRepo->getClosestHitWithImage($emotion, $i);
|
||||
}
|
||||
$img = $hit->getFeatureImgAsString($feature);
|
||||
$score = $hit->getEmotions()->getEmotionScore($emotion);
|
||||
|
||||
$percentage = sprintf("%.0f %%",$score);
|
||||
echo <<< EOSNIPPET
|
||||
<div class="block">
|
||||
<img src="data:image/x-icon;base64,$img" title="{$hit->getId()}">
|
||||
|
||||
<span class="perc">$percentage</span>
|
||||
</div>
|
||||
EOSNIPPET;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Emotion Hero</title>
|
||||
</head>
|
||||
<style type="text/css">
|
||||
body{
|
||||
background:#999;
|
||||
font-family:"Unifont";
|
||||
font-weight:bold;
|
||||
font-size:1vw;
|
||||
margin:0.5em;
|
||||
}
|
||||
h3{
|
||||
margin:0.5%;
|
||||
text-align:center;
|
||||
}
|
||||
h3 span{
|
||||
background:black;
|
||||
color:white;
|
||||
padding:0.2%;
|
||||
}
|
||||
|
||||
.block{
|
||||
width:100%;
|
||||
font-size:80%;
|
||||
}
|
||||
.mouth .emo-block{
|
||||
width:50%;
|
||||
float:left;
|
||||
}
|
||||
.mouth .emotitle{
|
||||
display:block;
|
||||
width:14%;
|
||||
margin-right:0.14%;
|
||||
margin-left:0.14%;
|
||||
float:left;
|
||||
font-size:80%;
|
||||
padding-top:2.5%
|
||||
}
|
||||
.mouth .block {
|
||||
width:14%;
|
||||
margin-right:0.14%;
|
||||
margin-left:0.14%;
|
||||
float:left;
|
||||
}
|
||||
|
||||
/*.emotitle span:before{content:"‹";}
|
||||
.emotitle span:after{content:"›";}*/
|
||||
.emotitle{font-style:italic;}
|
||||
.emotitle:before{content:"«";}
|
||||
.emotitle:after{content:"»";}
|
||||
|
||||
img{
|
||||
width:100%;
|
||||
filter:saturate(0%);
|
||||
mix-blend-mode: multiply;
|
||||
/*mix-blend-mode: exclusion;*/
|
||||
}
|
||||
|
||||
.perc{
|
||||
display:block;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.emo-block{
|
||||
float:left;
|
||||
text-align:center;
|
||||
}
|
||||
.brows .emo-block {
|
||||
width:23%;
|
||||
margin-left:1%;
|
||||
margin-right:1%;
|
||||
}
|
||||
|
||||
.nose .emo-block {
|
||||
width:12%;
|
||||
margin-left:1.14%;
|
||||
margin-right:1.14%;
|
||||
}
|
||||
.nose .emotitle{
|
||||
font-size:80%;
|
||||
}
|
||||
.emo-block-emos{
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.emo{
|
||||
text-align:center;
|
||||
float:left;
|
||||
background:#fff;
|
||||
}
|
||||
.brows{
|
||||
width:40%;
|
||||
margin-right:1%;
|
||||
}
|
||||
.nose{
|
||||
width:40%;
|
||||
margin-right:1%;
|
||||
}
|
||||
.mouth{
|
||||
width:81%;
|
||||
margin-top:1%;
|
||||
}
|
||||
img.curImg{
|
||||
position:absolute;
|
||||
left:0;
|
||||
mix-blend-mode:difference;
|
||||
}
|
||||
|
||||
svg{
|
||||
margin-top:1%;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.nose .block{position:relative;margin-bottom:2%;}
|
||||
.nose .block span{position:absolute;top:0;right:0;color:white;text-align:right;padding:0.5%;}
|
||||
.brow_explainer{
|
||||
}
|
||||
.brow_explainer {
|
||||
margin-top:3%;font-size:85%;
|
||||
}
|
||||
.brow_explainer img{filter:unset;margin-bottom:5%;}
|
||||
.brow_explainer ol{
|
||||
margin:0;padding:0;
|
||||
counter-reset:li 4;
|
||||
|
||||
}
|
||||
.brow_explainer li{
|
||||
text-align:left;
|
||||
margin-bottom:5%;
|
||||
list-style:none;
|
||||
}
|
||||
.brow_explainer li:before{
|
||||
content:counter(li) ". "; /* Use the counter as content */
|
||||
counter-increment:li; /* Increment the counter by 1 */
|
||||
color:red;
|
||||
}
|
||||
|
||||
.currentHit{
|
||||
width:17%;
|
||||
position:absolute;
|
||||
right:0.5em;
|
||||
top:0.5em;
|
||||
background:yellow;
|
||||
padding:0.5%;
|
||||
}
|
||||
.currentHit h3 span{
|
||||
color:yellow;
|
||||
}
|
||||
|
||||
ul{
|
||||
font-size:80%;
|
||||
list-style:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.currentHit li{
|
||||
clear:both;
|
||||
}
|
||||
.currentHit li .value{
|
||||
float:right;
|
||||
}
|
||||
.currentHit li .diff{
|
||||
float:right;
|
||||
clear:both;
|
||||
font-size:72%;
|
||||
color:gray;
|
||||
}
|
||||
.currentHit li .diff.negative{
|
||||
color:red;
|
||||
}
|
||||
|
||||
.currentHit li .diff.positive{
|
||||
color:green;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
echo "<div class='brows emo'><h3><span>eye brows</span></h3>";
|
||||
|
||||
|
||||
foreach(EmotionHero\Models\Emotions::$EMOTIONS as $emotion) {
|
||||
echo "<div class='emo-block'><span class='emotitle'>$emotion</span><div class='emo-block-emos'>";
|
||||
$printEmoBlocks($emotion, 'brows');
|
||||
//echo "<img class='curImg' src=\"data:image/x-icon;base64,{$currentHit->getFeatureImgAsString("brows")}\" title=\"{$currentHit->getId()}\" style=\"top:{$currentHit->getEmotions()->getEmotionScore($emotion)}%\">";
|
||||
echo "</div></div>";
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="emo-block brow_explainer">
|
||||
<img src="brow_explain.png">
|
||||
<ol start="5">
|
||||
<li>Outer Right Brow Corner</li>
|
||||
<li>Right Brow Center</li>
|
||||
<li>Inner Right Brow Corner</li>
|
||||
<li>Inner Left Brow Corner</li>
|
||||
<li>Left Brow Center</li>
|
||||
<li>Outer Left Brow Corner</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
echo "</div>"; // .brows
|
||||
|
||||
echo "<div class='nose emo'><h3><span>nose</span></h3>";
|
||||
foreach(EmotionHero\Models\Emotions::$EMOTIONS as $emotion) {
|
||||
echo "<div class='emo-block'><span class='emotitle'>$emotion</span><div class='emo-block-emos'>";
|
||||
$printEmoBlocks($emotion, 'nose');
|
||||
//echo "<img class='curImg' src=\"data:image/x-icon;base64,{$currentHit->getFeatureImgAsString("nose")}\" title=\"{$currentHit->getId()}\" style=\"top:{$currentHit->getEmotions()->getEmotionScore($emotion)}%\">";
|
||||
echo "</div></div>";
|
||||
}
|
||||
|
||||
echo "</div>"; // .nose
|
||||
|
||||
|
||||
echo "<div class='mouth emo'><h3><span>mouth</span></h3>";
|
||||
foreach(EmotionHero\Models\Emotions::$EMOTIONS as $emotion) {
|
||||
echo "<div class='emo-block'><span class='emotitle'>$emotion</span><div class='emo-block-emos'>";
|
||||
$printEmoBlocks($emotion, 'mouth_left');
|
||||
echo "</div></div>";
|
||||
}
|
||||
|
||||
echo "</div>"; // .mouth
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<div class='currentHit'>";
|
||||
echo "<h3><span>last</span><span>vs</span><span>perfect</span></h3>";
|
||||
echo "<p>{$currentHit->getGame()->getOriginalGameAt()}</p>";
|
||||
echo "<p>aim: {$currentHit->getTarget()->getScore()}% ".$currentHit->getTarget()->getEmotion()->getName()."</p>";
|
||||
echo "<ul>";
|
||||
$expressions = array_keys($currentHit->getExpressions()::$EXPRESSIONS_2ND_PERSON);
|
||||
sort($expressions);
|
||||
foreach($expressions as $expression) {
|
||||
$currentScore = $currentHit->getExpressions()->getExpressionScore($expression);
|
||||
$betterScore = $betterHit->getExpressions()->getExpressionScore($expression);
|
||||
$diff = $betterScore - $currentScore;
|
||||
if($diff > 0) {
|
||||
$diffclass = "positive";
|
||||
}elseif($diff < 0) {
|
||||
$diffclass = "negative";
|
||||
}
|
||||
echo "<li>";
|
||||
echo "<span class='name'>$expression</span>";
|
||||
echo "<span class='value'>". sprintf("%.5f", $currentScore)." %</span>";
|
||||
echo "<span class='diff $diffclass'>". sprintf("%+.5f", $diff)." %</span>";
|
||||
echo "</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
$circles = "";
|
||||
foreach($betterHit->getPoints()->getNormalisedPoints() as $i => $point) {
|
||||
/* $circles .= '<circle
|
||||
style="fill:gray;"
|
||||
id="point'.$i.'"
|
||||
cx="'.$point->getX().'"
|
||||
cy="'.$point->getY().'"
|
||||
r="0.7" />';*/
|
||||
$circles .= '<text
|
||||
style="fill:green;font-size:4"
|
||||
id="point'.$i.'"
|
||||
x="'.$point->getX().'"
|
||||
y="'.$point->getY().'"
|
||||
r="0.7">'.$i.'</text>';
|
||||
}
|
||||
|
||||
foreach($currentHit->getPoints()->getNormalisedPoints() as $i => $point) {
|
||||
$circles .= '<text
|
||||
style="fill:red;font-size:4"
|
||||
id="point'.$i.'"
|
||||
x="'.$point->getX().'"
|
||||
y="'.$point->getY().'"
|
||||
r="0.7">'.$i.'</text>';
|
||||
}
|
||||
|
||||
|
||||
echo <<< EOSVG
|
||||
<svg
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="-4 -4 108 108"
|
||||
id="svg2"
|
||||
version="1.1">
|
||||
<g id="layer1">
|
||||
$circles
|
||||
</g>
|
||||
</svg>
|
||||
EOSVG;
|
||||
|
||||
|
||||
|
||||
|
||||
echo "</div>"; // .currentHit
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue