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

Image files are unable to load after camera stream. #441

Open
Forchapeatl opened this issue Aug 4, 2022 · 2 comments
Open

Image files are unable to load after camera stream. #441

Forchapeatl opened this issue Aug 4, 2022 · 2 comments
Labels

Comments

@Forchapeatl
Copy link
Collaborator

Image files are unable to load after camera stream.

@jywarren , please i can't seem to diagnose the source of this unexpected behavior. Could you help me please?

f7cea621-a077-4cfe-a1ac-f0bc38c5.mp4

Originally posted by @Forchapeatl in #439 (comment)

@Forchapeatl Forchapeatl changed the title **Image files are unable to load after camera stream.** Image files are unable to load after camera stream. Aug 4, 2022
@jywarren
Copy link
Member

jywarren commented Aug 5, 2022

OK, so i think when we start video mode, we begin a loop to fetch images from the video element. When we try to go back to upload mode, we need to find and halt that loop. Let me look...

Yes, we do it in this function:

// split into processor.video() methods
options.video = function video() {
options.camera.initialize();
var interval;
if (options.processor.type == "webgl") interval = 15;
else interval = 150;
setInterval(function() {
if (image) options.run(options.mode);
options.camera.getSnapshot();
//if (options.colorized) return options.colorize();
}, interval);
}

And that function is called from here:

$("#webcam-activate").click(function() {
$('.choose-prompt').hide();
$("#save-modal-btn").show();
$("#save-zone").show();
save_infragrammar_inputs();
options.video();
$('#preset-modal').modal('show');
return true;
});

So we have to save the setInterval object and stop it with clearInterval(). Intervals are a little weird but they are just repeated timers. You can read how they work here! https://developer.mozilla.org/en-US/docs/Web/API/setInterval#return_value There are good examples lower on that page that you can model to use here. But, I think we could also solve this in a separate PR - i don't think it's your code that's causing it, it's already the case in the main branch!

And, solving it may be a little more complex, we have to think carefully about where we store the interval return value so that we can make a stopVideo() function, probably? I can help you figure that out too but we might as well move this whole comment thread to its own issue, what do you think?

@ojninja16
Copy link

HI @Forchapeatl I would like to try ...if no one else is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants