派生自 Algorithm/baseDetector

孙天宇
2022-07-12 ce9d187fd294cca192a27f52719094e9df7b1b62
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
    //
// Created by Scheaven on 2019/11/18.
//
#include "src/h_interface.h"
#include "src/std_target.h"
#include <opencv2/opencv.hpp>           // C++
#include "src/utils/draw_util.h"
 
using namespace std;
using namespace cv;
void* handle;
bool do_frame(Mat frame, TImage *img, void *sr, void* handle, int cam_id)
{
    if(!frame.empty())
    {
        img->width = frame.cols;
        img->height = frame.rows;
        img->channel = frame.channels();
        img->data = frame.data;
        const char * img_time = fa_getSysTime();
        const char* mode = "video";
//        printf("===%s\n",img_time);
        std::cout<< "===%s:" << img_time << std::endl;
 
        sr = get_result2(handle, img, cam_id, img_time, mode);
        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;
            cout << "====1111111111===attri:" << t_result->targets[i].attribute << endl;
        }
 
        return true;
    }else{
        cout << "-----------------------over--" << endl;
        release(handle);
        release_result(sr);
        return false;
    }
}
 
int main(int argc, char *argv[])
{
//    //视频流信息
    VideoCapture cap;
    VideoCapture cap2;
    int cam_id = 0;
    int cam_id2 = 1;
 
    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;
    cap = VideoCapture("/data/disk2/01_dataset/03_human/34983128.mp4");
 
    while(1){        /* code */
        cap >> frame;
        if(!frame.empty())
        {
            // std::clock_t t_strat2 = std::clock();
            if(!do_frame(frame, img, sr, handle, i))
                return 0;
            cout << "-------------" << endl;
        }else{
            cout << "------------over--" << endl;
            release(handle);
            release_result(sr);
            break;
        }
    }
    return 0;
}