Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow Chrome to access my camera on localhost?

I cloned a project about real-time image processing on a web browser from this link: Then I could not allow my browser to access my camera. I got this javascript alert:

Uh-oh, the webcam didn't start. Do you have a webcam? Did you give it permission? Refresh to try again. And the allow button is not shown as if I access his site.

like image 637
Methuz Kaewsai-kao Avatar asked May 30 '13 11:05

Methuz Kaewsai-kao


People also ask

Why can't chrome access my webcam?

Check your browser permissions On Chrome or Microsoft Edge: Open the menu (the three dots ⋮) in the top, right-hand corner of your browser. Select Settings > Privacy & Security > Site Settings. Ensure that your Camera and Microphone both have Ask before accessing set to ON.


2 Answers

To ignore Chrome’s secure origin policy, follow these steps.

Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure in Chrome.

Find and enable the Insecure origins treated as secure section (see below).

Add any addresses you want to ignore the secure origin policy for. Remember to include the port number too (if required).

Save and restart Chrome.

I found solution from below link.Hope it will help to someone

https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339

like image 64
DKR Avatar answered Sep 22 '22 02:09

DKR


Are you accessing the webpage that is served over HTTP, on localhost? If you are accessing it from http://localhost/... , Chrome will ask for your permission to use the camera.

Chrome accessing camera on localhost

If you are opening the web page directly, i.e. /Users/Methuz/Documents/index.html then it will not work, even if you explicitly allows it permission

Chrome cannot access camera over file protocol


In this case, the workaround I use is to host the HTML file on a webserver. A quick hack is to use python, in the folder where the HTML page is lcoated: python -m SimpleHTTPServer

like image 22
Hanxue Avatar answered Sep 23 '22 02:09

Hanxue