admin
2025-04-27 9280d221d473730e81738628d1b247131f500a64
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
#pragma once
#include <cuda_runtime.h>
#include <vector>
 
#define min_utils(a,b) ((a)<(b)?(a):(b))
 
//计算仿射变换矩阵,矩阵是居中缩放
struct AffineMatrix {
 
    float i2d[6], d2i[6];
 
    void compute(const int from_width, const int from_height, const int to_width, const int to_height) {
        float scale_x = to_width / (float)from_width;
        float scale_y = to_height / (float)from_height;
 
        float scale = min_utils(scale_x, scale_y);
        float ox = (-scale * from_width + to_width + scale - 1) * 0.5;
        float oy = (-scale * from_height + to_height + scale - 1) * 0.5;
        float k = 1 / scale;
 
        i2d[0] = scale;  i2d[1] = 0; i2d[2] = ox;
        i2d[3] = 0;  i2d[4] = scale;  i2d[5] = oy;
 
        d2i[0] = k;  d2i[1] = 0; d2i[2] = -k * ox;
        d2i[3] = 0;  d2i[4] = k;  d2i[5] = -k * oy;
 
    }
 
};
 
struct Box {
    int x, y, width, height;
    float score;
    int class_id;
};
 
struct point {
    float x;
    float y;
};
 
bool panduan(std::vector<point> polygons, point p);