xf::cv::fast解析笔记...

7 篇文章 1 订阅

 

template<int NMS,int SRC_T,int ROWS, int COLS,int NPC=1>
void fast(xf::Mat<SRC_T, ROWS, COLS, NPC> & _src_mat,xf::Mat<SRC_T, ROWS, COLS, NPC> & _dst_mat,unsigned char _threshold)

This function can be used for both still images and videos. The corners are marked in the image. If the corner is found in a particular location, that location is marked with 255, otherwise it is zero.

Table 216. fast Parameter Description
ParameterDescription
NMSIf NMS == 1, non-maximum suppression is applied to detected corners (keypoints). The value should be 0 or 1.
SRC_TInput pixel type. Only 8-bit, unsigned, 1-channel is supported (XF_8UC1)
ROWSMaximum height of input image.
COLSMaximum width of input image (must be a multiple of 8, for 8-pixel operation)
NPCNumber of pixels to be processed per cycle; possible options are XF_NPPC1 and XF_NPPC8 for 1 pixel and 8 pixel operations respectively.
_src_matInput image
_dst_matOutput image. The corners are marked in the image.
_threshol dThreshold on the intensity difference between the center pixel and its neighbors. Usually it is taken around 20.

库参考

xf::Mat Image Container Class

Data Types

数据类型会有所不同,这取决于像素的深度和图像中通道的数量的组合。参数的通用命名法如下所示

XF_<Number of bits per pixel><signed (S) or unsigned (U) or float (F)>C<number of channels>

The following table lists the available data types for the xf::Mat class:

Table xf::Mat Class - Available Data Types
OptionNumber of bits per PixelUnsigned/ Signed/ Float TypeNumber of Channels
XF_8UC18Unsigned1
XF_16UC116Unsigned1
XF_16SC116Signed1
XF_32UC132Unsigned1
XF_32FC132Float1
XF_32SC132Signed1
XF_8UC28Unsigned2
XF_8UC48Unsigned4
XF_8UC38Unsigned3
XF_2UC12Unsigned1

 

XF_8UC1 stands for 8-bit unsigned and one channel pixel. More types can be found in include/common/xf_params.h.

SRC_T  :XF_8UC1

Vitis_Libraries-master\vision\L1\include\feature\xf_fast.hpp

xf_params.hpp

xf_params.hpp

// Pixel Per Cycle
enum _pixel_per_cycle {
    XF_NPPC1 = 1,
    XF_NPPC2 = 2,
    XF_NPPC4 = 4,
    XF_NPPC8 = 8,
    XF_NPPC16 = 16,
    XF_NPPC32 = 32,
    XF_NPPC64 = 64
};
typedef _pixel_per_cycle XF_nppc_e;

// Pixel types
enum _pixel_type {
    XF_8UP = 0,
    XF_8SP = 1,
    XF_16UP = 2,
    XF_16SP = 3,
    XF_32UP = 4,
    XF_32SP = 5,
    XF_19SP = 6,
    XF_32FP = 7,
    XF_35SP = 8,
    XF_24SP = 9,
    XF_20SP = 10,
    XF_48SP = 11,
    XF_2UP = 12,
    XF_9SP = 13,
    XF_9UP = 14,
    XF_24UP = 15,
    XF_64UP = 16,
    XF_10UP = 17,
    XF_12UP = 18,
    XF_40UP = 19,
    XF_48UP = 20,
    XF_30UP = 21,
    XF_36UP = 22
};
typedef _pixel_type XF_pixel_type_e;

XF_DEPTH、XF_WORDWIDTH

xf_types.hpp 


#define XF_DEPTH(flags, npc) DataType<flags, npc>::pixeldepth
#define XF_WORDWIDTH(flags, npc) DataType<flags, npc>::wordwidth
#define XF_PTNAME(flags) typename PixelType<flags>::name

struct DataType<XF_8UC1, XF_NPPC8> {
    typedef ap_uint<64> name;
    typedef ap_uint<8> uname;
    typedef ap_uint<8> cname;
    typedef unsigned char sname;
    typedef unsigned long long wname;
    static const int bitdepth = 8;
    static const int pixelwidth = 8;
    static const int pixeldepth = XF_8UP;
    static const int wordwidth = XF_64UW;
    static const int channel = 1;
};

template <>
struct DataType<XF_8UC1, XF_NPPC1> {
    typedef ap_uint<8> name;
    typedef ap_uint<8> uname;
    typedef ap_uint<8> cname;
    typedef unsigned char sname;
    typedef unsigned char wname;
    static const int bitdepth = 8;
    static const int pixelwidth = 8;
    static const int pixeldepth = XF_8UP;
    static const int wordwidth = XF_8UW;
    static const int channel = 1;
};

void fast()

template <int NMS, int SRC_T, int ROWS, int COLS, int NPC = 1>
void fast(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat,
          xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _dst_mat,
          unsigned char _threshold) {
    #pragma HLS inline off
    xFFastCornerDetection<SRC_T, ROWS, COLS, XF_DEPTH(SRC_T, NPC), NPC, XF_WORDWIDTH(SRC_T, NPC), XF_32UW, NMS>(
        _src_mat, _dst_mat, _src_mat.rows, _src_mat.cols, _threshold);
}

 

void xFFastCornerDetection()

template <int SRC_T, int ROWS, int COLS, int DEPTH, int NPC, int WORDWIDTH_SRC, int WORDWIDTH_DST, int NMSVAL>
void xFFastCornerDetection(xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _src_mat,
                           xf::cv::Mat<SRC_T, ROWS, COLS, NPC>& _dst_mat,
                           unsigned short _image_height,
                           unsigned short _image_width,
                           uchar_t _threshold) {
#ifndef __SYNTHESIS__
    assert(((DEPTH == XF_8UP)) &&
           "Invalid Depth. The function xFFast "
           "is valid only for the Depths AU_8U");

    assert(((NMSVAL == 0) || (NMSVAL == 1)) && "Invalid Value. The NMS value should be either 0 or 1");

    assert(((_image_height <= ROWS) && (_image_width <= COLS)) && "ROWS and COLS should be greater than input image");
#endif

    xf::cv::Mat<SRC_T, ROWS, COLS, NPC> _dst(_image_height, _image_width);

#pragma HLS stream variable = _dst.data dim = 1 depth = 2

    if (NMSVAL == 1) {
        #pragma HLS DATAFLOW
        xFfast7x7<SRC_T, ROWS, COLS, DEPTH, NPC, WORDWIDTH_SRC, (COLS >> XF_BITSHIFT(NPC)) + (7 >> 1), 7, 7 * 7>(
            _src_mat, _dst, 7, _image_height, _image_width, _threshold);
        xFfastnms<SRC_T, ROWS, COLS, DEPTH, NPC, WORDWIDTH_SRC, (COLS >> XF_BITSHIFT(NPC)) + (3 >> 1), 3, 3 * 3>(
            _dst, _dst_mat, 3, _image_height, _image_width);
    } 
    else if (NMSVAL == 0) {
        #pragma HLS DATAFLOW
        xFfast7x7<SRC_T, ROWS, COLS, DEPTH, NPC, WORDWIDTH_SRC, (COLS >> XF_BITSHIFT(NPC)) + (7 >> 1), 7, 7 * 7>(
            _src_mat, _dst_mat, 7, _image_height, _image_width, _threshold);
    }
}

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值