CameraPreviewFragment.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. package com.epson.cameracopy.ui;
  2. import android.app.Service;
  3. import android.content.Intent;
  4. import android.hardware.Camera;
  5. import android.hardware.SensorManager;
  6. import android.os.AsyncTask;
  7. import android.os.Bundle;
  8. import android.view.LayoutInflater;
  9. import android.view.Menu;
  10. import android.view.MenuInflater;
  11. import android.view.MenuItem;
  12. import android.view.View;
  13. import android.view.ViewGroup;
  14. import android.view.WindowManager;
  15. import android.widget.Button;
  16. import androidx.fragment.app.Fragment;
  17. import com.epson.cameracopy.alt.FileUtils;
  18. import com.epson.cameracopy.alt.UiCommon;
  19. import com.epson.cameracopy.device.AptSensorAdapter;
  20. import com.epson.cameracopy.device.CameraFile;
  21. import com.epson.cameracopy.device.CameraPreviewControl;
  22. import com.epson.cameracopy.device.OpenCvCameraView;
  23. import com.epson.cameracopy.device.RectangleDetector;
  24. import org.opencv.android.CameraBridgeViewBase;
  25. import org.opencv.android.OpenCVLoader;
  26. import org.opencv.core.CvType;
  27. import org.opencv.core.Mat;
  28. import org.opencv.core.Point;
  29. import org.opencv.core.Scalar;
  30. import org.opencv.core.Size;
  31. import org.opencv.imgproc.Imgproc;
  32. import java.util.Date;
  33. import java.util.Iterator;
  34. import java.util.List;
  35. import epson.print.R;
  36. import epson.print.imgsel.CameraCopyImageSelectActivity;
  37. /* renamed from: com.epson.cameracopy.ui.CameraPreviewFragment */
  38. public class CameraPreviewFragment extends Fragment implements CameraBridgeViewBase.CvCameraViewListener2, OpenCvCameraView.AutoFocusCallBack {
  39. private static final Scalar COLOR_BLACK = new Scalar(0.0d, 0.0d, 0.0d, 255.0d);
  40. private static final Scalar[] PAPER_SQUARE_COLOR = {new Scalar(255.0d, 0.0d, 0.0d, 255.0d), new Scalar(0.0d, 255.0d, 0.0d, 255.0d)};
  41. private static final Point POSITION_0_0 = new Point(0.0d, 0.0d);
  42. private static final double REFERENCE_ACCELARATION = 0.45d;
  43. private static final String TAG = "CameraPreviewFragment";
  44. private final double AUTO_PICTURE_RANGE_VALUE = AptSensorAdapter.getRangeCompValue(20);
  45. private final int INIT_SPAN = 2;
  46. private final double PAPER_DETECT_VALUE = AptSensorAdapter.getRangeCompValue(45);
  47. private boolean isFragmentVisible;
  48. private boolean mAutoPhotoMode;
  49. private final long mAutoPictureStillTime = 3000;
  50. private SimpleMessageDialogFragment mCameraPictureLowResolutionDialog;
  51. private CameraPreviewControl mCameraPreviewControl;
  52. private boolean mDisableSettingsButton = false;
  53. private float mDisplayDensity;
  54. private int mDisplayRotation;
  55. private View mFunctionBarView;
  56. private final Scalar mGridColor = new Scalar(255.0d, 163.0d, 0.0d, 255.0d);
  57. private final int mGridColorWidth = 1;
  58. private boolean mHasCamera;
  59. private int mInitCount;
  60. private OpenCvCameraView mOpenCvCameraView;
  61. private long mPAfTime;
  62. private final int mPaperSquareCircleSize = 20;
  63. private Button mPhotoSelectButton;
  64. private Button mPhtographButton;
  65. private volatile boolean mPictureTaking;
  66. private final Scalar mPositionCursorColor = new Scalar(255.0d, 0.0d, 0.0d, 255.0d);
  67. private final float mPositionCursorDispRate = 0.05098581f;
  68. private volatile boolean mPreviewActivityStarted;
  69. private Mat mRgba;
  70. private final Point mScreenSize = new Point();
  71. private final AptSensorAdapter mSensorEventListener = new AptSensorAdapter();
  72. private TakePictureTask mTakePictureTask;
  73. private boolean noCameraDialog;
  74. private void startInformationActivity() {
  75. }
  76. static {
  77. OpenCVLoader.initDebug();
  78. }
  79. public void setAppInitFlag(boolean z) {
  80. if (z) {
  81. noCameraDialog = true;
  82. }
  83. }
  84. public boolean isPreviewActivityStarted() {
  85. return mPreviewActivityStarted;
  86. }
  87. public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
  88. View inflate = layoutInflater.inflate(R.layout.fragment_camera_preview, viewGroup, false);
  89. setHasOptionsMenu(true);
  90. setButtonListener(inflate);
  91. mOpenCvCameraView = (OpenCvCameraView) inflate.findViewById(R.id.view1);
  92. if (CameraPreviewControl.hasBackCamera()) {
  93. mHasCamera = true;
  94. mOpenCvCameraView.setCvCameraViewListener((CameraBridgeViewBase.CvCameraViewListener2) this);
  95. } else {
  96. mHasCamera = false;
  97. UiCommon.setButtonEnabled(mPhtographButton, false);
  98. if (bundle == null && noCameraDialog) {
  99. noCameraDialog = false;
  100. SimpleMessageDialogFragment.newInstance(R.string.back_camera_not_exists_message).show(getFragmentManager(), "error-dialog");
  101. }
  102. }
  103. mOpenCvCameraView.setVisibility(View.VISIBLE);
  104. mDisplayRotation = ((WindowManager) getActivity().getSystemService(Service.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
  105. mSensorEventListener.setDisplayRotation(mDisplayRotation);
  106. mSensorEventListener.setSensorManager((SensorManager) getActivity().getSystemService("sensor"));
  107. mSensorEventListener.setReferenceAccelaration(REFERENCE_ACCELARATION);
  108. mFunctionBarView = inflate.findViewById(R.id.function_bar);
  109. mDisplayDensity = getActivity().getResources().getDisplayMetrics().density;
  110. return inflate;
  111. }
  112. private void setButtonListener(View view) {
  113. mPhotoSelectButton = (Button) view.findViewById(R.id.photo_select_button);
  114. mPhotoSelectButton.setOnClickListener(new View.OnClickListener() {
  115. public void onClick(View view) {
  116. if (!CameraPreviewFragment.mPictureTaking) {
  117. CameraPreviewFragment.this.startPhotoSelectActivity();
  118. }
  119. }
  120. });
  121. mPhtographButton = (Button) view.findViewById(R.id.photograph_button);
  122. mPhtographButton.setOnClickListener(new View.OnClickListener() {
  123. public void onClick(View view) {
  124. if (!CameraPreviewFragment.mPictureTaking) {
  125. CameraPreviewFragment.this.takePicture();
  126. }
  127. }
  128. });
  129. }
  130. private void startSettingActivity() {
  131. startActivity(new Intent(getActivity(), CameraPreviewOptionActivity.class));
  132. }
  133. private void startPhotoSelectActivity() {
  134. startActivity(new Intent(getActivity(), CameraCopyImageSelectActivity.class));
  135. }
  136. public void onCameraViewStarted(int i, int i2) {
  137. mRgba = new Mat(i, i2, CvType.CV_8UC4);
  138. savePictureSizeList();
  139. checkPictureSize();
  140. }
  141. private void savePictureSizeList() {
  142. List<Camera.Size> pictureSizeList;
  143. OpenCvCameraView openCvCameraView = mOpenCvCameraView;
  144. if (openCvCameraView != null && (pictureSizeList = openCvCameraView.getPictureSizeList()) != null) {
  145. Iterator<Camera.Size> it = pictureSizeList.iterator();
  146. while (it.hasNext()) {
  147. Camera.Size next = it.next();
  148. if (next.width * next.height < 1000000) {
  149. it.remove();
  150. }
  151. }
  152. CameraPreviewControl.getInstance(getActivity()).setCameraPictureSizes(pictureSizeList);
  153. }
  154. }
  155. private void checkPictureSize() {
  156. OpenCvCameraView openCvCameraView;
  157. Camera.Size cameraPictureSize;
  158. CameraPreviewControl instance = CameraPreviewControl.getInstance(getActivity());
  159. if (instance.getPictureResolutionMode() == 0 && (openCvCameraView = mOpenCvCameraView) != null && (cameraPictureSize = openCvCameraView.getCameraPictureSize()) != null && cameraPictureSize.width * cameraPictureSize.height < 1000000) {
  160. int i = R.string.camera_picture_low_message;
  161. List<android.graphics.Point> cameraPictureSizes = instance.getCameraPictureSizes();
  162. if (cameraPictureSizes == null || cameraPictureSizes.size() <= 0) {
  163. i = R.string.has_no_hireso_picture_message;
  164. }
  165. mCameraPictureLowResolutionDialog = SimpleMessageDialogFragment.newInstance(i);
  166. mCameraPictureLowResolutionDialog.show(getFragmentManager(), "camera-resolution-warning-dialog");
  167. }
  168. }
  169. public void onCameraViewStopped() {
  170. mRgba.release();
  171. SimpleMessageDialogFragment simpleMessageDialogFragment = mCameraPictureLowResolutionDialog;
  172. if (simpleMessageDialogFragment != null) {
  173. simpleMessageDialogFragment.dismiss();
  174. mCameraPictureLowResolutionDialog = null;
  175. }
  176. }
  177. private void drawSensorPos(Mat mat, boolean z) {
  178. int i;
  179. int height = mat.height();
  180. if (height > 0) {
  181. double scale = (1.0f / mOpenCvCameraView.getScale());
  182. int height2 = ((mFunctionBarView.getHeight()) * scale);
  183. int height3 = ((mOpenCvCameraView.getHeight()) * scale);
  184. double d = height;
  185. if (height2 + 0 + height > height3) {
  186. i = ((0) - (((height3 - height)) / 2.0d));
  187. d = ((height3 - 0) - height2);
  188. } else {
  189. i = 0;
  190. }
  191. Size size = mRgba.size();
  192. double d2 = size.width / 2.0d;
  193. double d3 = d / 10.0d;
  194. double d4 = scale;
  195. double d5 = i;
  196. Point point = new Point();
  197. double d6 = d / 2.0d;
  198. Point point2 = new Point();
  199. double d7 = size.width / 10.0d;
  200. double d8 = d2 - 1.0d;
  201. point.f432x = d8;
  202. point.f433y = d5 + d3;
  203. point2.f432x = d8;
  204. double d9 = d5 + d;
  205. point2.f433y = d9 - d3;
  206. Imgproc.line(mRgba, point, point2, mGridColor, 1);
  207. double d10 = d7;
  208. point.f432x = d10;
  209. double d11 = d5 + d6;
  210. point.f433y = d11;
  211. Size size2 = size;
  212. double d12 = d2;
  213. point2.f432x = size2.width - d10;
  214. point2.f433y = d11;
  215. Imgproc.line(mRgba, point, point2, mGridColor, 1);
  216. double d13 = size2.width / 20.0d;
  217. double d14 = d / 20.0d;
  218. double d15 = d13 * 3.0d;
  219. double d16 = d14 + d5;
  220. double d17 = 3.0d * d14;
  221. double d18 = size2.width - d13;
  222. double d19 = d5 + d17;
  223. double d20 = d5;
  224. double d21 = d9 - d17;
  225. double d22 = d9 - d14;
  226. point.f432x = d13;
  227. double d23 = d16;
  228. point.f433y = d23;
  229. point2.f432x = d15;
  230. point2.f433y = d23;
  231. double d24 = d21;
  232. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  233. double d25 = size2.width - d15;
  234. point.f432x = d25;
  235. point.f433y = d23;
  236. double d26 = d19;
  237. double d27 = d18;
  238. point2.f432x = d27;
  239. point2.f433y = d23;
  240. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  241. point.f432x = d13;
  242. double d28 = d23;
  243. double d29 = d22;
  244. point.f433y = d29;
  245. point2.f432x = d15;
  246. point2.f433y = d29;
  247. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  248. point.f432x = d25;
  249. point.f433y = d29;
  250. point2.f432x = d27;
  251. point2.f433y = d29;
  252. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  253. point.f432x = d13;
  254. double d30 = d28;
  255. point.f433y = d30;
  256. point2.f432x = d13;
  257. double d31 = d26;
  258. point2.f433y = d31;
  259. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  260. point.f432x = d13;
  261. double d32 = d24;
  262. point.f433y = d32;
  263. point2.f432x = d13;
  264. point2.f433y = d29;
  265. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  266. point.f432x = d27;
  267. point.f433y = d30;
  268. point2.f432x = d27;
  269. point2.f433y = d31;
  270. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  271. point.f432x = d27;
  272. point.f433y = d32;
  273. point2.f432x = d27;
  274. point2.f433y = d29;
  275. Imgproc.line(mRgba, point, point2, mGridColor, 2);
  276. if (z) {
  277. double posX = d12 - (((mSensorEventListener.getPosX() * 0.05098581f)) * d12);
  278. double posY = d6 + (((mSensorEventListener.getPosY() * 0.05098581f)) * d6) + d20;
  279. int i2 = (d4 * 20.0d * (mDisplayDensity));
  280. Imgproc.circle(mRgba, new Point(posX, posY), i2, mPositionCursorColor, 1);
  281. double d33 = i2;
  282. Imgproc.line(mRgba, new Point(posX, posY - d33), new Point(posX, posY + d33), mPositionCursorColor);
  283. Imgproc.line(mRgba, new Point(posX - d33, posY), new Point(posX + d33, posY), mPositionCursorColor);
  284. }
  285. }
  286. }
  287. private void myDrawRect(Mat mat, Point[] pointArr, boolean z) {
  288. if (pointArr != null && pointArr.length >= 1 && pointArr.length >= 2) {
  289. Scalar[] scalarArr = PAPER_SQUARE_COLOR;
  290. Scalar scalar = scalarArr[0];
  291. if (z) {
  292. scalar = scalarArr[1];
  293. }
  294. Imgproc.line(mat, pointArr[0], pointArr[1], scalar, 2);
  295. if (pointArr.length >= 3) {
  296. Imgproc.line(mat, pointArr[1], pointArr[2], scalar, 2);
  297. if (pointArr.length >= 4) {
  298. Imgproc.line(mat, pointArr[0], pointArr[3], scalar, 2);
  299. Imgproc.line(mat, pointArr[2], pointArr[3], scalar, 2);
  300. }
  301. }
  302. }
  303. }
  304. private boolean checkAutoPictureAngle() {
  305. return mSensorEventListener.isTerminalAngleInRange(this.AUTO_PICTURE_RANGE_VALUE);
  306. }
  307. private boolean checkAccelerrationTime() {
  308. long lastOverTime2 = mSensorEventListener.getLastOverTime2();
  309. if (lastOverTime2 > 0 && System.currentTimeMillis() - lastOverTime2 >= 3000) {
  310. return true;
  311. }
  312. return false;
  313. }
  314. private boolean autofousTime() {
  315. return System.currentTimeMillis() - mSensorEventListener.getLastOverTime2() >= 500;
  316. }
  317. private void sensorAndCamera() {
  318. if (this.isFragmentVisible) {
  319. long currentTimeMillis = System.currentTimeMillis();
  320. if (mAutoPhotoMode && mSensorEventListener.isTerminalAngleInRange(this.PAPER_DETECT_VALUE)) {
  321. boolean checkAutoPictureAngle = checkAutoPictureAngle();
  322. int detectAndDrawRectangle2 = RectangleDetector.detectAndDrawRectangle2(mRgba.getNativeObjAddr(), 0, mFunctionBarView.getHeight(), checkAutoPictureAngle);
  323. if (checkAutoPictureAngle && detectAndDrawRectangle2 == 1 && checkAccelerrationTime()) {
  324. takePicture();
  325. return;
  326. } else if (detectAndDrawRectangle2 != 0) {
  327. mPAfTime = currentTimeMillis;
  328. }
  329. }
  330. if (!mPictureTaking && !mAutoPhotoMode && !mPictureTaking && currentTimeMillis - mPAfTime > 4000 && !mOpenCvCameraView.isInAutofocus() && autofousTime()) {
  331. mOpenCvCameraView.doAutofocus(this);
  332. mPAfTime = currentTimeMillis;
  333. }
  334. }
  335. }
  336. public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame cvCameraViewFrame) {
  337. mRgba = cvCameraViewFrame.rgba();
  338. if (!mHasCamera || mPictureTaking) {
  339. return mRgba;
  340. }
  341. int i = mInitCount;
  342. if (i < 2) {
  343. mInitCount = i + 1;
  344. mScreenSize.f432x = mRgba.width();
  345. mScreenSize.f433y = mRgba.height();
  346. Imgproc.rectangle(mRgba, POSITION_0_0, mScreenSize, COLOR_BLACK, -1);
  347. }
  348. sensorAndCamera();
  349. if (mCameraPreviewControl.getGuideMode()) {
  350. drawSensorPos(mRgba, mSensorEventListener.isTerminalAngleInRange(this.PAPER_DETECT_VALUE));
  351. }
  352. return mRgba;
  353. }
  354. public void onCreate(Bundle bundle) {
  355. super.onCreate(bundle);
  356. mCameraPreviewControl = CameraPreviewControl.getInstance(getActivity());
  357. mPictureTaking = false;
  358. }
  359. public void onResume() {
  360. super.onResume();
  361. if (mHasCamera) {
  362. enableAllButton();
  363. if (mOpenCvCameraView.checkBackCamera()) {
  364. mOpenCvCameraView.enableView();
  365. mSensorEventListener.start();
  366. mPAfTime = 0;
  367. } else {
  368. UiCommon.setButtonEnabled(mPhtographButton, false);
  369. disableSettingButton(true);
  370. SimpleMessageDialogFragment.newInstance(R.string.back_camera_not_exists_message).show(getFragmentManager(), "error-dialog");
  371. }
  372. mPictureTaking = false;
  373. }
  374. mInitCount = 0;
  375. if (mPreviewActivityStarted) {
  376. mPreviewActivityStarted = false;
  377. mPictureTaking = false;
  378. enableAllButton();
  379. }
  380. mAutoPhotoMode = mCameraPreviewControl.getAutoPictureMode();
  381. isFragmentVisible = true;
  382. }
  383. public void onPause() {
  384. isFragmentVisible = false;
  385. mSensorEventListener.stop();
  386. TakePictureTask takePictureTask = mTakePictureTask;
  387. if (takePictureTask != null) {
  388. takePictureTask.cancel(false);
  389. mTakePictureTask = null;
  390. }
  391. OpenCvCameraView openCvCameraView = mOpenCvCameraView;
  392. if (openCvCameraView != null) {
  393. openCvCameraView.cancelAutofocus();
  394. mOpenCvCameraView.disableView();
  395. }
  396. mPictureTaking = false;
  397. super.onPause();
  398. }
  399. public void onDestroy() {
  400. OpenCvCameraView openCvCameraView = mOpenCvCameraView;
  401. if (openCvCameraView != null) {
  402. openCvCameraView.cancelAutofocus();
  403. mOpenCvCameraView.disableView();
  404. mOpenCvCameraView.setCvCameraViewListener((CameraBridgeViewBase.CvCameraViewListener2) null);
  405. mOpenCvCameraView = null;
  406. }
  407. super.onDestroy();
  408. }
  409. private void showErrorDialog() {
  410. SimpleMessageDialogFragment.newInstance(R.string.file_save_error_message).show(getFragmentManager(), "error-dialog");
  411. }
  412. public void takePicture() {
  413. if (!mPictureTaking) {
  414. mPictureTaking = true;
  415. getActivity().runOnUiThread(new Runnable() {
  416. public void run() {
  417. CameraPreviewFragment.this.disableAllButton();
  418. }
  419. });
  420. mSensorEventListener.stop();
  421. mTakePictureTask = new TakePictureTask(mOpenCvCameraView);
  422. mTakePictureTask.execute(new Void[0]);
  423. }
  424. }
  425. private void takePictureStep2() {
  426. mOpenCvCameraView.takePicture(FileUtils.getNewTemporaryJpegFile(getActivity()).getPath(), new OpenCvCameraView.MyPictureTakeCallback() {
  427. public void onMyPictureTaken(boolean z, String str) {
  428. if (!z || str == null) {
  429. CameraPreviewFragment.this.enableAllButton();
  430. CameraPreviewFragment.mSensorEventListener.start();
  431. boolean unused = CameraPreviewFragment.mPictureTaking = false;
  432. CameraPreviewFragment.this.showErrorDialog();
  433. return;
  434. }
  435. CameraPreviewFragment.this.startPictureViewActivity(str);
  436. }
  437. });
  438. }
  439. private void enableAllButton() {
  440. if (CameraPreviewControl.hasBackCamera()) {
  441. UiCommon.setButtonEnabled(mPhtographButton, true);
  442. disableSettingButton(false);
  443. }
  444. UiCommon.setButtonEnabled(mPhotoSelectButton, true);
  445. }
  446. private void disableAllButton() {
  447. UiCommon.setButtonEnabled(mPhtographButton, false);
  448. disableSettingButton(true);
  449. UiCommon.setButtonEnabled(mPhotoSelectButton, false);
  450. }
  451. private void startPictureViewActivity(String str) {
  452. Intent intent = new Intent(getActivity(), ImagePreviewActivity.class);
  453. intent.putExtra(ImagePreviewActivity.PARAM_CAMERA_FILE, new CameraFile(new Date(), str));
  454. startActivity(intent);
  455. mPreviewActivityStarted = true;
  456. }
  457. public void onAutoFocusCompleted(boolean z) {
  458. mPAfTime = System.currentTimeMillis();
  459. }
  460. private void disableSettingButton(boolean z) {
  461. mDisableSettingsButton = z;
  462. getActivity().invalidateOptionsMenu();
  463. }
  464. public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
  465. if (!mDisableSettingsButton) {
  466. menuInflater.inflate(R.menu.camera_menu, menu);
  467. }
  468. super.onCreateOptionsMenu(menu, menuInflater);
  469. }
  470. public boolean onOptionsItemSelected(MenuItem menuItem) {
  471. if (menuItem.getItemId() != R.id.camera_setting) {
  472. return super.onOptionsItemSelected(menuItem);
  473. }
  474. if (mPictureTaking) {
  475. return false;
  476. }
  477. startSettingActivity();
  478. return true;
  479. }
  480. public boolean onBackPressed() {
  481. return !mPictureTaking;
  482. }
  483. /* renamed from: com.epson.cameracopy.ui.CameraPreviewFragment$TakePictureTask */
  484. class TakePictureTask extends AsyncTask<Void, Void, Void> {
  485. private OpenCvCameraView mMyOpenCvCameraView;
  486. public TakePictureTask(OpenCvCameraView openCvCameraView) {
  487. mMyOpenCvCameraView = openCvCameraView;
  488. }
  489. protected Void doInBackground(Void... voidArr) {
  490. System.currentTimeMillis();
  491. while (!isCancelled() && mMyOpenCvCameraView.isInAutofocus()) {
  492. try {
  493. Thread.sleep(100);
  494. } catch (InterruptedException e) {
  495. e.printStackTrace();
  496. }
  497. }
  498. return null;
  499. }
  500. protected void onPostExecute(Void voidR) {
  501. CameraPreviewFragment.this.takePictureStep2();
  502. }
  503. }
  504. }