| 95 | } |
| 96 | }; |
| 97 | void proposal_local_anchor(int feat_height, int feat_width, int feat_stride, std::vector<Anchor>& anchors, |
| 98 | float* local_anchors) |
| 99 | { |
| 100 | int length = std::max(feat_height, feat_width); |
| 101 | int feat_size = feat_height * feat_width; |
| 102 | int* map_m = new int[length]; |
| 103 | for(int i = 0; i < length; ++i) |
| 104 | { |
| 105 | map_m[i] = i * feat_stride; |
| 106 | } |
| 107 | float* shift_x = new float[feat_size]; |
| 108 | float* shift_y = new float[feat_size]; |
| 109 | for(int i = 0; i < feat_height; ++i) |
| 110 | { |
| 111 | for(int j = 0; j < feat_width; ++j) |
| 112 | { |
| 113 | shift_x[i * feat_width + j] = map_m[j]; |
| 114 | shift_y[i * feat_width + j] = map_m[i]; |
| 115 | } |
| 116 | } |
| 117 | int num_anchors = ( int )anchors.size(); |
| 118 | float* a = local_anchors; |
| 119 | for(int i = 0; i < num_anchors; ++i) |
| 120 | { |
| 121 | _set(feat_size, anchors[i].x0, a + (i * 4 + 0) * feat_size); |
| 122 | _set(feat_size, anchors[i].y0, a + (i * 4 + 1) * feat_size); |
| 123 | _set(feat_size, anchors[i].x1, a + (i * 4 + 2) * feat_size); |
| 124 | _set(feat_size, anchors[i].y1, a + (i * 4 + 3) * feat_size); |
| 125 | _axpy(feat_size, shift_x, a + (i * 4 + 0) * feat_size); |
| 126 | _axpy(feat_size, shift_x, a + (i * 4 + 2) * feat_size); |
| 127 | _axpy(feat_size, shift_y, a + (i * 4 + 1) * feat_size); |
| 128 | _axpy(feat_size, shift_y, a + (i * 4 + 3) * feat_size); |
| 129 | } |
| 130 | delete[] map_m; |
| 131 | delete[] shift_x; |
| 132 | delete[] shift_y; |
| 133 | } |
| 134 | |
| 135 | void bbox_tranform_inv(float* m_box, float* local_anchors, int height, int width, int channel, int num_anchors) |
| 136 | { |