New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 343894 link

Starred by 20 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Feature

Blocked on:
issue 518807



Sign in to add a comment

Enable focus within getUserMedia()

Reported by torben.f...@gmail.com, Feb 14 2014

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/31.0.1650.63 Chrome/31.0.1650.63 Safari/537.36

Example URL:
http://shinydemos.com/qr-code/

Steps to reproduce the problem:
1. Setup a video stream with getUserMedia()
2. Place camera really close to something
3. See blurriness

What is the expected behavior?
Like in native mobile Apps it should be possible to trigger the autofocus for given coordinates, e.g. on touch.

What went wrong?
The ability to trigger the autofocus is missing.

Did this work before? No 

Is it a problem with Flash or HTML5? HTML5

Does this work in other browsers? N/A 

Chrome version: 31.0.1650.63  Channel: stable
OS Version: ubuntu0.13.04.1~20131204.1
Flash Version: Shockwave Flash 11.0 r1

Tested with Lenovo X220 and Samsung Galaxy S3.

Usecase: A QR-code scanner, trying to scan e.g. 10x10mm codes.
 
Labels: Cr-Blink-WebRTC
Labels: -Cr-Internals-Media
Cc: niklase@chromium.org sergel@chromium.org juberti@chromium.org jansson@chromium.org tnakamura@chromium.org
Labels: -Type-Bug Type-Feature
Status: Available

Comment 4 by m...@sowbug.com, Feb 27 2014

See https://chrome.google.com/webstore/detail/scanqr/nihhbejdflkeingkkpakffdlmepaeaah for an example of a Chrome App that could really stand to benefit from this enhancement.

Comment 5 by vrk@chromium.org, Sep 24 2014

Labels: Cr-UI
Cc: mcasas@chromium.org
I'm assuming that adding support for custom focus areas would require changes to the media capture spec. Does the current implementation of media capture in Chrome for Android at least properly trigger the auto-focus feature of the camera on the device? I'm not finding any focus related settings in the video  source code (https://code.google.com/p/chromium/codesearch#chromium/src/media/base/android/java/src/org/chromium/media/VideoCaptureAndroid.java&sq=package:chromium&type=cs) 

Comment 7 by mcasas@chromium.org, Nov 13 2014

Labels: -Cr-UI OS-Chrome OS-Android
a) the current WebRTC JS API is quite bare-bones when it comes to Camera control features. Moreover, the underlying signalling flow from Renderer to Browser side is reduced to operational start/stop like commands, essentially. (NB: there's new code under review for picture taking).

b) Android Video Capture does not implement auto focus. IIRC, AutoFocus is continuously doing so while on Preview. Btw Camera2 code is in the making [1], so this is the perfect time for suggestions :)

c) The App in #4 refers to a CrOs, in this case the cameras follow UVC model and should be on continuous auto focus. I'd recommend trying with an external USB camera; perhaps the internals do not have the good parameters for macro. 

PS: I see in #1: "Chrome version: 31.0.1650.63" <-- it needs update.

[1] http://crrev.com/611283002 f.i.
a) Suggesting a spec update :) Actually tried already to get some spec people onto the topic… There are more related ideas, like controlling the flash, when available.

b) The issue is not Android specific. I would like to be able to use the camera of my laptop to scan bar/qr codes as well.

Unfortunately I cannot update my own issues o.O But the issue still exists in 40.0.2209.0
mcasas@, regarding (b) as far as I can tell from the documentation (http://developer.android.com/reference/android/hardware/Camera.Parameters.html) even the now deprecated Camera API on Android supports auto-focus (via Parameters.FOCUS_MODE_CONTINUOUS_VIDEO).  Could it be as easy as adding that param somewhere near: https://code.google.com/p/chromium/codesearch#chromium/src/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java&l=172 ? 
Owner: mcasas@chromium.org
Status: Assigned
Regarding #9: It seems that adding the focus mode does the trick for Android.
Sorry, I jumped ahead of myself, seems like ToT and stable 39 focus fine. 
This is what I tried:

- Vanilla Clankium on my N5 Android-L, it focuses correctly to very close characters (~2cm) and then farther objects.

- Stock Cr 39.0.2171.59 on a N4 JB, same results.

For testing I used peerconnection page [1], click on "getDevices", select second
source, then click on "Request GetUserMedia", then "Resize: To stream size" and
just get real close to some printed out paper, then focus on some farther objects.

[1] http://goo.gl/hsfT0d
Project Member

Comment 12 by bugdroid1@chromium.org, Nov 19 2014

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/667e79783dd2bbd413b165abfd7fae2bfa3210d5

commit 667e79783dd2bbd413b165abfd7fae2bfa3210d5
Author: mcasas <mcasas@chromium.org>
Date: Wed Nov 19 22:42:29 2014

Android Video Capture: Set continuous focus mode on in cam parameters.

This is, apparently, needed for macro modes, although
autofocus seems to work ok in general.

BUG= 343894 
TEST=Please refer to the bug, basically a gUM() + close QR codes focus test.

Review URL: https://codereview.chromium.org/737003003

Cr-Commit-Position: refs/heads/master@{#304909}

[modify] http://crrev.com/667e79783dd2bbd413b165abfd7fae2bfa3210d5/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java

Labels: M-41
mcasas@ - can this be considered fixed with r304909?

Comment 14 by miket@chromium.org, Nov 20 2014

I'd rather it not be marked fixed if that means that Chrome OS behavior won't improve. If you'd prefer to focus on the Android-only elements of the original issue, then a separate bug to track other host OSes might make sense.
Status: Started
Agree with #14. This bug is for all platforms ergo stays open. If other platforms
prove too complex to address we'll shift this to Android only, mark as Fixed and
make daughter Issues. So far I haven't tried reproing with CrOs/Linux.
Project Member

Comment 16 by bugdroid1@chromium.org, Nov 20 2014

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ee8c7cac097f864b19d69dcabd6782e4d8c793dd

commit ee8c7cac097f864b19d69dcabd6782e4d8c793dd
Author: tommi <tommi@chromium.org>
Date: Thu Nov 20 14:17:07 2014

Revert of Set camera parameters continuous focus mode on (patchset #1 id:1 of https://codereview.chromium.org/737003003/)

Reason for revert:
Looks like this is causing MANUAL_CanAcquireVgaOnRealWebcam to fail.

Original issue's description:
> Android Video Capture: Set continuous focus mode on in cam parameters.
>
> This is, apparently, needed for macro modes, although
> autofocus seems to work ok in general.
>
> BUG= 343894 
> TEST=Please refer to the bug, basically a gUM() + close QR codes focus test.
>
> Committed: https://crrev.com/667e79783dd2bbd413b165abfd7fae2bfa3210d5
> Cr-Commit-Position: refs/heads/master@{#304909}

TBR=qinmin@chromium.org,mcasas@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG= 343894 

Review URL: https://codereview.chromium.org/740363002

Cr-Commit-Position: refs/heads/master@{#305009}

[modify] http://crrev.com/ee8c7cac097f864b19d69dcabd6782e4d8c793dd/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java

Project Member

Comment 17 by bugdroid1@chromium.org, Nov 21 2014

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0910435eba14f433438ed2e448a67e799e851bdd

commit 0910435eba14f433438ed2e448a67e799e851bdd
Author: mcasas <mcasas@chromium.org>
Date: Fri Nov 21 00:10:59 2014

Android video capture: Set camera parameters continuous focus mode on, where supported

This is, apparently, needed for macro modes, although autofocus seems to
work ok in general.

A similar CL was landed and reverted (http://crrev.com/737003003). This CL
is an alternative where the supported focus modes are tested before being
set in the Camera.Parameters.

BUG= 343894 
TEST=Please refer to the bug, basically a gUM() + close text or QR codes focus test.

Review URL: https://codereview.chromium.org/744193002

Cr-Commit-Position: refs/heads/master@{#305117}

[modify] http://crrev.com/0910435eba14f433438ed2e448a67e799e851bdd/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java

Project Member

Comment 18 by bugdroid1@chromium.org, Nov 24 2014

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d4bc57e27767335584181a8ec7918f9f19ff72e0

commit d4bc57e27767335584181a8ec7918f9f19ff72e0
Author: mcasas <mcasas@chromium.org>
Date: Mon Nov 24 23:37:44 2014

Android Video Capture: Rename L with LOLLIPOP in Version check.

BUG= 343894 
TBR=qinmin@chromium.org, acleung@chromium.org

Review URL: https://codereview.chromium.org/756773002

Cr-Commit-Position: refs/heads/master@{#305520}

[modify] http://crrev.com/d4bc57e27767335584181a8ec7918f9f19ff72e0/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java

Labels: -M-41 M-42 MovedFrom-41
Moving all non essential bugs to the next Milestone.
Labels: -M-42 MovedFrom-42
[AUTO] This issue has already been moved once and is lower than Priority 1,therefore removing mstone.

Comment 21 Deleted

I am building a PDF417 scanner based on getUserMedia() however have found noise to be an issue and having the ability to focus or set focal point would likely enable this solution to work but without it I fear it wont. Please consider providing a way to do this with getUserMedia also.
Blockedon: 518807
Components: -Blink>WebRTC Blink>ImageCapture Blink>GetUserMedia>Webcam
Labels: -OS-Linux -OS-Chrome
Components: -Blink>ImageCapture Blink>MediaStream>ImageCapture
Renaming Blink>ImageCapture to Blink>MediaStream>ImageCapture. Moving these bugs to the new component.
https://bugs.chromium.org/p/chromium/issues/detail?id=518807#c73 was a 
first step for this to happen.
Project Member

Comment 26 by bugdroid1@chromium.org, Aug 23 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736

commit 0e630cf2c14d1e0c815c95a8710e4d6eb5e09736
Author: mcasas <mcasas@chromium.org>
Date: Tue Aug 23 05:56:38 2016

ImageCapture: add sequence<Point2D> pointsOfInterest and wire for Android

This CL:
- adds a Point2D.idl to describe a coordinate [1] and
- adds a sequence<Point2D> to describe a series of
 points of interest [2]
- adds the correspondents to image_capture.mojom
 (note that I'd rather reuse gfx::mojom::PointF but a
 WebKit presumit prevents me from doing it).
- extends the Java_VideoCapture_setPhotoOptions to
 accept the said list of points of interest
- implements the points of interest for (Auto)Focus,
 limitation: only one such is actually used
 (enforced by assert).

[1] https://w3c.github.io/mediacapture-image/#Point2D
[2] https://w3c.github.io/mediacapture-image/#dom-photosettings-pointsofinterest

BUG= 343894 ,  518807 

Review-Url: https://codereview.chromium.org/2257613002
Cr-Commit-Position: refs/heads/master@{#413675}

[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/media/capture/video/android/java/src/org/chromium/media/VideoCapture.java
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera.java
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera2.java
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/media/capture/video/android/video_capture_device_android.cc
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/media/mojo/interfaces/image_capture.mojom
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/third_party/WebKit/LayoutTests/imagecapture/setoptions.html
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/third_party/WebKit/Source/modules/imagecapture/PhotoSettings.idl
[add] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/third_party/WebKit/Source/modules/imagecapture/Point2D.idl
[modify] https://crrev.com/0e630cf2c14d1e0c815c95a8710e4d6eb5e09736/third_party/WebKit/Source/modules/modules.gypi

Status: Fixed (was: Started)
Components: -Blink>MediaStream>ImageCapture Blink>ImageCapture
mcasas@ can you confirm that this is fixed for Android only? The reason I ask is that Comment #15 states that it should remain open until its fixed for all platforms yet the only OS box ticked is Android.
#30 you're right. However, per-platform implementations might 
be quite different, e.g. this feature is:
- implemented for Android,
- not available in the OS API in Mac, 
- not scheduled for working on it any time soon for Linux/CrOs
- not scheduled for working on it any time soon for Windows, 
with the added complication that most of the infra is also not
available for this platform.

With that, jansson@, should we split this bug...?
Labels: M-54

Sign in to add a comment