CameraPreviewFragment.java 21 KB

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