RetinaFace-Cpp
RetinaFace-Cpp copied to clipboard
about Cube struct
Cube cls;
Cube reg;
Cube pts;
// get blob output
char clsname[100]; sprintf(clsname, "face_rpn_cls_prob_reshape_stride%d", _feat_stride_fpn[i]);
char regname[100]; sprintf(regname, "face_rpn_bbox_pred_stride%d", _feat_stride_fpn[i]);
char ptsname[100]; sprintf(ptsname, "face_rpn_landmark_pred_stride%d", _feat_stride_fpn[i]);
net.Extract(nc, clsname, cls);
net.Extract(nc, regname, reg);
net.Extract(nc, ptsname, pts);
```when i use caffe C++, i find Cube not defined. Can you show me its structure?
if you use caffe, replace cube to "caffe:Blob"
mxnet 如何替换,有没有提示性质的建议
参考mxnet c++接口的例子
int AnchorGenerator::FilterAnchor(mxnet::cpp::NDArray& cls, mxnet::cpp::NDArray& reg, mxnet::cpp::NDArray& pts, std::vector<Anchor>& result) { assert(cls.GetShape()[1] == anchor_num2); assert(reg.GetShape()[1] == anchor_num4); int pts_length = 0;
assert(pts.GetShape()[1] % anchor_num == 0);
pts_length = pts.GetShape()[1]/anchor_num/2;
int w = cls.GetShape()[3];
int h = cls.GetShape()[2];
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
int id = i * w + j;
for (int a = 0; a < anchor_num; ++a)
{
//std::cout<< j << "--------"<< i << "--------"<< id << "--------"<<cls.channel(anchor_num + a)[id]<<std::endl;
if (cls.GetData()[(anchor_num + a) * h * w + id] >= cls_threshold) {
//printf("cls %f\n", cls.channel(anchor_num + a)[id]);
CRect2f box(j * anchor_stride + preset_anchors[a][0],
i * anchor_stride + preset_anchors[a][1],
j * anchor_stride + preset_anchors[a][2],
i * anchor_stride + preset_anchors[a][3]);
//printf("%f %f %f %f\n", box[0], box[1], box[2], box[3]);
CRect2f delta(reg.GetData()[(a*4+0) * h * w+id],
reg.GetData()[(a*4+1) * h * w+id],
reg.GetData()[(a*4+2) * h * w+id],
reg.GetData()[(a*4+3) * h * w+id]);
Anchor res;
res.anchor = cv::Rect_< float >(box[0], box[1], box[2], box[3]);
bbox_pred(box, delta, res.finalbox);
//printf("bbox pred\n");
res.score = cls.GetData()[(anchor_num + a) * h * w+id];
res.center = cv::Point(j,i);
//printf("center %d %d\n", j, i);
if (1) {
std::vector<cv::Point2f> pts_delta(pts_length);
for (int p = 0; p < pts_length; ++p) {
pts_delta[p].x = pts.GetData()[(a*pts_length*2+p*2) * h * w+id];
pts_delta[p].y = pts.GetData()[(a*pts_length*2+p*2+1) * h * w+id];
}
//printf("ready landmark_pred\n");
landmark_pred(box, pts_delta, res.pts);
//printf("landmark_pred\n");
}
result.push_back(res);
}
}
}
}
return 0;
}
@Charrin @dwjlw1314 @zys1994 What is Cube? is it C++ class?