Capturing CameraStream raises error "No data, did you record anything?"
See original GitHub issueI am trying to capture 100 snapshots programatically from my webcam but somehow, the ImageRecorder
does not record any image. However, when capturing the images using the dedicated widget button, it works like charm.
This is my code:
First code block (which simply shows the user the webcam input)
from ipywebrtc import CameraStream, ImageRecorder
from time import sleep
camera = CameraStream.facing_user(audio=False)
camera
Second code block (which should capture 100 shots from the camera):
recorder = ImageRecorder(stream=camera)
recorder.recording = True
for i in range(1,100):
sleep(0.1)
recorder.save("webcam/" + str(i) + ".png")
Executing the last block, the following error appears:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-77bec100e9f4> in <module>
4 for i in range(1,100):
5 sleep(0.1)
----> 6 recorder.save("webcam/" + str(i) + ".png")
c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\ipywebrtc\webrtc.py in save(self, filename)
397 filename += '.' + self.format
398 if len(self.image.value) == 0:
--> 399 raise ValueError('No data, did you record anything?')
400 with open(filename, 'wb') as f:
401 f.write(self.image.value)
ValueError: No data, did you record anything?
What am I missing here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top Results From Across the Web
Capture video from camera/file with OpenCV in Python
In Python, you can read, capture, and display video files and camera stream using the VideoCapture class with OpenCV.
Read more >4. Advanced Recipes — Picamera 1.13 Documentation
Capturing to a numpy array¶. Since 1.11, picamera can capture directly to any object which supports Python's buffer protocol (including numpy's ndarray )....
Read more >Freely Accessing Your Own Nest HD Camera Stream - Den
A twist on a project I worked on a couple of years ago, that makes it easier to get the Nest HD camera...
Read more >How to Access a Webcam and Record Video with JavaScript
Learn how to access a webcam and record video using JavaScript. ... Download Code h... ... Your browser can 't play...
Read more >MediaCapture Class (Windows.Media.Capture)
To capture video, the image encoding profile can be set to Auto or you need to specify an encoding profile that matches the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It finally works 🎉 In case someone wants to do the same as I want, this is the code:
I’m not sure I get why…
This could make it work, but I don’t see why it is needed: