递归火山软件开发平台

标题: libmatch库怎么封装呢 不会嵌套结构体 [打印本页]

作者: quick    时间: 昨天 14:30
标题: libmatch库怎么封装呢 不会嵌套结构体
这是仓库地址     GITHUB.com/futz12/libmatch

**上倒是有个人封装开源过,但那是旧版本,没有复杂的结构体,还得用cmake生成工程编译出dll

现在新版本模仿封装弄不明白

看到里面一些结构体 也有嵌套的结构体,不会封装,希望大师封装一下,参考学习。


struct objectEx {
    Rect rect;
    float prob;
};




struct feature_config {
    int detector_type = SIFT_MODE;

    union {
        struct {
            int nfeatures;
            int nOctaveLayers;
            double contrastThreshold;
            double edgeThreshold;
            double sigma;
        } sift;

        struct {
            int nfeatures;
            float scaleFactor;
            int nlevels;
            int edgeThreshold;
            int firstLevel;
            int WTA_K;
            int scoreType;
            int patchSize;
            int fastThreshold;
        } orb;

        struct {
            int descriptor_type;
            int descriptor_size;
            int descriptor_channels;
            int threshold;
            int nOctaves;
            int nOctaveLayers;
            int diffusivity;
            int max_points;
        } akaze;
    } params;
};


作者: Xelloss0618    时间: 昨天 15:09
用别名封装就行了,可以看官方的结构体封装例子
作者: quick    时间: 昨天 15:28
Xelloss0618 发表于 2025-8-14 15:09
用别名封装就行了,可以看官方的结构体封装例子

x大师, 这是我尝试封装,结构体我用的别名和别名类型,太绕了搞不定

<火山程序 类型 = "通常" 版本 = 1 />

类 LibMatch类 <公开 @视窗.头文件搜寻目录 = "libmatch\\include" @视窗.库文件搜寻目录 = "libmatch\\lib"
        @视窗.外部源文件 = "libmatch\\src\\base_algorithm.cpp\nlibmatch\\src\\base_match.cpp\nlibmatch\\src\\c_api.cpp\nlibmatch\\src\\clipper.cpp\nlibmatch\\src\\ddddrec.cpp\nlibmatch\\src\\library.cpp\nlibmatch\\src\\pp_ocr.cpp">
{
    变量 引擎指针 <公开 类型 = 通用指针 @输出名 = "Pmatcher">

    方法 create_template_matcher <公开>
    参数 img <类型 = 字节集类>
    参数 mode <类型 = 整数>
    {
        @ Pmatcher = create_template_matcher((uint8_t*)@<img>.GetPtr(), @<img>.GetSize(),@<mode>);
    }

    #
}

作者: quick    时间: 昨天 15:29
Xelloss0618 发表于 2025-8-14 15:09
用别名封装就行了,可以看官方的结构体封装例子

x大师,可以给个例子吗 ? 我使用了别名和别名类型,太绕了搞不定。
作者: Xelloss0618    时间: 昨天 16:06
本帖最后由 Xelloss0618 于 2025-8-14 16:08 编辑

<火山程序 类型 = "通常" 版本 = 1 />

类 sift结构 <公开 基础类 = 本地结构模板 折叠 @别名 = "feature_config::params::sift" @模板实现类 = "">
{
    变量 nfeatures <公开 类型 = 整数 @输出名 = "nfeatures">
    变量 nOctaveLayers <公开 类型 = 整数 @输出名 = "nOctaveLayers">
    变量 contrastThreshold <公开 类型 = 小数 @输出名 = "contrastThreshold">
    变量 edgeThreshold <公开 类型 = 小数 @输出名 = "edgeThreshold">
    变量 sigma <公开 类型 = 小数 @输出名 = "sigma">
}

类 orb结构 <公开 基础类 = 本地结构模板 折叠 @别名 = "feature_config::params::orb" @模板实现类 = "">
{
    变量 nfeatures <公开 类型 = 整数 @输出名 = "nfeatures">
    变量 scaleFactor <公开 类型 = 单精度小数 @输出名 = "scaleFactor">
    变量 nlevels <公开 类型 = 整数 @输出名 = "nlevels">
    变量 edgeThreshold <公开 类型 = 整数 @输出名 = "edgeThreshold">
    变量 firstLevel <公开 类型 = 整数 @输出名 = "firstLevel">
    变量 WTA_K <公开 类型 = 整数 @输出名 = "WTA_K">
    变量 scoreType <公开 类型 = 整数 @输出名 = "scoreType">
    变量 patchSize <公开 类型 = 整数 @输出名 = "patchSize">
    变量 fastThreshold <公开 类型 = 整数 @输出名 = "fastThreshold">
}

类 akaze结构 <公开 基础类 = 本地结构模板 折叠 @别名 = "feature_config::params::akaze" @模板实现类 = "">
{
    变量 descriptor_type <公开 类型 = 整数 @输出名 = "descriptor_type">
    变量 descriptor_size <公开 类型 = 整数 @输出名 = "descriptor_size">
    变量 descriptor_channels <公开 类型 = 整数 @输出名 = "descriptor_channels">
    变量 threshold <公开 类型 = 整数 @输出名 = "threshold">
    变量 nOctaves <公开 类型 = 整数 @输出名 = "nOctaves">
    变量 nOctaveLayers <公开 类型 = 整数 @输出名 = "nOctaveLayers">
    变量 diffusivity <公开 类型 = 整数 @输出名 = "diffusivity">
    变量 max_points <公开 类型 = 整数 @输出名 = "max_points">
}

类 feature_config <公开 基础类 = 本地结构模板 折叠 @别名 = "feature_config" @模板实现类 = "">
{
    变量 detector_type <公开 类型 = 整数 @输出名 = "detector_type">
    变量 sift <公开 类型 = sift结构 @输出名 = "params.sift">
    变量 orb <公开 类型 = orb结构 @输出名 = "params.orb">
    变量 akaze <公开 类型 = akaze结构 @输出名 = "params.akaze">
}



作者: quick    时间: 昨天 16:32
Xelloss0618 发表于 2025-8-14 16:06
类 sift结构
{
    变量 nfeatures

谢谢谢谢!!! x大真神。




欢迎光临 递归火山软件开发平台 (https://bbs.voldp.com/) Powered by Discuz! X3.4