61 lines
No EOL
1.6 KiB
PHP
61 lines
No EOL
1.6 KiB
PHP
<?php
|
|
require __DIR__ . '/../bootstrap.php';
|
|
error_reporting(E_ALL);ini_set('display_errors', true);
|
|
|
|
$em = \EmotionHero\Application::getInstance()->getEm();
|
|
$hitRepo = $em->getRepository(\EmotionHero\Models\Hit::class);
|
|
|
|
$currentEmotion = 'anger';
|
|
|
|
$hits = $hitRepo->findBy([], ["emotions.$currentEmotion"=>'ASC']);
|
|
|
|
?>
|
|
<html>
|
|
<head>
|
|
<title>Emotion Hero</title>
|
|
</head>
|
|
<style type="text/css">
|
|
body{
|
|
background:yellow;
|
|
font-family:"Unifont";
|
|
font-weight:bold;
|
|
}
|
|
</style>
|
|
<body>
|
|
<?php
|
|
|
|
foreach(range(0, 100, 10) as $i) {
|
|
/* @var $hitRepo EmotionHero\Models\HitRepository */
|
|
$hitRepo = $em->getRepository(EmotionHero\Models\Hit::class);
|
|
$hit = $hitRepo->getClosestHit("anger", $i);
|
|
$img = $hit->getFeatureImgAsString("brows");
|
|
$score = $hit->getEmotions()->getEmotionScore("anger");
|
|
|
|
$percentage = sprintf("%.4f %%",$score);
|
|
echo <<< EOSNIPPET
|
|
<div class="block">
|
|
<span class="perc">$percentage</span>
|
|
<img src="data:image/x-icon;base64,$img" title='{$hit->getId()}'>
|
|
</div>
|
|
EOSNIPPET;
|
|
}
|
|
|
|
/* @var $hit EmotionHero\Models\Hit */
|
|
foreach($hits as $hit) {
|
|
$filename = __DIR__ . '/../files/hits/brows/'. $hit->getId() . '.jpg';
|
|
if(!file_exists($filename))
|
|
continue;
|
|
|
|
$img = file_get_contents($filename);
|
|
$data = base64_encode($img);
|
|
$percentage = sprintf("%.4f %%",$hit->getEmotions()->getEmotionScore($currentEmotion));
|
|
echo <<< EOSNIPPET
|
|
<div class="block">
|
|
<span class="perc">$percentage</span>
|
|
<img src="data:image/x-icon;base64,$data" title='{$hit->getId()}'>
|
|
</div>
|
|
EOSNIPPET;
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|