Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open camera on mobile via progressive web app

I would like to make a website that can open the camera on mobile like this example.

On mobile, by clicking the AR icon a camera app is opened. Does anyone know how to do this? More specifically, what kind of libraries and JavaScript libraries are required.

like image 926
PiccolMan Avatar asked May 16 '21 08:05

PiccolMan


People also ask

Can Progressive Web App access camera?

Progressive web apps can also access device features, like the camera, GPS, contact book, and calendar.

Can a web app access Android camera?

On Android devices, you can access the camera from the Browser widget. The feature is available on devices with Android OS 5.0 and later.

Does PWA work on mobile?

In addition to PWAs being able to work on all devices, it also doesn't matter which operating system the user has. They work on both Apple and Android devices.

How do I use Progressive Web Apps (PWAs)?

You can use Progressive Web Apps (PWAs) for a fast web experience on your computer or mobile device. You can install the PWA for faster access and additional functionality, like more storage for content to use offline. On your Android device, open Chrome . Go to a website with a PWA that you want to install. Tap Install.

How to launch the camera of your mobile device using PWA?

Build and serve the static files in build directory to get the following view, which will launch the camera of your mobile device (android) by clicking the camera icon on the UI after installing the PWA app in your device. In this article, you were able to learn how to create a simple PWA which can access a device’s camera, using React.

Do progressive web apps increase web traffic?

“The numbers don’t lie! Companies that have launched Progressive Web Apps have seen impressive results. For example, Twitter saw a 65% increase in pages per session, 75% more Tweets, and a 20% decrease in bounce rate, all while reducing the size of their app by over 97%.

What is the difference between native and progressive apps?

Like native apps though they can be launched from a home screen icon, send push notifications to the user’s device, load in a split second, and be built to work offline. Progressive web apps are not separate from your site.


2 Answers

If I am getting you right then you are talking about adding AR to the web so that you can provide an AR experience to your users.

You can achieve these types of things using the immersive web. The immersive web means virtual world experiences hosted through the browser. This covers entire virtual reality (VR) experiences surfaced in the browser or VR-enabled headsets like Google's Daydream, Oculus Rift, Samsung Gear VR, HTC Vive, and Windows Mixed Reality Headsets, as well as augmented reality experiences developed for AR-enabled mobile devices.

For web applications to make use of Augmented Reality (AR) capabilities, they must be able to identify real-world geometry. For example, a web application may wish to detect a horizontal plane (e.g, the floor) in the camera feed, and render an object (e.g, a mouse) on that plane. For this thing, you can use the hit-test API. This API would allow the developer to cast a ray into the real world and return a list of intersection points for that ray against whatever world understanding the underlying system gathers.

Learn more about hit-test API - https://github.com/immersive-web/hit-test/

You can read more about immersive-web here - https://developers.google.com/web/updates/2018/05/welcome-to-immersive

like image 81
thelovekesh Avatar answered Sep 25 '22 00:09

thelovekesh


If you are looking to create a custom AR application, Google Developers has a tutorial on using the WebXR API. However, if you just want to display a model object (such as the Logitech mouse), you can use Google's <model-viewer> component, which will launch a separate AR viewer on supported devices.

If you are not looking to build an AR application and just want access to the camera stream for whatever reason, you can use the MediaDevices web API, specifically getUserMedia(). If you do not need a live video feed and just want a video file, an <input> element also has attributes that allows users to upload pre-recorded videos, as well as capture new ones. Google Web Fundamentals has more information about these different options of capturing video, depending on your use-case, as well as code examples and tutorials.

like image 43
person_v1.32 Avatar answered Sep 24 '22 00:09

person_v1.32