Commit 6a8f57e5 authored by Florian Echtler's avatar Florian Echtler Committed by Alexander Alekhin

Merge pull request #10081 from floe:java-camera2-view

* add (untested) JavaCamera2View class

* initial fixes

* minor cleanup

* exclude JavaCamera2View from build for older SDK version

* fix method name typo

* add asserts + sanity checks

* fix preview format checks

* fix the memory leak

* export cvtTwoPlaneYUVtoBGR for Java usage

* add handling for two-plane YUV frames (C wrapper still missing)

* add two-plane cvtColor helper function

* fix warnings

* actually use the new cvtColorTwoPlane helper func

* fix wrong output matrix size

* fix wrong conversion type

* simplify method signature, add error condition

* minor fixes to Mat types

* remove leftover semaphore from camera api 1

* android: JavaCamera2View minor refactoring

- re-apply Java code style
- imports cleanup
- dump exceptions information

* android: JavaCamera2View: pause/resume fixes

* android: JavaCamera2View: fix mScale
parent eb94dfb4
......@@ -3694,6 +3694,8 @@ channels is derived automatically from src and code.
*/
CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 );
CV_EXPORTS_W void cvtColorTwoPlane( InputArray src1, InputArray src2, OutputArray dst, int code );
//! @} imgproc_misc
// main function for all demosaicing processes
......
......@@ -11050,6 +11050,42 @@ inline bool isFullRange(int code)
} // namespace::
// helper function for dual-plane modes
void cv::cvtColorTwoPlane( InputArray _ysrc, InputArray _uvsrc, OutputArray _dst, int code )
{
// only YUV420 is currently supported
switch (code) {
case COLOR_YUV2BGR_NV21: case COLOR_YUV2RGB_NV21: case COLOR_YUV2BGR_NV12: case COLOR_YUV2RGB_NV12:
case COLOR_YUV2BGRA_NV21: case COLOR_YUV2RGBA_NV21: case COLOR_YUV2BGRA_NV12: case COLOR_YUV2RGBA_NV12:
break;
default:
CV_Error( CV_StsBadFlag, "Unknown/unsupported color conversion code" );
return;
}
int stype = _ysrc.type();
int depth = CV_MAT_DEPTH(stype), uidx, dcn;
Mat ysrc, uvsrc, dst;
ysrc = _ysrc.getMat();
uvsrc = _uvsrc.getMat();
Size ysz = _ysrc.size();
Size uvs = _uvsrc.size();
// http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples
// http://www.fourcc.org/yuv.php#NV12 -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
dcn = (code==COLOR_YUV420sp2BGRA || code==COLOR_YUV420sp2RGBA || code==COLOR_YUV2BGRA_NV12 || code==COLOR_YUV2RGBA_NV12) ? 4 : 3;
uidx = (code==COLOR_YUV2BGR_NV21 || code==COLOR_YUV2BGRA_NV21 || code==COLOR_YUV2RGB_NV21 || code==COLOR_YUV2RGBA_NV21) ? 1 : 0;
CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( ysz.width == uvs.width * 2 );
CV_Assert( ysz.width % 2 == 0 && depth == CV_8U );
CV_Assert( ysz.height == uvs.height * 2 );
_dst.create( ysz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
hal::cvtTwoPlaneYUVtoBGR(ysrc.data, uvsrc.data, ysrc.step, dst.data, dst.step, dst.cols, dst.rows, dcn, swapBlue(code), uidx);
}
//////////////////////////////////////////////////////////////////////////////////////////
// The main function //
//////////////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment