NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import ctypes, ctypes.util
from ctypes import *
from numpy.ctypeslib import ndpointer
import sys
import os

lib_path = os.path.abspath(os.path.dirname(__file__)) + '/libs/libttvfaceengine7.so'
liveness_engine = cdll.LoadLibrary(lib_path)

ttv_version = liveness_engine.ttv_version
ttv_version.argtypes = []
ttv_version.restype = ctypes.c_char_p

ttv_get_hwid = liveness_engine.ttv_get_hwid
ttv_get_hwid.argtypes = []
ttv_get_hwid.restype = ctypes.c_char_p

ttv_init = liveness_engine.ttv_init
ttv_init.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
ttv_init.restype = ctypes.c_int32

ttv_init_offline = liveness_engine.ttv_init_offline
ttv_init_offline.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
ttv_init_offline.restype = ctypes.c_int32


ttv_detect_face = liveness_engine.ttv_detect_face
ttv_detect_face.argtypes = [ndpointer(ctypes.c_ubyte, flags='C_CONTIGUOUS'), ctypes.c_int32, ctypes.c_int32, ndpointer(ctypes.c_int32, flags='C_CONTIGUOUS'), ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), ndpointer(ctypes.c_double, flags='C_CONTIGUOUS')]
ttv_detect_face.restype = ctypes.c_int32



cmake_minimum_required(VERSION 3.5)

project(test_liveness LANGUAGES CXX)

find_package(OpenCV REQUIRED)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(ttvfaceengine7 SHARED IMPORTED)
set_target_properties(ttvfaceengine7 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libttvfaceengine7.so)

add_executable(test_liveness main.cpp
)

target_include_directories(test_liveness
PUBLIC ${PROJECT_SOURCE_DIR}
PUBLIC ${OpenCV_INCLUDE_DIRS}
)


target_link_libraries(test_liveness
ttvfaceengine7
${OpenCV_LIBS}
)


#include <iostream>
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <vector>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <dirent.h>
#include <unistd.h>


#include "ttvfaceengine.h"

int main(int argc, char* argv[])
{
if (argc != 3)
{
printf("LiveTest: n"
"LiveTest [in folderPath] [out result.txt]n"
"tEx) ./LiveTest images result.txtn");
return 0;
}

const char* version = ttv_version();
printf("version: %sn", version);

int ret = ttv_init_offline("./dict", "license.txt");
if (ret != 0) {
printf("init failed: %dn", ret);
return 0;
}

printf("init ok!n");


cv::Mat image = cv::imread(argv[1]);

int faceBox[4] = { 0 };
double liveness[1] = { 0 };
double angles[3] = { 0 };
ttv_detect_face(image.data, image.cols, image.rows, faceBox, liveness, angles);

printf("%s, score = %f, ret = %d, yaw = %f, roll = %f, pitch = %fn", szFileName, liveness[0], ret, angles[0], angles[1], angles[2]);

return 0;
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.