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

Add support to convert from NV12 and YUYV to RGB #825

Open
yongtang opened this issue Mar 3, 2020 · 8 comments
Open

Add support to convert from NV12 and YUYV to RGB #825

yongtang opened this issue Mar 3, 2020 · 8 comments

Comments

@yongtang
Copy link
Member

yongtang commented Mar 3, 2020

Video capture has been supported in tensorflow-io (see PR #821), through Video4Linux on Linux and AVFoundation on macOS. Now we are able to extract video captures and output raw image format as a Dataset.

The raw format, by default, is kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange (NV12) on macOS, and V4L2_PIX_FMT_YUYV (YUYV) on Linux, they will need to be converted to RGB so that they could be further processed by tf's common ops.

This is an issue to track the progress for NV12 and YUYV support.

/cc @bhack

@bhack
Copy link

bhack commented Mar 3, 2020

@julienvalentin do you plan to expand color conversion namespace in tf.graphics or move It in tf.image?

yongtang added a commit to yongtang/io that referenced this issue Mar 25, 2020
This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
yongtang added a commit to yongtang/io that referenced this issue Mar 25, 2020
This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
yongtang added a commit to yongtang/io that referenced this issue Mar 27, 2020
This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
yongtang added a commit to yongtang/io that referenced this issue Mar 28, 2020
This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
yongtang added a commit to yongtang/io that referenced this issue Mar 30, 2020
This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang
Copy link
Member Author

Let me reopen this one for the following comment:

Do we plan to use GPU operation like
https://docs.nvidia.com/cuda/npp/group__nv12torgb.html#details?

@yongtang yongtang reopened this Mar 31, 2020
@bhack
Copy link

bhack commented Mar 31, 2020

I don't know if we would depend on nv12 for nvidia GPU. I suppose that also intel on linux support that in https://github.com/intel/libva.
Yes hwacceleration is well known mess https://trac.ffmpeg.org/wiki/HWAccelIntro 😟

@bhack
Copy link

bhack commented Mar 31, 2020

@bhack Yes it is definitely on the roadmap. In fact in last month's meeting we also discussed about the possible MLIR integration into tensorflow-io. Will need to do some exploration work first, though.

Yes this is super interesting also for other image processing ops that are landing in Addons PRs. Can you share something more about this topic (MLIR tensorflow-io integration)?

@yongtang
Copy link
Member Author

@bhack We are still in exploration mode.. but will circle back soon.

@bhack
Copy link

bhack commented Mar 31, 2020

Let me know

@bhack
Copy link

bhack commented Apr 1, 2020

/cc @antiagainst As he is active in MLIR but also in the Vlukan ML WG. Seems that Vulkan announced HW video enc/dec for H1 2020 https://www.khronos.org/assets/uploads/apis/Vulkan-1-2-Launch_Jan20.pdf

i-ony pushed a commit to i-ony/io that referenced this issue Feb 8, 2021
* Add decode_nv12 to allow convert nv12 to rgb

This PR adds support of decode_nv12 decode_nv12 to allow convert nv12 to rgb.
This is useful for Video Capture and MP4 decoding on macOS, as macOS's
default pixel format is NV12 (hardware-accelerated)

This PR fixes 825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Add decode_yuy2 (YUYV/YUY2/YUYV422) support

This PR adds support of decode_yuy2 to allow convert yuy2 to rgb.
This is useful for Video Capture in Linux (Video4Linux2) as the default
format is YUYV.

This PR fixes tensorflow#825

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@Sherlock-hh
Copy link

hello, may i ask how to use this function? i tried to use it in tensorflow 1.14.0 like tf.image.decode_nv12() but it's reports AttributeError: module 'tensorflow._api.v1.image' has no attribute 'decode_nv12', and can i make the input belike a yuv image which size is (n,1.5*height, width,1) and get rgb outputs will belike (n,height,width,3)?
looking for your reply,thank u very much!

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

3 participants