Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate latest camera selection API from getUserMedia #39

Open
jywarren opened this issue Jan 3, 2019 · 34 comments
Open

Integrate latest camera selection API from getUserMedia #39

jywarren opened this issue Jan 3, 2019 · 34 comments
Labels
enhancement gsoc Issues associated with Google Summer of Code(GSOC) help wanted

Comments

@jywarren
Copy link
Member

jywarren commented Jan 3, 2019

Potentially using a new getUserMedia shim library?

https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Parameters

Maybe using https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices

Code for this is here:

var webRtcOptions = options.webRtcOptions || {
"audio": false,
"video": true,
// the element (by id) you wish to use for
// displaying the stream from a camera
el: "webcam",
extern: null,
append: true,
// height and width of the output stream
// container
width: 640,
height: 480,

We can apparently also specify different resolutions!

{
  audio: true,
  video: {
    width: { min: 1024, ideal: 1280, max: 1920 },
    height: { min: 776, ideal: 720, max: 1080 }
  }
}

Let's do both!

@jywarren
Copy link
Member Author

jywarren commented Nov 6, 2020

Noting this was done in spectral-workbench.js here -- using Temasys - publiclab/spectral-workbench.js#173

Also noting: https://github.com/webrtcHacks/WebRTC-Camera-Resolution

@jywarren
Copy link
Member Author

This could be integrated with the initial work of this PR where we try to dynamically set the pixel resolution/size: #21

@Somya-Singhal
Copy link
Contributor

Hello @jywarren, I am an outreachy applicant. I would like to work on this issue.

@jywarren
Copy link
Member Author

jywarren commented Apr 5, 2022

Hello @Somya-Singhal this will be part of the work of the Outreachy project itself, so we aren't quite ready to begin coding. However, if you would like to help research where changes will have to be made, or add other contextual information here, to prepare, that would be appreciated! Thank you!!

@Somya-Singhal
Copy link
Contributor

Somya-Singhal commented Apr 29, 2022

I have gone through the link you provided above and found that we could some more features like:

  1. implement it in a way that it could also be used in old browsers.

  2. In some cases, lower frame rates may be desirable, so we could add bandwidth restrictions.
    var constraints = { video: { frameRate: { ideal: 10, max: 15 } } };

  3. For mobile devices, rear camera would be preferred over the front camera, so we could add:
    { audio: true, video: { facingMode: { exact: "environment" } } }

If we want to add both, front as well as rear camera for mobile devices, we can also use this:
var front = false; document.getElementById('flip-button').onclick = function() { front = !front; }; var constraints = { video: { facingMode: (front? "user" : "environment") } };

@Forchapeatl Forchapeatl added the gsoc Issues associated with Google Summer of Code(GSOC) label Jul 31, 2022
@Forchapeatl
Copy link
Collaborator

Forchapeatl commented Jul 31, 2022

The integration of Temasys on infragram has been a success . Now iOs users can perform vegetation analysis over Webcam stream.

Problem: only The first input frame is captured for both live stream and Prerecorded video on Safari (iOS)

Hello @jywarren , @TildaDares , @cesswairimu , @stephaniequintana and @RaviAnand111 please help me test the webcam and local video behavior at your end https://forchapeatl.github.io/infragram/indexT.html#

VID-20220801-WA0002.mp4

@RaviAnand111
Copy link

Hey @Forchapeatl , I tried the link and its working great on chrome in Manjaro OS, both the image and live video.
Thanks

@stephaniequintana
Copy link
Collaborator

@Forchapeatl - I'm on a MacBook Air (macOS Catalina) and both uploading a video and connecting to the webcam are working great on Chrome and Firefox, but neither work on Safari.

For the webcam on Safari, I get a black screen after clicking the webcam button and when I try to upload a video (mp4) the selection is disabled in the file list and thus I am unable to select it. Perhaps this is a simple setting on my end(?) - Please let me know if you would like me to try another browser or video format.

@jywarren
Copy link
Member Author

jywarren commented Aug 2, 2022

Hi @stephaniequintana if you don't first try to connect to a webcam, does video upload work normally in Safari? That is, is the attempt to connect to a webcam interfering with video upload, or does it not work at all in Safari? Thank you!

@stephaniequintana
Copy link
Collaborator

@jywarren, I believe it's due to a bug in Safari that hasn't been addressed. I found a short discussion on stack overflow (from 2014!!) about it - the suggested "solution" does not work for me - and am hoping it's isolated to macOS Catalina. I didn't dive deeper than this, though.

The webcam in not causing interference. This happens whenever I try to upload a video to the site in Safari.

@Forchapeatl
Copy link
Collaborator

@jywarren , @stephaniequintana and @RaviAnand111 , I appreciate the feedbacks. Thank you!

@Forchapeatl
Copy link
Collaborator

Hello @jywarren .
This is the implementation of P5.js https://forchapeatl.github.io/infragram/indexP.html

Existing Limitations

  • CreateCaputure( ) gets called only within the setup( ) function.
  • The setup() gets called once.
  • Hence we can stream once.
  • We won't be able to toggle between camera and video streams.

References
https://p5js.org/reference/#/p5/createCapture
https://p5js.org/reference/#/p5/setup
https://forchapeatl.github.io/infragram/indexP.html

Request

Please may we use getUserMedia API to move forward on camera stream. Here is a working example on safari https://codepen.io/ocinpp/pen/EpbXKz . The trick on safari is to use async functions

@jywarren
Copy link
Member Author

jywarren commented Aug 4, 2022

I think this sounds great and if it works in safari iOS I'm super happy. I don't think it has to toggle back and forth. People can reload. Let's do this! Is it ready to merge?

I think it's interesting to know if it works on Firefox in Arch Linux but if it doesn't, let's try thinking on that in a separate issue/pr. Thanks all!

@Forchapeatl
Copy link
Collaborator

@jywarren Please I am abit confused.
P5.js or getUserMedia ? They both work on Safari

@jywarren
Copy link
Member Author

jywarren commented Aug 4, 2022

@jywarren, I believe it's due to a bug in Safari that hasn't been addressed. I found a short discussion on stack overflow (from 2014!!) about it - the suggested "solution" does not work for me - and am hoping it's isolated to macOS Catalina. I didn't dive deeper than this, though.

The webcam in not causing interference. This happens whenever I try to upload a video to the site in Safari.

Regarding this shall we open it in a new issue? Thank you?

@jywarren
Copy link
Member Author

jywarren commented Aug 5, 2022 via email

@Forchapeatl
Copy link
Collaborator

Forchapeatl commented Aug 5, 2022

@jywarren It seems all libraries (Temasys, P5.js and getUserMedia) work fine on safari problem is Safari doesn't recognize setInterval() https://stackoverflow.com/questions/12683510/ios-6-safari-setinterval-doesnt-get-fired

setInterval(function() {
if (image) options.run(options.mode);
options.camera.getSnapshot();
//if (options.colorized) return options.colorize();
}, interval);
}

@jywarren, I am sorry for the whole confusion. I just discovered this bug/malfunction now. Thank you I think getUserMedia will help me maintain the codebase. Thank you!

@Forchapeatl
Copy link
Collaborator

Safari doesn't recognize setInterval

@jywarren
Copy link
Member Author

jywarren commented Aug 5, 2022

Oh whoa, really! Wild. It's listed ok here, it's a pretty fundamental JavaScript feature...

https://caniuse.com/?search=setinterval

@jywarren
Copy link
Member Author

jywarren commented Aug 5, 2022

But is it only safari iOS 6 then? Does that happen to be the version you're testing with?

@jywarren
Copy link
Member Author

jywarren commented Aug 5, 2022

Maybe if it's just the one ios version that's older, we can live with it?

@Forchapeatl
Copy link
Collaborator

Yes. I works on chrome IOS smoothly. But on safari nothing happens after capturing the first frame. Please have a look here https://forchapeatl.github.io/infragram/indexs.html

@stephaniequintana
Copy link
Collaborator

@jywarren

Regarding this shall we open it in a new issue?

I don’t know how we could address it, but opening an issue is a good place to document that Safari on MacOS Catalina does not support video upload. We can also use it as a place to collect info on other Mac operating systems…(although my limited research leads me to believe it is isolated to Catalina)

@Forchapeatl
Copy link
Collaborator

@stephaniequintana Please could you test this https://forchapeatl.github.io/infragram/indexs.html . Just the webcam feature on your MacOS . please

@stephaniequintana
Copy link
Collaborator

stephaniequintana commented Aug 5, 2022

edit below...

@Forchapeatl
Copy link
Collaborator

@stephaniequintana , Please,please test on all browsers currently existing on your MacOS. Please

@Forchapeatl
Copy link
Collaborator

@stephaniequintana , Please,please test on all browsers currently existing on your MacOS. Please

It doesn't work on my Phone Safari version 15.5. PLease could you try it on your phone. Sorry for the trouble.

@stephaniequintana
Copy link
Collaborator

@Forchapeatl - No trouble at all, I'm glad I can help...
On my Mac, it works on Chrome and Firefox - but i'm still getting a black screen on Safari.
On my iPhone, it works with the Google Chrome app but it is just picking up the first frame on Safari.

@Forchapeatl
Copy link
Collaborator

Thank you so much @stephaniequintana

@stephaniequintana
Copy link
Collaborator

Is Safari the new Internet Explorer? 😆

@Forchapeatl
Copy link
Collaborator

Forchapeatl commented Aug 5, 2022

Steaming works fine on Safari but setInterval() is problematic

VIDEO-2022-08-05-02-05-11.online-video-cutter.com.mp4

We have an issue with the setInterval() function. may be it doesn't update large buffers

@jywarren should I prepare a PR for the good steaming functionality on safari but open an issue on setInterval( ) malfunction on safari?

@jywarren
Copy link
Member Author

jywarren commented Aug 5, 2022

Yes, let's just move ahead and open a separate issue for the Safari iOS thing. @Forchapeatl would you mind opening it? We may also be able to put a notice that it works in iOS Chrome, so people can still use it.

Safari on MacOS Catalina does not support video upload

I think we'd better open a separate issue for this since it's not iOS, just so the two don't get confused with one another. @stephaniequintana would you mind?

Thanks, both of you!

@jywarren
Copy link
Member Author

jywarren commented Oct 11, 2022 via email

@proy03
Copy link

proy03 commented Feb 6, 2023

@jywarren hey Jeffery, I would love to contribute to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement gsoc Issues associated with Google Summer of Code(GSOC) help wanted
Projects
None yet
Development

No branches or pull requests

6 participants