|
|
@ -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)
|
|
|
|
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
|
|
|
|
// rotate nv21
|
|
|
|
int w = 0;
|
|
|
|
int w = 0;
|
|
|
|
int h = 0;
|
|
|
|
int h = 0;
|
|
|
|
int rotate_type = 0;
|
|
|
|
int rotate_type = 0;
|
|
|
|
|
|
|
|
cv::Mat nv21_rotated;
|
|
|
|
const unsigned char* yuv420data = nv21;
|
|
|
|
const unsigned char* yuv420data = nv21;
|
|
|
|
// TODO !!!???
|
|
|
|
// TODO !!!???
|
|
|
|
// int co = camera_orientation > 0 ? camera_orientation + 90 : camera_orientation;
|
|
|
|
// 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;
|
|
|
|
h = nv21_height;
|
|
|
|
rotate_type = camera_facing == 0 ? 2 : 1;
|
|
|
|
rotate_type = camera_facing == 0 ? 2 : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (co == 90)
|
|
|
|
else if (co == 90)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
w = nv21_height;
|
|
|
|
w = nv21_height;
|
|
|
|
h = nv21_width;
|
|
|
|
h = nv21_width;
|
|
|
|
rotate_type = camera_facing == 0 ? 5 : 6;
|
|
|
|
rotate_type = camera_facing == 0 ? 5 : 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (co == 180)
|
|
|
|
else if (co == 180)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
w = nv21_width;
|
|
|
|
w = nv21_width;
|
|
|
|
h = nv21_height;
|
|
|
|
h = nv21_height;
|
|
|
|
rotate_type = camera_facing == 0 ? 4 : 3;
|
|
|
|
rotate_type = camera_facing == 0 ? 4 : 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (co == 270)
|
|
|
|
else if (co == 270)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
w = nv21_height;
|
|
|
|
w = nv21_height;
|
|
|
|
h = nv21_width;
|
|
|
|
h = nv21_width;
|
|
|
|
rotate_type = camera_facing == 0 ? 7 : 8;
|
|
|
|
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);
|
|
|
|
ncnn::kanna_rotate_yuv420sp(nv21, nv21_width, nv21_height, nv21_rotated.data, w, h, rotate_type);
|
|
|
|
yuv420data = nv21_rotated.data;
|
|
|
|
yuv420data = nv21_rotated.data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|