1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #26698 from warped-rudi:mediandk2

AndroidMediaNdkVideoWriter pixel format enhancement #26698

* videoio(Android): Add source pixel formats RGBA and GRAY to AndroidMediaNdkVideoWriter

Let AndroidMediaNdkVideoWriter::write() deduce source pixel format from matrix type:

CV_8UC3 -> BGR   (as before)
CV_8UC4 -> RGBA  (use in conjunction with CvCameraViewFrame)
CV_8UC1 -> GRAY

* samples/android/video-recorder: Send images to VideoWriter in RGBA format

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Rüdiger Ihle
2025-01-03 15:53:00 +01:00
committed by GitHub
parent f65006eee1
commit a6f72f813d
2 changed files with 41 additions and 28 deletions
@@ -164,16 +164,15 @@ public class RecorderActivity extends CameraActivity implements CvCameraViewList
{
Log.d(TAG, "Camera frame arrived");
Mat rgbMat = inputFrame.rgba();
mVideoFrame = inputFrame.rgba();
Log.d(TAG, "Size: " + rgbMat.width() + "x" + rgbMat.height());
Log.d(TAG, "Size: " + mVideoFrame.width() + "x" + mVideoFrame.height());
if (mVideoWriter != null && mVideoWriter.isOpened()) {
Imgproc.cvtColor(rgbMat, mVideoFrame, Imgproc.COLOR_RGBA2BGR);
mVideoWriter.write(mVideoFrame);
}
return rgbMat;
return mVideoFrame;
}
@Override