-
Notifications
You must be signed in to change notification settings - Fork 143
VideoFrame needs an way to export pixels into ImageData #660
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
Comments
Looks like So having a method is just the difference between:
If we were to add an API, it seems we'd want something simpler, but mirroring canvas API:
Or if we need a synchronous method just using the canvas name:
We can't get rid of the copy, so the two issues developers face today here are:
Enhancing copyTo to allow format changes (or at least only to RGBA/BGRA) seems like a good first step. |
Indeed if But adding format conversion to `copyTo() would require either
Adding a specific method intended for RGBA conversion resolves the practical need without having to solve generic format conversion in |
I think we'd just have |
If we're sure we can determine format support synchronously, we could also have |
Closing this in favor of #92 (comment) |
VideoFrame
s can have multiple pixel formats depending on where they come from.Currently
VideoFrame.copyTo()
doesn't do format conversions and can only export data in the same pixel format.It's a bit complicated to spec and implement universal format conversion in
copyTo()
(#92)Most image/video processing libraries (for example opencv.js and tensorflow.js) accept
ImageData
as an input.So it makes sense to remove the format conversion burden from website/app developers and introduce a way to read-back
VideoFrame
s intoImageData
converting pixel format to RGBA along the way.Something like
VideoFrame.copyToImageData(imagedata, x, y)
imagedata
theImageData
to read to and to getwidth
andheight
of the rectangle from which the ImageData will be extracted.x
andy
- coordinates of the top-left corner of the rectangle from which the ImageData will be extracted.Most likely most developers currently achieve the same result by drawing the frame on the canvas and calling
CanvasRenderingContext2D.getImageData()
later. But it introduces unnecessary copies along the way.The text was updated successfully, but these errors were encountered: