• 特征点方法


    整理去年做的小项目,纪念我的图像处理入门。

    因为要在DSP上实现,所以完全手工C代码垒起来的,还要保证和PC端跑的结果一样,觉得可能特殊场景会有用,上传github,没有依赖任何库;

    格式注释什么的暂时没有整理,没有优化,能用,但是可能不够快,也没有考虑内存开销的优化,直接就在DDR2/SRAM上跑的。

    Harris c代码实现    因为要匹配,最后对检测到的角点做了SAD(效率高)

    matlab代码网上down的,自己添加下采样和匹配改了个面目全非。

    DSP输出:

    Harris start: Sample = 1 , Region = 8
    
    max R = 32487164.72,(247, 3)
    1 Harris: 178, 64
    2 Harris: 186, 83
    3 Harris: 191, 85
    4 Harris: 195, 86
    5 Harris:  67, 88
    6 Harris: 217, 90
    7 Harris:  58, 91
    8 Harris:  52, 95
    9 Harris: 241, 98
    10 Harris:  17,112
    11 Harris:   9,114
    12 Harris: 217,115
    13 Harris:  43,119
    14 Harris: 233,119
    15 Harris: 239,123
    16 Harris: 228,126
    17 Harris:  11,128
    18 Harris: 234,130
    19 Harris:  64,133
    20 Harris: 240,133
    21 Harris:  61,135
    22 Harris: 225,135
    23 Harris: 233,138
    24 Harris: 204,139
    25 Harris: 176,140
    26 Harris: 119,141
    27 Harris: 147,141
    28 Harris:  60,142
    29 Harris:  90,142
    30 Harris:  30,143
    31 Harris: 241,144
    32 Harris: 238,145
    33 Harris: 225,150
    34 Harris: 233,151
    35 Harris: 167,153
    36 Harris: 201,153
    37 Harris: 134,154
    38 Harris: 100,155
    39 Harris:  66,156
    40 Harris: 221,156
    41 Harris:  31,157
    42 Harris: 239,163
    43 Harris:  24,168
    44 Harris: 237,174
    45 Harris:  34,179
    46 Harris:  65,183
    47 Harris: 241,185
    48 Harris:  11,188
    49 Harris:  40,191
    50 Harris:  70,191
    51 Harris:  12,200
    52 Harris:  30,200
    53 Harris:  26,202
    54 Harris:  46,207
    55 Harris: 165,210
    56 Harris: 222,213
    57 Harris:  93,215
    58 Harris: 218,217
    59 Harris: 163,222
    60 Harris:  11,224
    61 Harris: 233,226
    62 Harris: 227,230
    63 Harris:  15,232
    64 Harris:  18,234
    65 Harris: 239,240
    66 Harris:  16,243
    67 Harris:  31,244
    68 Harris:  23,245
    69 Harris: 194,245
    70 Harris: 210,246
    71 Harris: 233,246
    max R = 8346880.08,(1, 113)
    1 Harris: 137,  9
    2 Harris: 154, 10
    3 Harris: 140, 24
    4 Harris: 171, 64
    5 Harris: 175, 65
    6 Harris: 148, 67
    7 Harris:  49, 75
    8 Harris:  88, 80
    9 Harris: 174, 82
    10 Harris: 117, 83
    11 Harris: 178, 83
    12 Harris: 184, 83
    13 Harris:  80, 84
    14 Harris: 188, 85
    15 Harris: 104, 86
    16 Harris: 193, 86
    17 Harris:  69, 87
    18 Harris:  63, 88
    19 Harris: 205, 89
    20 Harris: 104, 90
    21 Harris: 212, 90
    22 Harris:  55, 91
    23 Harris:  67, 93
    24 Harris:  48, 94
    25 Harris:  42, 95
    26 Harris: 175, 96
    27 Harris:  38, 97
    28 Harris: 122, 97
    29 Harris: 236, 98
    30 Harris:  32, 99
    31 Harris: 205,104
    32 Harris:  13,105
    33 Harris:  44,105
    34 Harris: 197,105
    35 Harris: 212,105
    36 Harris:  44,107
    37 Harris:  34,110
    38 Harris: 225,110
    39 Harris: 199,111
    40 Harris:  10,112
    41 Harris:  65,112
    42 Harris: 204,112
    43 Harris:  83,114
    44 Harris: 210,115
    45 Harris: 217,117
    46 Harris:  35,119
    47 Harris: 226,119
    48 Harris: 245,120
    49 Harris: 192,123
    50 Harris: 231,123
    51 Harris: 219,125
    52 Harris: 228,127
    53 Harris: 185,129
    54 Harris: 225,131
    55 Harris:  54,132
    56 Harris: 230,132
    57 Harris: 208,134
    58 Harris:  46,135
    59 Harris:  51,135
    60 Harris: 215,135
    61 Harris: 201,136
    62 Harris: 194,139
    63 Harris: 222,139
    64 Harris: 137,140
    65 Harris: 165,140
    66 Harris: 183,140
    67 Harris: 108,141
    68 Harris:  19,142
    69 Harris:  34,142
    70 Harris:  49,142
    71 Harris:  79,142
    72 Harris: 118,142
    73 Harris: 203,142
    74 Harris: 214,143
    75 Harris: 230,144
    76 Harris: 178,145
    77 Harris: 227,145
    78 Harris: 238,145
    79 Harris: 163,146
    80 Harris: 155,147
    81 Harris: 180,149
    82 Harris: 213,150
    83 Harris: 221,151
    84 Harris:  61,152
    85 Harris: 154,153
    86 Harris: 188,153
    87 Harris: 121,154
    88 Harris: 232,154
    89 Harris:  87,155
    90 Harris:  53,156
    91 Harris: 208,156
    92 Harris:  18,157
    93 Harris:  74,157
    94 Harris: 189,159
    95 Harris: 161,162
    96 Harris: 127,163
    97 Harris: 166,163
    98 Harris: 225,163
    99 Harris: 184,164
    100 Harris:  33,166
    101 Harris:  52,166
    102 Harris:  58,168
    103 Harris:   9,169
    104 Harris:  41,169
    105 Harris: 218,170
    106 Harris:  27,171
    107 Harris:  56,172
    108 Harris:  17,173
    109 Harris: 135,173
    110 Harris:  25,174
    111 Harris:  66,174
    112 Harris:  50,175
    113 Harris: 222,175
    114 Harris:  98,176
    115 Harris:  56,177
    116 Harris: 234,177
    117 Harris:  17,178
    118 Harris:  29,178
    119 Harris: 116,179
    120 Harris:  44,180
    121 Harris: 131,180
    122 Harris: 244,180
    123 Harris: 234,181
    124 Harris:  32,182
    125 Harris:  14,183
    126 Harris:  48,183
    127 Harris: 167,183
    128 Harris: 131,184
    129 Harris: 140,184
    130 Harris: 241,184
    131 Harris: 215,186
    132 Harris:  19,187
    133 Harris: 223,187
    134 Harris: 148,188
    135 Harris:  27,189
    136 Harris:  23,190
    137 Harris:  31,191
    138 Harris:  52,191
    139 Harris: 120,192
    140 Harris: 147,194
    141 Harris: 167,195
    142 Harris: 187,195
    143 Harris:  34,197
    144 Harris: 220,197
    145 Harris: 193,198
    146 Harris:  29,199
    147 Harris: 225,199
    148 Harris: 180,200
    149 Harris: 189,200
    150 Harris: 144,201
    151 Harris:  16,203
    152 Harris: 110,203
    153 Harris: 147,203
    154 Harris: 230,203
    155 Harris:   9,204
    156 Harris:  88,205
    157 Harris: 182,205
    158 Harris: 191,205
    159 Harris: 206,206
    160 Harris:  26,207
    161 Harris: 144,210
    162 Harris: 244,210
    163 Harris: 194,211
    164 Harris:  56,212
    165 Harris: 202,212
    166 Harris:  95,213
    167 Harris:  12,215
    168 Harris:  31,215
    169 Harris:  72,215
    170 Harris: 182,216
    171 Harris: 196,216
    172 Harris: 104,217
    173 Harris: 112,217
    174 Harris:  99,219
    175 Harris: 141,222
    176 Harris: 233,222
    177 Harris: 200,223
    178 Harris:   9,224
    179 Harris: 210,226
    180 Harris:  15,229
    181 Harris: 147,229
    182 Harris: 204,230
    183 Harris:  47,234
    184 Harris: 126,234
    185 Harris: 139,234
    186 Harris:   9,235
    187 Harris:  53,236
    188 Harris: 212,238
    189 Harris: 129,239
    190 Harris: 206,239
    191 Harris:  27,240
    192 Harris:  12,244
    193 Harris: 190,244
    194 Harris: 244,244
    195 Harris: 235,245
    196 Harris:  29,247
    197 Harris: 210,247
    Matched points: 29
     0: matchedCorner[174] (163,222,141,222) d: 0.03975
     1: matchedCorner[160] (165,210,144,210) d: 0.05183
     2: matchedCorner[168] ( 93,215, 72,215) d: 0.05275
     3: matchedCorner[84] (167,153,154,153) d: 0.05445
     4: matchedCorner[89] ( 66,156, 53,156) d: 0.05949
     5: matchedCorner[137] ( 70,191, 52,191) d: 0.05978
     6: matchedCorner[125] ( 65,183, 48,183) d: 0.06032
     7: matchedCorner[69] ( 60,142, 49,142) d: 0.06281
     8: matchedCorner[91] ( 31,157, 18,157) d: 0.06552
     9: matchedCorner[159] ( 46,207, 26,207) d: 0.06596
    10: matchedCorner[13] (191, 85,188, 85) d: 0.06981
    11: matchedCorner[178] (233,226,210,226) d: 0.07079
    12: matchedCorner[70] ( 90,142, 79,142) d: 0.07585
    13: matchedCorner[135] ( 40,191, 23,190) d: 0.07670
    14: matchedCorner[46] (233,119,226,119) d: 0.07697
    15: matchedCorner[67] ( 30,143, 19,142) d: 0.07735
    16: matchedCorner[64] (176,140,165,140) d: 0.07751
    17: matchedCorner[181] (227,230,204,230) d: 0.07766
    18: matchedCorner[58] ( 61,135, 51,135) d: 0.07878
    19: matchedCorner[11] (186, 83,184, 83) d: 0.08188
    20: matchedCorner[45] ( 43,119, 35,119) d: 0.08230
    21: matchedCorner[54] ( 64,133, 54,132) d: 0.08530
    22: matchedCorner[86] (134,154,121,154) d: 0.08576
    23: matchedCorner[49] (239,123,231,123) d: 0.08604
    24: matchedCorner[88] (100,155, 87,155) d: 0.09002
    25: matchedCorner[63] (147,141,137,140) d: 0.09699
    26: matchedCorner[82] (233,151,221,151) d: 0.09712
    27: matchedCorner[90] (221,156,208,156) d: 0.09803
    28: matchedCorner[176] (218,217,200,223) d: 0.09966
    29: matchedCorner[43] (217,115,210,115) d: 0.10124
    30: matchedCorner[97] (239,163,225,163) d: 0.10264
    31: matchedCorner[15] (195, 86,193, 86) d: 0.10453
    32: matchedCorner[81] (225,150,213,150) d: 0.10457
    33: matchedCorner[39] ( 17,112, 10,112) d: 0.10529
    34: matchedCorner[61] (204,139,194,139) d: 0.10692
    35: matchedCorner[85] (201,153,188,153) d: 0.10697
    36: matchedCorner[20] (217, 90,212, 90) d: 0.10785
    37: matchedCorner[66] (119,141,108,141) d: 0.10903
    38: matchedCorner[96] ( 24,168,166,163) d: 0.11074
    39: matchedCorner[116] ( 34,179, 17,178) d: 0.11335
    40: matchedCorner[17] ( 67, 88, 63, 88) d: 0.11478
    41: matchedCorner[37] (194,245,225,110) d: 0.11824
    42: matchedCorner[74] (241,144,230,144) d: 0.11879
    43: matchedCorner[59] (225,135,215,135) d: 0.12120
    44: matchedCorner[21] ( 58, 91, 55, 91) d: 0.12153
    45: matchedCorner[76] (238,145,227,145) d: 0.12230
    46: matchedCorner[ 3] (178, 64,171, 64) d: 0.12550
    47: matchedCorner[28] (241, 98,236, 98) d: 0.12557
    48: matchedCorner[27] ( 11,188,122, 97) d: 0.13124
    49: matchedCorner[23] ( 52, 95, 48, 94) d: 0.14120
    50: matchedCorner[164] (222,213,202,212) d: 0.14147
    51: matchedCorner[37] ( 30,200,225,110) d: 0.14359
    52: matchedCorner[71] ( 11,128,118,142) d: 0.14817
    53: matchedCorner[165] ( 18,234, 95,213) d: 0.14993
    54: matchedCorner[55] (240,133,230,132) d: 0.15049
    55: matchedCorner[188] (241,185,129,239) d: 0.15167
    56: matchedCorner[112] (237,174,222,175) d: 0.15237
    57: matchedCorner[53] (234,130,225,131) d: 0.15975
    58: matchedCorner[94] ( 12,200,161,162) d: 0.16515
    59: matchedCorner[130] (210,246,215,186) d: 0.16592
    60: matchedCorner[171] ( 15,232,104,217) d: 0.17298
    61: matchedCorner[62] (233,138,222,139) d: 0.17425
    62: matchedCorner[77] ( 26,202,238,145) d: 0.17961
    63: matchedCorner[187] (239,240,212,238) d: 0.18350
    64: matchedCorner[157] (  9,114,191,205) d: 0.18354
    65: matchedCorner[19] ( 31,244,104, 90) d: 0.18516
    66: matchedCorner[196] (233,246,210,247) d: 0.19022
    67: matchedCorner[50] (228,126,219,125) d: 0.19145
    68: matchedCorner[174] ( 11,224,141,222) d: 0.19151
    69: matchedCorner[167] ( 16,243, 31,215) d: 0.22552
    70: matchedCorner[163] ( 23,245, 56,212) d: 0.23696
    Harris end!
    View Code

    SURF c代码实现    为了利用积分图最后求特征向量的时候没有旋转图像,基本是参考OpenCV和网上down到的一份matlab以及C#拼起来的

    matlab代码可能来自这里,记不清楚了,总之是网上不知名大神共享的,当时连OpenCV都没用过的小白我如获至宝...

    DSP输出:

    OpenSURF test:
    Cycle to get ipt1 is 0
    Number of key points in pic1:103
    Cycle to describe ipt1 is 0
    Number of key points in pic2:128
    Cycle to get and describe ipt2 is 0
    Time to matched: 0 ms
     0: matchedIpt[95] ( 85.99, 85.17, 82.86, 85.30) d: 0.00260
     1: matchedIpt[70] ( 47.06, 95.99, 42.83, 95.91) d: 0.00359
     2: matchedIpt[82] ( 67.96,194.75, 49.92,194.57) d: 0.00455
     3: matchedIpt[13] (214.44,125.26,205.99,125.16) d: 0.00532
     4: matchedIpt[69] (202.97, 92.88,198.14, 92.96) d: 0.00570
     5: matchedIpt[69] (205.31, 93.83,198.14, 92.96) d: 0.00662
     6: matchedIpt[ 5] ( 35.38, 99.79, 29.98, 99.51) d: 0.00670
     7: matchedIpt[54] ( 61.49,217.59, 38.79,217.87) d: 0.00806
     8: matchedIpt[35] (152.79,179.11,136.93,179.25) d: 0.00806
     9: matchedIpt[38] ( 58.68,183.02, 41.89,182.71) d: 0.00832
    10: matchedIpt[92] ( 72.85,239.35, 48.47,239.21) d: 0.00904
    11: matchedIpt[80] ( 73.11,186.04, 55.19,186.07) d: 0.00931
    12: matchedIpt[ 3] (231.97, 93.13,227.17, 93.04) d: 0.00975
    13: matchedIpt[25] (132.31,160.72,118.63,160.50) d: 0.01006
    14: matchedIpt[30] (149.93,167.20,134.69,166.84) d: 0.01027
    15: matchedIpt[ 8] ( 94.27,111.85, 87.44,111.56) d: 0.01030
    16: matchedIpt[94] (122.94, 83.84,119.90, 83.62) d: 0.01062
    17: matchedIpt[105] (176.30,191.17,157.86,191.50) d: 0.01115
    18: matchedIpt[31] (223.54,168.70,208.99,168.44) d: 0.01183
    19: matchedIpt[12] ( 46.80,120.28, 38.81,119.73) d: 0.01211
    20: matchedIpt[71] (224.16,100.35,219.76,100.07) d: 0.01308
    21: matchedIpt[44] (186.16,195.73,166.90,195.93) d: 0.01309
    22: matchedIpt[77] (213.58,172.32,198.76,172.91) d: 0.01331
    23: matchedIpt[107] (115.48,203.99, 95.71,203.96) d: 0.01420
    24: matchedIpt[20] (169.80,146.23,158.25,146.20) d: 0.01550
    25: matchedIpt[ 7] (232.83,101.16,227.14,100.89) d: 0.01680
    26: matchedIpt[ 9] ( 86.30,113.77, 79.05,113.92) d: 0.01721
    27: matchedIpt[66] (122.35, 83.45,119.29, 83.40) d: 0.01780
    28: matchedIpt[ 6] ( 27.53,101.58, 22.73,101.44) d: 0.01916
    29: matchedIpt[ 1] ( 60.16, 90.06, 56.41, 89.71) d: 0.01963
    30: matchedIpt[37] (137.53,181.55,120.93,181.54) d: 0.01971
    31: matchedIpt[58] (118.01,226.98, 94.54,227.09) d: 0.02034
    32: matchedIpt[112] (171.38,220.73,149.69,221.25) d: 0.02042
    33: matchedIpt[17] (230.51,135.97,219.99,135.96) d: 0.02077
    34: matchedIpt[61] (110.96,230.61, 87.16,230.17) d: 0.02178
    35: matchedIpt[125] (169.41,123.85,166.05,124.65) d: 0.02278
    36: matchedIpt[52] ( 65.81,216.05, 46.05,215.23) d: 0.02281
    37: matchedIpt[87] (168.93,219.45,148.37,220.08) d: 0.02330
    38: matchedIpt[110] ( 70.02,219.18, 48.17,218.89) d: 0.02513
    39: matchedIpt[32] (211.27,171.33,197.11,171.64) d: 0.02650
    40: matchedIpt[115] ( 81.10,228.88, 57.83,229.34) d: 0.02689
    41: matchedIpt[96] (231.62, 91.24,226.57, 88.88) d: 0.02925
    42: matchedIpt[64] (108.60,243.74, 82.07,243.78) d: 0.03126
    43: matchedIpt[22] (140.21,154.63,127.19,154.34) d: 0.03203
    44: matchedIpt[95] ( 91.32, 84.99, 82.86, 85.30) d: 0.03230
    45: matchedIpt[93] (146.93, 27.16,146.03, 27.53) d: 0.03469
    46: matchedIpt[60] (134.77,229.37,110.14,228.31) d: 0.03591
    47: matchedIpt[105] (175.91,189.85,157.86,191.50) d: 0.04027
    48: matchedIpt[125] (174.17,124.58,166.05,124.65) d: 0.04138
    49: matchedIpt[85] (199.25,207.93,178.58,207.88) d: 0.04370
    50: matchedIpt[24] ( 37.63,159.41, 24.60,158.93) d: 0.04504
    51: matchedIpt[97] (220.12,128.17,211.02,128.12) d: 0.05070
    52: matchedIpt[25] (229.83,128.56,118.63,160.50) d: 0.05942
    53: matchedIpt[78] (238.84,169.78,238.67,173.68) d: 0.07877
    54: matchedIpt[108] (172.92,208.34,151.75,208.93) d: 0.07884
    55: matchedIpt[39] (156.11,186.26,147.67,185.59) d: 0.08015
    56: matchedIpt[55] (165.94,219.38,144.14,219.32) d: 0.08813
    57: matchedIpt[27] (234.62,162.62,220.43,162.56) d: 0.09373
    58: matchedIpt[14] (155.06,171.10,228.58,124.93) d: 0.09682
    59: matchedIpt[17] ( 38.87,167.80,219.99,135.96) d: 0.09913
    60: matchedIpt[10] (218.30,114.22,211.73,114.14) d: 0.10389
    61: matchedIpt[121] (227.64,178.41,205.99,178.25) d: 0.10590
    62: matchedIpt[38] ( 58.80,196.00, 41.89,182.71) d: 0.10633
    63: matchedIpt[34] ( 36.21,174.12, 20.49,173.70) d: 0.10729
    64: matchedIpt[121] (229.02,176.50,205.99,178.25) d: 0.11332
    65: matchedIpt[14] (236.82,124.87,228.58,124.93) d: 0.11353
    66: matchedIpt[120] (207.85,159.31,194.75,159.18) d: 0.11531
    67: matchedIpt[114] ( 51.57,229.20, 33.27,226.18) d: 0.11878
    68: matchedIpt[71] (224.11,101.66,219.76,100.07) d: 0.11981
    69: matchedIpt[99] ( 43.98,156.20, 31.10,155.11) d: 0.12281
    70: matchedIpt[99] (241.88,195.45, 31.10,155.11) d: 0.12402
    71: matchedIpt[25] (235.89,145.88,118.63,160.50) d: 0.12459
    72: matchedIpt[66] (110.62,216.96,119.29, 83.40) d: 0.12702
    OpenSURF end!
    View Code

    其实写那些代码的时候根本不懂SURF的原理,依样画葫芦竟然还画的有模有样,当然理论水平还是要跟上去。

    斑点检测  尺度空间 特征点方法综述  觉得这个博客特别好,很形象的解释。

    大部分参考了《图像局部不变性特征与描述》。

  • 相关阅读:
    线程的同步之Synchronized的使用
    线程的优先级
    线程的状态和常用操作
    Eclipse设置代码模板Code Template
    Eclipse设置每行代码的长度
    Eclipse设置控制台字体
    Gradle 安装(Windows)
    DSL与GPL
    Windows 新增 Sublime Text3 右键快捷方式
    mvn install 上传 jar 包到Maven仓库
  • 原文地址:https://www.cnblogs.com/zhengmeisong/p/7927864.html
Copyright © 2020-2023  润新知