派生自 Algorithm/baseDetector

Scheaven
2021-06-03 168af40fe9a3cc81c6ee16b3e81f154780c36bdb
main.cpp
New file
@@ -0,0 +1,93 @@
//
// 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;
    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;
}