如何在ASP.NET中集成USB摄像头 [英] How to integrate USB camera in ASP.NET

查看:65
本文介绍了如何在ASP.NET中集成USB摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在asp.net中集成三个USB摄像头。每个摄像头都应显示在单独的小部件中。如何整合它以及如何识别相机。请给出一些指导..



我的尝试:



这是笔记本电脑摄像头代码,



Hi,
I need to integrate three USB cameras in asp.net. Each camera should be shown in separate widget. how to integrate it and also how to identify the cameras. please give some guidelines..

What I have tried:

This is laptop webcam code,



< ; video id =videowidth =215height =150autoplay =autoplaystyle =margin-top:10vh; background-color:none; z-index:2!important;>< / video>

< canvas id =canvaswidth =205height =150style =background-color:none;>< / canvas>

< button id =snapclass =sexyButtonstyle =height:30px; width:100px; border:0px; border-radius:3px; margin-top:8vh; margin-left:13vw > Snap Photo< / button>

< script>



//将事件监听器放到位

window.addEventListener(DOMContentLoaded,function(){

//抓取元素,创建设置,等等

var canvas = document.getElementById(canvas),

context = canvas.getContext(2d),

video = document.getElementById(video),

videoObj = {video:true},

errBack = function(error){

console.log(视频捕获错误:,error.code);

};



//将视频监听器放置到位

if(navigator.getUserMedia){//标准

navigator.getUserMedia(videoObj,function(stream){

video.src = stream ;

video.play();

},errBack);

} else if(navigator.webkitG etUserMedia){// WebKit-prefixed

navigator.webkitGetUserMedia(videoObj,function(stream){

video.src = window.webkitURL.createObjectURL(stream);

video.play();

},errBack);

}否则if(navigator.mozGetUserMedia){// WebKit-prefixed

navigator.mozGetUserMedia(videoObj,function(stream){

video.src = window.URL.createObjectURL(stream);

video.play() ;

},errBack);

}



//触发拍照

document.getElementById(snap)。addEventListener(click,function(){

context.drawImage(vid) eo,0,0,220,150);

});

},false);



< / script>




<video id="video" width="215" height="150" autoplay="autoplay" style="margin-top: 10vh; background-color: none; z-index: 2 !important;"></video>
<canvas id="canvas" width="205" height="150" style="background-color: none;"></canvas>
<button id="snap" class="sexyButton" style="height: 30px; width: 100px; border: 0px; border-radius: 3px; margin-top: 8vh; margin-left: 13vw">Snap Photo</button>
<script>

// Put event listeners into place
window.addEventListener("DOMContentLoaded", function () {
// Grab elements, create settings, etc.
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
video = document.getElementById("video"),
videoObj = { "video": true },
errBack = function (error) {
console.log("Video capture error: ", error.code);
};

// Put video listeners into place
if (navigator.getUserMedia) { // Standard
navigator.getUserMedia(videoObj, function (stream) {
video.src = stream;
video.play();
}, errBack);
} else if (navigator.webkitGetUserMedia) { // WebKit-prefixed
navigator.webkitGetUserMedia(videoObj, function (stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}, errBack);
} else if (navigator.mozGetUserMedia) { // WebKit-prefixed
navigator.mozGetUserMedia(videoObj, function (stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
}, errBack);
}

// Trigger photo take
document.getElementById("snap").addEventListener("click", function () {
context.drawImage(video, 0, 0, 220, 150);
});
}, false);

</script>





工作正常。





但是,如何将它用于USB摄像头以及如何识别摄像头?



it was working fine.


but, how to use it for USB cameras and how to identify the cameras?

推荐答案

Quote:

我需要在asp.net中集成三个USB摄像头

I need to integrate three USB cameras in asp.net





ASP.NET无法做到这一点。您的USB驱动器位于客户端的PC上,ASP.NET Web应用程序在浏览器上运行 - 它们之间存在断开的空间。



也许使用ActiveX / Java Applet可能是可能,但我无法保证。



ASP.NET can't do that. Your USB drive is on the client's PC and ASP.NET web app runs on the browser - there's a disconnected space between them.

Perhaps using ActiveX/Java Applets might be possible but I can't guarantee it.


这篇关于如何在ASP.NET中集成USB摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆