网页端UVC相机测试_艾孜尔江撰

网友投稿 622 2022-10-27

网页端UVC相机测试_艾孜尔江撰

网页端UVC相机测试_艾孜尔江撰

​​multiCam.html​​:

Document

​​multiCam.js​​:

// 获取页面视频元素var video = document.getElementById('video');var video1 = document.getElementById('video1');navigator.mediaDevices.enumerateDevices().then(getMyDevices).catch(handleError);// 遍历所有的设备,包括视频和音频设备,找出 RGB相机设备。 function getMyDevices(deviceInfos) { let constraints = new Array(2); let id = 0; for (let i = 0; i !== deviceInfos.length; ++i) { let deviceInfo = deviceInfos[i]; console.log("device info: " + Object.keys(deviceInfo)); if (deviceInfo.kind === 'videoinput') { console.log("$$$$$"); console.log("label: " + deviceInfo.label); // if (deviceInfo.label.search("RGB") !== -1) { if (deviceInfo.label.search("Full HD webcam") !== -1) { console.log("deviceID is ###: " + deviceInfo.deviceId); constraints[id] = { video: { deviceId: deviceInfo.deviceId }, // audio: true, video: { width: 1280, height: 720 } }; id = id + 1; } } } navigator.mediaDevices.getUserMedia(constraints[0]). then(getStreamFromCamA).catch(handleError); navigator.mediaDevices.getUserMedia(constraints[0]). then(getStreamFromCamB).catch(handleError);}function getStreamFromCamA(stream) { window.stream = stream; // make stream available to console video.srcObject = stream; video.play();}function getStreamFromCamB(stream) { window.stream = stream; // make stream available to console video1.srcObject = stream; video1.play();}function handleError(error) { console.log('Error: ', error);}// var id = setInterval(function () {// console.log("drawing...");// draw(id)// }, 24);function draw(id) { localStorage.interval_id = id; let canvas = document.querySelector('canvas'); canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);}

​​uvc.html​​:

HTML5 code Reader


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:87版《红楼梦》与原著回目对应表
下一篇:python 小工具
相关文章

 发表评论

暂时没有评论,来抢沙发吧~