Commit 9e3ee32b authored by Michael Murtaugh's avatar Michael Murtaugh

moved scripts into folder, renaming, webm ipv gif

parent 5dd08814
......@@ -2,4 +2,9 @@
*.pyc
settings.json
node_modules/
frames/
output/
archive/
erkki/
asger/
This diff is collapsed.
......@@ -12,6 +12,9 @@
<div id="content">
<img src="blank.png" />
</div>
<div id="video">
<video autoplay loop></video>
</div>
<div id="message"></div>
</body>
</html>
......@@ -2,9 +2,11 @@ document.addEventListener("DOMContentLoaded", function () {
var sockaddr = window.location.protocol+'//'+window.location.host,
socket,
img = document.querySelector("img"),
video = document.querySelector("video"),
msg = document.getElementById("message");
img.style.display = "none";
video.style.display = "none";
console.log("opening connection to", sockaddr);
socket = io.connect();
socket.on("connect", function (data) {
......@@ -15,13 +17,13 @@ document.addEventListener("DOMContentLoaded", function () {
// img.style.display = "none";
});
socket.on("collage", function (d) {
img.style.display = "none";
video.style.display = "none";
msg.innerHTML = "Creating collage...";
});
socket.on("collagegif", function (d) {
console.log("collagegif", d.src);
msg.innerHTML = "";
img.src = d.src;
img.style.display = "block";
video.src = d.src;
video.style.display = "block";
});
})
#!/bin/bash
ffmpeg -i "$1" -b:v 1000k "$2" && \
rm $1
......@@ -6,6 +6,8 @@ p = ArgumentParser("make a movie from frames, using pyopencv")
p.add_argument("frame", nargs="+")
p.add_argument("--output", default="output.avi")
p.add_argument("--framerate", type=float, default=25, help="output frame rate")
p.add_argument("--reverseloop", default=False, action="store_true", help="repeat frames in reverse order")
p.add_argument("--repeatlast", default=False, action="store_true", help="repeat the last frame (for slow frame rates this seems important")
p.add_argument("--fourcc", default="XVID", help="MJPG,mp4v,XVID")
args = p.parse_args()
......@@ -14,14 +16,21 @@ try:
except AttributeError:
fourcc = cv2.VideoWriter_fourcc(*args.fourcc)
frames = args.frame
if (args.reverseloop):
for f in reversed(args.frame[:-1]):
frames.append(f)
out = None
for f in args.frame:
for f in frames:
frame = cv2.imread(f)
h, w, c = frame.shape
if out == None:
out = cv2.VideoWriter()
out.open(args.output, fourcc, args.framerate, (w, h))
out.write(frame)
if args.repeatlast:
out.write(frame)
out.release()
......@@ -27,7 +27,7 @@ while(True):
outpath = os.path.join(args.path, outpath)
cv2.imwrite(outpath, frame)
if (not os.path.exists(outpath)) or os.path.getsize(outpath) == 0:
print("Bad frame", file=sys.stderr)
print("Bad frame (camera connected?)", file=sys.stderr)
try:
os.remove(outpath)
except OSError:
......
......@@ -12,6 +12,9 @@
<div id="content">
<img src="blank.png" />
</div>
<div id="video">
<video autoplay loop></video>
</div>
<div id="message"></div>
</body>
</html>
......@@ -2,10 +2,12 @@ document.addEventListener("DOMContentLoaded", function () {
var sockaddr = window.location.protocol+'//'+window.location.host,
socket,
img = document.querySelector("img"),
video = document.querySelector("video"),
msg = document.getElementById("message"),
archivegif;
img.style.display = "none";
video.style.display = "none";
console.log("opening connection to", sockaddr);
socket = io.connect();
socket.on("connect", function (data) {
......@@ -23,17 +25,22 @@ document.addEventListener("DOMContentLoaded", function () {
// console.log("archiveframe", src, d);
var feature_name = (d.af.feature == "face") ? "Face" : "Eye";
// msg.innerHTML = feature_name + " detected";
msg.innerHTML = "";
msg.innerHTML = "Matching with faces & eyes <br>from the archive";
img.style.display = "block";
video.pause();
video.style.display = "none";
});
socket.on("analyze", function () {
// start a countdown...
msg.innerHTML = "Searching for faces <br>from the archive...";
img.style.display = "none";
video.pause();
video.style.display = "none";
})
socket.on("archivegif", function (d) {
console.log("archivegif", d.src);
archivegif = d.src;
msg.innerHTML = "";
//
// img.style.display = "block";
// img.src = d.src;
......@@ -41,7 +48,9 @@ document.addEventListener("DOMContentLoaded", function () {
socket.on("collagegif", function (d) {
// console.log("collagegif", d.src);
msg.innerHTML = "";
img.src = archivegif;
img.style.display = "block";
// img.src = archivegif;
img.style.display = "none";
video.src = archivegif;
video.style.display = "block";
});
})
......@@ -37,6 +37,22 @@ body#search {
margin-right: auto;
height: 100%;
}
#video {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
text-align: center;
}
#video video {
/*width: 100%;*/
margin-left: auto;
margin-right: auto;
height: 100%;
}
/*body#collage #content img {}*/
#message {
position: absolute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment