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

 

template
void fast(xf::Mat & _src_mat,xf::Mat & _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
Parameter Description
NMS If NMS == 1, non-maximum suppression is applied to detected corners (keypoints). The value should be 0 or 1.
SRC_T Input pixel type. Only 8-bit, unsigned, 1-channel is supported (XF_8UC1)
ROWS Maximum height of input image.
COLS Maximum width of input image (must be a multiple of 8, for 8-pixel operation)
NPC Number of pixels to be processed per cycle; possible options are XF_NPPC1 and XF_NPPC8 for 1 pixel and 8 pixel operations respectively.
_src_mat Input image
_dst_mat Output image. The corners are marked in the image.
_threshol d Threshold 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_C

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

Table xf::Mat Class - Available Data Types
Option Number of bits per Pixel Unsigned/ Signed/ Float Type Number of Channels
XF_8UC1 8 Unsigned 1
XF_16UC1 16 Unsigned 1
XF_16SC1 16 Signed 1
XF_32UC1 32 Unsigned 1
XF_32FC1 32 Float 1
XF_32SC1 32 Signed 1
XF_8UC2 8 Unsigned 2
XF_8UC4 8 Unsigned 4
XF_8UC3 8 Unsigned 3
XF_2UC1 2 Unsigned 1

 

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::pixeldepth
#define XF_WORDWIDTH(flags, npc) DataType::wordwidth
#define XF_PTNAME(flags) typename PixelType::name

struct DataType {
    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 {
    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 
void fast(xf::cv::Mat& _src_mat,
          xf::cv::Mat& _dst_mat,
          unsigned char _threshold) {
    #pragma HLS inline off
    xFFastCornerDetection(
        _src_mat, _dst_mat, _src_mat.rows, _src_mat.cols, _threshold);
}

 

void xFFastCornerDetection()

template 
void xFFastCornerDetection(xf::cv::Mat& _src_mat,
                           xf::cv::Mat& _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 _dst(_image_height, _image_width);

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

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

 

 

你可能感兴趣的:(VITIS,FPGA)