派生自 Algorithm/baseDetector

Scheaven
2021-01-05 6ae75cc17b2952c63a79ff2c86da841f0dbbf3c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Created by Scheaven on 2019/11/18.
//
#ifdef __cplusplus //
extern "C"
{
#endif
#include "h_interface.h"
#include "std_target.h"
#include "sdk.h"
#ifdef __cplusplus //
}
#endif
#include <thread>
#include <unistd.h>
#include <cstdlib>
#include "time.h"
#include <stdio.h>
#include <string.h>
//#ifdef OPENCV
#include <opencv2/opencv.hpp>            // C++
//#pragma comment(lib, "opencv_core249.lib")
//#pragma comment(lib, "opencv_imgproc249.lib")
//#pragma comment(lib, "opencv_highgui249.lib")
//#endif    // OPENCV
 
using namespace std;
using namespace cv;
 
 
int main(int argc, char *argv[])
{
//    //视频流信息
    VideoCapture cap;
 
    try {
 
       if(argc>1)
       {
           cap.open(argv[1]);
       }else
         cap.open("rtsp://admin:a1234567@192.168.5.37:554/h264/ch1/main/av_stream");
    }catch(exception){
        cout<<"输入视频"<<endl;
        return 0;
    }
 
    Mat frame, blob;
    Mat frame2, blob2;
    int ii = 0;
    const char *so_path = "../libyolo.so";
    const char *conf = "../config.json";
    std::cout << "create " << std::endl;
    container::sdk yoloSdk = container::sdk("1");
    int ret = yoloSdk.init(so_path, conf);
    std::cout << "create over" << ret << std::endl;
    int hum_i=0;
    while (true) {
        std::vector<int> cam_ids;
        //读取视频帧
        std::clock_t t_strat0 = std::clock();
        cap >> frame;
//        if(ii++%2){
//            continue;
//        }
        std::clock_t t_strat2 = std::clock();
  //      cout << "t2----"<<t_strat2<<endl;
        if(!frame.empty()){
           // cout << "=------cv rps" << cap.get(5) << endl;
           //  std::clock_t t_strat1 = std::clock();
            yoloSdk.run(frame.data, frame.cols, frame.rows, 3);
            //std::clock_t t_strat3 = std::clock();
           // cout << "rps---"<< CLOCKS_PER_SEC/(t_strat3 - t_strat1)  <<endl;
            
        }else{
            cout << "-----------------------over--" << endl;
            break;
        }
    }
           yoloSdk.release();
           cout << "--------------------" << endl;
       sleep(100);
 
    return 0;
}