2 lyp13140 lyp13140 于 2016.04.05 16:39 提问

求助大神~网页中调用摄像头左右方向反了额,用拍照软件试了,摄像头本身没问题,下面是代码
 <!DOCTYPE HTML >
<html>
  <head>
    <title>cam.html</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
   <video id="video" autoplay=""style='width:600px;height:400px'></video>
   <button id='picture'>拍照</button> 
   <canvas id="canvas" width="600" height="400"></canvas>
   <script type="text/javascript">
   var video = document.getElementById("video");
   var context = canvas.getContext("2d")
   var errocb = function () {
                             console.log('sth wrong!');
                        }
   if (navigator.getUserMedia) { // 标准的API
       navigator.getUserMedia({ "video": true }, function (stream) {
           video.src = stream;
           video.play();
       }, errocb);
} else if (navigator.webkitGetUserMedia) { // WebKit 核心的API
       navigator.webkitGetUserMedia({ "video": true }, function (stream) {
           video.src = window.webkitURL.createObjectURL(stream);
           video.play();
       }, errocb);
}
   document.getElementById("picture").addEventListener("click", function () {
       context.drawImage(video, 0, 0, 600, 400);
});

     </script>
  </body>
</html>

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!