// // Created by ps on 18-12-18. // #include #include "FaceTrackingWrapper.h" using namespace cv; //get current system time double msecond() { struct timeval tv; gettimeofday(&tv, 0); return (tv.tv_sec * 1.0e3 + tv.tv_usec * 1.0e-3); } int main(int argc, char **argv) { ENABLEGLOG("./log/"); FaceTrackingWrapper faceTrackingWrapper; bool bOpen; VideoCapture vc; // rtsp stream address bOpen = vc.open("rtsp://admin:a1234567@192.168.1.188:554/h264/ch1/main/av_stream"); //camera // if (1) { // bool bSet1 = vc.set(CV_CAP_PROP_FRAME_WIDTH, w); // bool bSet2 = vc.set(CV_CAP_PROP_FRAME_HEIGHT, h); // bOpen = vc.open(devID); // // } // //video file // else { // bOpen = vc.open("test.avi"); // // } if (!bOpen) { printf("Open video source faild."); return 0; } int nWidth = vc.get(CV_CAP_PROP_FRAME_WIDTH); int nHeight = vc.get(CV_CAP_PROP_FRAME_HEIGHT); printf("FRAME_WIDTH=%d,FRAME_HEIGHT=%d\n", nWidth, nHeight); BasicFace::InitParam initParam; initParam.nDeviceID = 0; initParam.nImageWidth = nWidth; initParam.nImageHeight = nHeight; initParam.nMaxFaceNum = 50; initParam.nSampleSize = nWidth / 2; initParam.nDetectionIntervalFrame = 12; faceTrackingWrapper.setChannelParam(0, initParam); faceTrackingWrapper.setChannelParam(1, initParam); faceTrackingWrapper.setChannelParam(2, initParam); faceTrackingWrapper.initHandle(); Mat frame; while (1) { vc >> frame; if (frame.empty()) { waitKey(30); continue; } int nNum = 0; THFT_FaceInfo *pFaceInfos = new THFT_FaceInfo[50]; double t1, t2; t1 = msecond(); // nNum = THFT_FaceTracking(2, frame.data, pFaceInfos); BasicFace::FaceImage faceImage2{frame.cols, frame.rows, frame.step, frame.data}; auto t_lists = faceTrackingWrapper.trackingFace(2, faceImage2); t2 = msecond(); delete[] pFaceInfos; printf("face tracking time=%fms faceNun is %d\n", t2 - t1, (int) t_lists.size()); imshow("Face Tracking", frame); waitKey(30); } destroyWindow("Face Tracking"); vc.release(); THFT_Release(); getchar(); return 0; INFO("test"); }