MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / Forward_cpu

Method Forward_cpu

rtpose_wrapper/src/caffe/cpm/layers/nms_layer.cpp:32–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31template <typename Dtype>
32void NmsLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top){
33 const int num = bottom[0]->shape(0);
34 //const int channel = bottom[0]->shape(1);
35 //std::cout << "cpu here!" << std::endl;
36 const int oriSpatialHeight = bottom[0]->shape(2);
37 const int oriSpatialWidth = bottom[0]->shape(3);
38
39 Dtype* dst_pointer = top[0]->mutable_cpu_data();
40 const Dtype* const src_pointer = bottom[0]->cpu_data();
41 const int offset2 = oriSpatialHeight * oriSpatialWidth;
42 const int offset2_dst = (max_peaks_+1)*2;
43
44 //stupid method
45 for(int n = 0; n < num; n++){
46 //assume only one channel
47 int peakCount = 0;
48
49 for (int y = 0; y < oriSpatialHeight; y++){
50 for (int x = 0; x < oriSpatialWidth; x++){
51 const Dtype value = src_pointer[n * offset2 + y*oriSpatialWidth + x];
52 if(value < threshold_) continue;
53 const Dtype top = (y == 0) ? 0 : src_pointer[n * offset2 + (y-1)*oriSpatialWidth + x];
54 const Dtype bottom = (y == oriSpatialHeight - 1) ? 0 : src_pointer[n * offset2 + (y+1)*oriSpatialWidth + x];
55 const Dtype left = (x == 0) ? 0 : src_pointer[n * offset2 + y*oriSpatialWidth + (x-1)];
56 const Dtype right = (x == oriSpatialWidth - 1) ? 0 : src_pointer[n * offset2 + y*oriSpatialWidth + (x+1)];
57 if(value > top && value > bottom && value > left && value > right){
58 dst_pointer[n*offset2_dst + (peakCount + 1) * 2] = x;
59 dst_pointer[n*offset2_dst + (peakCount + 1) * 2 + 1] = y;
60 peakCount++;
61 }
62 }
63 }
64 dst_pointer[n*offset2_dst] = peakCount;
65 }
66}
67
68template <typename Dtype>
69void NmsLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom){

Callers

nothing calls this directly

Calls 3

shapeMethod · 0.80
mutable_cpu_dataMethod · 0.45
cpu_dataMethod · 0.45

Tested by

no test coverage detected