# cv::VideoCapture::read() empty frames

**URL:** <https://forum.opencv.org/t/cv-read-empty-frames/16820>\
**Category:** Android/Java\
**Tags:** android, ndk, videoio\
**Created:** [March 15, 2024, 1:49am UTC](https://forum.opencv.org/t/cv-read-empty-frames/16820 "2024-03-15T01:49:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzavala](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/jzavala/32/9910_2.png) [@jzavala](https://forum.opencv.org/u/jzavala)\
**Post date:** [March 15, 2024, 1:49am UTC](https://forum.opencv.org/t/cv-read-empty-frames/16820/1 "2024-03-15T01:49:51Z")

</div>

Hello OpenCV Community

On Android C++ I’m getting empty frames from cv::VideoCapture:read() basically im doing this:

```auto
VideoCapture camera;
camera.open(index, mode);

if (camera.isOpened())//it's ok here
    return 0.0;
    
cv::Mat frame;
bool ret = camera.read(frame);//return true

//buff_img it's my buffer that I send to surface, but on android it's empty
std::memcpy(buff_img, frame_.data, frame_.total()*4);

```

This code works perfectly on Windows, iOS, MacOS and I need make it work on Android

Exactly same issue was experimented by someone else in this post: [How to open camera with cv::VideoCapture in Android Native C++ - Stack Overflow](https://stackoverflow.com/a/78058614/23564895)

First the problem was build the custom framework and get video features and now are that frames are empty.

(I can see that the camera it’s opened, due a light that appear when the camera it’s on use)

Any idea of how handle it?

Regards

---

<div class="post-metadata">

**Author:** ![jzavala](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/jzavala/32/9910_2.png) [@jzavala](https://forum.opencv.org/u/jzavala)\
**Post date:** [March 15, 2024, 2:56pm UTC](https://forum.opencv.org/t/cv-read-empty-frames/16820/2 "2024-03-15T14:56:07Z")

</div>

@berak Can you take a look? (sorry for the tag)

---

<div class="post-metadata">

**Author:** ![jzavala](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/jzavala/32/9910_2.png) [@jzavala](https://forum.opencv.org/u/jzavala)\
**Post date:** [March 21, 2024, 3:13pm UTC](https://forum.opencv.org/t/cv-read-empty-frames/16820/3 "2024-03-21T15:13:12Z")

</div>

Well, after a some research I succeed it avoiding read() and working on the JAVA side based in this file: [opencv/modules/java/generator/android-24/java/org/opencv/android/NativeCameraView.java at 3aefd4862c5ee92918e15d96e9973cbfde48e5c2 · opencv/opencv · GitHub](https://github.com/opencv/opencv/blob/3aefd4862c5ee92918e15d96e9973cbfde48e5c2/modules/java/generator/android-24/java/org/opencv/android/NativeCameraView.java#L7)
