Commit 241784c5 authored by Baumgärtner Lea's avatar Baumgärtner Lea

Try Camera still problems

parent b3d73638
This diff is collapsed.
......@@ -7,6 +7,7 @@ RUN pip install flask
RUN pip install ibm_watson
RUN pip install flask_cors
RUN pip install PILLOW
RUN pip install pyopenssl
EXPOSE 4000
......
......@@ -64,7 +64,7 @@ def main():
Main function for running the flask server.
"""
app.config['SERVER_NAME'] = '0.0.0.0:4000'
app.run(debug=True)
app.run(debug=True, ssl_context='adhoc')
if __name__ == "__main__":
......
......@@ -19,6 +19,55 @@ function previewFile() {
}
}
function createSnapShoot() {
const supported = 'mediaDevices' in navigator;
var player = document.getElementById('player');
var createImageButton = document.getElementById('shoot-image'); // Enable PhotoShoot
const canvas = document.getElementById('canvas'); // Canvas for Stream and Shoot
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture'); // Create SnapShoot
var preview = document.getElementById('img_preview'); // Look at yourself
const constraints = {
video: true,
};
createImageButton.addEventListener('click', () => {
context.disabled = false;
captureButton.disabled = false;
captureButton.addEventListener('click', () => {
// Draw the video frame to the canvas.
context.drawImage(player, 0, 0, preview.width, preview.height);
// Create SnapShoot and Upload File
var file = context;
var reader = new FileReader();
if (file) {
reader.addEventListener("Capture...", function () {
currentImage = reader.result;
preview.src = reader.result;
uploadFileButton.disabled = false;
}, false);
reader.readAsDataURL(file);
}
});
// Attach the video stream to the video element and autoplay.
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
context.srcObject = stream;
});
});
}
function uploadFile() {
var uploadFileButton = document.getElementById('upload-file');
var openFileButton = document.getElementById('open-filesystem-btn');
......
......@@ -28,11 +28,16 @@
<div class="main">
<div class="top box">
<img id="img_preview" src="">
<canvas id="canvas" width=320 height=240 disabled></canvas>
</div>
<div class="bottom">
<label for="open-filesystem" id="open-filesystem-btn" class="button">Browse for image ...</label>
<input type="file" name="photo" id="open-filesystem" accept="image/*" onchange="previewFile()" />
<button class="button" type="button" onclick="uploadFile()" id="upload-file" style="margin-top:-5px;" disabled>Upload File</button>
<button class="button" type="button" onclick="createSnapShoot()" id="shoot-image" style="margin-top:-5px;"> Take Snap Shoot</button>
<button class="button" type="button" onclick="createSnapShoot()" id="capture" style="margin-top:-5px;" disabled> Capture! </button>
<button class="button" type="button" onclick="uploadFile()" id="upload-file" style="margin-top:-5px;" disabled>Upload File</button>
<div class="alert is-error" id="bad-type-error" style="display:none; margin-top: 10px">The uploaded file is not an image.</div>
<div class="alert is-error" id="general-error" style="display:none; margin-top: 10px">Oh no! Something went wrong. Please try again.</div>
</div>
......
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