-
Notifications
You must be signed in to change notification settings - Fork 40
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.value is empty byte string #62
Comments
This is actually the correct behavior. This asynchronicity is due to the communication between the Python back-end and the JavaScript front-end. Another way of dealing with it is to define a callback function that will be called when the image value has changed: def on_value_changed(*args, **kwargs):
# The value has changed! (Note that the following print won't show up in JupyterLab,
# it only shows up in the classical Jupyter Notebook. You need to use the Output
# widget if you want to capture streams in JLab)
print(image_recorder.image.value)
print(args, kwargs)
# Do whatever you want with your newly received image
image_recorder.image.observe(on_value_changed, 'value')
image_recorder.recording = True The Ouptut widget I mention in the comment: https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html This |
Try defining def on_value_changed(_):
global did_the_callback_run
did_the_callback_run = True Also, I suggest using the from ipywidgets import Output
out = Output()
out.layout.border = 'solid'
display(out)
@out.capture()
def on_value_changed(_):
global did_the_callback_run
print("It works!!")
did_the_callback_run = True
It will print it infinitely only if you set from ipywidgets import Output
out = Output()
out.layout.border = 'solid'
display(out)
@out.capture()
def on_value_changed(_):
global did_the_callback_run
print("It works!!")
did_the_callback_run = True
image_recorder.recording = True I would agree that |
Also, it might be super slow to capture frames infinitely... ipywebrtc needs some love in terms of optimization (PRs welcome!). So try using the |
@martinRenou Your suggestions for the infinite loop does not work (at least not for Every time I execute the last cell again, it will add a line to the output but the point was to not needing to do that. |
I found if you display the recorder and hit the camera icon, this actually triggers an infinite loop. Looking at the code, I have no idea what is executed by pressing the camera icon. Does someone have some pointers for me to check what is happening besides setting |
I am running into a similar problem. If the value However, I have noticed that if the callback takes just a bit too long to complete, it will still fail to be called again, even if set to |
Same here... Still buggy... Magic webrtc ....
|
Hi! Was this ever resolved? Also in our case the |
I'm having a strange issue. When I capture an image from the image recorder, it's value ends up being the empty byte string. If I then ask for the value in the subsequent cell, I get the bytes. What's causing this asynchrony? I tried to "fix" it by adding a delay between defining
image
and asking for its value, but that didn't work. What's the "correct" way of reliably grabbing the current camera frame's value?The text was updated successfully, but these errors were encountered: