2

What I'm curious is simple. We created video calling functionality using mobile technology on WebRTC. In addition, I would like to use the OpenCV library to add face detection during video calls. To implement this function, it is necessary to convert Bitmap to WebRTC I420Frame. Is there a way?

ASH
  • 29
  • 3

2 Answers2

0

Using libYuv (https://chromium.googlesource.com/libyuv/libyuv/) would likely be the best way. Once you determine what type the bitmap is (rgb, bgr, argb, etc...), you can pass it to libYuv and it will convert it to i420 for you in an efficient way.

You could also run the calculations yourself if you really wanted to but you wouldn't get the arm specific performance calls that libYuv would do for you.

Josh Mackey
  • 233
  • 2
  • 10
0

Using libYuv https://chromium.googlesource.com/libyuv/libyuv/

The following code works:

size_t file_size = frame.width() * frame.height() * 3;
std::unique_ptr<uint8_t[]> res_rgb_buffer2(new uint8_t[file_size]);
webrtc::ConvertFromI420(frame, webrtc::VideoType::kRGB24, 0,
                                    res_rgb_buffer2.get());

now res_rgb_buffer2 contains a pointer for raw BMP data. you can save it in a file but you need to write file header first. the latter part can be found here.

M.Hefny
  • 2,677
  • 1
  • 26
  • 30