#include "PipeLine.h" #include "PL_RTSPClient.h" #include "PL_RTSPServer.h" #include "PL_H264Decoder.h" #include "PL_H264Encoder.h" #include "PL_AVFrameYUV420.h" #include "PL_AVFrameBGRA.h" #include "PL_Queue.h" #include "PL_Scale.h" #include "PL_Fork.h" #include "PL_SensetimeFaceTrack.h" #include "PL_DlibFaceTrack.h" #include "PipeLinePool.h" #include "ev_server.h" #include "ev_proto.h" #include "logger.h" PipeLinePool g_PipeLinePool; evclient_proc_t evclient_proc; bool ev_proc_SensetimeFaceDetect(EVClientStub& client) { } bool ev_proc(EVClientStub& client) { EVPHeader* evpHeader = (EVPHeader*)client.recvBuff; //#todo check cmd and size //#test send 01000B0000004142434445 //LOG_DEBUG << "cmd=" << evpHeader->cmd << ", size=" << evpHeader->size << ", \t" << (char*)(evpHeader + sizeof(EVPHeader)); //return true; PipeLine* pipeLine = nullptr; if (g_PipeLinePool.wait_free()) pipeLine = g_PipeLinePool.get_free(); if (pipeLine == nullptr) { LOG_WARN << "can't get free pipeline";//#todo send err packet return false; } PipeMaterial pm; // fill PipeLineElem* plElem = pipeLine.pipe(&pm); if (! pipeLine.check_pipe_complete(plElem)) { LOG_WARN << "pipeline not complete"; g_PipeLinePool.release(pipeLine);//#todo send err packet return false; } if (!plElem->gain(pm)) { LOG_WARN << "pipeline gain error"; g_PipeLinePool.release(pipeLine);//#todo send err packet return false; } if (pm.type == PipeMaterial::PMT_PM_LIST) { PipeMaterial& facePM = ((PipeMaterial*)(pm.buffer))[1]; st_ff_vect_t& faceFeatures = *((st_ff_vect_t*)facePM.buffer); LOG_NOTICE << "faceFeatures " << faceFeatures.size(); //#todo send result packet } g_PipeLinePool.release(pipeLine); return false; } int main(int argc, char** argv) { initLogger(LV_DEBUG); PipeLine::register_global_elem_creator("PL_SensetimeFaceTrack", create_PL_SensetimeFaceTrack); g_PipeLinePool = new PipeLinePool(true); for (int i = 0; i < 5; i++) { PipeLine* pipeLine = new PipeLine; {//payer//#todo } { SensetimeFaceTrackConfig config; config.generate_face_feature = true; PL_SensetimeFaceTrack* sensetimeFaceTrack = (PL_SensetimeFaceTrack*)pipeLine->push_elem("PL_SensetimeFaceTrack"); bool ret = sensetimeFaceTrack->init(&config); if (!ret) { LOG_ERROR << "sensetimeFaceTrack init error"; exit(EXIT_FAILURE); } } g_PipeLinePool.manage(pipeLine); } evclient_proc = ev_proc; return server_main(argc, argv); while(true) { //LOG_ERROR << "begin pipe"; PipeMaterial pm; if (pipeLine.pipe(&pm) == sensetimeFaceTrack); sensetimeFaceTrack->gain(pm); if (pm.type == PipeMaterial::PMT_PM_LIST) { PipeMaterial& facePM = ((PipeMaterial*)(pm.buffer))[1]; st_ff_vect_t& faceFeatures = *((st_ff_vect_t*)facePM.buffer); LOG_NOTICE << "faceFeatures " << faceFeatures.size(); } //LOG_ERROR << "end pipe"; } }