派生自 Algorithm/baseDetector

Scheaven
2021-06-03 168af40fe9a3cc81c6ee16b3e81f154780c36bdb
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// Created by Scheaven on 2019/11/18.
//
#include "h_interface.h"
#include "std_target.h"
#include "time.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;
void* handle;
 
int main(int argc, char *argv[])
{
//    //视频流信息
    VideoCapture cap;
    VideoCapture cap2;
    int cam_id = 0;
    int cam_id2 = 1;
    std::string cam_name = "18eadadc-f583-4517-8c5d-e2a8cb605f97";
    std::string cam_name2 = "71ddf5e0-c059-48d7-8a58-dfe824d6e462";
 
    try {
//        cap.open("rtsp://admin:a1234567@192.168.5.35:554/h264/ch1/main/av_stream");
//        cap2.open("rtsp://admin:a1234567@192.168.5.34:554/h264/ch1/main/av_stream");
        cap.open("/data/disk1/project/data/01_reid/sun_37.avi");
        cap2.open("/data/disk1/project/data/01_reid/sun_51.avi");
//        cap.open("/home/disk2/workspace/Scheaven/data/01_reid/cD3.avi");
//        cap2.open("/home/disk2/workspace/Scheaven/data/01_reid/cT3.avi");
    }catch(exception){
        cout<<"输入视频"<<endl;
        return 0;
    }
 
    Mat frame, blob;
    Mat frame2, blob2;
 
    const char *conf = "../config.json";
    int *max_chan;
    int x = 5;
    max_chan=&x;
    handle = create(conf, max_chan);
 
    void *sr;
    void *sr2;
    TImage *img = new TImage();
    TImage *img2 = new TImage();
    int i = 0;
 
    while (true)
    {
        std::vector<int> cam_ids;
        //读取视频帧
        cap >> frame;
        //cap2 >> frame2;
        //if(i++%5!= 0)
        //    sleep(1000);
 
        clock_t t_strat2 = clock();
        if(!frame.empty())
        {
            img->width = frame.cols;
            img->height = frame.rows;
            img->channel = frame.channels();
            img->data = frame.data;
            sr = get_result(handle, img, 0);
 
            TResult * t_result = (TResult*) sr;
 
            cout << "=======t_result->count==" << t_result->count  << endl;
            for (int i=0; i<t_result->count; i++)
                cout << "====1111111111===confidence:" << t_result->targets[i].confidence << endl;
 
        }else{
            cout << "-----------------------over--" << endl;
            release(handle);
            release_result(sr);
            break;
        }
 
        clock_t t_strat3 = clock();
        cout << "rps---"<< CLOCKS_PER_SEC/(t_strat3 - t_strat2)  <<endl;
//
//        if(!frame2.empty())
//        {
//            img2->width = frame2.cols;
//            img2->height = frame2.rows;
//            img2->channel = frame2.channels();
//            img2->data = frame2.data;
//
//            sr2 = get_result(handle, img, 1);
//
//            TResult * t_result2 = (TResult*) sr2;
//
//            cout << "=======t_result2->count==" << t_result2->count  << endl;
//            for (int i=0; i<t_result2->count; i++)
//                cout << "====22222222===confidence:" << t_result2->targets[i].id << endl;
//
//        }else{
//            cout << "-----------------------over2--" << endl;
//            release(handle);
//            release_result(sr2);
//            break;
//        }
    }
    return 0;
}