hi
i have try this sample
Capture Image (Photo) from Web Camera (Webcam) in ASP.Net using C# and VB.Net
running well in computer, when i try running on smartphone i get message error like this,webcam.js error: webcam is not loaded yet
how running well this code on computer and smartphone
thanks
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm15.aspx.vb" Inherits="payroll.WebForm15" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th align="center"><u>Live Camera</u></th>
<th align="center"><u>Captured Picture</u></th>
</tr>
<tr>
<td><div id="webcam"></div></td>
<td><img id="imgCapture" /></td>
</tr>
<tr>
<td align="center">
<input type="button" id="btnCapture" value="Capture" />
</td>
<td align="center">
<input type="button" id="btnUpload" value="Upload" disabled="disabled" />
</td>
</tr>
</table>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webcamjs/1.0.26/webcam.js"></script>
<script type="text/javascript">
$(function () {
Webcam.set({
width: 320,
height: 240,
image_format: 'jpeg',
jpeg_quality: 90
});
Webcam.attach('#webcam');
$("#btnCapture").click(function () {
Webcam.snap(function (data_uri) {
$("#imgCapture")[0].src = data_uri;
$("#btnUpload").removeAttr("disabled");
});
});
$("#btnUpload").click(function () {
$.ajax({
type: "POST",
url: "WebForm15.aspx/SaveCapturedImage",
data: "{data: '" + $("#imgCapture")[0].src + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) { }
});
});
});
</script>
</div>
</form>
</body>
</html>
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Web.Services
Partial Public Class WebForm15
Inherits System.Web.UI.Page
Public Shared xuser As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
xuser = User.Identity.Name.ToString
End Sub
<WebMethod()> _
Public Shared Function SaveCapturedImage(ByVal data As String) As Boolean
Dim fileName As String = xuser + " " + DateTime.Now.ToString("dd-MM-yy hh-mm-ss")
'Convert Base64 Encoded string to Byte Array.
Dim imageBytes() As Byte = Convert.FromBase64String(data.Split(",")(1))
'Save the Byte Array as Image File.
Dim filePath As String = HttpContext.Current.Server.MapPath(String.Format("~/photo/{0}.jpg", fileName))
File.WriteAllBytes(filePath, imageBytes)
Return True
End Function
End Class