|
|
|
@ -457,7 +457,6 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START;
|
|
|
|
|
// status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig);
|
|
|
|
|
m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
@ -744,6 +743,8 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int orgWidth = mWidth;
|
|
|
|
|
int orgHeight = mHeight;
|
|
|
|
|
// int co = camera_orientation > 0 ? camera_orientation + 90 : camera_orientation;
|
|
|
|
|
if (m_params.orientation != 0)
|
|
|
|
|
{
|
|
|
|
@ -771,6 +772,10 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
|
{
|
|
|
|
|
w = nv21_height;
|
|
|
|
|
h = nv21_width;
|
|
|
|
|
|
|
|
|
|
orgWidth = mHeight;
|
|
|
|
|
orgHeight = mWidth;
|
|
|
|
|
|
|
|
|
|
rotate_type = camera_facing == ACAMERA_LENS_FACING_FRONT ? 5 : 6;
|
|
|
|
|
}
|
|
|
|
|
else if (co == 180)
|
|
|
|
@ -783,6 +788,10 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
|
{
|
|
|
|
|
w = nv21_height;
|
|
|
|
|
h = nv21_width;
|
|
|
|
|
|
|
|
|
|
orgWidth = mHeight;
|
|
|
|
|
orgHeight = mWidth;
|
|
|
|
|
|
|
|
|
|
rotate_type = camera_facing == ACAMERA_LENS_FACING_FRONT ? 7 : 8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -799,7 +808,7 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
|
|
|
|
|
|
// nv21_rotated to rgb
|
|
|
|
|
cv::Mat rgb;
|
|
|
|
|
if (w == mWidth && h == mHeight)
|
|
|
|
|
if (w == orgWidth && h == orgHeight)
|
|
|
|
|
{
|
|
|
|
|
rgb.create(h, w, CV_8UC3);
|
|
|
|
|
// ncnn::yuv420sp2rgb(nv21_rotated.data, w, h, rgb.data);
|
|
|
|
@ -809,16 +818,16 @@ void NdkCamera::on_image(const unsigned char* nv21, int nv21_width, int nv21_hei
|
|
|
|
|
{
|
|
|
|
|
cv::Mat org(h, w, CV_8UC3);
|
|
|
|
|
ncnn::yuv420sp2rgb_nv12(yuv420data, w, h, org.data);
|
|
|
|
|
if (w * mHeight == h * mWidth) // Same Ratio
|
|
|
|
|
if (w * orgHeight == h * orgWidth) // Same Ratio
|
|
|
|
|
{
|
|
|
|
|
cv::resize(org, rgb, cv::Size(mWidth, mHeight));
|
|
|
|
|
cv::resize(org, rgb, cv::Size(orgWidth, orgHeight));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Crop image
|
|
|
|
|
int left = (w - mWidth) / 2;
|
|
|
|
|
int top = (h - mHeight) / 2;
|
|
|
|
|
rgb = org(cv::Range(top, top + mHeight), cv::Range(left, left + mWidth));
|
|
|
|
|
int left = (w - orgWidth) / 2;
|
|
|
|
|
int top = (h - orgHeight) / 2;
|
|
|
|
|
rgb = org(cv::Range(top, top + orgHeight), cv::Range(left, left + orgWidth));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
on_image(rgb);
|
|
|
|
|