派生自 Algorithm/baseDetector

cv
Scheaven
2021-06-03 fe1f84a5771290fa36f35478d13e117c58068b63
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
//
// Created by Scheaven on 2019/11/18.
//
#include "h_interface.h"
#include "std_target.h"
#include "time.h"
 
#include <opencv2/opencv.hpp>            // C++
 
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;
 
    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");
 
    // string path="/data/disk1/workspace/07_CPP/build/re";
    // std::vector<string> video_path_vec;
 
    // globFile(path, video_path_vec, "jpg");
 
    // for (auto& file:video_path_vec)
    // {
    while(1){        /* code */
        // printf("----start--%s\n", file);
        // cout<<"----------------\n\n"<<file<<endl;
        // frame = imread(file);
        cap >> frame;
        // frame = imread("/data/disk1/project/data/04_human/error/4.png");
        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;
 
            // if (t_result->count>0)
            // {
            //    imwrite("/data/disk2/01_dataset/03_human/02_person/positive/"+file.substr(file.find_last_of("/")), frame);
            // }else
            // {
            //     imwrite("/data/disk2/01_dataset/03_human/02_person/negate/"+file.substr(file.find_last_of("/")), frame);
            // }
 
 
        }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;
    }
    return 0;
}