Skip to content

Commit

Permalink
Face SDK v3.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid-leshukov committed Jul 1, 2022
1 parent f6e7f6c commit 0ff26d1
Show file tree
Hide file tree
Showing 33 changed files with 1,126 additions and 271 deletions.
11 changes: 11 additions & 0 deletions conf/facerec/age_gender_estimator_v3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<opencv_storage>

<age_gender_impl_name>version_3.0</age_gender_impl_name>

<analysisa>share/age_second/age_model.enc</analysisa>
<age_second_impl>age_model_second</age_second_impl>
<analysisg>share/faceanalysis/gender.enc</analysisg>
<gender_use_cuda>false</gender_use_cuda>

</opencv_storage>
9 changes: 9 additions & 0 deletions conf/facerec/emotions_estimator_v2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<opencv_storage>

<emotion_impl_name>version_2.0</emotion_impl_name>

<analysis>share/faceanalysis/emotion.enc</analysis>
<use_cuda>false</use_cuda>

</opencv_storage>
9 changes: 9 additions & 0 deletions conf/facerec/liveness_2d_estimator_v3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<opencv_storage>
<quality_estimator_config>conf/facerec/quality_estimator_iso.xml</quality_estimator_config>
<liveness_2d_impl_name>cascade</liveness_2d_impl_name>
<liveness_2d_estimator_config>conf/facerec/liveness_2d_estimator_v2.xml</liveness_2d_estimator_config>
<liveness_2d_data>share/liveness_2d_v2/model.enc</liveness_2d_data>
<liveness_2d_impl>liveness_2d_v2</liveness_2d_impl>
<liveness_2d_score_threshold>0.9</liveness_2d_score_threshold>
</opencv_storage>
2 changes: 2 additions & 0 deletions conf/facerec/quality_estimator_iso.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

<quality_impl_name>the_iso</quality_impl_name>

<quality_estimator_iso_v>2</quality_estimator_iso_v>

<qm_fne>share/quality_iso/NoiseEstimateNet.bin</qm_fne>
<qm_ill>share/quality_iso/illuminationNet.bin</qm_ill>
<use_mobile_gpu>0</use_mobile_gpu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,12 @@ public void processingImage(Canvas canvas, byte[] data, int width, int height){
if (flag_liveness)
{
if(liveness2dEstimator == null){
liveness2dEstimator = service.createLiveness2DEstimator("liveness_2d_estimator_v2.xml");
liveness2dEstimator = service.createLiveness2DEstimator("liveness_2d_estimator_v3.xml");
}

// get liveness
final Liveness2DEstimator.LivenessAndScore liveness_and_score = liveness2dEstimator.estimate(sample);
String score_str = (liveness_and_score.liveness == Liveness2DEstimator.Liveness.REAL ||
liveness_and_score.liveness == Liveness2DEstimator.Liveness.FAKE) ?
String score_str = (liveness_and_score.liveness != Liveness2DEstimator.Liveness.NOT_ENOUGH_DATA) ?
String.format("%.03f", liveness_and_score.score) : "";
text += "Liveness: " + score_str + " - "+ liveness_and_score.liveness.name() + "\n";
}
Expand Down Expand Up @@ -441,4 +440,4 @@ public void dispose()
faceMaskEstimator.dispose();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:id="@+id/aboutText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="3DiVi video recognition with depth and IR liveness demo for Telpo (v 0.2)\n\n3DiVi Face SDK version 3.14.0\n"
android:text="3DiVi video recognition with depth and IR liveness demo for Telpo (v 0.2)\n\n3DiVi Face SDK version 3.15.0\n"
android:layout_below="@+id/aboutLogo"
/>

Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ add_subdirectory(test_calibration)
add_subdirectory(demo)
add_subdirectory(video_recognition_demo)
add_subdirectory(test_videocap)
add_subdirectory(body_detector)
add_subdirectory(processing_block)
55 changes: 37 additions & 18 deletions examples/cpp/demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@

#include "../console_arguments_parser/ConsoleArgumentsParser.h"


static const std::map<pbio::Liveness2DEstimator::Liveness, std::string> LivenessToStr{
{pbio::Liveness2DEstimator::BAD_IMAGE_BLUR, "FAKE - BAD IMAGE BLUR"},
{pbio::Liveness2DEstimator::BAD_IMAGE_FLARE, "FAKE - BAD IMAGE FLARE"},
{pbio::Liveness2DEstimator::BAD_IMAGE_LIGHTING, "FAKE - BAD IMAGE LIGHTING"},
{pbio::Liveness2DEstimator::BAD_IMAGE_NOISE, "FAKE - BAD IMAGE NOISE"},
{pbio::Liveness2DEstimator::FACE_NOT_FULLY_FRAMED, "FAKE - FACE NOT FULLY FRAMED"},
{pbio::Liveness2DEstimator::FACE_TURNED_DOWN, "FAKE - FACE TURNED DOWN"},
{pbio::Liveness2DEstimator::FACE_TURNED_LEFT, "FAKE - FACE TURNED LEFT"},
{pbio::Liveness2DEstimator::FACE_TURNED_RIGHT, "FAKE - FACE TURNED RIGHT"},
{pbio::Liveness2DEstimator::FACE_TURNED_UP, "FAKE - FACE TURNED UP"},
{pbio::Liveness2DEstimator::FAKE, "FAKE - NOT REAL FACE"},
{pbio::Liveness2DEstimator::REAL, "REAL"},
{pbio::Liveness2DEstimator::MULTIPLE_FACE_FRAMED, "FAKE - MORE THAN ONE FACE FRAMED"},
{pbio::Liveness2DEstimator::NOT_COMPUTED, "NOT COMPUTED"},
{pbio::Liveness2DEstimator::NOT_ENOUGH_DATA, "NOT ENOUGH DATA"}
};

// calss that will do all the work
class Worker
{
Expand All @@ -36,7 +54,7 @@ class Worker
const pbio::QualityEstimator::Ptr _quality_estimator;

// one age and gender estimator
const pbio::AgeGenderEstimator::Ptr _age_geder_estimator;
const pbio::AgeGenderEstimator::Ptr _age_gender_estimator;

// one emotions estimator
const pbio::EmotionsEstimator::Ptr _emotions_estimator;
Expand Down Expand Up @@ -71,7 +89,7 @@ class Worker

// liveness estimator
pbio::Liveness2DEstimator::Ptr liveness2d;
const std::string liveness_config = "liveness_2d_estimator_v2.xml";
const std::string liveness_config = "liveness_2d_estimator_v3.xml";

bool& flag(int i);
std::string flag_name(int i) const;
Expand Down Expand Up @@ -204,9 +222,8 @@ _tracker(
.overrideParameter("downscale_rawsamples_to_preferred_size", 0)
.overrideParameter("iris_enabled", 1))),
_quality_estimator( _service->createQualityEstimator("quality_estimator_iso.xml") ),
_age_geder_estimator( _service->createAgeGenderEstimator("age_gender_estimator.xml") ),
//_age_geder_estimator( _service->createAgeGenderEstimator("age_gender_estimator_v2.xml") ),
_emotions_estimator( _service->createEmotionsEstimator("emotions_estimator.xml") ),
_age_gender_estimator( _service->createAgeGenderEstimator("age_gender_estimator_v3.xml") ),
_emotions_estimator( _service->createEmotionsEstimator("emotions_estimator_v2.xml") ),
_face_quality_estimator( _service->createFaceQualityEstimator("face_quality_estimator.xml")),

_flag_positions( true ),
Expand Down Expand Up @@ -425,7 +442,7 @@ void Worker::work(const pbio::InternalImageBuffer::Ptr frame)
if( _flag_age_gender )
{
const pbio::AgeGenderEstimator::AgeGender age_gender =
_age_geder_estimator->estimateAgeGender(sample);
_age_gender_estimator->estimateAgeGender(sample);

std::ostringstream age_text;

Expand Down Expand Up @@ -479,6 +496,9 @@ void Worker::work(const pbio::InternalImageBuffer::Ptr frame)
emotion == pbio::EmotionsEstimator::EMOTION_HAPPY ? cv::Scalar(0, 255, 0) :
emotion == pbio::EmotionsEstimator::EMOTION_ANGRY ? cv::Scalar(0, 0, 255) :
emotion == pbio::EmotionsEstimator::EMOTION_SURPRISE ? cv::Scalar(0, 255, 255) :
emotion == pbio::EmotionsEstimator::EMOTION_DISGUSTED ? cv::Scalar(255, 255, 0) :
emotion == pbio::EmotionsEstimator::EMOTION_SAD ? cv::Scalar(255, 0, 255) :
emotion == pbio::EmotionsEstimator::EMOTION_SCARED ? cv::Scalar(0, 255, 127) :
cv::Scalar(0, 0, 0),
-1);

Expand All @@ -487,7 +507,10 @@ void Worker::work(const pbio::InternalImageBuffer::Ptr frame)
emotion == pbio::EmotionsEstimator::EMOTION_NEUTRAL ? "neutral" :
emotion == pbio::EmotionsEstimator::EMOTION_HAPPY ? "happy" :
emotion == pbio::EmotionsEstimator::EMOTION_ANGRY ? "angry" :
emotion == pbio::EmotionsEstimator::EMOTION_SURPRISE ? "surprise" : "?",
emotion == pbio::EmotionsEstimator::EMOTION_SURPRISE ? "surprised" :
emotion == pbio::EmotionsEstimator::EMOTION_DISGUSTED ? "disgusted" :
emotion == pbio::EmotionsEstimator::EMOTION_SAD ? "sad":
emotion == pbio::EmotionsEstimator::EMOTION_SCARED ? "scared" : "?",
text_point + cv::Point2f(100, 0));

text_point.y += text_line_height;
Expand Down Expand Up @@ -608,19 +631,15 @@ void Worker::work(const pbio::InternalImageBuffer::Ptr frame)
}
pbio::Liveness2DEstimator::LivenessAndScore liveness_2d_result;
liveness_2d_result = liveness2d->estimate(sample);
auto info = LivenessToStr.find(liveness_2d_result.liveness);
puttext(draw_image, "Liveness: " + (info == LivenessToStr.end() ? " not enough data" : info->second), text_point);
text_point.y += text_line_height;
text_point.y += (text_line_height / 3);
std::stringstream ss;
ss << std::fixed << std::setprecision(3) << liveness_2d_result.score;
std::string score_str = ss.str();
puttext(
draw_image,
std::string("liveness: ") + (
liveness_2d_result.liveness == pbio::Liveness2DEstimator::REAL ? score_str + " - real" :
liveness_2d_result.liveness == pbio::Liveness2DEstimator::FAKE ? score_str + " - fake" :
liveness_2d_result.liveness == pbio::Liveness2DEstimator::NOT_ENOUGH_DATA ? "not enough data" : "??"),
text_point);

ss << "score: " << std::fixed << std::setprecision(3) << liveness_2d_result.score;
puttext(draw_image, ss.str(), text_point);
text_point.y += text_line_height;
text_point.y += text_line_height / 3;
text_point.y += (text_line_height / 3);
}

// draw face attribute (masked_face)
Expand Down
15 changes: 15 additions & 0 deletions examples/cpp/processing_block/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.1)

set(name processing_block_demo)

project(${name})

include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable(${name} processing_block.cpp)

set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)

target_link_libraries( ${name} pbio_cpp ${OpenCV_LIBS})

install(TARGETS ${name} DESTINATION bin)
Loading

0 comments on commit 0ff26d1

Please sign in to comment.