简体   繁体   English

使用 Blazor 访问设备摄像头

[英]Access Device Camera with Blazor

I have a Blazor Web Assembly PWA, how do I open a devices native camera?我有一个 Blazor Web 组装 PWA,如何打开设备本机摄像头?

I am trying to write a PWA to capture and save pictures.我正在尝试编写 PWA 来捕获和保存图片。

EDIT编辑

Would like to save captured images as jpeg's to Azure Blob Storage.想将捕获的图像以 jpeg 格式保存到 Azure Blob Storage。

You can achieve this with HTML input.您可以使用 HTML 输入来实现此目的。 You only need to add the attribute capture for opening device camera straight away.您只需要添加属性capture即可立即打开设备摄像头。

<input type="file" accept="image/*" capture>

You can have a look at the full source code here:你可以在这里查看完整的源代码:

https://github.com/mehmettahameral/Blazor-wasm-pwa-camera https://github.com/mehmettahameral/Blazor-wasm-pwa-camera

and live demo here: https://infallible-bohr-56743b.netlify.app/并在此处进行现场演示: https://infallible-bohr-56743b.netlify.app/

-- --

about saving the images: it depends where do you want to save it really.关于保存图像:这取决于您要真正保存它的位置。 If you can tell me more, I might update the solution.如果您能告诉我更多信息,我可能会更新解决方案。

Hope it helps希望能帮助到你

You can follow this tutorial: https://wellsb.com/csharp/aspnet/blazor-webcam-capture to capture camera device, stream the content, process an image.您可以按照本教程: https://wellsb.com/csharp/aspnet/blazor-webcam-capture来捕获摄像头设备,stream 内容,处理图像。

Then, you can use the Azure Blob Storage client library v12 for .NET to upload your images to your Storage Account.然后,您可以使用Azure Blob Storage client library v12 for .NET将图像上传到您的存储帐户。

You can find a Quickstart here: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet您可以在此处找到快速入门: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet

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

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