w3c / mediacapture-image

Mediastream Image Capture
https://w3c.github.io/mediacapture-image/
Other
74 stars 40 forks source link

Pan and Tilt Constraints #177

Closed dsanders11 closed 5 years ago

dsanders11 commented 7 years ago

What are the feelings on adding a pan constraint and a tilt constraint?

Both settings are part of the UVC spec. They're supported on Windows (getRange_Pan and getRange_Tilt) and via V4L2 on Linux (V4L2_CID_PAN_ABSOLUTE and V4L2_CID_TILT_ABSOLUTE).

They do not, however, appear to be supported on Android via either API (android.hardware.camera or android.hardware.camera2). Most built-in cameras on Android devices likely don't support them anyway, from my experience.

Logitech webcams support pan and tilt and it would be a great resource to have in the spec for fully controlling these types of cameras.

dsanders11 commented 7 years ago

@yellowdoge, thoughts? I do see in this commit you mentioned "Avoid reset PAN/TILT controls due to Image Capture API not giving access to them (yet)" so it sounds like you're in favor of adding the controls to the spec.

Anything learned there with V4L2 that makes the implementation seem too tricky to tackle at the moment?

yellowdoge commented 7 years ago

Yeah, there's a private webcam extension (code), essentially a JS-surfaced IDL directly touching the filesystem /dev/videoX to manipulate zoom, pan and tilt for certain cameras (more code). The issue that prompted that commit was to avoid resetting those controls because the clients of this extension API relied on the V4L2 API persisting the configuration values.

dsanders11 commented 7 years ago

Would that pose a large problem for adding pan and tilt constraints, or does it seem possible to work around?

yellowdoge commented 7 years ago

I think the private api should not prevent consensus and addition to the spec of this new capabilities/constraints, but from the point of view of the implementation, we should have a way to allow those users an easy migration and right now they rely on the UVC camera to store the last configured state (except across reboots). Such path could be provided via a method to return constraints to their default values; a discussion did not really clarify to me if applyConstraints() (with an empty dictionary) would clear all constraints (which would cover my needs), or do nothing at all :-)

@jan-ivar, wdyt?

jan-ivar commented 7 years ago

Yes applyConstraints({}) removes all your constraints, leaving the device "unconstrained" if you are the only user. Other tabs may be accessing the same device, but barring that edge-case, the API should¹ play well with outside controls (which could even be a web api in a different tab).

As to "default values", constraints is a device settings API. Device setting defaults may vary from browser to browser, device to device, or even the situation, so never rely on them. If you care about a setting, constrain it.

1. In theory. The browser is the ultimate owner of the device. How well it plays with others depends.

dsanders11 commented 7 years ago

@yellowdoge, @jan-ivar, unless any reasons not to, I'll go ahead and make a PR adding pan and tilt to the spec, after the focus distance PR is finished (still waiting on IPR stuff).

yellowdoge commented 7 years ago

Ofc, please go ahead, we'll debate over the PR.