From 96024c860270477fe9cf387ba855632a3ead08ee Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期二, 18 十二月 2018 18:08:24 +0800
Subject: [PATCH] add Face tracking demo code

---
 QiaoJiaSystem/testCodeMod/main.cpp |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/QiaoJiaSystem/testCodeMod/main.cpp b/QiaoJiaSystem/testCodeMod/main.cpp
index 7bd3451..11f3fd1 100644
--- a/QiaoJiaSystem/testCodeMod/main.cpp
+++ b/QiaoJiaSystem/testCodeMod/main.cpp
@@ -3,10 +3,95 @@
 //
 
 #include <Debug.h>
+#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");
 

--
Gitblit v1.8.0