mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
Merge branch 'master' of github.com:kou029w/camera-example
This commit is contained in:
parent
d5e5bd563d
commit
18af5b3f85
3 changed files with 28 additions and 3 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Kohei Watanabe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -8,7 +8,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<video autoplay></video>
|
||||
<input type="button" value="Capture" onclick="capture()" />
|
||||
<input type="button" value="Capture" />
|
||||
ref.
|
||||
<a href="https://media-example.kou029w.now.sh/"
|
||||
>https://media-example.kou029w.now.sh/</a
|
||||
|
|
8
main.js
8
main.js
|
@ -1,13 +1,17 @@
|
|||
const video = document.body.querySelector("video");
|
||||
const button = document.body.querySelector(
|
||||
'input[type="button"][value="Capture"]'
|
||||
);
|
||||
|
||||
let canvas = document.createElement("canvas");
|
||||
async function main() {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
||||
video.srcObject = stream;
|
||||
|
||||
button.addEventListener("click", capture);
|
||||
}
|
||||
|
||||
function capture() {
|
||||
if (canvas == null) return;
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.setAttribute("width", video.videoWidth);
|
||||
canvas.setAttribute("height", video.videoHeight);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue