From e95d0b51393a697665e79dfb9363335f960a3dfe Mon Sep 17 00:00:00 2001 From: BlueMatthew Date: Tue, 16 Jan 2024 18:42:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcrash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/camera2/ndkcamera.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index 09018c7f..1ca37387 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -713,11 +713,12 @@ bool NdkCamera::on_image(cv::Mat& rgb) void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_height) { - ALOGW("nv21 size: %d x %d", nv21_width, nv21_height); + // ALOGW("nv21 size: %d x %d", nv21_width, nv21_height); // rotate nv21 int w = 0; int h = 0; int rotate_type = 0; + cv::Mat nv21_rotated; const unsigned char* yuv420data = nv21; // TODO !!!??? // int co = camera_orientation > 0 ? camera_orientation + 90 : camera_orientation; @@ -739,26 +740,26 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei h = nv21_height; rotate_type = camera_facing == 0 ? 2 : 1; } - if (co == 90) + else if (co == 90) { w = nv21_height; h = nv21_width; rotate_type = camera_facing == 0 ? 5 : 6; } - if (co == 180) + else if (co == 180) { w = nv21_width; h = nv21_height; rotate_type = camera_facing == 0 ? 4 : 3; } - if (co == 270) + else if (co == 270) { w = nv21_height; h = nv21_width; rotate_type = camera_facing == 0 ? 7 : 8; } - cv::Mat nv21_rotated(h + h / 2, w, CV_8UC1); + nv21_rotated.create(h + h / 2, w, CV_8UC1); ncnn::kanna_rotate_yuv420sp(nv21, nv21_width, nv21_height, nv21_rotated.data, w, h, rotate_type); yuv420data = nv21_rotated.data; }