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

TraitError: The 'filename' trait of an ImageRecorder instance must be a unicode string #52

Open
chalgand opened this issue May 29, 2019 · 5 comments

Comments

@chalgand
Copy link

Hello,

I would like to apply visual processing on stream of my camera but...

from ipywebrtc import CameraStream, ImageRecorder
camera = CameraStream(constraints=
                                      {'facing_mode': 'user',
                                       'audio': False,
                                       'video': { 'width': 640, 'height': 480 }
                                       })
camera
image_recorder = ImageRecorder(stream=camera)
image_recorder

I get an error by IPython on my jupyter lab :
TraitError: The 'filename' trait of an ImageRecorder instance must be a unicode string, but a value of traitlets.Undefined <class 'traitlets.utils.sentinel.Sentinel'> was specified.

Best,

@martinRenou
Copy link
Collaborator

Which version of ipywebrtc are you using? If not 0.4.3 would you mind trying to update ipywebrtc? I suppose this is fixed in the last release.

As a workaround, you can try this code:

from ipywebrtc import CameraStream, ImageRecorder
camera = CameraStream(constraints=
                                      {'facing_mode': 'user',
                                       'audio': False,
                                       'video': { 'width': 640, 'height': 480 }
                                       })
camera
image_recorder = ImageRecorder(stream=camera, filename='record')
image_recorder

@chalgand
Copy link
Author

Hi Martin,

I have a conda environment up to date :
-ipywebrtc 0.4.3

  • python 3.7.3
  • jupyterlab 0.35.4

The full error message is :
`

TraitError Traceback (most recent call last)
in
----> 1 image_recorder = ImageRecorder(stream=camera)
2 image_recorder

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\ipywebrtc\webrtc.py in init(self, format, filename, recording, autosave, **kwargs)
352 def init(self, format='png', filename=Undefined, recording=False, autosave=False, **kwargs):
353 super(ImageRecorder, self).init(
--> 354 format=format, filename=filename, recording=recording, autosave=autosave, **kwargs)
355 if 'image' not in kwargs:
356 # Set up initial observer on child:

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\ipywidgets\widgets\widget.py in init(self, **kwargs)
409 """Public constructor"""
410 self._model_id = kwargs.pop('model_id', None)
--> 411 super(Widget, self).init(**kwargs)
412
413 Widget._call_widget_constructed(self)

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in init(self, *args, **kwargs)
995 for key, value in kwargs.items():
996 if self.has_trait(key):
--> 997 setattr(self, key, value)
998 else:
999 # passthrough args that don't set traits to super

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in set(self, obj, value)
583 raise TraitError('The "%s" trait is read-only.' % self.name)
584 else:
--> 585 self.set(obj, value)
586
587 def _validate(self, obj, value):

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in set(self, obj, value)
557
558 def set(self, obj, value):
--> 559 new_value = self._validate(obj, value)
560 try:
561 old_value = obj._trait_values[self.name]

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in _validate(self, obj, value)
589 return value
590 if hasattr(self, 'validate'):
--> 591 value = self.validate(obj, value)
592 if obj._cross_validation_lock is False:
593 value = self._cross_validate(obj, value)

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in validate(self, obj, value)
2052 msg = "Could not decode {!r} for unicode trait '{}' of {} instance."
2053 raise TraitError(msg.format(value, self.name, class_of(obj)))
-> 2054 self.error(obj, value)
2055
2056

C:\ProgramData\Anaconda3\envs\formation\lib\site-packages\traitlets\traitlets.py in error(self, obj, value)
623 e = "The '%s' trait must be %s, but a value of %r was specified."
624 % (self.name, self.info(), repr_type(value))
--> 625 raise TraitError(e)
626
627 def get_metadata(self, key, default=None):

TraitError: The 'filename' trait of an ImageRecorder instance must be a unicode string, but a value of traitlets.Undefined <class 'traitlets.utils.sentinel.Sentinel'> was specified.
`

Regards,

@martinRenou
Copy link
Collaborator

Weird, I would have thought it is fixed on the last release.

Did you try the workaround I gave you?

@chalgand
Copy link
Author

Oh, i'm sorry.

Your code works fine ! Thank you

Best regards

@martinRenou
Copy link
Collaborator

If you don't mind I will keep this issue opened until we fix it properly.

Thanks a lot for reporting this issue!

@martinRenou martinRenou reopened this May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants