Merge branch 'master' of rubenvandeven.com:~/git/crowdcamera
This commit is contained in:
commit
b6ab33ab97
5 changed files with 86 additions and 40 deletions
53
graphs.php
53
graphs.php
|
@ -7,7 +7,7 @@
|
|||
|
||||
var d1 = <?php echo require "output/talk1.json" ?>;
|
||||
var d2 = <?php echo require "output/talk2.json" ?>;
|
||||
var d3 = <?php echo require "output/talk3.json" ?>;
|
||||
//~ var d3 = <?php echo require "output/talk3.json" ?>;
|
||||
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
@ -22,10 +22,10 @@ var d3 = <?php echo require "output/talk3.json" ?>;
|
|||
overflow-x:auto;
|
||||
}
|
||||
#presentations{
|
||||
width:300%;
|
||||
width:200%;
|
||||
}
|
||||
#presentations .presentation{
|
||||
width:33%;
|
||||
width:50%;
|
||||
float:left;
|
||||
}
|
||||
#presentations .presentation div.plot{
|
||||
|
@ -59,8 +59,15 @@ var d3 = <?php echo require "output/talk3.json" ?>;
|
|||
|
||||
}
|
||||
|
||||
#imgwrap div{
|
||||
display:block;
|
||||
color:#999;
|
||||
font-size:80%;
|
||||
}
|
||||
#imgwrap img{
|
||||
width:90%;
|
||||
height:7em;
|
||||
min-width: 3em;
|
||||
background:#ccc;
|
||||
margin-left:2%;
|
||||
margin-top:1em;
|
||||
}
|
||||
|
@ -78,29 +85,31 @@ var d3 = <?php echo require "output/talk3.json" ?>;
|
|||
|
||||
<div id="scroller">
|
||||
<div id='presentations'>
|
||||
<div class='presentation'>
|
||||
<h1>Orit Halpern</h1>
|
||||
<div class='stats' id='plot1-stats'></div>
|
||||
<div class='plot' id="plot1-div"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='presentation'>
|
||||
<h1>Penousal Machado</h1>
|
||||
<div class='stats' id='plot2-stats'></div>
|
||||
<div class='plot' id="plot2-div"></div>
|
||||
</div>
|
||||
|
||||
<div class='presentation'>
|
||||
<h1>Orit Halpern</h1>
|
||||
<div class='stats' id='plot1-stats'></div>
|
||||
<div class='plot' id="plot1-div"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
<div class='presentation'>
|
||||
<h1>Nicolas Maigret</h1>
|
||||
<div class='stats' id='plot3-stats'></div>
|
||||
<div class='plot' id="plot3-div"></div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id='imgwrap'>
|
||||
<img src="" id="hoverimg">
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
|
@ -251,19 +260,19 @@ for(var i in facialParameters){
|
|||
labelEl.title = "Expressiveness: " + d1ParamExpressiveness[param] + ", " + d2ParamExpressiveness[param] + ", " + d3ParamExpressiveness[param];
|
||||
}
|
||||
|
||||
var imgEl = document.getElementById("hoverimg");
|
||||
var imgwrapEl = document.getElementById("imgwrap");
|
||||
var plot1Div = document.getElementById('plot1-div');
|
||||
var plot2Div = document.getElementById('plot2-div');
|
||||
var plot3Div = document.getElementById('plot3-div');
|
||||
// var plot3Div = document.getElementById('plot3-div');
|
||||
var stats1Div = document.getElementById('plot1-stats');
|
||||
var stats2Div = document.getElementById('plot2-stats');
|
||||
var stats3Div = document.getElementById('plot3-stats');
|
||||
// var stats3Div = document.getElementById('plot3-stats');
|
||||
|
||||
function drawGraphs(){
|
||||
params = getCheckedParams();
|
||||
drawGraph("talk1", plot1Div, d1, params, stats1Div);
|
||||
drawGraph("talk2", plot2Div, d2, params, stats2Div);
|
||||
drawGraph("talk3", plot3Div, d3, params, stats3Div);
|
||||
//~ drawGraph("talk3", plot3Div, d3, params);
|
||||
}
|
||||
|
||||
|
||||
|
@ -470,12 +479,20 @@ function drawGraph(id, targetEl, d, params, statsEl) {
|
|||
//~ });
|
||||
|
||||
targetEl.on('plotly_hover', function (data){
|
||||
let HTML = "";
|
||||
var points = data.points[0],
|
||||
pointNum = points.pointNumber;
|
||||
console.log(pointNum, d['windows'][pointNum]['startFrame'], data);
|
||||
imgEl.src = "/images.php?i="+d['windows'][pointNum]['startFrame']+"¶ms="+params.join() + "&nr=" + d['outputNr'] ;
|
||||
console.log(d);
|
||||
for(let i in d['windows'][pointNum]['frames']) {
|
||||
console.log(pointNum, d['windows'][pointNum]['frames'][i], data);
|
||||
//~ imgEl.src = "/images.php?i="+d['windows'][pointNum]['frames'][i]+"¶ms="+params.join() + "&nr=" + d['outputNr'] ;
|
||||
HTML+= "<div>"+d['windows'][pointNum]['frames'][i]+"<img src=\"/images.php?i="+d['windows'][pointNum]['frames'][i]+"¶ms="+params.join() + "&nr=" + d['outputNr'] +"\"></div>" ;
|
||||
}
|
||||
imgwrapEl.innerHTML = HTML;
|
||||
|
||||
var audio = new Audio('output/'+d['outputNr']+'/'+d['windows'][pointNum]['startFrame']+'.wav');
|
||||
audio.play();
|
||||
|
||||
//~ Plotly.Fx.hover('plot-div',[
|
||||
//~ { curveNumber:0, pointNumber:pointNum },
|
||||
//~ { curveNumber:1, pointNumber:pointNum },
|
||||
|
|
20
images.php
20
images.php
|
@ -61,21 +61,28 @@ usort($json['faces'], function ($f1, $f2) {
|
|||
return $f1['diff'] > $f2['diff'] ? -1 : 1;
|
||||
});
|
||||
|
||||
$targetIm = imagecreatetruecolor(1920, 1080);
|
||||
$i = 0;
|
||||
$faceDim = 120;
|
||||
$faceMargin = 20;
|
||||
$faceCount = count($json['faces']);
|
||||
$widthNr = max(1, $faceCount);
|
||||
$targetIm = imagecreatetruecolor(($faceDim+$faceMargin)* $widthNr, $faceDim + 20);
|
||||
$white = imagecolorallocate($targetIm, 255, 255, 255);
|
||||
imagefill($targetIm, 0, 0, $white);
|
||||
|
||||
$i = 0;
|
||||
$faceDim = 120;
|
||||
$faceMargin = 20;
|
||||
$itemsPerRow = (int) 1080 / ($faceDim + $faceMargin);
|
||||
//~ $itemsPerRow = (int) 1080 / ($faceDim + $faceMargin);
|
||||
$maxDiff = sqrt(count($params) * 100);
|
||||
foreach($json['faces'] as $face) {
|
||||
$posX = $i % $itemsPerRow;
|
||||
$posY = (int) ($i / $itemsPerRow);
|
||||
|
||||
$destX = $posX * ($faceDim + $faceMargin);
|
||||
$destY = $posY * ($faceDim + $faceMargin);
|
||||
//~ $posY = (int) ($i / $itemsPerRow);
|
||||
//~
|
||||
//~ $destX = $posX * ($faceDim + $faceMargin);
|
||||
//~ $destY = $posY * ($faceDim + $faceMargin);
|
||||
$destX = $i * ($faceDim + $faceMargin);
|
||||
$destY = 0;
|
||||
|
||||
imagecopyresampled ( $targetIm , $im , $destX , $destY , (int) $face['rect']['x'] , (int) $face['rect']['y'] , $faceDim , $faceDim , (int) $face['rect']['w'], (int) $face['rect']['h']);
|
||||
|
||||
|
@ -85,7 +92,6 @@ foreach($json['faces'] as $face) {
|
|||
imagettftext($targetIm, 12, 0, $destX, $destY + $faceDim + $faceMargin/1.2, $colorBg, "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", round($face['diff'],2));
|
||||
$i++;
|
||||
}
|
||||
|
||||
$im = $targetIm;
|
||||
|
||||
/*
|
||||
|
|
|
@ -245,6 +245,18 @@ int main(int argsc, char ** argsv)
|
|||
|
||||
int frameNrIn = 1;
|
||||
int frameNrOut = 1;
|
||||
// increase number to current pos:
|
||||
while(true) {
|
||||
char buff[100];
|
||||
snprintf(buff, sizeof(buff), (use_segments ? "segment%06d.json" : "frame%06d.json"), frameNrIn);
|
||||
boost::filesystem::path jsonPath = outPath / buff;
|
||||
if ( boost::filesystem::exists( jsonPath.native() )) {
|
||||
frameNrIn++;
|
||||
frameNrOut++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::time_t lastImgUpdate(0);
|
||||
int seconds = 1;
|
||||
while(true){ //(cv::waitKey(20) != -1);
|
||||
|
|
|
@ -217,6 +217,9 @@ class Window:
|
|||
return np.std(vectors)
|
||||
|
||||
def getAverageV(self, params):
|
||||
# when no faces, return faux vector
|
||||
if len(self.getFaces()) < 1:
|
||||
return [0.0 for p in params]
|
||||
vectors = [f.getCharacteristicVector(params) for f in self.getFaces()]
|
||||
vAvg = np.mean(vectors, axis=0)
|
||||
return vAvg
|
||||
|
@ -458,12 +461,13 @@ def getGraphData(frames, params, window_size, outputNr):
|
|||
"""
|
||||
collection = WindowCollection(window_size, frames)
|
||||
windows = collection.windows
|
||||
jsonOutput = {'windows':[], 'outputNr': outputNr}
|
||||
jsonOutput = {'windows':[], 'outputNr': outputNr, 'window_size': window_size}
|
||||
for window in windows:
|
||||
w = {
|
||||
'start': window.getStartTime().strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'end': window.getEndTime().strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'startFrame': window.frames[0].name,
|
||||
'frames': [frame.name for frame in window.frames],
|
||||
'params': {},
|
||||
'param_values': {},
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ nextOutNr = segmentCount
|
|||
while True:
|
||||
nextJpg = os.path.join(args.frameOutput, "frame%06d.jpg" % nextInNr)
|
||||
nextInJson = os.path.join(args.frameOutput, "frame%06d.json" % nextInNr)
|
||||
while os.path.exists(nextJpg) and not os.path.exists(nextInJson):
|
||||
while os.path.exists(nextJpg):
|
||||
if not os.path.exists(nextInJson):
|
||||
print("(SPLIT) Found: {}".format(nextJpg))
|
||||
img = Image.open(nextJpg)
|
||||
|
||||
|
@ -46,11 +47,14 @@ while True:
|
|||
segmentFilename = os.path.join(args.segmentDir, "segment%06d.jpg" % segmentNr)
|
||||
segmentImg.save(segmentFilename, quality=90)
|
||||
print("(SPLIT) Created: {}".format(segmentFilename))
|
||||
else:
|
||||
print("(SPLIT) Skip: {}".format(nextJpg))
|
||||
|
||||
nextInNr += 1
|
||||
nextJpg = os.path.join(args.frameOutput, "frame%06d.jpg" % nextInNr)
|
||||
nextInJson = os.path.join(args.frameOutput, "frame%06d.jpg" % nextInNr)
|
||||
nextInJson = os.path.join(args.frameOutput, "frame%06d.json" % nextInNr)
|
||||
|
||||
continue
|
||||
nextJson = os.path.join(args.segmentDir, "segment%06d.json" % nextOutNr)
|
||||
while os.path.exists(nextJson):
|
||||
print("(MERGE) Found: {}".format(nextJson))
|
||||
|
@ -88,8 +92,11 @@ while True:
|
|||
print("(MERGE) Wrote: {}".format(jsonOutFilename))
|
||||
print("(MERGE) Cleanup segments for frame {}".format(frameOutNr))
|
||||
for imgName in segmentImages:
|
||||
if os.path.exists(imgName):
|
||||
print("(MERGE) \t Unlink {}".format(imgName))
|
||||
os.unlink(imgName)
|
||||
else:
|
||||
print("(MERGE) \t Already unlinked {}".format(imgName))
|
||||
|
||||
nextOutNr += segmentCount
|
||||
nextJson = os.path.join(args.segmentDir, "segment%06d.json" % nextOutNr)
|
||||
|
|
Loading…
Reference in a new issue