Commit 8c6f7daa by wangquyuan

add by wqy

1 parent 641cf4ba
Showing with 31 additions and 12 deletions
......@@ -27,6 +27,8 @@ struct bone_config : public websocketpp::config::asio
static bool const enable_multithreading = true;
static size_t const max_message_size = 2048 * 1000 * 1000;
static long const timeout_open_handshake = 60 * 1000;
struct transport_config : public core::transport_config
{
typedef core::concurrency_type concurrency_type;
......
......@@ -509,7 +509,7 @@ static std::vector<float> face_action( const SeetaImageData &image, const SeetaP
try
{
features.resize( g_action->GetExtractFeatureSize() );
std::cout << "face_action: GetExtractFeatureSize():" << g_action->GetExtractFeatureSize() << std::endl;
//std::cout << "face_action: GetExtractFeatureSize():" << g_action->GetExtractFeatureSize() << std::endl;
g_action->Extract( image, points, features.data() );
}
catch( std::exception &e )
......@@ -526,7 +526,7 @@ static std::vector<float> face_emotion( const SeetaImageData &image, const Seeta
try
{
features.resize( g_emotion->emotion_count() );
std::cout << "face_emotion: emotion_count():" << g_emotion->emotion_count() << std::endl;
//std::cout << "face_emotion: emotion_count():" << g_emotion->emotion_count() << std::endl;
g_emotion->recognize_emotion( image, points, features.data() );
}
catch( std::exception &e )
......@@ -992,12 +992,12 @@ static void do_heart_rate( const std::string &videofile, int *rate )
}
}
std::cout << "-----num:" << num << std::endl;
//std::cout << "-----num:" << num << std::endl;
double value = 0.0;
int nret = recognize( m_heartrate, mat, img, faces.data[index].pos, value );
if( nret == 0 )
{
std::cout << "-----rate:" << value << std::endl;
//std::cout << "-----rate:" << value << std::endl;
rates.push_back( value );
if( rates.size() <= 1 )
{
......@@ -1162,7 +1162,7 @@ static void do_video( const std::string &videofile, int frameNum, int *eyes,
}
}
std::cout << "-----num:" << num << std::endl;
//std::cout << "-----num:" << num << std::endl;
SeetaPointF points[5];
......@@ -1194,6 +1194,8 @@ static void do_video( const std::string &videofile, int frameNum, int *eyes,
poses.push_back(yaw);
poses.push_back(pitch);
poses.push_back(roll);
//std::cout << "yaw:" << yaw << ",pitch:" << pitch << ",roll:" << roll << std::endl;
face_poses.push_back(poses);
seeta::EyeStateDetector::EYE_STATE leftstate, rightstate;
......@@ -1201,19 +1203,31 @@ static void do_video( const std::string &videofile, int frameNum, int *eyes,
eye_detect(img, points,leftstate,rightstate);
int count = geteyecount(m_leftstate, leftstate);
/*
if(count >= 0)
{
*eyes += count;
//*eyes += count;
m_leftstate = leftstate;
}
count = geteyecount(m_rightstate, rightstate);
if(count >= 0)
*/
m_leftstate = leftstate;
int count2 = geteyecount(m_rightstate, rightstate);
/*
if(count2 >= 0)
{
*eyes += count;
//*eyes += count;
m_rightstate = rightstate;
}
*/
m_rightstate = rightstate;
if ((count > 0) && (count2 > 0))
{
*eyes = (*eyes) + 1;
std::cout << "eyes:" << *eyes << std::endl;
}
if((leftstate == seeta::EyeStateDetector::EYE_OPEN) ||
(rightstate == seeta::EyeStateDetector::EYE_OPEN))
......@@ -1516,9 +1530,10 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
remove( filename.c_str() );
strresponse = "{\"code\":" + std::to_string(nret) + ",\"msg\":\"" + GetError( nret ) + "\",\"data\":{";
strresponse += "\"resultData\":{\"blinkNum\":" + std::to_string(eyes) + ",\"heartRate\":" + std::to_string(hearts) + "}";
strresponse += ",\"userfaces\":[";
strresponse += ",\"userFaces\":[";
for(int i=0; i<face_features.size(); i++)
//for(int i=0; i<2; i++)
{
std::string strtmp( ( const char * )face_features[i].data(), int( face_features[i].size() * sizeof( float ) ) );
std::string enbase64 = base64_encode( strtmp );
......@@ -1542,7 +1557,7 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
num = blink_eyes.size();
std::cout << "num:" << num << std::endl;
//num = 10;
//num = 3;
for(int i=0; i<num; i++)
{
if(i > 0)
......@@ -1597,6 +1612,7 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
std::cout << "response:" << strresponse.length() << std::endl;
create_http_response(con, strresponse, 200);
/*
int fd = open( "/tmp/response.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666 );
if( fd >= 0 )
{
......@@ -1604,6 +1620,7 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
close( fd );
}
sleep(1);
*/
return;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!