| | |
| | | @ViewById |
| | | public ImageView camera2; |
| | | @ViewById |
| | | public View camera2_separator; |
| | | public View camera2_separator, textureViewParent; |
| | | @ViewById |
| | | public View textureViewParent; |
| | | @ViewById |
| | | public Preview rgb_camera; |
| | | @ViewById |
| | | public Preview gray_camera; |
| | | public Preview rgb_camera, gray_camera; |
| | | @ViewById |
| | | public RelativeLayout faceOuterBorderViewParent; |
| | | public List<RecognizeFaceInfoView> recognizeFaceInfoViewList = new ArrayList<>(); |
| | |
| | | long prevDrawTime = System.currentTimeMillis(); |
| | | private boolean initCamera = false; |
| | | |
| | | public void addDetectedResult(DetectedResult detectedResult) { |
| | | if (!CfCompareFeatureThread.isRunning) { |
| | | CameraFragment.detectedResult = detectedResult; |
| | | BaseApplication.getApplication().executorService.execute(CfCompareFeatureThread); |
| | | } |
| | | } |
| | | |
| | | public void clearAllFaceRectWhenTimeout() { |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | |
| | | if (recognizeFaceInfoViewList.size() - 1 < i) { |
| | | recognizeFaceInfoView = new RecognizeFaceInfoView(getContext()); |
| | | recognizeFaceInfoViewList.add(recognizeFaceInfoView); |
| | | int childCount = faceOuterBorderViewParent.getChildCount(); |
| | | // System.out.println("CfDetectFace.drawFaceRect childCount="+childCount); |
| | | faceOuterBorderViewParent.addView(recognizeFaceInfoView, 4); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | faceOuterBorderViewParent.addView(recognizeFaceInfoView, 4); |
| | | } else { |
| | | faceOuterBorderViewParent.addView(recognizeFaceInfoView, 3); |
| | | } |
| | | } else { |
| | | recognizeFaceInfoView = recognizeFaceInfoViewList.get(i); |
| | | } |
| | | if (textureViewParent != null) { |
| | | recognizeFaceInfoView.showAtPosition(facePosition, textureViewParent.getHeight(), |
| | | textureViewParent.getWidth(), |
| | | if (Constants.indoorOutdoorInOne) { |
| | | if (textureViewParent != null) { |
| | | recognizeFaceInfoView.showAtPosition(facePosition, textureViewParent.getHeight(), |
| | | textureViewParent.getWidth(), |
| | | detectedResult.width, |
| | | detectedResult.height |
| | | ); |
| | | } |
| | | } else { |
| | | recognizeFaceInfoView.showAtPosition(facePosition, rgb_camera.getHeight(), |
| | | rgb_camera.getWidth(), |
| | | detectedResult.width, |
| | | detectedResult.height |
| | | ); |
| | |
| | | return inflater.inflate(ResolutionAdaptation.fragment_camera(), container, false); |
| | | } |
| | | |
| | | public void addDetectedResult(DetectedResult detectedResult) { |
| | | if (!CfCompareFeatureThread.isRunning) { |
| | | CameraFragment.detectedResult = detectedResult; |
| | | BaseApplication.getApplication().executorService.execute(CfCompareFeatureThread); |
| | | } |
| | | } |
| | | |
| | | @Click |
| | | public void nic_back_person_manager() { |
| | | SystemInitManager.showSecondDisplay(mainActivity()); |
| | |
| | | } |
| | | |
| | | public void showCameraInGuestMode(boolean showBorder) { |
| | | try { |
| | | if (showBorder) { |
| | | LayoutUtil.applyStyle(faceOuterBorderViewParent, StyleBuilder.newStyleBuild().marginTop(20).marginRight(0).marginBottom(161).marginLeft(20).buildStyle()); |
| | | hideOverlay(); |
| | | topBlurView2_guest_mode.setVisibility(View.VISIBLE); |
| | | topBackground2_guest_mode.setVisibility(View.VISIBLE); |
| | | } else { |
| | | overlay.setVisibility(View.VISIBLE); |
| | | topBlurView2_guest_mode.setVisibility(View.INVISIBLE); |
| | | topBackground2_guest_mode.setVisibility(View.INVISIBLE); |
| | | cameraExitGuestMode(); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | try { |
| | | if (showBorder) { |
| | | LayoutUtil.applyStyle(faceOuterBorderViewParent, StyleBuilder.newStyleBuild().marginTop(20).marginRight(0).marginBottom(161).marginLeft(20).buildStyle()); |
| | | hideOverlay(); |
| | | topBlurView2_guest_mode.setVisibility(View.VISIBLE); |
| | | topBackground2_guest_mode.setVisibility(View.VISIBLE); |
| | | } else { |
| | | overlay.setVisibility(View.VISIBLE); |
| | | topBlurView2_guest_mode.setVisibility(View.INVISIBLE); |
| | | topBackground2_guest_mode.setVisibility(View.INVISIBLE); |
| | | cameraExitGuestMode(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @UiThread |
| | | public void showOverlay() { |
| | |
| | | if (nic_back_person_manager != null) { |
| | | nic_back_person_manager.setVisibility(View.GONE); |
| | | } |
| | | showCameraInGuestMode(); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | showCameraInGuestMode(); |
| | | } |
| | | } |
| | | |
| | | @UiThread |
| | | public void hideOverlay() { |
| | | showCameraInGuestMode(); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | showCameraInGuestMode(); |
| | | } |
| | | if (overlay != null) { |
| | | overlay.setVisibility(View.INVISIBLE); |
| | | } |
| | |
| | | } else { |
| | | openCamera(); |
| | | } |
| | | camera2.setClipToOutline(true); |
| | | camera2.setOutlineProvider(new ViewOutlineProvider() { |
| | | public void getOutline(View view, Outline outline) { |
| | | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), getResources().getDimension(com.basic.security.utils.RUtils.R_dimen_corner_radius)); |
| | | } |
| | | }); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | camera2.setClipToOutline(true); |
| | | camera2.setOutlineProvider(new ViewOutlineProvider() { |
| | | public void getOutline(View view, Outline outline) { |
| | | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), getResources().getDimension(com.basic.security.utils.RUtils.R_dimen_corner_radius)); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| | |
| | | } |
| | | }); |
| | | rgb_camera.setClipToOutline(true); |
| | | textureView.setOutlineProvider(new ViewOutlineProvider() { |
| | | public void getOutline(View view, Outline outline) { |
| | | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), getActivity().getResources().getDimension(com.basic.security.utils.RUtils.R_dimen_corner_radius)); |
| | | } |
| | | }); |
| | | textureView.setClipToOutline(true); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | textureView.setOutlineProvider(new ViewOutlineProvider() { |
| | | public void getOutline(View view, Outline outline) { |
| | | outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), getActivity().getResources().getDimension(com.basic.security.utils.RUtils.R_dimen_corner_radius)); |
| | | } |
| | | }); |
| | | textureView.setClipToOutline(true); |
| | | textureView.setSurfaceTextureListener(rgb_camera); |
| | | } |
| | | if (getActivity() == null) { |
| | | return; |
| | | } |
| | | textureView.setSurfaceTextureListener(rgb_camera); |
| | | FaceId.initSdk(getActivity(), rgb_camera, gray_camera, detectedResult -> { |
| | | if (detectedResult.facePositions.size() > 0) { |
| | | if (mainActivity().currentFragment == mainActivity().fragment_su_auto_wait_face |
| | |
| | | camera2_separator.setVisibility(View.VISIBLE); |
| | | LayoutUtil.applyStyle(faceOuterBorderViewParent, StyleBuilder.newStyleBuild().marginTop(20).marginRight(0).marginBottom(300).marginLeft(20).buildStyle()); |
| | | } else { |
| | | camera2.setVisibility(View.GONE); |
| | | camera2_separator.setVisibility(View.GONE); |
| | | LayoutUtil.applyStyle(faceOuterBorderViewParent, StyleBuilder.newStyleBuild().marginTop(20).marginRight(0).marginBottom(161).marginLeft(20).buildStyle()); |
| | | if (Constants.indoorOutdoorInOne) { |
| | | camera2.setVisibility(View.GONE); |
| | | camera2_separator.setVisibility(View.GONE); |
| | | LayoutUtil.applyStyle(faceOuterBorderViewParent, StyleBuilder.newStyleBuild().marginTop(20).marginRight(0).marginBottom(161).marginLeft(20).buildStyle()); |
| | | } |
| | | } |
| | | } |
| | | |