當前位置: 首頁>>代碼示例>>Java>>正文


Java PreProcessorFactory類代碼示例

本文整理匯總了Java中ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory的典型用法代碼示例。如果您正苦於以下問題:Java PreProcessorFactory類的具體用法?Java PreProcessorFactory怎麽用?Java PreProcessorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PreProcessorFactory類屬於ch.zhaw.facerecognitionlibrary.PreProcessor包,在下文中一共展示了PreProcessorFactory類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCameraFrame

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat imgRgba = inputFrame.rgba();
    Mat img = new Mat();
    imgRgba.copyTo(img);
    List<Mat> images = ppF.getProcessedImage(img, PreProcessorFactory.PreprocessingMode.RECOGNITION);
    Rect[] faces = ppF.getFacesForRecognition();

    // Selfie / Mirror mode
    if(front_camera){
        Core.flip(imgRgba,imgRgba,1);
    }
    if(images == null || images.size() == 0 || faces == null || faces.length == 0 || ! (images.size() == faces.length)){
        // skip
        return imgRgba;
    } else {
        faces = MatOperation.rotateFaces(imgRgba, faces, ppF.getAngleForRecognition());
        for(int i = 0; i<faces.length; i++){
            MatOperation.drawRectangleAndLabelOnPreview(imgRgba, faces[i], rec.recognize(images.get(i), ""), front_camera);
        }
        return imgRgba;
    }
}
 
開發者ID:Qualeams,項目名稱:Android-Face-Recognition-with-Deep-Learning-Test-Framework,代碼行數:23,代碼來源:RecognitionActivity.java

示例2: onResume

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
@Override
public void onResume()
{
    super.onResume();
    ppF = new PreProcessorFactory(getApplicationContext());
    numberOfTries = 0;
    animalOverlay = animalOverlayHelper.getAnimalOverlay("");
    if (animalOverlay != null) {
        mediaPlayerAnimalSound = MediaPlayer.create(this, getResources().getIdentifier(animalOverlay.getSoundFile(), AuthenticationInstructionHelper.RESOURCES_RAW_FOLDER, getPackageName()));
    }
    preview.enableView();
    mediaPlayerTabletPlacement = AuthenticationInstructionHelper.getMediaPlayerTabletPlacement(getApplicationContext());
    mediaPlayerTabletPlacement.start();
    mediaPlayerTabletPlacementOverlay = AuthenticationInstructionHelper.getMediaPlayerTabletPlacementOverlay(getApplicationContext());
    tensorFlowLoadingThread.start();
    startTimeFallback = new Date().getTime();
    startTimeAuthenticationAnimation = new Date().getTime();
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:19,代碼來源:AuthenticationActivity.java

示例3: onResume

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
@Override
public void onResume()
{
    super.onResume();
    ppF = new PreProcessorFactory(getApplicationContext());
    animalOverlay = animalOverlayHelper.getAnimalOverlay(animalOverlayName);
    if (animalOverlay != null){
        mediaPlayerAnimalSound = MediaPlayer.create(this, getResources().getIdentifier(animalOverlay.getSoundFile(), AuthenticationInstructionHelper.RESOURCES_RAW_FOLDER, getPackageName()));
    }
    preview.enableView();
    if (!authenticationAnimationAlreadyPlayed){
        mediaPlayerTabletPlacement = AuthenticationInstructionHelper.getMediaPlayerTabletPlacement(getApplicationContext());
        mediaPlayerTabletPlacement.start();
    }
    mediaPlayerTabletPlacementOverlay = AuthenticationInstructionHelper.getMediaPlayerTabletPlacementOverlay(getApplicationContext());
    startTimeFallback = new Date().getTime();
    startTimeAuthenticationAnimation = new Date().getTime();
    if (authenticationAnimationAlreadyPlayed){
        prepareForAuthentication();
    }
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:22,代碼來源:StudentImageCollectionActivity.java

示例4: onResume

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
@Override
public void onResume()
{
    super.onResume();

    ppF = new PreProcessorFactory(this);
    mAddPersonView.enableView();
}
 
開發者ID:Qualeams,項目名稱:Android-Face-Recognition-with-Deep-Learning-Test-Framework,代碼行數:9,代碼來源:AddPersonPreviewActivity.java

示例5: onResume

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
@Override
public void onResume()
{
    super.onResume();

    ppF = new PreProcessorFactory(getApplicationContext());

    final android.os.Handler handler = new android.os.Handler(Looper.getMainLooper());
    Thread t = new Thread(new Runnable() {
        public void run() {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    progressBar.setVisibility(View.VISIBLE);
                }
            });
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            String algorithm = sharedPref.getString("key_classification_method", getResources().getString(R.string.eigenfaces));
            rec = RecognitionFactory.getRecognitionAlgorithm(getApplicationContext(), Recognition.RECOGNITION, algorithm);
            handler.post(new Runnable() {
                @Override
                public void run() {
                    progressBar.setVisibility(View.GONE);
                }
            });
        }
    });

    t.start();

    // Wait until Eigenfaces loading thread has finished
    try {
        t.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    mRecognitionView.enableView();
}
 
開發者ID:Qualeams,項目名稱:Android-Face-Recognition-with-Deep-Learning-Test-Framework,代碼行數:40,代碼來源:RecognitionActivity.java

示例6: MergeThread

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
public MergeThread(MergeSimilarStudentsJobService mergeService){
    Context context = mergeService.getApplicationContext();
    trainingThread = new TrainingThread(context);
    ppF = new PreProcessorFactory(context);
    LiteracyApplication literacyApplication = (LiteracyApplication) context.getApplicationContext();
    DaoSession daoSession = literacyApplication.getDaoSession();
    studentDao = daoSession.getStudentDao();
    studentImageCollectionEventDao = daoSession.getStudentImageCollectionEventDao();
    gson = new Gson();
    this.mergeService = mergeService;
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:12,代碼來源:MergeThread.java

示例7: findSimilarStudentsUsingMeanFeatureVector

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
/**
 * Find similar students
 * Case 2: Student was added regularly but maybe on another tablet or due to some reason the authentication didn't recognize the student correctly in the numberOfTries
 * ---> Use the meanFeatureVector as input for the cosineSimilarityScore calculation
 * @param ppF
 * @param tensorFlow
 */
private synchronized void findSimilarStudentsUsingMeanFeatureVector(PreProcessorFactory ppF, TensorFlow tensorFlow){
    Log.i(getClass().getName(), "findSimilarStudentsUsingMeanFeatureVector");
    // Iterate through all StudentImageCollectionEvents, where the Student is not null
    List<StudentImageCollectionEvent> studentImageCollectionEvents = studentImageCollectionEventDao.queryBuilder().where(StudentImageCollectionEventDao.Properties.StudentId.notEq(0)).list();
    Log.i(getClass().getName(), "studentImageCollectionEvents.size(): " + studentImageCollectionEvents.size());
    for (StudentImageCollectionEvent studentImageCollectionEvent : studentImageCollectionEvents){
        Student student = studentImageCollectionEvent.getStudent();
        // Take the meanFeatureVector of the StudentImageCollectionEvent
        List<Float> meanFeatureVectorList = gson.fromJson(studentImageCollectionEvent.getMeanFeatureVector(), new TypeToken<List<Float>>(){}.getType());
        Mat meanFeatureVector = Converters.vector_float_to_Mat(meanFeatureVectorList);
        RecognitionThread recognitionThread = new RecognitionThread(tensorFlow, studentImageCollectionEventDao);
        recognitionThread.setImg(meanFeatureVector);
        recognitionThread.setStudent(student);
        // To indicate, that this Mat object contains the already extracted features and therefore this step can be skipped in the RecognitionThread
        recognitionThread.setFeaturesAlreadyExtracted(true);
        Log.i(getClass().getName(), "findSimilarStudentsUsingMeanFeatureVector: recognitionThread will be started to recognize student: " + student.getUniqueId());
        recognitionThread.start();
        try {
            recognitionThread.join();
            List<Student> recognizedStudents = recognitionThread.getRecognizedStudent();
            if (recognizedStudents.size() > 0){
                for (Student recognizedStudent : recognizedStudents){
                    if (recognizedStudent != null){
                        Log.i(getClass().getName(), "findSimilarStudentsUsingMeanFeatureVector: The student " + student.getUniqueId() + " has been recognized as " + recognizedStudent.getUniqueId());
                        mergeSimilarStudents(student, recognizedStudent);
                    }
                }
            } else {
                Log.i(getClass().getName(), "findSimilarStudentsUsingMeanFeatureVector: The student " + student.getUniqueId() + " was not recognized");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:43,代碼來源:MergeThread.java

示例8: onResume

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
@Override
protected void onResume() {
    super.onResume();
    ppF = new PreProcessorFactory(getApplicationContext());
    mDetectionView.enableView();
}
 
開發者ID:Qualeams,項目名稱:Android-Face-Recognition-with-Deep-Learning-Test-Framework,代碼行數:7,代碼來源:DetectionActivity.java

示例9: findSimilarStudentsUsingAvatarImages

import ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory; //導入依賴的package包/類
/**
 * Find similar students
 * Case 1: Student was added during fallback but in the meantime the same person has an existing StudentImageCollectionEvent and a new Student entry
 * ---> Use the avatar image as input for the recognition
 * @param ppF
 * @param tensorFlow
 */
private synchronized void findSimilarStudentsUsingAvatarImages(PreProcessorFactory ppF, TensorFlow tensorFlow){
    Log.i(getClass().getName(), "findSimilarStudentsUsingAvatarImages");
    // Iterate through all Students
    List<Student> students = studentDao.loadAll();
    for (Student student : students){
        // Take the avatar image of the Student
        Mat avatarImage = Imgcodecs.imread(student.getAvatar());
        // Search for faces in the avatar image
        List<Mat> faceImages = ppF.getCroppedImage(avatarImage);
        if (faceImages != null && faceImages.size() == 1) {
            // Proceed if exactly one face has been detected
            Mat faceImage = faceImages.get(0);
            if (faceImage != null) {
                // Get detected face rectangles
                Rect[] faces = ppF.getFacesForRecognition();
                if (faces != null && faces.length == 1) {
                    // Proceed if exactly one face rectangle exists
                    RecognitionThread recognitionThread = new RecognitionThread(tensorFlow, studentImageCollectionEventDao);
                    recognitionThread.setImg(faceImage);
                    recognitionThread.setStudent(student);
                    Log.i(getClass().getName(), "findSimilarStudentsUsingAvatarImages: recognitionThread will be started to recognize student: " + student.getUniqueId());
                    recognitionThread.start();
                    try {
                        recognitionThread.join();
                        List<Student> recognizedStudents = recognitionThread.getRecognizedStudent();
                        if (recognizedStudents.size() > 0){
                            for (Student recognizedStudent : recognizedStudents){
                                if (recognizedStudent != null){
                                    Log.i(getClass().getName(), "findSimilarStudentsUsingAvatarImages: The student " + student.getUniqueId() + " has been recognized as " + recognizedStudent.getUniqueId());
                                    mergeSimilarStudents(student, recognizedStudent);
                                }
                            }
                        } else {
                            Log.i(getClass().getName(), "findSimilarStudentsUsingAvatarImages: The student " + student.getUniqueId() + " was not recognized");
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:51,代碼來源:MergeThread.java


注:本文中的ch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。