简体   繁体   中英

Implement FaceDetector and TextRecognizer in single CameraSource (Google Mobile Vision)

In my android application I need both face detection and ORC function at the same time. Can I implement both on same CameraSource? Is it possible?

Context context = getApplicationContext();

TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));

FaceDetector detector = new FaceDetector.Builder(context).setClassificationType(FaceDetector.ALL_CLASSIFICATIONS).build();
detector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build());

mCameraSource = new CameraSource.Builder(getApplicationContext(), detector)
                    .setFacing(CameraSource.CAMERA_FACING_BACK)
                    .setRequestedPreviewSize(1280, 1024)
                    .setRequestedFps(15.0f)
                    .setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
                    .setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null)
                    .build();

In the sample codes they pass only one detector at a time to the CameraSource. textRecognizer or detector

Update: I have found a way. You can create a MultiDetector and add both FaceDetector and TextRecognizer in to that and pass the MultiDetector object in to CameraSource.Builder

MultiDetector multiDetector = new MultiDetector.Builder()
            .add(textRecognizer)
            .add(detector)
            .build();

The multi-detector will receive a series of frames from the camera source. Each frame is submitted to both detectors. 多角色

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM