How Android implements the front camera selfie mirror feature

Source: Internet
Author: User

The default front camera, the text "Xi" is displayed as "IX" when preview (front camera preview has a mirror effect by default), the photo taken is "Xi", how to make the photo taken is also "IX", Which is consistent with preview?



For normal single shooting (non-ZSD or other photo mode), the code that needs to be modified is the Oncmd_capture () method in the NormalShot.cpp file.
The original
bool
Normalshot::
Oncmd_capture ()
{
Autocptlog Cptlog (event_shot_capture);
Mbool ret = mtrue;
Nscamshot::isingleshot *psingleshot = nscamshot::isingleshot::createinstance (static_cast<eshotmode> ( Mu4shotmode), "Normalshot");
......

Shot param
Nscamshot::shotparam Rshotparam (eimgfmt_yuy2,//YUV format
Mshotparam.mi4picturewidth,//picutre width
Mshotparam.mi4pictureheight,//picture height
Mshotparam.mi4rotation,//picture rotation
0,//picture Flip
EPOSTVIEWFMT,//Postview format
Mshotparam.mi4postviewwidth,//postview width
Mshotparam.mi4postviewheight,//postview height
0,//postview rotation
0,//postview Flip
Mshotparam.mu4zoomratio//zoom
);

......
}

Modified to:
bool
Normalshot::
Oncmd_capture ()
{
Autocptlog Cptlog (event_shot_capture);
Mbool ret = mtrue;
Nscamshot::isingleshot *psingleshot = nscamshot::isingleshot::createinstance (static_cast<eshotmode> ( Mu4shotmode), "Normalshot");
......

Shot param
Nscamshot::shotparam Rshotparam (eimgfmt_yuy2,//YUV format
Mshotparam.mi4picturewidth,//picutre width
Mshotparam.mi4pictureheight,//picture height
Mshotparam.mi4rotation,//picture rotation
(Getopenid () ==1 1:0),//picture flip//Here for the modified code, change the value here to 1, the bottom will be the image of the horizontal flip, equivalent to mirror.
EPOSTVIEWFMT,//Postview format
Mshotparam.mi4postviewwidth,//postview width
Mshotparam.mi4postviewheight,//postview height
0,//postview rotation
0,//postview Flip
Mshotparam.mu4zoomratio//zoom
);

......
}

The main parameter rshotparam inside the flip value is changed to 1, a value of 1 means the bottom will be the image to do the horizontal flip, if 0 does not do.
(Getopenid () ==1 in the above changes? 1:0 only for testing, meaning to determine whether the current is the front camera, if it is the front camera, the assignment value is 1)
Please note:
In a real-world application, add a flip parameter to the parameters and pass the flip value to the HAL layer in the app via parameters to notify the bottom of flip. (to avoid affecting CTS tests and three-party applications, do not pin the above mentioned flip value directly to 1.)
The main documents involved in the modification are as follows:
NormalShot.cpp (Mediatek\platform\mt6589\hardware\camera\hal\adapter\scenario\shot\normalshot)
IShot.h (Mediatek\platform\mt6589\hardware\camera\hal\adapter\inc\scenario\shot)
CameraParameters.cpp (Frameworks\av\camera)
CameraParameters.h (Frameworks\av\include\camera)
ParamsManager.update.cpp (Mediatek\hardware\camera\common\paramsmgr\params)
MtkPhotoCamAdapter.Capture.cpp (Mediatek\platform\mt6589\hardware\camera\hal\adapter\mtkphoto)
Camera.java (\frameworks\base\core\java\android\hardware\)

How Android implements the front camera selfie mirror feature

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.