I'm trying to get the camera to focus on an object, by using focusMode
on the stream track received from getUserMedia
. But after changing the property of focus mode to manual
mode, I don't see it reflect on the stream also I could see that after applying focusMode
constraint it stays unchanged(focusMode: continuous
). The issue is when I capture an image, using the stream, the image is blurry because of lack of focus.
Here is a code snippet.
navigator.mediaDevices.getUserMedia({ video: true })
.then((stream) => {
video.srcObject = stream;
track = stream.getVideoTracks()[0];
track.applyConstraints({
advanced: [
{ focusMode: 'manual', focusDistance: 0.33 }
]
})
});
Does anybody have experience with getting the camera to focus using the manual
or single-shot
mode? Any help is appreciated.