xuxiuxi
2017-05-11 109ffe9a777658936a38d0c146579a67c60a0d17
RtspFace/main.cpp
@@ -14,10 +14,13 @@
#include "PL_DlibFaceTrack.h"
#include "logger.h"
#include <iostream>
Logger g_logger(std::cout);
int main(int argc, char** argv)
{
   initLogger(LV_DEBUG);
   g_logger.set_level(VERBOSE);
   PipeLine pipeLine;
   
@@ -25,6 +28,7 @@
   PipeLine::register_global_elem_creator("PL_RTSPServer", create_PL_RTSPServer);
   PipeLine::register_global_elem_creator("PL_H264Decoder", create_PL_H264Decoder);
   PipeLine::register_global_elem_creator("PL_AVFrameYUV420", create_PL_AVFrameYUV420);
   PipeLine::register_global_elem_creator("PL_AVFrameBGRA", create_PL_AVFrameBGRA);
   PipeLine::register_global_elem_creator("PL_H264Encoder", create_PL_H264Encoder);
   PipeLine::register_global_elem_creator("PL_Queue", create_PL_Queue);
   PipeLine::register_global_elem_creator("PL_Scale", create_PL_Scale);
@@ -46,7 +50,7 @@
      bool ret = rtspClient->init(&rtspConfig);
      if (!ret)
      {
         LOG_ERROR << "rtspClient.init error";
         LOG_ERROR << "rtspClient.init error" << std::endl;
         exit(EXIT_FAILURE);
      }
   }
@@ -56,7 +60,7 @@
      bool ret = h264Decoder->init(nullptr);
      if (!ret)
      {
         LOG_ERROR << "PL_H264Decoder.init error";
         LOG_ERROR << "PL_H264Decoder.init error" << std::endl;
         exit(EXIT_FAILURE);
      }
   }
@@ -66,30 +70,42 @@
      bool ret = avFrameYUV420->init(nullptr);
      if (!ret)
      {
         LOG_ERROR << "PL_AVFrameYUV420.init error";
         LOG_ERROR << "PL_AVFrameYUV420.init error" << std::endl;
         exit(EXIT_FAILURE);
      }
   }
   
   {
      PL_Scale_Config config;
      config.toWidth = 800;
      config.toHeight = 600;
      config.toWidth = 480;
      config.toHeight = 360;
      PL_Scale* ple = (PL_Scale*)pipeLine.push_elem("PL_Scale");
      bool ret = ple->init(&config);
      if (!ret)
      {
         LOG_ERROR << "PL_Scale.init error";
         LOG_ERROR << "PL_Scale.init error" << std::endl;
         exit(EXIT_FAILURE);
      }
   }
   {
      PL_AVFrameBGRA_Config config;
      config.convertTo = PL_AVFrameBGRA_Config::I420_TO_RGBA8888;
      PL_AVFrameBGRA* ple = (PL_AVFrameBGRA*)pipeLine.push_elem("PL_AVFrameBGRA");
      bool ret = ple->init(&config);
      if (!ret)
      {
         LOG_ERROR << "PL_AVFrameBGRA.init error" << std::endl;
         exit(EXIT_FAILURE);
      }
   }
   {
      SensetimeFaceTrackConfig config;
      //config.generate_face_feature = true;
      PL_SensetimeFaceTrack* ple = (PL_SensetimeFaceTrack*)pipeLine.push_elem("PL_SensetimeFaceTrack");
      ple->init(&config);
   }
   //{
   //   SensetimeFaceTrackConfig config;
   //   //config.generate_face_feature = true;
   //   PL_SensetimeFaceTrack* ple = (PL_SensetimeFaceTrack*)pipeLine.push_elem("PL_SensetimeFaceTrack");
   //   ple->init(&config);
   //}
   
   //PipeLine pipeLine2;
   //{
@@ -119,36 +135,39 @@
   //   bool ret = queue1->init(&config);
   //   if (!ret)
   //   {
   //      LOG_ERROR << "queue1.init error";
   //      LOG_ERROR << "queue1.init error" << std::endl;
   //      exit(EXIT_FAILURE);
   //   }
   //}
   {
      PL_H264Encoder_Config config;
      PL_H264Encoder* h264Encoder = (PL_H264Encoder*)pipeLine.push_elem("PL_H264Encoder");
      bool ret = h264Encoder->init(&config);
      if (!ret)
      {
         LOG_ERROR << "PL_H264Encoder.init error";
         exit(EXIT_FAILURE);
      }
   }
   {
      PL_RTSPServer* rtspServer = (PL_RTSPServer*)pipeLine.push_elem("PL_RTSPServer");
      bool ret = rtspServer->init(nullptr);
      if (!ret)
      {
         LOG_ERROR << "rtspServer.init error";
         exit(EXIT_FAILURE);
      }
   }
   //{
   //   PL_H264Encoder_Config config;
   //   config.av_opt_preset = "superfast";
   //   config.av_opt_tune = "zerolatency";
   //   config.avc_profile_str = "baseline";
   //   PL_H264Encoder* h264Encoder = (PL_H264Encoder*)pipeLine.push_elem("PL_H264Encoder");
   //   bool ret = h264Encoder->init(&config);
   //   if (!ret)
   //   {
   //      LOG_ERROR << "PL_H264Encoder.init error" << std::endl;
   //      exit(EXIT_FAILURE);
   //   }
   //}
    //
   //{
   //   PL_RTSPServer* rtspServer = (PL_RTSPServer*)pipeLine.push_elem("PL_RTSPServer");
   //   bool ret = rtspServer->init(nullptr);
   //   if (!ret)
   //   {
   //      LOG_ERROR << "rtspServer.init error" << std::endl;
   //      exit(EXIT_FAILURE);
   //   }
   //}
   
   while(true)
   {
      //LOG_ERROR << "begin pipe";
      //LOG_ERROR << "begin pipe" << std::endl;
      pipeLine.pipe();
      //LOG_ERROR << "end pipe";
      //LOG_ERROR << "end pipe" << std::endl;
   }
}