我已经完成了一个网络摄像头项目,它将支持查看实时网络摄像头图像。我在本地使用“ENTER USB 2.0”工作正常..当我将其上传到网络服务器并使用客户端浏览器进行测试时..它不工作..它的错误是“找不到设备”..是否有任何服务器设置来检测网络摄像头?..
我们怎样才能在asp.net中检测到任何类型的网络摄像头??或者是否有用于在客户端浏览器上检测网络摄像头的activeX插件..
对我来说非常重要..请与我分享..如果您有任何想法吗?
提前感谢..
答案 0 :(得分:2)
我曾使用jpegcam一次从网络摄像头上传照片。希望这可以帮助。基本代码就像(使用jquery):
<script type="text/javascript" src="<path to webcam.js (inside jpegcam)>"></script>
<script type="text/javascript">
$(function () {
webcam.set_swf_url('path to webcam.swf(inside jpegcam)');
webcam.set_api_url(document.URL);
webcam.set_quality(90); // JPEG quality (1 - 100)
webcam.set_shutter_sound(false);
$("#imgWrapper").css({ height: "262px",
width: "215px",
border: "solid 1px #aaa"
});
var pb = $("#tp");
pb.addClass("spbtn");
pb.click(function () {
$("#fc").html(webcam.get_html(215, 262));
viewCam(true);
});
});
function viewCam(show) {
if (show) {
$("#sc").hide();
$("#iUploadFrame").fadeIn();
}
else {
$("#iUploadFrame").hide();
$("#sc").fadeIn();
}
}
function camReset() {
webcam.reset();
setCamInstruction("Adjust, snap, then upload", "#666");
}
function setCamInstruction(msg, c) {
$("#upStatus").html(msg).css("color", c);
}
function handleUpload() {
var gi = $("#ghimg");
gi.css("visibility", "visible")
webcam.upload(document.URL, function () {
gi.css("visibility", "hidden")
setCamInstruction("Upload complete!", "green");
});
}
</script>
HTML:
<div id="sc" style="width: 218px">
<div id="imgWrapper">
<img src="<path to a placeholder image>" alt="no photo" id="imgPhoto"
runat="server" height="262" width="215" />
</div>
<br />
<div style="text-align: center">
<span id="tp">Open Webcam</span>
</div>
<br />
</div>
<div id="iUploadFrame" style="display: none;">
<div id="fc">
-- Cam Content --
</div>
<div id="upStatus" style="padding: 5px 0; color: #666;">
Adjust, snap, then upload</div>
<input type="button" value="Snap" onclick="webcam.freeze()" />
<input type="button" value="Reset" onclick="camReset();" />
<input type="button" value="Upload" onclick="handleUpload()" />
<div class="progress_beside_inline" id="ghimg">
</div>
</div>