Bhavesh Vankar

Bhavesh Vankar

  • 753
  • 1.2k
  • 89.4k

Webcam Image Capturing but image not getting...

Jul 31 2020 3:19 AM
Here is my Asp.Net C# Web code for image capture from webcame using jquery. But when i'm going to take image webcam access but image not getting on image control please suggest me whats the issue in this code....?
  1. <head runat="server">  
  2. <title>Crop Image</title>  
  3. <script src="FinalJquery/jquery-1.8.3.min.js"></script>  
  4. <script src="FinalJquery/jquery.webcam.js"></script>  
  5. <script src="FinalJquery/webcam.min.js"></script>  
  6. </head>  
  7. <body>  
  8. <form id="form1" runat="server">  
  9. <div>  
  10. <table border="1" align="center">  
  11. <tr>  
  12. <th colspan="2">Croped Image</th>  
  13. </tr>  
  14. <tr>  
  15. <th>Live Camera</th>  
  16. <th>Captured Image</th>  
  17. </tr>  
  18. <tr>  
  19. <td id="my_camera"></td>  
  20. <td>  
  21. <asp:Image ID="imgCapture" runat="server" Height="250" Width="200" />  
  22. </td>  
  23. </tr>  
  24. <tr>  
  25. <td colspan="2" align="center">  
  26. <asp:Button ID="btnCapture" runat="server" Text="Take Pic" OnClientClick=" return Capture()" /></td>  
  27. </tr>  
  28. </table>  
  29. </div>  
  30. </form>  
  31. <script type="text/javascript">  
  32. var pageUrl = '<%=ResolveUrl("~/Default2.aspx") %>';  
  33. Webcam.set({  
  34. width: 400,  
  35. height: 400,  
  36. image_format: 'jpeg',  
  37. jpeg_quality: 100  
  38. });  
  39. Webcam.attach('#my_camera');  
  40. function take_snapshot() {  
  41. Webcam.snap(function (data_uri) {  
  42. $(".image-tag").val(data_uri);  
  43. document.getElementById('imgCaputre');  
  44. },  
  45. {  
  46. onSave: function (data) {  
  47. $.ajax({  
  48. type: "POST",  
  49. url: pageUrl + "/GetCapturedImage",  
  50. data: '',  
  51. contentType: "application/json; charset=utf-8",  
  52. dataType: "json",  
  53. success: function (r) {  
  54. $("[id*=imgCaputre]").css("visibility""visible");  
  55. $("[id*=imgCaputre]").attr("src", r.d);  
  56. },  
  57. failure: function (response) {  
  58. alert(response.d);  
  59. }  
  60. });  
  61. },  
  62. onCapture: function () {  
  63. webcam.save(pageUrl);  
  64. }  
  65. });  
  66. };  
  67. function Capture() {  
  68. webcam.capture();  
  69. return false;  
  70. };  
  71. </script>  
  72. </body>  

Answers (2)