简体   繁体   English

jQuery网络摄像头插件和Asp .NET

[英]Jquery Webcam Plugin and Asp .NET

I have a problem using the Jquery Plugin for Webcam to take a picture of the user. 我在使用用于网络摄像头的Jquery插件拍摄用户照片时遇到问题。

Here are the codes : 以下是代码:

$("#camera").webcam({
    width: 320,
    height: 240,
    mode: "save",
    swffile: '@Url.Content("~/Scripts/jscam.swf")',
    debug: function (type, string) {
        $('#Status').append(type + ": " + string + '<br /><br />');
    }

});

$('#takePhoto').click(function () {
    webcam.capture();
    webcam.save('/Photo/TakePhoto');
});

The debug give : 调试给出:

notify: Camera started 通知:相机已启动

notify: Capturing started. 通知:捕获已开始。

notify: Capturing finished. 通知:捕获完成。

The problem is the save, I use MVC3, and I want to call the action TakePhoto in my controler Photo, is that possible? 问题是保存,我使用MVC3,我想在控件Photo中调用动作TakePhoto,这可能吗? And have you a good tutorial to retrieve the image in my controler in C#? 您是否有一个很好的教程,可以使用C#在我的控制器中检索图像?

Thank you 谢谢

You want to find out what parameter the plug in is passing your image data to as such. 您想找出插件将图像数据传递给哪个参数。

Let's assume the parameter is "WebCamImage". 假设参数为“ WebCamImage”。

Then your action method would be as such (note: code has not been checked as I'm writing this on my Mac): 然后您的操作方法将是这样(注意:在我在Mac上编写代码时,尚未检查代码):

[HttpPost]
void TakePhoto(byte[] WebCamImage)
{
     System.IO.File.WriteBytesToFile('my/path.jpg', WebCamImage).
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM