关于ROI Align的算法原理讲解,博客有很多,但是暂时没发现有讲解源码的,笔者最近使用Faster rcnn代码时就想仔细了解一下roi align的代码。于是就读了一下其代码,代码由C语言写的,也不是非常难理解,在这里贴一下自己对代码的理解,若有错误,欢迎大家批评指正。
void ROIAlignForwardCpu(const float* bottom_data, const float spatial_scale, const int num_rois,
const int height, const int width, const int channels,
const int aligned_height, const int aligned_width, const float * bottom_rois,
float* top_data)//参数众多,第一个是data_flat,数据集合,第二个是空间尺度,第
//第三个rios数量,第四个data height 第五个 data width 第六个通道数量,第七
和第八个aligned 高和宽,接下来两个分别是rios的数据信息和输出的信息output
{
const int output_size = num_rois * aligned_height * aligned_width * channels;
int idx = 0;
for (idx = 0; idx < output_size; ++idx)
{
// (n, c, ph, pw) is an element in the aligned output
int pw = idx