├── cache └── vpdetection │ └── text │ ├── 001_input_hole-vanishingpoints.txt │ ├── 009_input_hole-vanishingpoints.txt │ └── 022_input_hole-vanishingpoints.txt ├── data ├── 001_input_hole.png ├── 009_input_hole.png └── 022_input_hole.png ├── demo.py ├── init_opt.py ├── readme.md ├── result ├── 22_completion.png └── 9_completion.png ├── source ├── __init__.py ├── __pycache__ │ └── __init__.cpython-35.pyc ├── extract │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-35.pyc │ │ ├── extract_planar_structure.cpython-35.pyc │ │ ├── extract_plane.cpython-35.pyc │ │ └── extract_regularity.cpython-35.pyc │ ├── extract_planar_structure.py │ ├── extract_plane.py │ ├── extract_regularity.py │ └── util.py ├── pyramid │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-35.pyc │ │ ├── create_pyramid.cpython-35.pyc │ │ └── planar_structure_pyramid.cpython-35.pyc │ ├── create_pyramid.py │ └── planar_structure_pyramid.py └── synthesis │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-35.pyc │ └── synthesis.cpython-35.pyc │ ├── check_valid_uv.py │ ├── clamp.py │ ├── draw_plane_id.py │ ├── init_lvl_nnf.py │ ├── patch_cost.py │ ├── prep_dist_patch.py │ ├── prep_source_patch.py │ ├── prep_target_patch.py │ ├── sc_pass.py │ ├── scale_tform.py │ ├── src_domain_tform.py │ ├── synthesis.py │ ├── trans_tform.py │ ├── update_NNF.py │ ├── update_uvMap.py │ ├── uvMat_from_uvMap.py │ └── voting.py ├── util └── __init__.py └── vpdetection.exe /cache/vpdetection/text/001_input_hole-vanishingpoints.txt: -------------------------------------------------------------------------------- 1 | vx vy vz score numLines 2 | -0.83619847 -0.54842506 -0.00144211 4546.04 285 3 | -0.09789688 0.99519651 -0.00033090 4010.68 315 4 | 0.97825488 -0.20740577 -0.00048248 2365.94 180 5 | 6 | nLines x1 y1 x2 y2 length 7 | 285 8 | 5.13 3.78 21.42 15.04 19.80 9 | 22.17 3.74 28.90 7.68 7.80 10 | 34.95 4.07 94.84 45.24 72.67 11 | 42.07 3.89 100.03 43.43 70.16 12 | 150.13 40.89 157.02 46.48 8.87 13 | 167.56 54.00 196.23 74.91 35.48 14 | 210.88 4.10 218.03 10.97 9.92 15 | 338.54 3.98 342.92 10.01 7.46 16 | 357.48 4.01 361.01 9.99 6.94 17 | 365.84 4.09 380.35 27.10 27.20 18 | 370.26 3.85 377.07 15.97 13.90 19 | 379.96 3.57 385.60 16.22 13.84 20 | 384.72 3.96 390.36 14.82 12.24 21 | 393.43 4.03 412.07 39.93 40.45 22 | 400.59 3.95 408.07 20.90 18.52 23 | 505.60 4.31 506.51 11.04 6.79 24 | 541.19 3.98 543.81 24.94 21.12 25 | 19.23 4.65 91.16 52.83 86.58 26 | 95.94 7.06 102.05 12.43 8.14 27 | 333.99 7.01 342.47 20.03 15.54 28 | 349.88 20.11 364.88 44.07 28.27 29 | 70.00 7.52 79.99 15.02 12.49 30 | 3.57 8.52 19.19 18.61 18.59 31 | 363.77 9.16 378.63 34.92 29.74 32 | 479.76 8.98 481.98 16.09 7.46 33 | 78.98 11.11 106.10 34.03 35.50 34 | 361.02 17.99 372.04 35.98 21.09 35 | 36.67 12.96 43.83 17.26 8.36 36 | 222.82 13.79 227.34 18.76 6.72 37 | 352.75 15.18 367.35 38.86 27.82 38 | 23.98 15.77 40.88 27.11 20.35 39 | 570.30 15.99 570.01 24.00 8.01 40 | 244.29 16.66 279.43 55.46 52.35 41 | 397.99 18.00 413.01 44.90 30.80 42 | 113.02 19.98 117.19 23.13 5.22 43 | 529.69 20.02 530.51 30.07 10.08 44 | 50.67 22.44 74.01 37.48 27.77 45 | 395.30 48.05 406.08 66.97 21.77 46 | 506.64 22.99 509.57 43.99 21.21 47 | 345.93 25.04 362.21 49.75 29.59 48 | 478.01 24.98 480.08 31.02 6.38 49 | 87.06 26.28 100.13 34.90 15.65 50 | 246.09 25.92 250.28 30.68 6.34 51 | 251.12 38.93 268.25 54.79 23.35 52 | 8.08 27.29 18.08 32.82 11.42 53 | 395.91 27.05 416.13 62.95 41.20 54 | 6.14 54.78 34.94 69.23 32.22 55 | 572.19 27.92 572.49 33.98 6.07 56 | 44.95 30.07 87.17 57.84 50.53 57 | 294.91 31.08 298.50 35.78 5.90 58 | 543.25 31.04 544.52 38.90 7.96 59 | 394.93 32.03 412.92 64.06 36.73 60 | 411.46 77.01 406.48 69.07 9.38 61 | 229.99 34.34 237.23 41.84 10.42 62 | 46.02 35.96 67.08 51.39 26.11 63 | 269.08 38.97 275.56 46.96 10.29 64 | 103.47 37.67 111.98 42.96 10.02 65 | 216.16 39.80 223.97 46.45 10.26 66 | 370.24 39.92 384.27 61.83 26.02 67 | 350.24 40.75 356.87 50.14 11.50 68 | 419.26 40.99 427.37 57.25 18.18 69 | 107.30 90.20 134.81 107.83 32.67 70 | 85.83 46.29 91.97 50.05 7.20 71 | 245.84 45.62 268.20 67.73 31.44 72 | 398.30 45.83 402.97 54.02 9.43 73 | 217.84 47.22 222.75 51.23 6.35 74 | 55.04 50.89 64.96 56.56 11.43 75 | 335.98 51.02 343.69 61.27 12.83 76 | 366.66 52.21 379.69 70.24 22.24 77 | 112.93 52.73 152.59 81.51 49.01 78 | 319.32 54.92 322.98 60.02 6.28 79 | 566.86 55.69 567.47 62.94 7.27 80 | 113.08 57.38 146.69 82.36 41.88 81 | 55.82 58.36 95.75 83.31 47.09 82 | 306.88 59.11 318.00 70.99 16.27 83 | 396.70 63.04 408.01 82.99 22.93 84 | 399.79 63.15 403.89 70.06 8.03 85 | 304.94 64.10 313.40 73.92 12.96 86 | 112.02 66.49 117.23 69.65 6.10 87 | 547.27 66.00 550.86 92.99 27.23 88 | 140.02 66.94 158.05 78.40 21.37 89 | 222.42 68.48 228.22 74.08 8.06 90 | 366.71 68.25 370.76 74.05 7.07 91 | 56.97 68.63 67.35 75.67 12.54 92 | 414.68 69.17 417.38 75.01 6.43 93 | 34.11 70.77 39.37 73.37 5.87 94 | 110.96 73.07 134.31 87.61 27.50 95 | 123.99 75.06 194.25 122.62 84.84 96 | 545.46 75.97 548.34 95.01 19.26 97 | 194.21 106.79 240.29 139.07 56.26 98 | 404.11 80.98 410.80 93.11 13.85 99 | 229.07 81.81 237.29 87.99 10.29 100 | 11.90 82.66 37.07 95.39 28.21 101 | 16.84 83.31 29.76 89.87 14.49 102 | 292.91 83.22 298.65 88.44 7.76 103 | 311.06 83.95 314.99 88.01 5.65 104 | 304.10 85.84 307.38 89.62 5.01 105 | 307.93 96.01 321.20 109.67 19.04 106 | 385.96 86.41 397.29 103.12 20.19 107 | 157.86 86.73 167.11 93.90 11.70 108 | 308.65 87.28 326.11 104.85 24.77 109 | 65.89 87.76 94.72 104.30 33.23 110 | 152.09 90.91 203.17 124.66 61.22 111 | 513.36 92.76 514.62 98.00 5.38 112 | 28.62 93.99 37.00 99.00 9.77 113 | 137.87 94.16 189.01 127.91 61.27 114 | 146.34 93.56 151.17 96.73 5.77 115 | 171.85 96.46 180.27 101.54 9.83 116 | 407.31 98.00 411.03 103.98 7.04 117 | 137.92 100.24 157.14 112.87 23.00 118 | 181.88 99.67 190.84 106.21 11.10 119 | 529.12 103.38 530.00 109.00 5.68 120 | 216.06 104.36 220.25 107.16 5.03 121 | 306.65 105.92 318.87 117.74 17.00 122 | 62.81 106.99 92.15 124.28 34.06 123 | 485.05 106.88 487.57 113.99 7.54 124 | 106.01 109.99 132.80 125.26 30.83 125 | 61.94 130.05 91.10 145.37 32.94 126 | 230.11 113.26 234.83 117.18 6.13 127 | 160.00 114.35 168.87 120.11 10.57 128 | 135.20 116.76 148.11 124.87 15.24 129 | 170.99 121.19 220.01 152.51 58.17 130 | 195.99 124.01 212.08 134.87 19.41 131 | 221.11 136.78 212.08 130.89 10.78 132 | 173.95 127.16 187.13 135.70 15.71 133 | 192.00 129.99 224.82 151.50 39.24 134 | 105.10 130.86 132.04 143.81 29.89 135 | 175.05 132.35 185.10 139.33 12.24 136 | 60.13 153.27 89.98 166.60 32.69 137 | 293.14 134.78 297.11 138.19 5.23 138 | 353.83 143.18 350.25 139.11 5.41 139 | 213.97 136.04 217.96 139.06 5.00 140 | 191.01 137.98 196.09 140.89 5.85 141 | 273.22 162.76 301.01 181.99 33.80 142 | 220.05 139.92 227.09 144.85 8.60 143 | 224.89 139.72 238.99 149.02 16.89 144 | 178.99 142.35 242.13 180.29 73.66 145 | 243.07 151.92 266.03 166.94 27.43 146 | 354.74 145.24 361.03 151.46 8.85 147 | 103.01 151.00 130.70 164.42 30.77 148 | 133.23 153.70 138.08 156.29 5.50 149 | 230.95 155.10 272.07 180.90 48.54 150 | 143.54 157.41 162.00 166.53 20.58 151 | 531.33 158.10 533.04 165.99 8.08 152 | 229.90 158.69 250.20 171.83 24.19 153 | 57.65 176.24 89.03 188.83 33.81 154 | 142.99 161.02 160.85 170.21 20.09 155 | 184.98 163.09 240.69 195.21 64.31 156 | 306.84 163.20 323.96 176.36 21.59 157 | 538.17 164.00 538.84 169.02 5.07 158 | 145.82 168.31 157.02 173.99 12.56 159 | 185.96 180.56 239.04 207.77 59.65 160 | 102.07 171.90 129.98 183.54 30.23 161 | 132.08 172.90 136.94 175.17 5.37 162 | 252.00 173.02 256.89 176.11 5.78 163 | 196.03 175.98 204.19 180.81 9.48 164 | 260.01 177.94 296.04 200.45 42.49 165 | 517.91 177.98 519.58 183.11 5.39 166 | 287.89 179.70 293.07 182.88 6.07 167 | 261.95 182.09 268.26 185.45 7.15 168 | 275.01 182.97 289.34 191.47 16.66 169 | 130.98 192.03 137.00 195.00 6.71 170 | 100.47 192.64 129.12 203.51 30.65 171 | 290.36 192.51 295.15 195.30 5.54 172 | 266.22 209.83 302.56 228.37 40.79 173 | 266.02 194.51 306.88 218.40 47.32 174 | 182.77 196.50 239.07 222.67 62.09 175 | 251.03 197.28 262.02 203.92 12.84 176 | 309.21 196.79 331.02 210.95 26.01 177 | 342.86 234.01 351.98 240.02 10.93 178 | 56.07 199.72 86.99 210.54 32.77 179 | 183.95 214.12 239.03 237.70 59.92 180 | 46.90 210.31 39.05 207.79 8.25 181 | 304.90 206.66 313.40 211.86 9.96 182 | 304.07 208.87 312.02 213.97 9.44 183 | 129.93 211.08 136.03 213.49 6.56 184 | 314.91 212.44 321.82 217.22 8.40 185 | 269.60 217.04 274.01 219.48 5.04 186 | 99.06 214.84 128.11 224.38 30.57 187 | 351.95 214.57 361.69 222.33 12.46 188 | 183.02 230.95 239.07 252.29 59.97 189 | 270.93 223.66 301.21 238.49 33.72 190 | 55.03 223.91 85.85 233.27 32.21 191 | 319.08 225.22 326.09 229.86 8.41 192 | 346.08 227.34 357.28 235.65 13.94 193 | 354.36 227.47 364.42 234.53 12.29 194 | 566.50 248.73 567.75 261.41 12.75 195 | 501.22 231.59 503.67 236.36 5.36 196 | 181.97 248.48 239.01 267.90 60.26 197 | 98.00 236.43 127.06 244.23 30.09 198 | 267.95 235.58 301.08 250.77 36.44 199 | 343.18 245.00 351.91 250.10 10.11 200 | 592.39 237.98 591.89 242.95 5.00 201 | 268.00 249.43 301.97 264.16 37.03 202 | 368.00 241.30 377.33 247.63 11.27 203 | 136.97 247.06 157.16 253.50 21.19 204 | 53.06 248.34 84.02 255.88 31.86 205 | 128.00 250.46 132.99 252.11 5.25 206 | 609.39 251.99 608.18 256.98 5.14 207 | 181.96 266.15 233.81 281.42 54.06 208 | 355.00 253.97 362.47 257.60 8.30 209 | 366.89 258.42 378.68 265.25 13.62 210 | 97.06 258.78 125.00 266.00 28.86 211 | 267.00 263.03 302.02 275.88 37.31 212 | 366.96 268.08 378.73 274.31 13.31 213 | 95.99 285.04 123.90 288.64 28.13 214 | 344.18 266.86 351.01 270.55 7.77 215 | 126.98 271.08 133.03 272.86 6.31 216 | 366.08 276.89 379.16 283.71 14.76 217 | 15.83 275.53 22.92 277.15 7.26 218 | 258.03 275.42 266.96 277.75 9.22 219 | 276.01 279.96 302.04 287.88 27.20 220 | 544.03 274.74 547.81 288.02 13.81 221 | 345.04 277.92 351.14 280.56 6.65 222 | 14.02 281.90 19.08 282.44 5.09 223 | 539.04 281.88 541.20 288.10 6.58 224 | 181.00 284.00 237.99 298.08 58.71 225 | 42.14 299.31 34.00 298.10 8.23 226 | 134.97 288.12 167.85 296.27 33.87 227 | 344.96 289.10 351.97 292.13 7.64 228 | 269.05 291.12 302.02 300.86 34.38 229 | 567.09 291.97 570.11 322.99 31.17 230 | 164.06 310.90 177.00 312.98 13.11 231 | 131.98 292.77 234.01 311.94 103.81 232 | 564.36 295.84 568.34 325.94 30.36 233 | 117.99 297.19 122.98 298.02 5.05 234 | 14.90 298.88 20.89 299.45 6.01 235 | 560.48 298.91 562.36 307.92 9.20 236 | 8.99 301.19 21.00 302.04 12.04 237 | 57.93 305.45 73.16 307.71 15.40 238 | 205.97 310.31 215.74 312.53 10.02 239 | 32.30 318.67 41.00 319.97 8.80 240 | 221.03 312.70 233.95 315.10 13.15 241 | 354.85 313.16 362.03 315.18 7.46 242 | 447.99 318.59 458.98 323.05 11.86 243 | 203.99 327.58 255.01 334.51 51.48 244 | 241.03 322.36 258.96 326.08 18.30 245 | 56.19 336.19 39.70 334.57 16.57 246 | 74.02 324.39 85.04 325.00 11.04 247 | 28.04 328.29 17.94 327.61 10.12 248 | 58.53 344.02 75.99 345.94 17.57 249 | 114.74 325.34 121.00 326.27 6.33 250 | 56.97 327.26 61.99 328.13 5.09 251 | 43.00 328.97 51.89 329.38 8.91 252 | 268.86 329.44 275.00 330.12 6.17 253 | 11.00 333.04 16.93 333.18 5.94 254 | 19.94 334.88 27.76 335.50 7.85 255 | 65.01 338.05 73.04 338.17 8.04 256 | 343.06 338.91 347.95 340.04 5.02 257 | 340.20 346.38 347.88 347.14 7.72 258 | 282.06 345.54 287.14 346.29 5.14 259 | 32.08 351.83 54.10 351.93 22.02 260 | 247.94 360.25 255.13 360.69 7.21 261 | 169.97 357.79 178.18 357.70 8.21 262 | 504.35 356.60 510.88 358.32 6.75 263 | 555.18 357.23 559.98 362.07 6.82 264 | 449.07 362.10 457.00 362.68 7.95 265 | 13.00 359.00 20.77 359.36 7.78 266 | 77.00 360.98 88.93 361.60 11.94 267 | 182.06 362.45 187.98 362.65 5.93 268 | 504.39 365.49 511.99 367.40 7.83 269 | 564.01 364.99 568.17 368.81 5.64 270 | 74.00 370.13 90.05 369.68 16.05 271 | 182.17 369.58 189.00 369.61 6.83 272 | 508.05 372.83 515.98 373.84 8.00 273 | 456.00 374.78 461.94 375.32 5.97 274 | 596.00 375.99 603.44 374.53 7.59 275 | 357.89 379.84 363.05 379.76 5.16 276 | 58.00 383.99 3.99 383.35 54.01 277 | 536.97 381.06 544.02 380.94 7.05 278 | 4.02 392.11 65.03 390.34 61.03 279 | 233.00 391.68 242.20 391.20 9.21 280 | 50.97 394.13 63.04 393.20 12.10 281 | 3.90 398.92 17.67 397.64 13.83 282 | 41.91 399.23 47.95 398.67 6.06 283 | 168.88 407.34 174.98 406.86 6.11 284 | 616.95 406.13 621.23 409.06 5.19 285 | 3.98 412.85 65.01 408.13 61.21 286 | 11.97 416.34 117.81 409.48 106.06 287 | 179.03 414.73 159.21 415.56 19.84 288 | 55.03 421.71 112.98 415.86 58.24 289 | 10.04 417.33 4.00 417.66 6.05 290 | 493.03 417.04 488.20 419.19 5.29 291 | 188.05 421.03 198.13 419.72 10.16 292 | 98.98 421.70 113.97 419.86 15.10 293 | 315 294 | 78.11 4.01 77.31 10.03 6.07 295 | 83.77 3.93 83.28 11.07 7.15 296 | 103.95 4.00 103.53 9.93 5.95 297 | 120.14 4.02 118.86 20.00 16.03 298 | 138.92 4.01 137.97 17.00 13.03 299 | 150.80 3.98 149.25 35.02 31.08 300 | 157.30 4.00 154.98 41.00 37.07 301 | 170.32 4.03 167.55 53.01 49.06 302 | 301.26 4.00 300.83 37.91 33.91 303 | 325.30 3.95 327.15 39.00 35.09 304 | 505.60 4.31 506.51 11.04 6.79 305 | 513.14 3.98 513.89 19.94 15.97 306 | 541.19 3.98 543.81 24.94 21.12 307 | 582.37 4.02 584.20 21.01 17.09 308 | 598.33 4.01 599.86 16.03 12.12 309 | 166.16 7.95 165.49 32.98 25.04 310 | 572.38 8.00 574.13 21.94 14.06 311 | 243.35 8.70 243.16 14.80 6.10 312 | 527.04 9.00 528.28 30.97 22.00 313 | 382.37 10.94 384.20 36.96 26.08 314 | 516.27 12.00 517.48 32.00 20.04 315 | 586.92 12.00 587.45 18.19 6.21 316 | 305.59 13.22 305.36 24.92 11.71 317 | 453.62 13.02 454.11 18.99 5.99 318 | 103.13 13.94 102.07 26.00 12.11 319 | 318.00 14.00 319.00 37.00 23.02 320 | 472.61 13.94 472.91 19.02 5.09 321 | 507.23 13.97 507.71 21.06 7.11 322 | 597.58 13.82 598.39 20.03 6.26 323 | 421.41 14.93 421.20 22.84 7.91 324 | 41.61 27.95 36.90 67.98 40.31 325 | 495.29 17.02 496.14 27.98 11.00 326 | 491.83 18.01 492.60 27.99 10.02 327 | 138.35 24.99 138.42 37.05 12.07 328 | 482.86 19.00 482.92 31.02 12.02 329 | 117.87 24.25 117.62 37.99 13.74 330 | 473.46 21.94 474.04 34.01 12.09 331 | 529.69 20.02 530.51 30.07 10.08 332 | 162.00 21.00 161.28 35.88 14.90 333 | 128.74 21.97 128.04 28.00 6.07 334 | 110.50 23.03 109.59 32.04 9.05 335 | 342.57 36.02 342.58 44.99 8.97 336 | 453.13 23.01 456.43 51.98 29.16 337 | 506.64 22.99 509.57 43.99 21.21 338 | 309.01 24.98 309.53 34.76 9.79 339 | 362.81 50.15 363.22 57.17 7.04 340 | 173.30 26.03 172.45 54.00 27.99 341 | 250.88 31.08 250.72 38.11 7.04 342 | 430.25 26.08 430.81 40.94 14.87 343 | 572.19 27.92 572.49 33.98 6.07 344 | 505.85 30.97 506.46 43.99 13.03 345 | 345.33 31.98 346.79 49.01 17.09 346 | 190.31 33.05 189.46 49.65 16.63 347 | 136.34 43.01 135.80 52.98 9.99 348 | 183.26 35.11 182.33 48.00 12.93 349 | 229.70 40.01 229.31 48.94 8.94 350 | 145.14 42.06 144.69 58.98 16.93 351 | 110.76 42.97 107.09 89.02 46.20 352 | 196.36 43.98 196.16 49.96 5.98 353 | 102.45 47.52 98.09 82.01 34.77 354 | 331.27 48.02 331.33 56.08 8.07 355 | 452.96 47.90 453.07 53.03 5.13 356 | 188.55 51.11 188.41 67.05 15.94 357 | 154.10 54.00 153.06 66.00 12.05 358 | 150.54 53.01 149.44 65.12 12.16 359 | 240.07 58.94 239.70 71.01 12.08 360 | 566.86 55.69 567.47 62.94 7.27 361 | 237.25 57.93 237.61 65.04 7.12 362 | 547.27 66.00 550.86 92.99 27.23 363 | 88.03 67.00 87.83 73.00 6.01 364 | 517.80 68.26 518.85 88.00 19.77 365 | 244.42 69.23 243.50 111.05 41.83 366 | 182.95 71.02 182.64 77.03 6.02 367 | 511.99 71.00 513.86 90.05 19.14 368 | 291.63 72.23 291.32 85.02 12.79 369 | 232.18 72.98 232.03 79.00 6.02 370 | 356.87 73.07 357.40 83.88 10.83 371 | 324.40 73.88 324.90 81.04 7.17 372 | 484.47 73.96 486.92 103.00 29.15 373 | 533.37 76.04 534.16 95.00 18.98 374 | 545.46 75.97 548.34 95.01 19.26 375 | 527.81 77.03 529.22 96.00 19.03 376 | 198.13 78.01 198.03 84.00 5.99 377 | 411.76 78.01 412.93 90.00 12.05 378 | 520.61 78.27 522.74 98.03 19.87 379 | 192.32 79.03 191.14 101.01 22.00 380 | 417.56 78.87 417.80 93.00 14.13 381 | 83.34 80.01 83.05 93.01 13.00 382 | 180.31 80.01 180.38 86.93 6.93 383 | 434.39 91.01 435.39 115.95 24.97 384 | 510.28 81.00 512.29 99.97 19.08 385 | 237.66 89.00 237.76 109.90 20.90 386 | 496.41 81.95 497.97 102.00 20.11 387 | 499.43 82.02 501.14 100.99 19.05 388 | 90.03 84.99 89.60 95.19 10.21 389 | 308.33 89.72 308.03 95.00 5.29 390 | 63.78 104.00 65.00 88.59 15.46 391 | 200.60 92.98 199.74 107.04 14.08 392 | 6.24 91.04 3.48 112.95 22.09 393 | 106.62 92.99 105.33 108.06 15.12 394 | 438.51 93.96 438.62 108.28 14.31 395 | 16.31 96.04 15.13 103.99 8.04 396 | 291.68 103.93 291.95 98.01 5.93 397 | 412.98 96.01 413.68 103.03 7.05 398 | 234.82 104.11 235.11 112.00 7.90 399 | 246.57 100.05 246.60 113.02 12.97 400 | 38.18 100.99 31.67 183.94 83.20 401 | 27.18 103.04 26.42 108.97 5.98 402 | 231.09 104.00 230.99 110.00 6.00 403 | 268.87 130.96 269.56 104.05 26.92 404 | 517.43 104.06 518.38 110.96 6.97 405 | 522.59 104.99 523.06 110.00 5.03 406 | 96.06 106.00 95.10 123.03 17.06 407 | 134.79 108.98 134.49 113.99 5.01 408 | 275.23 108.92 274.92 116.10 7.19 409 | 61.15 111.00 59.92 124.98 14.03 410 | 328.55 111.96 327.89 177.00 65.04 411 | 63.79 113.01 62.17 128.96 16.04 412 | 104.95 112.99 104.10 128.02 15.05 413 | 169.31 121.06 168.15 149.03 28.00 414 | 243.15 114.35 242.12 137.02 22.69 415 | 40.59 116.04 35.37 174.97 59.16 416 | 341.19 116.01 341.20 122.99 6.98 417 | 55.44 118.36 54.68 126.08 7.76 418 | 272.79 120.92 273.15 129.01 8.10 419 | 320.50 123.02 320.88 135.04 12.03 420 | 315.48 124.98 313.06 165.02 40.11 421 | 303.55 129.09 303.38 157.99 28.90 422 | 335.94 129.00 335.98 136.00 7.00 423 | 343.39 128.94 343.46 135.05 6.10 424 | 103.14 133.00 102.66 148.95 15.96 425 | 88.15 134.01 88.07 139.01 5.00 426 | 61.70 134.98 59.91 152.04 17.15 427 | 317.19 135.98 317.70 142.99 7.02 428 | 263.36 138.95 263.04 150.96 12.02 429 | 273.04 139.03 272.88 162.10 23.07 430 | 347.59 139.98 347.86 150.90 10.93 431 | 517.19 140.07 518.84 172.78 32.74 432 | 524.19 139.96 526.93 171.00 31.17 433 | 357.41 161.99 357.25 174.98 12.99 434 | 177.85 143.94 176.77 157.00 13.11 435 | 488.71 144.05 490.23 173.98 29.96 436 | 536.00 145.00 536.36 154.96 9.96 437 | 504.74 147.07 507.44 174.98 28.04 438 | 86.99 148.00 86.30 160.08 12.09 439 | 140.52 147.99 139.05 172.00 24.05 440 | 491.37 148.31 492.56 178.03 29.74 441 | 10.03 152.00 8.33 181.07 29.11 442 | 320.01 151.67 320.48 170.91 19.25 443 | 102.27 153.99 101.23 168.02 14.07 444 | 336.05 155.00 336.18 162.01 7.01 445 | 503.55 155.99 503.66 165.95 9.96 446 | 41.85 158.02 40.60 167.96 10.02 447 | 250.67 172.22 251.47 189.00 16.81 448 | 519.48 160.03 519.57 165.04 5.01 449 | 303.45 162.49 302.93 180.01 17.52 450 | 350.94 166.00 350.68 208.08 42.08 451 | 538.17 164.00 538.84 169.02 5.07 452 | 55.80 166.38 55.34 172.71 6.34 453 | 91.80 168.01 90.65 187.08 19.11 454 | 157.36 175.02 154.59 251.03 76.06 455 | 504.52 167.97 504.85 177.03 9.06 456 | 143.75 169.04 140.28 245.01 76.04 457 | 162.41 170.89 159.96 252.00 81.15 458 | 185.13 171.02 185.04 179.93 8.91 459 | 21.36 173.05 20.37 180.00 7.03 460 | 257.55 176.95 257.62 198.87 21.92 461 | 552.39 173.20 552.72 179.02 5.82 462 | 523.23 177.03 524.19 184.97 7.99 463 | 56.90 177.99 56.61 196.97 18.98 464 | 138.29 178.06 137.15 190.01 12.01 465 | 170.56 177.98 170.92 198.00 20.02 466 | 149.70 179.20 148.47 202.82 23.64 467 | 505.28 179.15 505.47 185.03 5.89 468 | 336.53 181.00 336.38 188.99 8.00 469 | 492.89 181.03 493.60 186.96 5.97 470 | 96.14 182.04 95.43 192.62 10.60 471 | 321.42 183.97 321.25 192.67 8.70 472 | 83.77 191.00 83.31 202.03 11.04 473 | 263.25 194.07 263.16 204.03 9.96 474 | 240.35 197.07 239.65 265.03 67.96 475 | 341.03 210.96 342.70 232.97 22.07 476 | 352.97 241.02 353.46 246.92 5.92 477 | 183.93 201.00 183.00 213.47 12.50 478 | 531.51 209.48 531.02 203.66 5.84 479 | 56.82 202.86 54.81 220.08 17.34 480 | 168.63 202.97 168.73 208.03 5.06 481 | 148.67 210.03 146.51 246.02 36.06 482 | 167.34 217.08 167.89 209.64 7.45 483 | 87.56 212.16 87.52 230.86 18.70 484 | 128.24 213.02 128.07 220.02 7.01 485 | 249.62 214.94 250.02 277.00 62.07 486 | 308.91 215.07 309.03 220.99 5.92 487 | 523.34 214.93 526.11 246.98 32.17 488 | 132.05 216.01 131.60 221.98 5.98 489 | 488.37 215.94 488.94 224.02 8.10 490 | 547.57 216.25 549.78 246.98 30.80 491 | 246.32 218.97 245.86 277.98 59.01 492 | 532.51 217.33 534.56 249.99 32.73 493 | 183.42 217.93 182.12 230.28 12.42 494 | 257.67 220.22 259.73 261.03 40.85 495 | 521.12 218.04 524.34 250.96 33.07 496 | 177.53 218.90 177.07 225.03 6.14 497 | 339.69 219.27 338.50 276.97 57.71 498 | 338.42 278.02 338.84 299.04 21.03 499 | 465.50 218.94 465.88 246.00 27.07 500 | 497.71 218.87 497.71 264.96 46.09 501 | 507.15 219.06 509.98 262.01 43.04 502 | 510.83 219.07 513.82 262.03 43.06 503 | 136.89 219.97 135.89 230.99 11.07 504 | 190.85 222.27 190.87 227.97 5.70 505 | 3.34 240.06 5.86 220.89 19.33 506 | 43.11 221.02 40.15 249.00 28.13 507 | 96.34 222.91 95.50 232.01 9.13 508 | 453.37 223.10 456.07 266.01 43.00 509 | 44.51 226.01 42.46 259.02 33.08 510 | 51.60 226.00 50.14 248.00 22.05 511 | 267.31 226.02 267.55 232.98 6.96 512 | 29.91 227.01 29.27 245.02 18.02 513 | 54.34 227.97 53.18 245.03 17.10 514 | 560.36 227.96 561.11 243.99 16.04 515 | 566.50 248.73 567.75 261.41 12.75 516 | 39.15 229.02 38.78 254.14 25.12 517 | 302.49 308.59 302.87 232.01 76.58 518 | 452.72 232.99 452.48 255.88 22.89 519 | 594.00 233.00 594.84 242.96 10.00 520 | 182.61 234.07 181.96 247.02 12.96 521 | 87.06 234.98 85.72 252.96 18.03 522 | 67.27 237.52 67.13 243.27 5.76 523 | 267.95 240.00 267.61 248.40 8.40 524 | 138.89 260.99 138.73 279.00 18.00 525 | 49.25 250.04 49.08 260.99 10.96 526 | 307.69 296.91 308.56 250.01 46.91 527 | 314.71 250.04 314.35 256.63 6.61 528 | 353.87 298.99 352.38 253.98 45.03 529 | 266.96 253.00 266.79 260.00 7.00 530 | 528.77 253.00 529.62 261.98 9.03 531 | 470.68 253.67 470.62 265.01 11.34 532 | 524.14 254.00 524.41 261.00 7.00 533 | 466.39 255.00 467.00 266.00 11.02 534 | 491.98 255.02 492.07 266.05 11.03 535 | 358.23 266.18 357.53 280.02 13.86 536 | 85.49 258.07 84.95 275.00 16.93 537 | 52.84 258.90 52.31 264.02 5.15 538 | 92.98 261.00 92.39 277.08 16.09 539 | 174.39 270.99 174.93 296.08 25.09 540 | 146.53 263.96 146.62 279.77 15.82 541 | 360.75 266.79 360.87 278.01 11.21 542 | 154.42 268.24 154.25 280.98 12.73 543 | 239.70 268.99 240.12 312.98 43.99 544 | 165.59 271.01 164.95 284.94 13.94 545 | 125.65 274.00 125.75 280.16 6.16 546 | 607.44 274.97 608.87 284.00 9.15 547 | 616.64 273.94 617.80 283.04 9.17 548 | 10.42 277.45 8.54 292.99 15.65 549 | 263.07 297.00 263.77 311.99 15.01 550 | 178.09 286.01 177.80 299.09 13.08 551 | 243.43 285.53 243.66 301.89 16.36 552 | 181.06 288.00 180.55 295.53 7.55 553 | 246.80 290.18 246.51 304.26 14.08 554 | 597.35 291.01 597.84 299.06 8.07 555 | 527.88 294.07 529.87 315.99 22.01 556 | 567.09 291.97 570.11 322.99 31.17 557 | 627.07 293.00 630.60 321.99 29.21 558 | 613.00 294.00 618.28 325.92 32.35 559 | 266.97 298.98 267.49 317.94 18.96 560 | 600.44 294.99 603.29 326.80 31.94 561 | 76.42 295.87 76.12 305.07 9.21 562 | 498.33 295.97 499.48 310.96 15.04 563 | 564.36 295.84 568.34 325.94 30.36 564 | 612.65 296.01 615.42 326.01 30.14 565 | 469.69 296.91 470.60 319.98 23.09 566 | 526.06 301.01 526.95 314.98 13.99 567 | 445.16 302.95 445.67 309.03 6.11 568 | 457.17 303.08 458.40 320.98 17.94 569 | 553.58 303.05 554.35 314.00 10.98 570 | 500.94 305.20 502.00 319.00 13.84 571 | 513.60 305.07 514.40 318.08 13.04 572 | 468.30 306.03 469.02 324.00 17.99 573 | 43.01 311.01 42.40 319.77 8.78 574 | 76.13 311.15 75.06 319.96 8.87 575 | 506.01 312.99 506.34 318.04 5.06 576 | 112.42 318.07 112.06 326.08 8.02 577 | 93.93 318.97 91.62 384.01 65.08 578 | 15.65 330.04 17.16 319.79 10.36 579 | 77.15 346.20 77.74 340.96 5.27 580 | 481.99 329.00 482.03 339.01 10.02 581 | 496.84 330.21 496.99 335.99 5.79 582 | 610.47 331.91 610.96 339.00 7.10 583 | 126.01 333.99 125.37 346.78 12.81 584 | 6.61 335.01 5.80 341.97 7.01 585 | 122.30 334.93 122.42 342.35 7.43 586 | 103.39 340.07 102.95 360.00 19.93 587 | 29.24 345.07 29.17 352.04 6.97 588 | 181.59 347.04 181.01 356.00 8.97 589 | 160.20 348.98 159.25 413.00 64.03 590 | 168.02 351.00 167.96 357.00 6.01 591 | 496.65 354.84 497.53 363.67 8.87 592 | 170.47 360.99 170.97 386.99 26.01 593 | 164.04 363.99 163.68 369.03 5.06 594 | 157.12 366.01 155.30 383.06 17.15 595 | 190.86 374.97 189.73 393.94 19.00 596 | 200.73 378.00 201.03 373.01 5.00 597 | 181.39 370.03 181.58 382.99 12.97 598 | 167.52 372.98 166.74 381.93 8.98 599 | 236.47 374.98 237.01 389.00 14.03 600 | 223.35 380.05 221.65 398.99 19.02 601 | 71.95 383.99 71.56 390.91 6.93 602 | 256.23 388.01 256.53 402.90 14.88 603 | 243.00 392.00 242.96 421.01 29.01 604 | 229.35 394.07 230.12 410.03 15.98 605 | 236.76 394.88 235.62 413.01 18.16 606 | 215.06 400.01 215.27 409.85 9.84 607 | 261.07 404.05 260.02 421.00 16.98 608 | 306.81 408.00 306.51 420.86 12.87 609 | 180 610 | 229.93 6.58 243.98 3.91 14.30 611 | 419.05 12.67 467.97 3.81 49.72 612 | 480.35 8.47 505.02 4.19 25.04 613 | 515.83 5.65 528.04 4.19 12.29 614 | 514.89 8.26 526.81 5.80 12.18 615 | 343.16 20.91 349.01 19.53 6.01 616 | 549.92 9.33 561.02 7.21 11.30 617 | 352.35 8.13 345.00 9.00 7.40 618 | 462.04 9.62 471.00 7.88 9.13 619 | 483.01 16.25 504.92 12.20 22.28 620 | 496.02 10.10 503.04 9.22 7.08 621 | 481.98 11.74 488.99 10.94 7.05 622 | 460.45 16.43 469.05 14.80 8.76 623 | 549.90 16.28 560.97 14.75 11.18 624 | 433.90 17.54 447.96 16.16 14.13 625 | 474.17 35.17 462.97 37.31 11.40 626 | 431.03 24.69 453.02 20.91 22.31 627 | 462.04 23.21 471.06 21.75 9.13 628 | 572.07 26.26 600.88 21.65 29.18 629 | 573.95 28.58 584.02 27.09 10.18 630 | 554.05 30.50 569.03 28.21 15.15 631 | 482.01 33.62 494.92 30.77 13.23 632 | 517.01 35.05 542.00 30.98 25.31 633 | 533.04 35.23 541.01 34.21 8.03 634 | 511.00 44.99 581.90 34.59 71.66 635 | 428.07 63.70 580.98 40.79 154.61 636 | 518.82 37.81 526.96 36.43 8.26 637 | 483.95 41.75 489.99 40.96 6.10 638 | 463.02 46.05 474.45 43.59 11.69 639 | 484.00 51.05 509.00 47.01 25.32 640 | 555.04 49.19 565.97 47.91 11.01 641 | 481.66 49.41 457.07 53.51 24.92 642 | 518.72 54.38 542.98 51.10 24.48 643 | 517.04 57.65 544.98 54.06 28.16 644 | 426.03 61.01 455.00 55.03 29.58 645 | 567.98 55.59 575.01 54.75 7.08 646 | 492.06 58.23 509.28 56.79 17.28 647 | 556.15 57.52 564.04 56.64 7.94 648 | 480.03 68.23 551.00 58.01 71.70 649 | 482.98 62.37 509.88 59.20 27.08 650 | 465.06 62.18 475.08 60.71 10.13 651 | 429.45 80.34 438.92 78.85 9.59 652 | 431.99 66.97 448.00 65.00 16.13 653 | 519.96 68.72 545.04 65.25 25.32 654 | 555.04 67.51 568.01 66.36 13.02 655 | 486.00 73.99 510.00 70.00 24.33 656 | 520.88 74.69 545.04 71.22 24.40 657 | 556.01 71.09 561.04 70.62 5.05 658 | 425.03 76.28 437.96 74.43 13.06 659 | 500.04 76.23 508.02 75.15 8.05 660 | 487.04 77.70 496.02 76.29 9.09 661 | 434.08 85.30 439.94 84.64 5.90 662 | 45.97 98.81 57.15 97.72 11.23 663 | 525.00 100.02 546.00 97.95 21.10 664 | 501.85 103.88 510.78 102.38 9.06 665 | 489.03 104.83 498.10 103.88 9.11 666 | 530.96 103.87 536.86 103.47 5.92 667 | 486.11 118.16 523.90 113.60 38.06 668 | 343.01 115.11 352.03 114.17 9.07 669 | 535.94 119.33 520.96 120.54 15.03 670 | 488.08 122.61 494.04 122.21 5.98 671 | 540.49 132.46 533.00 132.97 7.50 672 | 440.06 130.62 450.94 129.58 10.93 673 | 514.99 133.79 525.77 132.60 10.85 674 | 498.03 136.79 506.01 135.60 8.07 675 | 525.17 138.42 533.92 137.24 8.82 676 | 500.99 141.89 515.98 139.64 15.16 677 | 526.95 143.44 537.03 142.25 10.15 678 | 507.04 145.26 515.02 144.33 8.04 679 | 490.97 147.20 500.00 146.01 9.11 680 | 470.02 156.67 482.00 155.04 12.09 681 | 470.02 163.17 483.00 161.99 13.04 682 | 559.92 168.75 519.99 173.38 40.19 683 | 470.06 171.32 482.99 169.83 13.02 684 | 470.08 178.42 483.95 176.80 13.96 685 | 471.08 186.37 484.00 184.93 12.99 686 | 530.03 187.67 555.94 184.81 26.07 687 | 494.00 190.30 519.02 188.49 25.08 688 | 470.99 193.41 476.99 192.97 6.02 689 | 455.04 196.62 470.99 195.84 15.97 690 | 331.91 211.67 340.43 210.59 8.58 691 | 531.95 203.29 556.00 201.99 24.09 692 | 496.02 206.18 522.44 204.64 26.46 693 | 445.02 209.34 473.94 206.52 29.05 694 | 530.90 211.87 556.97 209.73 26.16 695 | 494.06 215.23 523.09 212.28 29.18 696 | 550.00 214.98 557.03 214.32 7.06 697 | 445.04 218.24 464.05 217.19 19.04 698 | 473.98 217.37 478.99 216.97 5.03 699 | 513.00 217.94 518.99 217.58 6.00 700 | 326.96 230.11 336.14 229.74 9.18 701 | 474.00 233.12 486.96 232.26 12.99 702 | 475.01 240.22 487.05 239.44 12.06 703 | 571.95 243.21 585.12 241.61 13.27 704 | 474.97 248.71 488.01 247.93 13.06 705 | 572.01 249.94 585.01 249.36 13.01 706 | 475.03 255.80 488.00 254.99 12.99 707 | 613.02 258.84 618.02 258.26 5.04 708 | 554.04 263.10 566.03 262.25 12.02 709 | 611.97 262.74 620.00 262.10 8.05 710 | 552.05 266.28 591.95 264.41 39.94 711 | 596.15 263.69 608.01 263.66 11.85 712 | 552.05 269.54 619.98 265.28 68.07 713 | 521.06 268.71 538.92 267.67 17.89 714 | 457.92 269.43 469.07 268.24 11.21 715 | 463.04 271.65 492.00 269.03 29.08 716 | 547.18 275.60 600.01 271.21 53.02 717 | 451.99 279.88 542.99 274.72 91.14 718 | 563.04 280.19 599.00 278.03 36.02 719 | 23.01 279.16 31.03 278.78 8.03 720 | 524.00 282.00 538.01 281.87 14.01 721 | 465.97 285.91 500.00 283.90 34.09 722 | 567.39 288.18 594.00 286.10 26.69 723 | 538.02 292.05 565.92 291.17 27.91 724 | 471.97 292.36 489.01 291.31 17.07 725 | 490.01 291.26 495.98 291.14 5.97 726 | 625.97 292.31 616.99 293.10 9.02 727 | 603.00 293.80 609.98 293.31 7.00 728 | 570.01 294.63 595.02 293.62 25.03 729 | 556.00 295.88 563.07 295.36 7.09 730 | 526.01 296.33 500.99 298.93 25.16 731 | 472.00 298.98 496.00 298.06 24.02 732 | 136.95 306.11 144.86 305.73 7.91 733 | 461.01 301.42 466.98 300.90 6.00 734 | 571.00 301.69 597.05 301.26 26.06 735 | 447.96 302.35 453.02 301.89 5.08 736 | 373.00 305.95 382.86 305.39 9.87 737 | 472.98 306.36 496.02 305.22 23.07 738 | 504.00 305.03 509.99 305.14 5.99 739 | 18.90 316.93 12.01 317.35 6.90 740 | 144.27 310.04 157.97 309.95 13.70 741 | 571.01 309.11 598.02 307.54 27.06 742 | 472.98 313.44 496.95 312.37 23.99 743 | 181.01 315.98 194.01 316.22 13.00 744 | 572.00 316.77 598.03 315.56 26.06 745 | 514.99 318.57 524.77 317.71 9.83 746 | 21.14 320.27 27.01 319.97 5.88 747 | 473.01 320.83 498.00 319.87 25.02 748 | 573.02 324.13 599.00 323.00 26.01 749 | 259.96 324.43 266.86 323.85 6.92 750 | 484.00 327.00 490.01 326.90 6.01 751 | 526.97 330.19 536.72 329.34 9.79 752 | 601.99 329.34 632.98 327.91 31.03 753 | 472.99 330.26 478.00 330.03 5.02 754 | 590.00 331.25 599.02 331.12 9.02 755 | 11.00 333.04 16.93 333.18 5.94 756 | 227.04 340.83 253.01 340.33 25.98 757 | 297.72 337.87 305.45 337.82 7.73 758 | 65.01 338.05 73.04 338.17 8.04 759 | 30.08 341.41 10.03 342.51 20.08 760 | 49.98 343.53 44.00 344.03 6.00 761 | 476.90 344.88 482.04 344.59 5.15 762 | 83.99 346.70 89.04 346.24 5.07 763 | 32.08 351.83 54.10 351.93 22.02 764 | 61.96 353.91 71.08 353.74 9.12 765 | 80.05 353.41 90.03 353.09 9.99 766 | 169.97 357.79 178.18 357.70 8.21 767 | 589.98 359.86 595.00 359.48 5.04 768 | 182.06 362.45 187.98 362.65 5.93 769 | 583.56 368.52 595.09 367.76 11.56 770 | 74.00 370.13 90.05 369.68 16.05 771 | 182.17 369.58 189.00 369.61 6.83 772 | 190.92 369.20 198.10 368.69 7.20 773 | 357.89 379.84 363.05 379.76 5.16 774 | 58.00 383.99 3.99 383.35 54.01 775 | 536.97 381.06 544.02 380.94 7.05 776 | 4.02 392.11 65.03 390.34 61.03 777 | 233.00 391.68 242.20 391.20 9.21 778 | 50.97 394.13 63.04 393.20 12.10 779 | 483.15 399.92 491.34 400.36 8.21 780 | 482.96 405.43 489.98 405.53 7.02 781 | 541.09 403.11 546.10 402.75 5.03 782 | 267.00 403.99 274.00 404.02 7.00 783 | 168.88 407.34 174.98 406.86 6.11 784 | 3.98 412.85 65.01 408.13 61.21 785 | 11.97 416.34 117.81 409.48 106.06 786 | 165.67 411.58 180.04 411.75 14.37 787 | 179.03 414.73 159.21 415.56 19.84 788 | 439.95 415.16 446.24 414.78 6.30 789 | 10.04 417.33 4.00 417.66 6.05 790 | -------------------------------------------------------------------------------- /cache/vpdetection/text/009_input_hole-vanishingpoints.txt: -------------------------------------------------------------------------------- 1 | vx vy vz score numLines 2 | -0.99993953 -0.01099670 -0.00001487 5892.67 165 3 | -0.12541680 0.99210407 -0.00038803 5096.55 144 4 | 0.95129897 0.30826963 0.00031729 334.31 52 5 | 6 | nLines x1 y1 x2 y2 length 7 | 165 8 | 192.90 58.76 116.03 58.26 76.87 9 | 466.04 63.34 542.98 62.76 76.94 10 | 521.98 30.08 535.02 30.45 13.04 11 | 478.17 5.60 483.98 5.28 5.81 12 | 609.05 5.88 618.25 6.20 9.21 13 | 473.03 9.53 482.27 9.74 9.25 14 | 185.00 9.99 192.98 10.28 7.98 15 | 184.60 14.61 191.92 14.67 7.32 16 | 358.04 20.12 369.01 20.49 10.97 17 | 477.00 22.84 484.98 22.95 7.98 18 | 465.93 23.70 470.99 23.97 5.07 19 | 125.99 26.92 143.97 26.95 17.98 20 | 249.02 43.24 239.32 42.62 9.72 21 | 585.98 30.55 601.96 30.22 15.99 22 | 293.01 31.23 305.00 32.01 12.02 23 | 119.97 38.09 139.66 38.64 19.70 24 | 598.01 42.12 586.97 42.11 11.04 25 | 517.94 42.93 537.06 43.56 19.13 26 | 469.12 45.05 479.86 44.59 10.75 27 | 582.92 63.31 634.00 63.99 51.09 28 | 273.98 55.78 283.14 55.43 9.17 29 | 4.00 55.62 75.01 57.02 71.02 30 | 232.01 59.93 309.91 59.87 77.90 31 | 349.02 60.86 425.82 61.38 76.80 32 | 4.00 61.60 80.01 62.83 76.02 33 | 107.89 62.51 199.05 64.61 91.19 34 | 224.98 65.57 312.00 66.03 87.02 35 | 343.02 66.09 433.82 66.32 90.81 36 | 467.99 69.56 559.96 69.20 91.97 37 | 576.98 69.19 634.00 70.07 57.02 38 | 4.03 83.44 77.09 84.88 73.08 39 | 106.07 87.09 197.95 88.18 91.89 40 | 225.05 87.80 314.96 88.08 89.91 41 | 343.03 89.09 433.06 90.42 90.03 42 | 3.99 90.20 69.91 91.60 65.94 43 | 147.04 90.43 155.81 90.50 8.77 44 | 161.20 90.12 177.89 90.25 16.70 45 | 468.02 89.61 553.01 90.99 85.00 46 | 229.14 91.66 235.89 91.65 6.75 47 | 580.20 91.83 634.00 91.90 53.80 48 | 354.94 93.05 360.26 93.19 5.33 49 | 480.59 93.00 485.76 92.88 5.17 50 | 588.11 184.94 634.00 187.73 45.98 51 | 115.00 93.89 190.02 95.21 75.03 52 | 605.04 94.46 599.14 94.58 5.90 53 | 611.05 94.84 617.01 94.54 5.96 54 | 234.00 95.04 308.09 95.78 74.10 55 | 525.00 95.01 530.02 95.02 5.03 56 | 350.90 96.39 426.01 98.05 75.13 57 | 470.93 97.22 545.03 98.28 74.10 58 | 587.96 98.32 634.01 99.27 46.06 59 | 232.99 103.42 241.98 102.95 9.00 60 | 521.97 101.91 538.94 102.75 16.99 61 | 409.94 104.82 423.96 104.07 14.04 62 | 411.03 144.88 422.95 145.63 11.95 63 | 36.04 124.50 30.14 124.34 5.90 64 | 354.00 114.03 359.99 114.28 5.99 65 | 503.16 113.32 515.97 113.22 12.81 66 | 602.04 118.10 608.34 118.44 6.31 67 | 46.00 118.99 51.03 119.03 5.03 68 | 233.99 120.97 240.96 121.21 6.98 69 | 308.01 178.10 228.77 177.72 79.23 70 | 367.95 140.45 380.04 140.86 12.10 71 | 304.98 144.41 299.94 144.52 5.05 72 | 12.01 153.60 3.77 153.26 8.24 73 | 359.03 160.94 368.64 160.70 9.61 74 | 408.11 155.76 414.01 155.43 5.92 75 | 4.01 173.32 63.00 174.06 58.99 76 | 107.13 175.72 187.12 176.59 80.00 77 | 350.15 177.80 430.71 178.57 80.56 78 | 4.00 179.64 68.97 180.54 64.98 79 | 473.00 179.52 552.98 179.90 79.98 80 | 594.30 180.45 634.00 181.60 39.71 81 | 98.03 181.65 193.01 182.94 95.00 82 | 220.96 183.53 315.97 182.89 95.00 83 | 471.99 186.11 559.98 185.58 87.98 84 | 347.92 184.24 438.04 184.65 90.12 85 | 300.05 204.43 311.98 205.05 11.94 86 | 3.94 205.25 67.00 205.97 63.07 87 | 323.96 207.23 340.03 207.78 16.07 88 | 538.01 206.05 549.01 206.21 11.01 89 | 95.00 207.02 187.01 207.40 92.01 90 | 220.02 208.34 315.98 209.63 95.96 91 | 9.00 208.99 18.97 208.83 9.98 92 | 21.99 209.07 32.87 208.70 10.89 93 | 49.06 209.53 61.83 209.29 12.78 94 | 343.32 209.47 439.73 211.45 96.43 95 | 467.33 210.38 563.97 210.66 96.64 96 | 153.62 210.21 158.89 209.95 5.28 97 | 166.87 210.05 171.98 209.99 5.11 98 | 99.22 211.33 113.08 210.58 13.88 99 | 146.70 211.25 152.59 211.39 5.90 100 | 165.44 211.42 160.29 211.64 5.15 101 | 174.01 211.87 186.91 211.77 12.89 102 | 591.03 211.72 634.00 212.19 42.97 103 | 4.01 212.74 58.08 213.60 54.08 104 | 271.35 212.63 277.01 213.02 5.67 105 | 103.04 214.61 183.06 215.29 80.02 106 | 609.39 215.07 614.51 215.00 5.12 107 | 622.85 215.05 627.92 214.96 5.07 108 | 351.99 216.68 430.01 217.16 78.02 109 | 228.01 216.92 307.04 217.26 79.04 110 | 475.99 217.04 554.96 217.24 78.97 111 | 599.01 218.94 633.97 219.30 34.97 112 | 547.77 226.33 556.01 226.21 8.25 113 | 508.98 234.41 521.92 234.61 12.95 114 | 146.95 239.03 139.53 238.55 7.44 115 | 260.91 235.26 270.05 234.84 9.16 116 | 386.96 261.09 396.93 260.84 9.97 117 | 294.85 253.70 305.97 253.65 11.12 118 | 261.51 255.85 268.81 256.26 7.30 119 | 245.01 262.08 252.03 262.09 7.03 120 | 164.02 269.94 174.99 269.26 11.00 121 | 536.92 267.92 546.93 268.67 10.04 122 | 370.34 279.43 365.00 279.54 5.34 123 | 32.96 288.88 38.94 288.79 5.98 124 | 13.15 291.42 19.99 291.65 6.84 125 | 3.99 304.18 50.07 304.68 46.08 126 | 96.04 305.52 179.94 305.27 83.90 127 | 224.01 306.58 263.99 306.96 39.98 128 | 358.00 307.00 435.88 307.55 77.89 129 | 479.97 307.59 563.94 308.33 83.97 130 | 360.00 313.35 444.99 314.08 84.99 131 | 4.01 310.48 49.93 309.94 45.93 132 | 605.98 309.53 634.01 310.32 28.04 133 | 97.01 310.74 186.98 312.84 90.00 134 | 478.92 314.13 566.18 314.16 87.26 135 | 606.47 315.51 634.00 317.03 27.57 136 | 3.99 337.98 29.07 338.68 25.08 137 | 32.94 338.36 56.01 338.50 23.07 138 | 84.04 339.07 182.40 339.58 98.36 139 | 214.12 341.17 256.06 340.62 41.94 140 | 373.02 341.90 441.95 341.30 68.93 141 | 21.03 342.56 31.97 341.89 10.96 142 | 41.90 342.22 51.01 341.97 9.11 143 | 476.06 342.66 572.03 343.80 95.97 144 | 603.00 344.08 633.99 343.91 30.99 145 | 216.10 344.14 225.16 344.21 9.06 146 | 3.99 346.49 45.12 346.60 41.12 147 | 92.01 346.68 176.96 346.24 84.95 148 | 483.99 350.66 565.98 351.47 81.99 149 | 612.00 352.03 634.00 351.94 22.00 150 | 243.01 353.25 253.96 353.77 10.96 151 | 159.00 358.00 166.01 357.95 7.00 152 | 245.98 404.47 232.00 404.99 14.00 153 | 389.71 377.60 397.00 378.02 7.31 154 | 533.01 396.02 523.96 396.21 9.06 155 | 109.91 391.45 119.02 391.95 9.13 156 | 107.70 395.34 119.00 394.93 11.30 157 | 81.47 448.64 172.81 448.35 91.35 158 | 89.12 398.32 95.03 398.57 5.92 159 | 577.01 451.49 488.00 451.04 89.01 160 | 625.01 407.33 634.01 407.48 9.00 161 | 16.54 409.50 24.11 409.83 7.58 162 | 566.02 419.05 550.98 419.78 15.06 163 | 528.07 416.66 535.04 416.59 6.97 164 | 4.00 447.85 36.05 447.62 32.05 165 | 403.02 449.54 440.99 449.65 37.97 166 | 251.00 455.95 218.98 456.19 32.01 167 | 622.00 452.08 634.01 452.77 12.02 168 | 4.00 454.49 36.99 454.93 32.99 169 | 80.04 454.97 173.00 456.96 92.98 170 | 404.00 456.73 447.95 457.42 43.95 171 | 487.97 457.44 578.76 457.84 90.79 172 | 621.00 459.78 634.00 459.80 13.00 173 | 144 174 | 625.82 9.20 626.86 27.06 17.89 175 | 80.33 4.02 75.59 55.01 51.21 176 | 86.07 4.00 80.72 61.86 58.10 177 | 111.70 3.98 106.64 61.97 58.21 178 | 118.31 9.01 114.34 57.01 48.16 179 | 196.02 4.00 193.42 58.07 54.13 180 | 202.29 4.01 199.73 62.99 59.03 181 | 227.11 4.00 224.17 64.00 60.07 182 | 233.38 3.99 232.08 21.03 17.09 183 | 280.58 4.25 280.57 12.00 7.75 184 | 311.29 4.04 310.89 58.99 54.96 185 | 316.70 3.99 317.20 63.99 60.00 186 | 341.50 4.01 341.04 64.99 60.98 187 | 347.67 4.11 347.46 21.79 17.69 188 | 431.04 4.00 433.95 65.00 61.07 189 | 456.05 4.00 459.46 68.07 64.16 190 | 462.07 4.00 465.31 62.74 58.83 191 | 546.90 4.01 552.63 65.98 62.24 192 | 570.80 4.01 576.19 67.91 64.12 193 | 490.00 7.00 491.94 26.99 20.08 194 | 376.25 27.72 375.72 13.06 14.67 195 | 605.89 10.05 607.00 18.00 8.03 196 | 293.77 17.96 293.84 11.80 6.17 197 | 425.91 15.97 426.30 59.99 44.02 198 | 237.24 18.81 236.90 23.99 5.19 199 | 347.54 28.02 347.96 60.01 31.99 200 | 232.29 24.98 231.39 59.85 34.88 201 | 543.42 34.93 544.41 47.93 13.04 202 | 578.54 37.96 579.46 43.92 6.03 203 | 120.08 41.02 119.03 56.00 15.01 204 | 544.20 49.98 544.58 61.96 11.99 205 | 77.91 85.12 69.33 179.36 94.62 206 | 315.99 88.55 316.67 181.95 93.40 207 | 105.88 88.00 97.55 180.02 92.40 208 | 224.23 89.03 220.19 181.97 93.02 209 | 434.02 90.96 438.55 183.13 92.28 210 | 342.36 90.10 342.56 181.02 90.92 211 | 465.07 184.00 461.75 94.01 90.06 212 | 554.01 91.49 562.01 184.00 92.86 213 | 112.41 96.01 106.23 174.96 79.19 214 | 467.56 94.56 469.77 134.93 40.43 215 | 71.95 92.98 63.82 173.84 81.27 216 | 229.31 92.79 228.86 106.98 14.19 217 | 579.89 93.01 587.57 184.00 91.32 218 | 192.42 95.26 187.53 174.99 79.88 219 | 347.72 94.84 349.35 176.99 82.17 220 | 583.63 96.26 593.42 180.02 84.33 221 | 124.66 101.44 122.77 127.92 26.55 222 | 603.72 146.94 598.83 102.76 44.45 223 | 551.38 150.09 553.99 179.00 29.02 224 | 228.82 116.00 229.29 132.98 16.98 225 | 283.06 121.00 282.22 136.99 16.01 226 | 230.37 145.92 227.94 177.01 31.19 227 | 429.31 125.05 430.48 149.89 24.87 228 | 499.74 126.15 501.81 141.91 15.89 229 | 196.46 134.02 196.00 140.00 6.00 230 | 155.65 134.96 155.10 141.00 6.06 231 | 310.26 135.00 308.65 177.58 42.61 232 | 470.14 140.00 472.22 178.87 38.92 233 | 229.54 137.88 229.04 144.00 6.14 234 | 195.54 142.96 194.52 151.99 9.09 235 | 430.82 153.01 431.04 178.01 24.99 236 | 595.32 154.07 596.11 159.98 5.96 237 | 611.60 154.13 613.03 163.99 9.97 238 | 358.08 155.02 358.41 160.47 5.46 239 | 606.50 160.01 606.95 166.30 6.31 240 | 64.46 206.92 63.75 213.07 6.19 241 | 192.00 211.00 191.06 226.01 15.04 242 | 94.34 207.74 90.89 261.00 53.37 243 | 564.73 211.19 572.98 307.00 96.17 244 | 219.16 209.97 218.93 226.00 16.03 245 | 343.03 210.00 343.88 287.99 78.00 246 | 316.49 211.03 316.75 269.90 58.87 247 | 60.16 212.08 51.51 303.94 92.26 248 | 101.11 215.99 94.24 304.97 89.24 249 | 440.19 212.00 444.85 312.01 100.12 250 | 187.77 213.04 186.98 221.95 8.95 251 | 349.71 218.05 350.18 294.00 75.95 252 | 186.10 214.04 180.70 304.02 90.15 253 | 471.57 215.27 478.58 306.97 91.96 254 | 434.21 216.18 436.60 306.96 90.81 255 | 468.27 215.99 471.41 303.98 88.04 256 | 565.39 306.99 558.08 219.98 87.31 257 | 596.87 221.00 603.97 312.07 91.34 258 | 190.83 229.02 189.64 251.96 22.98 259 | 218.29 229.00 215.68 310.98 82.02 260 | 591.43 231.99 597.14 274.94 43.33 261 | 598.03 276.01 599.44 311.97 36.00 262 | 186.66 237.05 185.73 247.71 10.70 263 | 224.19 239.03 224.08 246.99 7.96 264 | 401.42 246.08 401.16 258.09 12.01 265 | 310.32 253.07 309.68 269.96 16.90 266 | 223.18 263.99 222.17 305.00 41.03 267 | 518.10 265.11 518.32 271.29 6.19 268 | 90.90 267.00 90.15 277.02 10.05 269 | 187.02 267.01 187.28 287.99 20.99 270 | 166.70 271.63 166.45 279.96 8.33 271 | 58.48 274.97 57.29 292.97 18.04 272 | 90.34 280.03 86.36 306.91 27.17 273 | 226.81 280.98 226.77 289.91 8.93 274 | 606.45 283.02 607.17 294.24 11.25 275 | 186.26 294.06 185.62 301.95 7.92 276 | 57.32 294.95 57.01 307.00 12.06 277 | 187.48 304.95 187.16 311.02 6.09 278 | 213.89 342.02 213.74 359.01 16.99 279 | 185.84 343.97 185.66 348.99 5.02 280 | 220.95 350.03 219.98 363.99 14.00 281 | 478.90 366.14 476.79 349.03 17.24 282 | 47.09 347.05 41.24 426.98 80.14 283 | 178.74 347.96 177.63 382.96 35.02 284 | 604.88 348.02 608.93 400.01 52.15 285 | 439.16 357.95 438.72 350.99 6.97 286 | 479.91 349.06 484.63 450.71 101.76 287 | 84.27 349.98 83.37 377.28 27.31 288 | 571.98 390.00 568.72 355.06 35.10 289 | 608.04 350.96 619.84 445.02 94.79 290 | 617.45 447.62 610.56 402.18 45.95 291 | 444.59 354.02 444.76 369.02 15.01 292 | 572.99 354.01 573.81 359.85 5.90 293 | 439.45 361.97 441.87 413.90 51.99 294 | 213.16 364.03 212.41 394.99 30.97 295 | 219.72 365.96 219.35 384.03 18.07 296 | 85.94 373.02 85.75 378.06 5.05 297 | 182.74 374.07 181.01 396.01 22.01 298 | 81.40 377.01 79.31 392.98 16.11 299 | 87.66 378.95 86.30 391.99 13.10 300 | 576.83 381.99 578.71 401.90 20.00 301 | 122.92 384.97 121.83 395.94 11.03 302 | 176.84 386.00 174.89 450.96 64.99 303 | 85.88 396.01 81.14 447.98 52.18 304 | 79.21 397.05 73.51 450.98 54.23 305 | 212.18 398.01 212.30 418.10 20.09 306 | 218.77 402.00 217.22 448.94 46.97 307 | 445.99 402.00 448.62 430.00 28.12 308 | 573.87 410.03 577.74 450.95 41.11 309 | 244.02 408.01 243.07 418.69 10.72 310 | 180.14 417.01 178.98 438.99 22.01 311 | 125.87 420.01 125.36 434.02 14.03 312 | 580.74 422.94 581.01 429.00 6.07 313 | 519.96 425.05 521.15 433.98 9.01 314 | 442.00 430.00 443.63 449.07 19.14 315 | 210.96 435.00 209.70 449.00 14.05 316 | 480.80 437.04 481.66 448.12 11.11 317 | 581.76 438.06 583.28 451.11 13.14 318 | 52 319 | 627.22 27.88 634.06 30.73 7.41 320 | 481.97 31.17 476.71 29.59 5.49 321 | 170.99 13.28 175.99 14.94 5.27 322 | 272.05 23.58 266.96 22.04 5.32 323 | 494.73 22.38 503.00 25.22 8.74 324 | 283.10 26.97 290.32 29.53 7.66 325 | 145.04 26.08 157.36 29.84 12.89 326 | 398.00 30.82 404.00 33.00 6.38 327 | 607.98 31.06 617.07 34.79 9.83 328 | 283.07 44.66 292.99 47.84 10.42 329 | 294.00 55.02 298.86 56.69 5.14 330 | 384.07 55.76 389.98 58.03 6.33 331 | 461.94 67.24 466.97 69.33 5.44 332 | 118.90 98.10 126.75 100.52 8.21 333 | 380.06 99.28 387.02 101.53 7.31 334 | 620.98 107.89 615.03 105.53 6.40 335 | 270.00 106.98 277.11 109.34 7.48 336 | 478.07 115.04 486.91 118.17 9.38 337 | 625.06 114.76 634.04 117.91 9.52 338 | 23.08 129.89 31.96 132.53 9.26 339 | 501.99 119.05 506.91 120.72 5.20 340 | 623.31 129.07 617.92 127.12 5.73 341 | 417.01 130.42 422.02 131.92 5.23 342 | 300.06 133.32 305.88 135.36 6.17 343 | 120.00 141.29 130.95 143.79 11.23 344 | 624.04 142.45 629.99 144.12 6.18 345 | 114.97 147.56 121.06 149.57 6.41 346 | 233.00 152.44 240.03 154.67 7.37 347 | 489.07 160.60 482.70 158.67 6.66 348 | 585.02 206.19 590.01 207.89 5.27 349 | 231.27 211.06 236.82 212.55 5.75 350 | 264.00 229.88 276.95 233.62 13.49 351 | 266.03 244.27 271.80 245.39 5.88 352 | 519.00 258.00 513.15 256.69 6.00 353 | 160.11 263.38 177.98 267.55 18.35 354 | 496.90 274.47 488.89 272.16 8.34 355 | 486.16 266.29 499.99 270.02 14.32 356 | 615.00 265.92 626.33 269.56 11.90 357 | 116.99 269.38 121.94 270.47 5.07 358 | 293.14 270.83 299.00 272.17 6.01 359 | 412.13 273.32 422.09 275.73 10.25 360 | 526.99 277.85 533.87 279.71 7.12 361 | 496.00 286.46 484.98 283.67 11.36 362 | 563.73 346.35 568.99 347.78 5.46 363 | 606.98 346.73 612.47 348.49 5.77 364 | 113.98 352.27 129.95 355.58 16.30 365 | 619.91 458.25 614.70 456.95 5.37 366 | 141.92 352.69 157.05 356.36 15.57 367 | 141.62 359.46 147.88 361.19 6.49 368 | 394.63 394.39 401.02 395.64 6.51 369 | 100.97 400.57 108.87 401.73 7.98 370 | 154.96 416.66 160.00 418.00 5.22 371 | -------------------------------------------------------------------------------- /cache/vpdetection/text/022_input_hole-vanishingpoints.txt: -------------------------------------------------------------------------------- 1 | vx vy vz score numLines 2 | 0.77733745 -0.62908262 -0.00124372 2029.38 140 3 | -0.06053710 0.99816585 -0.00043268 1292.86 99 4 | -0.86587428 -0.50026065 -0.00100856 1136.69 132 5 | 6 | nLines x1 y1 x2 y2 length 7 | 140 8 | 201.08 166.15 206.99 163.96 6.30 9 | 191.15 186.38 208.92 179.87 18.93 10 | 194.05 190.13 205.95 184.86 13.02 11 | 196.01 195.04 200.91 192.86 5.36 12 | 176.02 212.15 209.95 199.34 36.27 13 | 204.00 228.47 180.05 236.18 25.16 14 | 217.00 243.91 223.02 242.06 6.30 15 | 173.98 247.95 180.00 246.00 6.33 16 | 297.06 329.30 357.04 317.70 61.09 17 | 328.76 327.45 323.00 328.89 5.93 18 | 269.99 344.22 368.02 326.78 99.57 19 | 276.98 345.69 368.04 330.21 92.37 20 | 254.99 364.77 262.68 363.38 7.82 21 | 253.03 371.22 306.98 362.57 54.64 22 | 284.92 374.62 309.08 371.35 24.38 23 | 249.98 378.45 283.40 373.20 33.83 24 | 247.04 385.52 308.99 375.83 62.71 25 | 127.25 387.55 159.98 380.25 33.53 26 | 230.06 383.16 239.01 381.69 9.07 27 | 162.07 385.08 111.04 393.23 51.67 28 | 237.98 386.70 244.99 385.66 7.09 29 | 151.02 392.94 161.95 391.76 10.99 30 | 107.01 400.08 119.91 398.70 12.97 31 | 314.17 418.48 308.00 419.06 6.20 32 | 316.24 424.28 321.88 424.09 5.64 33 | 34.99 428.48 58.03 426.96 23.09 34 | 287.03 430.52 307.05 428.80 20.09 35 | 217.93 431.89 224.05 431.13 6.17 36 | 255.03 434.30 284.04 431.27 29.16 37 | 338.04 444.41 358.93 443.94 20.89 38 | 363.98 442.40 375.04 441.95 11.07 39 | 412.99 445.04 419.00 444.94 6.01 40 | 52.96 460.78 74.03 458.48 21.19 41 | 383.89 451.39 388.90 451.23 5.01 42 | 407.92 454.74 413.02 454.18 5.13 43 | 277.55 458.15 271.96 458.56 5.61 44 | 73.00 471.01 82.95 470.63 9.96 45 | 344.06 466.05 350.06 466.16 5.99 46 | 296.15 475.83 306.01 476.18 9.87 47 | 88.98 468.91 98.00 468.96 9.01 48 | 101.92 468.60 112.99 468.55 11.06 49 | 125.00 472.16 130.01 471.85 5.02 50 | 395.00 473.01 402.04 472.42 7.07 51 | 364.95 475.18 370.02 474.87 5.08 52 | 49.04 478.28 60.40 478.48 11.37 53 | 265.03 481.12 279.96 480.70 14.94 54 | 113.97 488.15 134.14 486.56 20.23 55 | 314.00 482.94 329.00 482.94 15.00 56 | 385.02 482.96 402.83 482.54 17.82 57 | 410.99 484.10 421.02 484.47 10.04 58 | 17.79 487.62 37.96 486.85 20.18 59 | 22.00 495.14 34.98 495.39 12.98 60 | 47.99 485.85 55.00 485.73 7.02 61 | 219.61 493.52 208.03 493.31 11.58 62 | 79.03 488.40 88.03 488.01 9.01 63 | 164.99 488.05 170.01 488.02 5.02 64 | 73.00 494.64 87.97 494.74 14.96 65 | 90.07 494.63 99.01 494.51 8.95 66 | 98.00 496.48 75.02 496.52 22.98 67 | 100.04 494.40 115.00 495.01 14.97 68 | 374.98 499.11 393.96 500.13 19.01 69 | 297.00 498.96 329.95 498.71 32.95 70 | 41.89 497.78 54.06 497.30 12.18 71 | 99.00 496.57 112.96 496.57 13.96 72 | 266.02 498.24 285.80 498.06 19.77 73 | 402.02 499.67 421.01 499.89 18.99 74 | 44.25 501.44 50.92 501.35 6.67 75 | 271.08 501.89 280.97 502.08 9.90 76 | 104.00 513.16 134.94 511.46 30.99 77 | 309.99 504.15 315.94 504.11 5.96 78 | 4.03 505.94 23.05 504.84 19.05 79 | 34.00 515.15 79.03 514.62 45.03 80 | 45.00 505.89 50.94 505.69 5.94 81 | 373.01 507.17 390.00 506.35 17.00 82 | 401.99 506.58 421.00 506.92 19.02 83 | 67.99 507.77 79.02 507.42 11.04 84 | 102.98 506.82 112.01 506.62 9.03 85 | 32.00 508.26 42.01 507.91 10.02 86 | 53.00 507.83 60.99 507.82 7.99 87 | 265.94 508.19 332.11 508.39 66.18 88 | 321.00 511.02 332.92 511.55 11.94 89 | 137.16 519.65 145.99 519.45 8.83 90 | 153.11 516.82 161.93 517.19 8.83 91 | 221.99 513.10 230.00 513.62 8.03 92 | 269.98 514.21 285.98 515.30 16.03 93 | 312.11 514.48 318.07 514.62 5.97 94 | 3.98 515.15 9.81 514.88 5.84 95 | 100.00 521.26 134.00 520.76 34.01 96 | 222.99 520.94 263.02 519.35 40.05 97 | 264.01 519.31 359.00 523.01 95.06 98 | 360.00 523.04 421.00 520.05 61.08 99 | 4.00 522.31 88.00 522.40 84.00 100 | 149.05 521.64 169.00 522.29 19.96 101 | 121.23 522.79 142.08 523.71 20.87 102 | 395.98 523.35 417.99 524.80 22.05 103 | 84.93 526.58 119.79 525.31 34.88 104 | 4.00 527.88 54.01 527.09 50.01 105 | 381.01 526.47 372.93 526.57 8.09 106 | 139.00 526.98 156.98 527.58 18.00 107 | 390.01 529.38 402.03 529.50 12.02 108 | 135.00 530.93 140.00 530.96 5.00 109 | 216.96 531.40 235.02 531.32 18.06 110 | 239.10 531.47 265.98 532.15 26.88 111 | 77.99 534.16 88.00 534.01 10.02 112 | 163.02 534.71 177.03 535.62 14.04 113 | 213.99 536.17 220.97 536.30 6.99 114 | 371.97 536.69 380.01 537.48 8.08 115 | 234.99 536.82 240.02 536.94 5.02 116 | 289.99 537.39 420.99 542.49 131.10 117 | 4.01 537.89 24.98 539.40 21.02 118 | 114.00 538.27 127.02 538.42 13.02 119 | 145.01 538.06 159.99 539.08 15.02 120 | 87.00 538.95 94.01 539.15 7.01 121 | 105.99 538.77 112.00 538.62 6.02 122 | 164.95 539.35 182.21 539.59 17.26 123 | 96.96 539.76 103.03 539.63 6.07 124 | 55.00 542.84 86.95 543.34 31.95 125 | 11.96 548.61 21.03 548.73 9.08 126 | 61.94 549.33 72.96 550.73 11.11 127 | 3.99 549.65 27.01 551.81 23.11 128 | 232.00 554.96 241.98 554.84 9.99 129 | 217.01 556.48 232.00 557.93 15.06 130 | 208.00 560.10 225.04 561.64 17.11 131 | 271.01 560.57 281.00 561.13 10.00 132 | 298.01 562.92 312.00 563.97 14.04 133 | 334.00 563.90 356.00 564.97 22.02 134 | 237.01 570.15 249.12 570.68 12.13 135 | 201.00 571.00 212.01 571.56 11.02 136 | 21.99 576.79 34.02 577.37 12.04 137 | 152.93 578.22 203.11 586.54 50.87 138 | 216.00 587.03 225.02 587.82 9.06 139 | 240.00 589.97 246.00 590.97 6.08 140 | 5.97 591.28 13.00 592.50 7.13 141 | 175.03 596.90 183.98 598.26 9.06 142 | 214.94 604.32 235.00 606.67 20.19 143 | 253.97 608.22 284.03 611.50 30.23 144 | 140.93 611.72 146.00 612.39 5.12 145 | 292.00 613.54 329.00 617.59 37.22 146 | 236.00 625.03 248.99 626.56 13.08 147 | 385.00 625.02 414.00 627.83 29.14 148 | 99 149 | 209.01 167.00 209.75 175.94 8.98 150 | 178.95 191.00 178.94 199.00 8.01 151 | 239.32 192.99 239.89 199.99 7.03 152 | 204.37 206.07 204.33 223.91 17.84 153 | 208.77 205.95 209.02 216.00 10.05 154 | 219.43 206.21 219.63 214.98 8.76 155 | 223.88 208.99 224.30 224.93 15.94 156 | 193.66 210.08 193.68 223.01 12.93 157 | 228.05 210.95 229.00 227.00 16.08 158 | 188.38 211.91 189.08 224.00 12.11 159 | 257.70 264.03 262.57 362.04 98.13 160 | 232.64 212.95 233.28 229.07 16.14 161 | 163.81 270.00 162.91 383.99 114.00 162 | 212.82 220.02 212.83 229.99 9.97 163 | 213.74 249.05 214.76 267.96 18.94 164 | 224.97 250.63 225.49 266.98 16.35 165 | 205.09 254.02 204.54 270.92 16.90 166 | 212.46 256.98 212.58 268.98 12.00 167 | 180.10 263.00 180.34 267.99 5.00 168 | 11.38 296.00 9.05 365.00 69.04 169 | 249.94 292.02 250.15 298.02 6.01 170 | 217.03 303.00 217.70 314.03 11.05 171 | 213.81 305.04 214.22 329.93 24.89 172 | 227.31 320.97 230.90 371.10 50.26 173 | 217.34 323.04 218.73 339.28 16.30 174 | 242.08 325.99 242.14 331.01 5.02 175 | 213.99 331.99 214.00 359.00 27.01 176 | 369.74 341.01 371.04 353.00 12.06 177 | 218.05 341.99 218.55 360.12 18.14 178 | 237.99 344.00 238.14 349.00 5.01 179 | 301.17 346.96 301.80 352.01 5.09 180 | 351.93 347.03 352.35 353.04 6.03 181 | 296.07 347.98 296.60 353.07 5.11 182 | 335.02 350.99 335.28 356.04 5.05 183 | 323.39 351.95 323.86 357.97 6.04 184 | 238.22 352.95 238.35 359.00 6.05 185 | 318.02 352.99 318.67 358.02 5.06 186 | 347.00 358.00 347.55 363.02 5.04 187 | 25.26 363.00 21.20 444.83 81.93 188 | 170.00 362.00 169.78 376.00 14.00 189 | 209.22 363.02 210.24 414.00 50.99 190 | 224.51 362.99 226.89 423.92 60.98 191 | 9.80 366.94 8.83 387.99 21.08 192 | 205.66 370.01 205.44 391.04 21.03 193 | 12.20 373.94 10.26 412.37 38.48 194 | 17.51 375.11 15.73 426.96 51.88 195 | 288.49 383.89 288.55 388.90 5.01 196 | 327.59 384.05 327.89 389.97 5.93 197 | 172.68 386.06 172.67 391.24 5.18 198 | 230.56 391.04 232.97 430.01 39.05 199 | 302.53 393.95 303.03 399.00 5.08 200 | 341.41 394.19 341.96 400.01 5.84 201 | 374.38 399.98 374.86 415.03 15.05 202 | 237.31 401.95 237.75 406.99 5.06 203 | 341.84 403.99 342.23 408.98 5.00 204 | 105.67 417.01 105.97 407.00 10.02 205 | 8.31 406.03 7.73 427.97 21.95 206 | 173.00 406.40 172.85 412.28 5.88 207 | 317.98 406.00 318.32 411.01 5.02 208 | 247.54 411.84 247.53 416.95 5.11 209 | 12.14 413.01 11.35 427.07 14.09 210 | 361.49 417.92 361.68 423.89 5.97 211 | 322.84 419.18 324.08 428.98 9.88 212 | 358.43 428.79 360.33 443.06 14.40 213 | 16.44 430.00 16.71 447.01 17.01 214 | 6.08 431.01 6.12 447.01 16.00 215 | 30.36 433.10 30.12 443.03 9.93 216 | 323.57 433.03 324.23 438.98 5.99 217 | 36.69 434.99 36.13 447.00 12.03 218 | 413.76 435.07 414.29 441.83 6.79 219 | 420.91 435.01 421.57 441.06 6.08 220 | 173.46 436.44 173.20 466.02 29.58 221 | 61.49 442.94 61.56 451.02 8.08 222 | 48.14 438.98 47.53 447.98 9.02 223 | 54.03 441.00 53.99 447.00 6.00 224 | 134.99 443.00 135.01 450.20 7.20 225 | 346.64 447.71 346.99 452.99 5.30 226 | 327.81 448.93 328.12 454.82 5.90 227 | 92.15 451.00 92.16 456.03 5.03 228 | 113.63 478.80 113.99 461.01 17.80 229 | 419.16 456.93 419.84 465.04 8.14 230 | 130.96 459.00 131.42 467.82 8.83 231 | 148.73 459.87 149.01 468.00 8.13 232 | 168.48 460.99 169.00 468.00 7.03 233 | 306.76 463.02 306.73 475.04 12.02 234 | 295.12 467.01 295.32 474.95 7.94 235 | 88.10 470.03 87.72 478.03 8.01 236 | 370.80 470.02 371.48 476.08 6.10 237 | 391.15 470.99 391.65 476.03 5.07 238 | 112.72 482.11 112.97 487.48 5.38 239 | 299.39 483.04 300.60 496.96 13.97 240 | 359.33 484.14 359.46 498.88 14.74 241 | 63.82 485.00 64.89 512.01 27.03 242 | 220.00 486.01 220.34 492.90 6.90 243 | 353.36 486.87 354.74 506.07 19.24 244 | 160.13 493.12 160.78 502.96 9.86 245 | 331.62 494.06 332.93 507.02 13.02 246 | 360.25 503.95 360.49 509.04 5.09 247 | 145.97 513.01 145.87 518.05 5.05 248 | 132 249 | 212.07 183.26 218.41 186.51 7.13 250 | 218.82 183.35 225.85 186.27 7.61 251 | 220.95 188.63 232.89 193.71 12.98 252 | 211.01 199.03 238.92 210.17 30.05 253 | 222.09 228.85 240.92 237.16 20.58 254 | 241.05 245.83 246.03 247.93 5.40 255 | 366.67 320.22 420.64 340.95 57.82 256 | 369.00 326.55 404.15 340.55 37.84 257 | 369.01 330.12 402.11 340.19 34.60 258 | 373.76 343.49 383.88 347.41 10.85 259 | 385.87 347.83 391.85 349.38 6.17 260 | 392.85 350.58 421.00 359.02 29.39 261 | 376.82 354.73 420.99 367.06 45.86 262 | 11.95 359.18 25.05 361.98 13.40 263 | 308.01 361.92 332.04 367.77 24.74 264 | 391.97 367.13 420.98 375.07 30.07 265 | 310.00 371.34 333.14 375.48 23.51 266 | 389.96 375.31 413.00 381.02 23.73 267 | 309.99 375.72 340.09 381.57 30.66 268 | 376.71 380.64 382.85 382.48 6.40 269 | 384.97 383.15 391.87 384.36 7.00 270 | 393.99 385.05 416.69 389.55 23.14 271 | 376.79 390.59 386.81 392.62 10.23 272 | 388.96 393.19 420.94 398.12 32.36 273 | 407.83 405.58 388.99 402.25 19.13 274 | 377.84 399.54 386.91 401.40 9.26 275 | 384.00 410.35 390.86 411.53 6.96 276 | 385.13 418.86 400.98 422.08 16.17 277 | 392.99 412.22 408.01 415.08 15.29 278 | 375.54 416.98 383.04 418.26 7.61 279 | 325.93 419.88 339.97 421.15 14.10 280 | 303.18 420.32 313.03 421.64 9.93 281 | 9.00 429.04 14.99 429.41 6.00 282 | 332.01 431.44 342.02 432.82 10.11 283 | 373.93 431.91 379.97 432.33 6.05 284 | 38.02 433.66 47.98 435.01 10.05 285 | 240.07 438.25 232.95 437.51 7.16 286 | 348.96 434.68 353.93 435.54 5.04 287 | 308.02 438.23 315.26 438.56 7.25 288 | 23.98 444.74 32.81 445.39 8.86 289 | 143.03 448.33 150.07 449.09 7.08 290 | 50.02 449.63 57.00 450.13 7.00 291 | 37.93 460.12 46.96 460.74 9.05 292 | 350.00 462.97 355.24 463.47 5.27 293 | 344.06 466.05 350.06 466.16 5.99 294 | 22.20 467.33 36.94 468.45 14.79 295 | 296.15 475.83 306.01 476.18 9.87 296 | 88.98 468.91 98.00 468.96 9.01 297 | 101.92 468.60 112.99 468.55 11.06 298 | 334.02 474.07 358.01 476.25 24.09 299 | 49.04 478.28 60.40 478.48 11.37 300 | 265.03 481.12 279.96 480.70 14.94 301 | 28.14 482.36 39.00 483.00 10.88 302 | 314.00 482.94 329.00 482.94 15.00 303 | 385.02 482.96 402.83 482.54 17.82 304 | 410.99 484.10 421.02 484.47 10.04 305 | 17.79 487.62 37.96 486.85 20.18 306 | 22.00 495.14 34.98 495.39 12.98 307 | 47.99 485.85 55.00 485.73 7.02 308 | 219.61 493.52 208.03 493.31 11.58 309 | 79.03 488.40 88.03 488.01 9.01 310 | 164.99 488.05 170.01 488.02 5.02 311 | 73.00 494.64 87.97 494.74 14.96 312 | 90.07 494.63 99.01 494.51 8.95 313 | 98.00 496.48 75.02 496.52 22.98 314 | 100.04 494.40 115.00 495.01 14.97 315 | 413.86 494.36 420.99 494.87 7.14 316 | 374.98 499.11 393.96 500.13 19.01 317 | 297.00 498.96 329.95 498.71 32.95 318 | 41.89 497.78 54.06 497.30 12.18 319 | 99.00 496.57 112.96 496.57 13.96 320 | 266.02 498.24 285.80 498.06 19.77 321 | 402.02 499.67 421.01 499.89 18.99 322 | 44.25 501.44 50.92 501.35 6.67 323 | 271.08 501.89 280.97 502.08 9.90 324 | 104.00 513.16 134.94 511.46 30.99 325 | 309.99 504.15 315.94 504.11 5.96 326 | 4.03 505.94 23.05 504.84 19.05 327 | 34.00 515.15 79.03 514.62 45.03 328 | 45.00 505.89 50.94 505.69 5.94 329 | 373.01 507.17 390.00 506.35 17.00 330 | 401.99 506.58 421.00 506.92 19.02 331 | 67.99 507.77 79.02 507.42 11.04 332 | 102.98 506.82 112.01 506.62 9.03 333 | 32.00 508.26 42.01 507.91 10.02 334 | 53.00 507.83 60.99 507.82 7.99 335 | 265.94 508.19 332.11 508.39 66.18 336 | 137.16 519.65 145.99 519.45 8.83 337 | 309.00 519.33 421.00 512.47 112.21 338 | 312.11 514.48 318.07 514.62 5.97 339 | 3.98 515.15 9.81 514.88 5.84 340 | 100.00 521.26 134.00 520.76 34.01 341 | 222.99 520.94 263.02 519.35 40.05 342 | 360.00 523.04 421.00 520.05 61.08 343 | 4.00 522.31 88.00 522.40 84.00 344 | 149.05 521.64 169.00 522.29 19.96 345 | 419.99 527.93 408.07 528.67 11.94 346 | 84.93 526.58 119.79 525.31 34.88 347 | 4.00 527.88 54.01 527.09 50.01 348 | 381.01 526.47 372.93 526.57 8.09 349 | 135.00 530.93 140.00 530.96 5.00 350 | 216.96 531.40 235.02 531.32 18.06 351 | 77.99 534.16 88.00 534.01 10.02 352 | 225.01 536.69 231.00 535.93 6.03 353 | 241.11 539.12 288.99 537.40 47.91 354 | 114.00 538.27 127.02 538.42 13.02 355 | 105.99 538.77 112.00 538.62 6.02 356 | 96.96 539.76 103.03 539.63 6.07 357 | 3.92 545.61 48.00 541.97 44.23 358 | 4.01 558.25 252.02 541.54 248.58 359 | 46.00 548.71 61.00 546.88 15.11 360 | 36.00 552.05 54.01 551.24 18.03 361 | 251.00 552.50 262.00 551.86 11.02 362 | 207.01 561.74 201.00 561.94 6.01 363 | 242.03 561.17 251.00 559.97 9.05 364 | 172.05 561.19 128.95 566.68 43.44 365 | 263.00 562.49 254.00 563.91 9.12 366 | 124.04 566.23 94.99 569.61 29.24 367 | 302.95 566.48 296.03 567.60 7.01 368 | 37.98 575.52 91.03 570.66 53.28 369 | 260.02 571.69 274.02 570.55 14.04 370 | 342.96 573.58 353.01 571.57 10.24 371 | 332.00 573.17 337.01 572.56 5.04 372 | 305.03 581.65 314.01 580.08 9.12 373 | 284.04 585.32 291.02 584.08 7.09 374 | 184.05 586.19 189.96 585.65 5.93 375 | 28.08 590.54 42.00 588.07 14.14 376 | 250.87 594.44 263.99 592.41 13.27 377 | 243.05 594.23 252.05 592.31 9.20 378 | 219.98 593.85 227.00 593.00 7.07 379 | 298.10 608.32 303.97 606.85 6.05 380 | 244.04 622.14 253.93 619.79 10.16 381 | -------------------------------------------------------------------------------- /data/001_input_hole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/data/001_input_hole.png -------------------------------------------------------------------------------- /data/009_input_hole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/data/009_input_hole.png -------------------------------------------------------------------------------- /data/022_input_hole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/data/022_input_hole.png -------------------------------------------------------------------------------- /demo.py: -------------------------------------------------------------------------------- 1 | import time 2 | import cv2 3 | import os 4 | 5 | from init_opt import optA, optS 6 | from source.extract.extract_planar_structure import extract_planar_structure 7 | from source.pyramid.create_pyramid import create_pyramid 8 | from source.pyramid.planar_structure_pyramid import planar_structure_pyramid 9 | from source.synthesis.synthesis import synthesis 10 | 11 | if __name__ == "__main__": 12 | image_id = 22 13 | image_name = "%03d_input_hole.png" % image_id 14 | 15 | print('- Extract planar structures') 16 | time0 = time.time() 17 | img, mask, maskD, modelPlane, modelReg = extract_planar_structure(image_name, optA) 18 | print('Done in %6.3f seconds.\n' % (time.time() - time0)) 19 | 20 | print('- Construct image pyramid') 21 | time1 = time.time() 22 | imgPyr, maskPyr, scaleImgPyr = create_pyramid(img, maskD, optS) 23 | 24 | modelPlane, modelReg = planar_structure_pyramid(scaleImgPyr, modelPlane, modelReg) 25 | print('Done in %6.3f seconds.\n' % (time.time() - time1)) 26 | 27 | # Completion by synthesis 28 | time2 = time.time() 29 | print('- Image completion using planar structure guidance') 30 | imgPyr = synthesis(imgPyr, maskPyr, modelPlane, modelReg, optS) 31 | print('Synthesis took %6.3f seconds.\n' % (time.time() - time2)) 32 | 33 | imgSyn = imgPyr[0] 34 | cv2.imshow("Result", imgSyn) 35 | cv2.waitKey() 36 | 37 | if not os.path.exists("result"): 38 | os.makedirs("result") 39 | 40 | cv2.imwrite(os.path.join("result", str(image_id) + "_completion.png"), imgSyn * 255) -------------------------------------------------------------------------------- /init_opt.py: -------------------------------------------------------------------------------- 1 | import math 2 | import numpy as np 3 | print('- Initialize parameters') 4 | 5 | def gaussian_kernel(ksize, sigma): 6 | kernel = np.zeros((ksize[0], ksize[1]), dtype=np.float) 7 | halfsizeX = ksize[0] // 2 8 | halfsizeY = ksize[1] // 2 9 | 10 | sigma2 = 2 * sigma * sigma 11 | n_halfsizeX = halfsizeX 12 | n_halfsizeY = halfsizeY 13 | 14 | half_one_x = 0 15 | half_one_y = 0 16 | if ksize[0] % 2 == 0: 17 | n_halfsizeX -= 1 18 | half_one_x = 0.5 19 | if ksize[1] % 2 == 0: 20 | n_halfsizeY -= 1 21 | half_one_y = 0.5 22 | for i in range(n_halfsizeX + 1): 23 | for j in range(n_halfsizeY + 1): 24 | value = math.exp(-((i + half_one_x) ** 2 + (j + half_one_y) ** 2) / sigma2) 25 | kernel[halfsizeX + i][halfsizeY + j] = value 26 | kernel[halfsizeX + i][n_halfsizeY - j] = value 27 | kernel[n_halfsizeX - i][halfsizeY + j] = value 28 | kernel[n_halfsizeX - i][n_halfsizeY - j] = value 29 | kernel = kernel / kernel.sum() 30 | 31 | return kernel 32 | 33 | optA = type('opt_A', (), {}) 34 | optS = type('opt_A', (), {}) 35 | 36 | # Synthesis: guided completion 37 | # ========================================================================= 38 | # Patch size 39 | # ========================================================================= 40 | optS.pSize = 9 # Patch size (odd number), use larger patch for more coherent region 41 | optS.pRad = math.floor(optS.pSize / 2) # Patch radius 42 | optS.pNumPix = optS.pSize * optS.pSize # Number of pixels in a patch 43 | optS.pMidPix = round(optS.pNumPix / 2) # The center of the patch 44 | 45 | # ========================================================================= 46 | # Multi-resolution parameters 47 | # ========================================================================= 48 | optS.numPyrLvl = 10 # Number of coarse to fine layer 49 | optS.coarestImgSize = 32 # The size of the smallest image in the pyramid 50 | optS.useLogScale = 1 # Use log scales or linear scales for downsampling 51 | 52 | # Weighting parameters for patch match, larger weight put more emphasis on 53 | # pixels near to known pixels 54 | optS.wDist = 2 ** np.linspace(1, 0.0, optS.numPyrLvl) 55 | 56 | # Patch weighting kernel 57 | h = gaussian_kernel([optS.pSize, optS.pSize], optS.pRad) 58 | h = h.reshape(-1) / np.sum(h) 59 | optS.wPatch = h 60 | 61 | # ========================================================================= 62 | # Parameters for domain transformation and photometric compensation 63 | # ========================================================================= 64 | # This scale range is used to reject unlikely patch transformation 65 | optS.minScale = 0.75 # Mininum patch scale variation 66 | optS.maxScale = 1.25 # Maximum patch scale variation 67 | 68 | # Parameters for photometric compensation 69 | optS.minBias = -0.05 # Mininum bias compensation 70 | optS.maxBias = 0.05 # Maximum bias compensation 71 | 72 | # ========================================================================= 73 | # Coarse-to-fine iterations 74 | # ========================================================================= 75 | # Number of iterations per level 76 | optS.numIter = 10 # The initial iteration number, large hole might require 77 | # more iterations 78 | optS.numIterDec = optS.numIter / optS.numPyrLvl # Number of decrements 79 | optS.numIterMin = 3 # Minimum number of iterations 80 | optS.numPassPerIter = 1 81 | 82 | # ========================================================================= 83 | # Weighting parameters 84 | # ========================================================================= 85 | # To-Do: adaptive parameter selection 86 | optS.lambdaCoherence = 1e-2 # Weighting parameter for coherence 87 | 88 | # Planar cost 89 | optS.lambdaPlane = 5e-2 # Weighting parameters for planar cost 90 | 91 | # Directional cost 92 | optS.lambdaDirect = 5 # Weighting parameters for directional cost 93 | optS.directThres = 0.05 # Directional cost threshold 94 | 95 | optS.lambdaProx = 0e-2 # Weighting parameters for proximity cost 96 | optS.proxThres = 0.25 97 | 98 | optS.lambdaReg = -0.02 # Weighting parameters for encouraging 99 | # regularity-guided sampling 100 | 101 | # ========================================================================= 102 | # Method configuration 103 | # ========================================================================= 104 | 105 | optS.useRegGuide = 1 106 | optS.usePlaneGuide = 1 107 | optS.useBiasCorrection = 0 108 | 109 | # === Precomputed patch position in the reference position === 110 | X, Y = np.meshgrid(np.arange(-optS.pRad, optS.pRad+1), np.arange(-optS.pRad, optS.pRad+1)) 111 | optS.refPatchPos = np.vstack([Y.reshape(-1), X.reshape(-1), np.ones(optS.pSize*optS.pSize)]).T 112 | 113 | # === Propagation directions === 114 | optS.propDir = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]]) 115 | 116 | optS.rsThres = 0.05 # Random sampling threshold for early termination 117 | optS.voteUpdateW = 1 # Smaller number for quick voting update 118 | 119 | optS.numRegSample = 5 # Number of regularity-guided sampling per iteration 120 | optS.numRandSample = 5 # Number of coarse-to-fine random sampling per iteration 121 | 122 | # [To-Do] robust norm, e.g., huber 123 | optS.costType = 'L1' # Patch appearance cost, other option: 'L2' 124 | 125 | # Analysis: extracting planar structure 126 | # === Plane parameters === 127 | # Detect up to 3 vanishing points, always include dummy VP (froto-parallel plane) 128 | optA.numVP = 4 129 | 130 | # Fixed density for frontal parallel plane [To-Do] should adapt to image size 131 | optA.fpPlaneProb = 1e-4 132 | 133 | # === Regularity parameters === 134 | # Maximum number of local features 135 | optA.numFeatMatch = 2000 136 | 137 | # Blurring operations for estimating the plane spatial support 138 | optA.filterSize = 100 139 | optA.filterSigma = 50 140 | optA.numFilterIter = 20 141 | 142 | # Add the constant to all plane posterior probabilities 143 | optA.probConst = 0.05 144 | 145 | # Parameters for feature extraction and matching 146 | optA.PeakThreshold = 0.04 147 | optA.maxNumLocalFeat = 1000 148 | optA.numQueryNN = 3 149 | optA.maxDispVec = 1000 150 | optA.minDistDispVec = 100 151 | 152 | # Parameters for the Mean-Shift clustering algorithm 153 | optA.msBandwidth = 20 154 | optA.msMinNumClusterMember = 5 155 | 156 | # Threshold for determining whether a pair of feature matches is on a plane 157 | optA.prodProbThres = 0.5 -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # StructCompletion 2 | 3 | Image Completion using Planar Structure Guidance 4 | 5 | This is a python re-implementation(translation of the matlab code) of the paper. 6 | 7 | > Jia-Bin Huang, Sing Bing Kang, Narendra Ahuja, and Johannes Kopf, Image Completion using Planar Structure Guidance, ACM Transactions on Graphics (Proceedings of SIGGRAPH 2014), 33(4), 2014 8 | 9 | # Requirments 10 | 11 | opencv3.2 with contrib(https://pypi.python.org/pypi/opencv-contrib-python) 12 | 13 | * it brings a bug 14 | 15 | python 3.5 16 | 17 | # Origin 18 | 19 | https://github.com/jbhuang0604/StructCompletion/issues/new -------------------------------------------------------------------------------- /result/22_completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/result/22_completion.png -------------------------------------------------------------------------------- /result/9_completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/result/9_completion.png -------------------------------------------------------------------------------- /source/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/__init__.py -------------------------------------------------------------------------------- /source/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /source/extract/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/__init__.py -------------------------------------------------------------------------------- /source/extract/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /source/extract/__pycache__/extract_planar_structure.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/__pycache__/extract_planar_structure.cpython-35.pyc -------------------------------------------------------------------------------- /source/extract/__pycache__/extract_plane.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/__pycache__/extract_plane.cpython-35.pyc -------------------------------------------------------------------------------- /source/extract/__pycache__/extract_regularity.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/__pycache__/extract_regularity.cpython-35.pyc -------------------------------------------------------------------------------- /source/extract/extract_planar_structure.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | 6 | from .extract_regularity import extract_regularity 7 | from .extract_plane import extract_plane 8 | 9 | def extract_planar_structure(image_name, option): 10 | ''' 11 | :param image_name: 12 | :param option: 13 | :return: 14 | img: Original image 15 | mask: Hole mask 16 | modelPlane: Plane model 17 | modelReg: Regularity model 18 | ''' 19 | img = cv2.imread(os.path.join('data', image_name), cv2.IMREAD_UNCHANGED) 20 | #cv2.imshow("origin", img) 21 | #cv2.waitKey() 22 | assert(img.shape[-1] == 4) 23 | 24 | alpha = img[..., -1] 25 | mask = (alpha != 255).astype(np.uint8) 26 | 27 | image = img[..., :3].astype(np.double).copy() / 255 28 | 29 | mask = cv2.dilate(mask, np.ones((5, 5))) 30 | 31 | maskD = cv2.dilate(mask, cv2.getStructuringElement(cv2.MORPH_CROSS, (3, 3))) 32 | 33 | # Extract planar constructural constraints 34 | modelPlane = extract_plane(image_name, image, maskD, option) 35 | 36 | # Extract regularity constraints 37 | modelReg = extract_regularity(image, maskD, modelPlane, option) 38 | 39 | return image, mask.astype(np.double), maskD.astype(np.double), modelPlane, modelReg 40 | 41 | 42 | -------------------------------------------------------------------------------- /source/extract/extract_plane.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | from scipy import ndimage 6 | 7 | class vp(): 8 | def __init__(self, pos, score, numLines): 9 | self.pos = pos 10 | self.score = score 11 | self.numLines = numLines 12 | self.lines = None 13 | 14 | class VP_imgLines(): 15 | def __init__(self, imgLines, imgLinesPosMap): 16 | self.imgLines = imgLines 17 | self.imgLinesPosMap = imgLinesPosMap 18 | 19 | class Plane(): 20 | def __init__(self, vline, imgPlaneProb, sourceVP): 21 | self.vline = vline 22 | 23 | self.imgPlaneProb = imgPlaneProb 24 | self.score = imgPlaneProb.sum() 25 | self.sourceVP = sourceVP 26 | self.rotPar = [0, 0] 27 | 28 | self.dispVec = None 29 | self.numDispVec = None 30 | 31 | def vLineFromTwoVP(vp1, vp2): 32 | A = np.vstack([vp1, vp2]) 33 | u, s, v = np.linalg.svd(A) 34 | 35 | vLine = v.T[:, -1] 36 | vLine /= vLine[2] 37 | return vLine 38 | 39 | def gaussian_kernel(ksize, sigma): 40 | kernel = np.zeros((ksize[0], ksize[1]), dtype=np.float) 41 | halfsizeX = ksize[0] // 2 42 | halfsizeY = ksize[1] // 2 43 | 44 | sigma2 = 2 * sigma * sigma 45 | n_halfsizeX = halfsizeX 46 | n_halfsizeY = halfsizeY 47 | 48 | half_one_x = 0 49 | half_one_y = 0 50 | if ksize[0] % 2 == 0: 51 | n_halfsizeX -= 1 52 | half_one_x = 0.5 53 | if ksize[1] % 2 == 0: 54 | n_halfsizeY -= 1 55 | half_one_y = 0.5 56 | for i in range(n_halfsizeX + 1): 57 | for j in range(n_halfsizeY + 1): 58 | value = math.exp(-((i + half_one_x) ** 2 + (j + half_one_y) ** 2) / sigma2) 59 | kernel[halfsizeX + i][halfsizeY + j] = value 60 | kernel[halfsizeX + i][n_halfsizeY - j] = value 61 | kernel[n_halfsizeX - i][halfsizeY + j] = value 62 | kernel[n_halfsizeX - i][n_halfsizeY - j] = value 63 | kernel = kernel / kernel.sum() 64 | 65 | return kernel 66 | 67 | def detect_plane_from_vp(vpData, img, mask, option): 68 | ''' 69 | 70 | :param vpData: 71 | :param img: 72 | :param mask: 73 | :param option: 74 | :return: 75 | ''' 76 | assert (img.shape[-1] == 3) 77 | height, width, channel = img.shape 78 | HfilterX = gaussian_kernel([1, option.filterSize], option.filterSigma) 79 | HfilterY = HfilterX.T 80 | 81 | modelPlane = type("modelPlane", (), {"vp": []}) 82 | 83 | # first estimate the spatial support of each VP by diffusing 84 | # its corresponding line segments using a wide Gaussian kernel 85 | for i in range(vpData.numVP): 86 | imgLines = np.zeros((height, width)) 87 | for line in vpData.vp[i].lines: 88 | cv2.line(imgLines, (int(line[0]), int(line[1])), (int(line[2]), int(line[3])), 255, 1) 89 | 90 | #cv2.imshow("tmp", imgLines) 91 | #cv2.waitKey() 92 | imgLines = imgLines.astype(np.double) / 255 93 | imgLinesPosMap = imgLines.copy() 94 | 95 | for k in range(option.numFilterIter): 96 | imgLinesPosMap = cv2.filter2D(imgLinesPosMap, -1, HfilterX, borderType=cv2.BORDER_REPLICATE) 97 | 98 | for k in range(option.numFilterIter): 99 | imgLinesPosMap = cv2.filter2D(imgLinesPosMap, -1, HfilterY, borderType=cv2.BORDER_REPLICATE) 100 | 101 | # Save results 102 | modelPlane.vp.append(VP_imgLines(imgLines, imgLinesPosMap)) 103 | 104 | # Estimate plane support and plane parameters 105 | numPlane = vpData.numVP * (vpData.numVP - 1) // 2 106 | 107 | # Initialize plane data 108 | modelPlane.plane = [] 109 | 110 | # A pair of vanishing points forms a plane hypothesis 111 | for i in range(vpData.numVP - 1): 112 | for j in range(i + 1, vpData.numVP): 113 | modelPlane.plane.append(Plane(vLineFromTwoVP(vpData.vp[i].pos, vpData.vp[j].pos), 114 | modelPlane.vp[i].imgLinesPosMap * modelPlane.vp[j].imgLinesPosMap, 115 | [i, j])) 116 | 117 | 118 | for i in range(numPlane): 119 | for vpInd in [0, 1]: 120 | linesCurr = np.array(vpData.vp[modelPlane.plane[i].sourceVP[vpInd]].lines) 121 | 122 | invalidLieInd = linesCurr[:, 4] == 0 # 长度不是0的线段 123 | 124 | linesCurr = linesCurr[invalidLieInd == 0, :] 125 | numLines = linesCurr.shape[0] 126 | 127 | vLineCurr = modelPlane.plane[i].vline 128 | 129 | # Rectified homography 130 | H = np.eye(3) # 平移变换 131 | H[2, :] = vLineCurr 132 | 133 | 134 | linesStart = np.hstack([linesCurr[:, :2], np.ones((numLines, 1))]).T 135 | linesEnd = np.hstack([linesCurr[:, 2:4], np.ones((numLines, 1))]).T 136 | 137 | linesStartRect = H.dot(linesStart) 138 | linesStartRect = linesStartRect / np.vstack([linesStartRect[2, :], 139 | linesStartRect[2, :], 140 | linesStartRect[2, :]]) 141 | 142 | linesEndRect = H.dot(linesEnd) 143 | linesEndRect = linesEndRect / np.vstack([linesEndRect[2, :], 144 | linesEndRect[2, :], 145 | linesEndRect[2, :]]) 146 | 147 | linesVec = linesStartRect[:2, :] - linesEndRect[:2, :] 148 | linesSign = linesEndRect[1, :] > linesStartRect[1, :] 149 | linesSign = 2 * linesSign - 1 150 | 151 | linesLength = np.sqrt(np.sum(linesVec ** 2, axis=0)) 152 | linesCos = linesSign * linesVec[0, :] / linesLength 153 | 154 | theta = np.arccos(linesCos) 155 | thetaAvg = np.mean(theta) 156 | 157 | for iter in range(5): 158 | thetadiff = theta - thetaAvg 159 | indLargeTheat = thetadiff > math.pi / 2 160 | theta[indLargeTheat] = math.pi - theta[indLargeTheat] 161 | 162 | indSmallTheta = thetadiff < -math.pi / 2 163 | theta[indSmallTheta] = math.pi + theta[indSmallTheta] 164 | thetaAvg = np.mean(theta) 165 | 166 | modelPlane.plane[i].rotPar[vpInd] = thetaAvg 167 | 168 | # add ad fronto-parallel plane 169 | modelPlane.plane.append(Plane(np.array([0, 0, 1]), option.fpPlaneProb*np.ones((height, width)), 0)) 170 | numPlane += 1 171 | modelPlane.numPlane = numPlane 172 | 173 | # compute posterior prob 174 | planeProb = np.zeros((height, width, numPlane)) 175 | for i in range(numPlane): 176 | planeProb[:, :, i] = modelPlane.plane[i].imgPlaneProb 177 | 178 | planeProbSum = np.sum(planeProb, axis=2) 179 | planeProb = planeProb / planeProbSum[..., None] 180 | modelPlane.postProbHole = planeProb 181 | 182 | edt, inds = ndimage.distance_transform_edt(1-(mask == 0), return_indices=True) 183 | 184 | maskInt = mask.copy() 185 | maskInt[0, :] = 0 186 | maskInt[-1, :] = 0 187 | maskInt[:, 0] = 0 188 | maskInt[:, -1] = 0 189 | 190 | # propagate posterior prob into the hole region 191 | for i in range(numPlane): 192 | planeProbCh = planeProb[:, :, i] 193 | planeProb[:, :, i] = planeProbCh[inds[0, :, :], inds[1, :, :]].copy() 194 | #cv2.imshow("postProb", planeProb[:, :, i]) 195 | #cv2.waitKey() 196 | 197 | 198 | planeProbSum = np.sum(planeProb, axis=2) 199 | planeProb = planeProb / planeProbSum[..., None] 200 | 201 | planeProbSum = 1 + numPlane*option.probConst 202 | planeProb = (planeProb + option.probConst) / planeProbSum 203 | 204 | modelPlane.postProb = planeProb.copy() 205 | #print(modelPlane.postProb.shape) 206 | #cv2.imshow("postProb", modelPlane.postProb) 207 | #cv2.waitKey() 208 | return modelPlane 209 | 210 | def read_vpdata(fileName): 211 | ''' 212 | 213 | :param fileName: vp filename 214 | :return: VP: VPdata 215 | ''' 216 | VP = type("VPData", (), {"numVP": 0, "vp": []}) 217 | with open(fileName, 'r') as f: 218 | f.readline() 219 | while True: 220 | temp = f.readline() 221 | if temp == "\n": 222 | f.readline() 223 | break 224 | numbers = temp.split() 225 | record = list(map(float, numbers)) 226 | VP.vp.append(vp(np.array(record[:3]), record[3], int(record[4]))) 227 | VP.numVP += 1 228 | 229 | allLines = f.readlines() 230 | nowLine = 0 231 | for i in range(VP.numVP): 232 | numLines = VP.vp[i].numLines 233 | assert (int(allLines[nowLine]) == numLines) 234 | 235 | def clean(line): 236 | numbers = line.split() 237 | record = list(map(float, numbers)) 238 | return record 239 | 240 | VP.vp[i].lines = list(map(clean, allLines[nowLine + 1:nowLine + numLines + 1])) 241 | assert (len(VP.vp[i].lines) == numLines) 242 | nowLine += numLines + 1 243 | 244 | return VP 245 | 246 | def extract_plane(image_name, img, mask, option): 247 | ''' 248 | extract plane model from an image 249 | 250 | :param image_name: 251 | :param img: 252 | :param maskD: 253 | :param option: 254 | :return: modelPlane 255 | ''' 256 | # VP detection 257 | vpFilePath = 'cache/vpdetection' 258 | vpFileName = image_name[:-4] + '-vanishingpoints.txt' 259 | 260 | if not os.path.exists(os.path.join(vpFilePath, 'text', vpFileName)): 261 | vpDetectCMD = 'vpdetection.exe -indir data -infile ' + image_name + ' -outdir ' + vpFilePath 262 | print("Using CMD: ", vpDetectCMD) 263 | os.system(vpDetectCMD) 264 | 265 | # 获得三个消失点和对应的线段 266 | vpData = read_vpdata(os.path.join(vpFilePath, 'text', vpFileName)) 267 | 268 | modelPlane = detect_plane_from_vp(vpData, img, mask, option) 269 | 270 | return modelPlane -------------------------------------------------------------------------------- /source/extract/extract_regularity.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | from sklearn.cluster import MeanShift 6 | import matplotlib.pyplot as plt 7 | 8 | def extract_regularity(img, maskD, modelPlane, option): 9 | ''' 10 | 11 | :param img: 12 | :param maskD: 13 | :param modelPlane: 14 | :param option: 15 | :return: 16 | ''' 17 | img = img.astype(np.float32) 18 | imgGray = (cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) * 255).astype(np.uint8) 19 | 20 | H, W = imgGray.shape 21 | 22 | option.PeakThreshold = 0.12 23 | sift = cv2.xfeatures2d.SIFT_create(contrastThreshold=option.PeakThreshold) 24 | 25 | kp, des = sift.detectAndCompute(imgGray, None) 26 | 27 | if len(kp) > option.maxNumLocalFeat: 28 | index = np.random.permutation(len(kp))[:option.maxNumLocalFeat] 29 | kp_temp = [] 30 | des_temp = [] 31 | for ind in index: 32 | kp_temp.append(kp[ind]) 33 | des_temp.append(des[ind]) 34 | kp = kp_temp 35 | des = des_temp 36 | 37 | FLANN_INDEX_KDTREE = 0 38 | index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5) 39 | search_params = dict(checks=50) # or pass empty dictionary 40 | flann = cv2.FlannBasedMatcher(index_params, search_params) 41 | matches = flann.knnMatch(des, des, k=option.numQueryNN) 42 | 43 | draw_params = dict(matchColor=(0, 255, 0), 44 | singlePointColor=(255, 0, 0), 45 | flags=0) 46 | 47 | #img3 = cv2.drawMatchesKnn(img, kp, img, kp, matches, None, **draw_params) 48 | 49 | #cv2.imshow("tmp", img3) 50 | #cv2.waitKey() 51 | 52 | index = np.zeros((option.numQueryNN, len(kp)), dtype=np.int) 53 | distance = np.zeros((option.numQueryNN, len(kp))) 54 | keypoints = np.zeros((len(kp), 2)) 55 | for i in range(len(kp)): 56 | keypoints[i] = [kp[i].pt[0], kp[i].pt[1]] 57 | for j in range(option.numQueryNN): 58 | index[j, i] = matches[i][j].trainIdx 59 | distance[j, i] = matches[i][j].distance 60 | 61 | featMatchData = type("featMatchData", (), {}) 62 | featMatchData.index = index 63 | featMatchData.distance = distance 64 | featMatchData.K = option.numQueryNN 65 | featMatchData.frames = keypoints.T 66 | featMatchData.numFeat = len(kp) 67 | 68 | for indPlane in range(modelPlane.numPlane): 69 | H = np.eye(3) 70 | H[2, :] = modelPlane.plane[indPlane].vline 71 | 72 | framesRect = np.vstack([featMatchData.frames[:2, :], np.ones((1, featMatchData.numFeat))]) 73 | framesRect = H.dot(framesRect) 74 | framesRect = framesRect / framesRect[2, :] 75 | 76 | nn = featMatchData.index[:featMatchData.K+1, :] 77 | 78 | # 充分利用match信息 79 | targetPosRect = np.hstack([framesRect[:2, nn[0, :]], framesRect[:2, nn[0, :]], framesRect[:2, nn[1, :]]]) 80 | sourcePosRect = np.hstack([framesRect[:2, nn[1, :]], framesRect[:2, nn[2, :]], framesRect[:2, nn[2, :]]]) 81 | 82 | targetPos = np.hstack([featMatchData.frames[:2, nn[0, :]], 83 | featMatchData.frames[:2, nn[0, :]], 84 | featMatchData.frames[:2, nn[1, :]]]) 85 | sourcePos = np.hstack([featMatchData.frames[:2, nn[1, :]], 86 | featMatchData.frames[:2, nn[2, :]], 87 | featMatchData.frames[:2, nn[2, :]]]) 88 | 89 | targetPos = np.round(targetPos).astype(np.int) 90 | sourcePos = np.round(sourcePos).astype(np.int) 91 | 92 | # compute matching weights 93 | 94 | planeProb = modelPlane.postProb[:, :, indPlane] 95 | weightVec = planeProb[targetPos[1, :], targetPos[0, :]] * planeProb[sourcePos[1, :], sourcePos[0, :]] 96 | 97 | # get the matched features on the plane 98 | validMatchInd = weightVec >= option.prodProbThres 99 | 100 | sourcePosRect = sourcePosRect[:, validMatchInd] 101 | targetPosRect = targetPosRect[:, validMatchInd] 102 | 103 | # compute the displacement vectors in the rectified space 104 | dispVecRect = sourcePosRect - targetPosRect 105 | distDispVecRect = np.sum(dispVecRect ** 2, axis=0) 106 | 107 | validDispVecInd = distDispVecRect > option.minDistDispVec 108 | dispVecRect = dispVecRect[:, validDispVecInd] 109 | 110 | dispVecRect = np.hstack([dispVecRect, -dispVecRect]) 111 | dispVecRect = np.hstack([dispVecRect, 2 * dispVecRect]) 112 | 113 | validDispVecInd = (np.abs(dispVecRect[0, :]) < 1000) & (np.abs(dispVecRect[1, :]) < 1000) 114 | dispVecRect = dispVecRect[:, validDispVecInd] 115 | #print(dispVecRect.shape) 116 | #plt.scatter(dispVecRect[0, :], dispVecRect[1, :]) 117 | #plt.show() 118 | #cv2.waitKey() 119 | if dispVecRect.shape[1] != 0: 120 | clf = MeanShift(bandwidth=option.msBandwidth) 121 | clf.fit(dispVecRect.T) 122 | 123 | clustCent = clf.cluster_centers_ 124 | 125 | numMemberInCluster = np.zeros((clustCent.shape[0])) 126 | for clusterInd in range(numMemberInCluster.shape[0]): 127 | numMemberInCluster[clusterInd] = (clf.labels_ == clusterInd).sum() 128 | 129 | validClusterInd = numMemberInCluster >= option.msMinNumClusterMember 130 | 131 | clustCent = clustCent[validClusterInd, :] 132 | modelPlane.plane[indPlane].dispVec = clustCent.T # (numDim, numClust) 133 | modelPlane.plane[indPlane].numDispVec = clustCent.shape[0] 134 | 135 | else: 136 | modelPlane.plane[indPlane].dispVec = np.array([]) 137 | modelPlane.plane[indPlane].numDispVec = 0 138 | 139 | return modelPlane 140 | -------------------------------------------------------------------------------- /source/extract/util.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/extract/util.py -------------------------------------------------------------------------------- /source/pyramid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/pyramid/__init__.py -------------------------------------------------------------------------------- /source/pyramid/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/pyramid/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /source/pyramid/__pycache__/create_pyramid.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/pyramid/__pycache__/create_pyramid.cpython-35.pyc -------------------------------------------------------------------------------- /source/pyramid/__pycache__/planar_structure_pyramid.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/pyramid/__pycache__/planar_structure_pyramid.cpython-35.pyc -------------------------------------------------------------------------------- /source/pyramid/create_pyramid.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | from scipy import ndimage 6 | 7 | def init_coarsest_level(img, mask): 8 | 9 | _, idMap = ndimage.distance_transform_edt(1 - (mask == 0), return_indices=True) 10 | maskInt = mask.copy().astype(np.uint8) 11 | maskInt[0, :] = 0 12 | maskInt[-1, :] = 0 13 | maskInt[:, 0] = 0 14 | maskInt[:, -1] = 0 15 | 16 | for ch in range(3): 17 | imgCh = img[:, :, ch] 18 | imgCh = imgCh[idMap[0, :, :], idMap[1, :, :]] 19 | img[:, :, ch] = imgCh 20 | #cv2.imshow("tmp", img) 21 | #cv2.waitKey() 22 | # TODO: roifill 23 | #temp = cv2.blur(img, (3, 3)) 24 | 25 | #img[maskInt == 1] = temp[maskInt == 1] 26 | #img = cv2.inpaint((img* 255).astype(np.uint8), maskInt, 3, cv2.INPAINT_TELEA) 27 | 28 | return img 29 | 30 | def create_scale_pyramid(h, w, option): 31 | min_size = min(h, w) 32 | coarestScale = option.coarestImgSize / min_size 33 | 34 | scalePyr = None 35 | if option.useLogScale: 36 | scalePyr = 2 ** np.linspace(0, np.log2(coarestScale), option.numPyrLvl) 37 | 38 | imgHpyr = np.round(h * scalePyr) 39 | imgWpyr = np.round(w * scalePyr) 40 | 41 | scaleImgPyr = [] 42 | scaleImgPyr.append([1, [h, w]]) # imgscale, imgsize[h, w] 43 | for k in range(1, option.numPyrLvl): 44 | scaleImgPyr.append([scalePyr[k], [int(imgHpyr[k]), int(imgWpyr[k])]]) 45 | 46 | return scaleImgPyr 47 | 48 | def create_image_pyramid(img, scaleImgPyr, imageType, option): 49 | imgPyr = [img] 50 | for ilvl in range(1, option.numPyrLvl): 51 | imgHcurlvl = scaleImgPyr[ilvl][1][0] 52 | imgWcurlvl = scaleImgPyr[ilvl][1][1] 53 | 54 | imgCur = imgPyr[ilvl - 1] 55 | 56 | imgPyr.append(cv2.resize(imgCur, (imgWcurlvl, imgHcurlvl), interpolation=cv2.INTER_CUBIC)) 57 | #cv2.imshow("tmp", imgPyr[ilvl]) 58 | #cv2.waitKey() 59 | 60 | if imageType == "mask": 61 | for ilvl in range(1, option.numPyrLvl): 62 | imgPyr[ilvl] = (imgPyr[ilvl] > 0.5).astype(np.float32) 63 | 64 | return imgPyr 65 | 66 | def create_pyramid(img, mask, option): 67 | img_copy = img.copy() 68 | H, W, ch = img.shape 69 | 70 | img = init_coarsest_level(img_copy, mask) 71 | 72 | scaleImgPyr = create_scale_pyramid(H, W, option) 73 | 74 | maskPyr = create_image_pyramid(mask, scaleImgPyr, 'mask', option) 75 | imgPyr = create_image_pyramid(img, scaleImgPyr, 'image', option) 76 | 77 | imgPyr[-1] = init_coarsest_level(imgPyr[-1], maskPyr[-1]) 78 | 79 | return imgPyr, maskPyr, scaleImgPyr -------------------------------------------------------------------------------- /source/pyramid/planar_structure_pyramid.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | 6 | def planar_structure_pyramid(scaleImgPyr, modelPlane, modelReg): 7 | numLevel = len(scaleImgPyr) 8 | 9 | modelPlanePyr = [] 10 | modelRegPyr = [] 11 | 12 | planePostProb = modelPlane.postProb 13 | 14 | for ilvl in range(numLevel): 15 | scaleImgCur = scaleImgPyr[ilvl][0] 16 | 17 | sizeImgCur = scaleImgPyr[ilvl][1] 18 | 19 | planePostProbCur = cv2.resize(planePostProb, (sizeImgCur[1], sizeImgCur[0]), interpolation=cv2.INTER_CUBIC) 20 | planePostProbCursum = np.sum(planePostProbCur, axis=2) 21 | planePostProbCur = planePostProbCur / planePostProbCursum[..., None] 22 | 23 | singlePlanePyr = type('PlanePyr', (), {}) 24 | singlePlanePyr.numPlane = modelPlane.numPlane 25 | singlePlanePyr.planeProb = planePostProbCur 26 | singlePlanePyr.mLogPlaneProb = -np.log(planePostProbCur) 27 | singlePlanePyr.rectMat = [] 28 | singlePlanePyr.rotPar = [] 29 | singlePlanePyr.rotMat = [] 30 | modelPlanePyr.append(singlePlanePyr) # numPlane, planePostProbCur, -log(planePostProbCur) 31 | 32 | for iplane in range(modelPlane.numPlane): 33 | H = np.eye(3) 34 | vline = modelPlane.plane[iplane].vline.copy() 35 | 36 | vline[:1] = vline[:1] / scaleImgCur 37 | H[2, :] = vline 38 | 39 | modelPlanePyr[ilvl].rectMat.append(H) 40 | modelPlanePyr[ilvl].rotPar.append(modelPlane.plane[iplane].rotPar) 41 | modelPlanePyr[ilvl].rotMat.append([]) 42 | 43 | for itheta in range(2): 44 | t = modelPlanePyr[ilvl].rotPar[iplane][itheta] 45 | Hr = np.eye(3) 46 | Hr[0, 0] = np.cos(t) 47 | Hr[0, 1] = -np.sin(t) 48 | Hr[1, 0] = np.sin(t) 49 | Hr[1, 1] = np.cos(t) 50 | 51 | modelPlanePyr[ilvl].rotMat[iplane].append(Hr) 52 | 53 | singleRegPyr = type('RegPyr', (), {}) 54 | dispVec = [] 55 | numDispVec = [] 56 | 57 | for iplane in range(modelPlane.numPlane): 58 | dispVec.append(scaleImgCur * modelReg.plane[iplane].dispVec) 59 | numDispVec.append(modelReg.plane[iplane].numDispVec) 60 | 61 | singleRegPyr.dispVec = dispVec 62 | singleRegPyr.numDispVec = numDispVec 63 | modelRegPyr.append(singleRegPyr) 64 | 65 | return modelPlanePyr, modelRegPyr -------------------------------------------------------------------------------- /source/synthesis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/synthesis/__init__.py -------------------------------------------------------------------------------- /source/synthesis/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/synthesis/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /source/synthesis/__pycache__/synthesis.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/source/synthesis/__pycache__/synthesis.cpython-35.pyc -------------------------------------------------------------------------------- /source/synthesis/check_valid_uv.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def check_valid_uv(srcPos, validSrcMask): 4 | srcPos_in = np.round(srcPos) 5 | numUvPix = srcPos.shape[0] 6 | 7 | uvValidInd = np.zeros((numUvPix, 1)) 8 | 9 | validSrcInd = (srcPos_in[:, 0] >= 0) & (srcPos_in[:, 0] < validSrcMask.shape[1]) \ 10 | & (srcPos_in[:, 1] >= 0) & (srcPos_in[:, 1] < validSrcMask.shape[0]) 11 | 12 | uvValidInd[validSrcInd] = validSrcMask[srcPos_in[validSrcInd, 1:2].astype(np.int), srcPos_in[validSrcInd, 0:1].astype(np.int)] 13 | return uvValidInd -------------------------------------------------------------------------------- /source/synthesis/clamp.py: -------------------------------------------------------------------------------- 1 | 2 | def clamp(v, low, high): 3 | v[v < low] = low 4 | v[v > high] = high 5 | return v -------------------------------------------------------------------------------- /source/synthesis/draw_plane_id.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def draw_plane_id(planeProbAccData): 4 | numUvPix = planeProbAccData.shape[0] 5 | numPlane = planeProbAccData.shape[1] - 1 6 | 7 | randSample = np.random.rand(numUvPix) 8 | uvPlaneIDData = np.zeros((numUvPix, 1), dtype=np.uint8) 9 | 10 | for indPlane in range(numPlane): 11 | 12 | indSamplePlane = (planeProbAccData[:, indPlane] < randSample) & \ 13 | (planeProbAccData[:, indPlane+1] >= randSample) 14 | 15 | uvPlaneIDData[indSamplePlane == 1] = indPlane 16 | 17 | return uvPlaneIDData 18 | -------------------------------------------------------------------------------- /source/synthesis/init_lvl_nnf.py: -------------------------------------------------------------------------------- 1 | from .prep_source_patch import prep_source_patch 2 | from .prep_target_patch import prep_target_patch 3 | from .patch_cost import patch_cost 4 | from .voting import voting 5 | from .src_domain_tform import src_domain_tform 6 | from .update_uvMap import update_uvMap 7 | from .prep_dist_patch import prep_dist_patch 8 | from .clamp import clamp 9 | from .uvMat_from_uvMap import uvMat_from_uvMap 10 | from .check_valid_uv import check_valid_uv 11 | from .trans_tform import trans_tform 12 | 13 | import numpy as np 14 | import cv2 15 | from scipy import ndimage 16 | 17 | def imshow(img): 18 | cv2.imshow("tmp", img) 19 | cv2.waitKey() 20 | 21 | def getTargPathInd(NNF, option): 22 | pixIndMap = np.arange(NNF.imgH*NNF.imgW).reshape((NNF.imgW, NNF.imgH)).T[..., None].astype(np.float32) 23 | indTrgPatch = prep_target_patch(pixIndMap, NNF.uvPix.sub, option) 24 | trgPatchInd = indTrgPatch.squeeze() 25 | 26 | trgPatchInd = np.vstack([trgPatchInd, trgPatchInd+NNF.imgH*NNF.imgW, trgPatchInd+2*NNF.imgH*NNF.imgW]) 27 | 28 | return trgPatchInd 29 | 30 | def getUvPix(uvMap): 31 | uvPix = type("uvPix", (), {}) 32 | 33 | uvPix.sub = np.array(np.where(uvMap.T)).T # col, row 34 | uvPix.mask = uvMap.copy() 35 | uvPix.ind = np.ravel_multi_index([uvPix.sub[:, 1], uvPix.sub[:, 0]], uvMap.shape, order='F') 36 | uvPix.numPix = uvPix.ind.shape[0] 37 | return uvPix 38 | 39 | def getUvPixN(NNF, option): 40 | uvPixN = [] 41 | for i in range(4): 42 | singleUvPixN = type("singleUvPixN", (), {}) 43 | singleUvPixN.sub = NNF.uvPix.sub - option.propDir[i, :][None, ...] # N * 2 44 | singleUvPixN.ind = np.ravel_multi_index([singleUvPixN.sub[:, 1], singleUvPixN.sub[:, 0]], 45 | [NNF.imgH, NNF.imgW], order='F') 46 | 47 | singleUvPixN.validInd = NNF.uvPix.mask[singleUvPixN.sub[:, 1], singleUvPixN.sub[:, 0]] 48 | 49 | uvPixN.append(singleUvPixN) 50 | 51 | return uvPixN 52 | 53 | def prep_plane_prob_acc(planeProb, NNF): 54 | numPlane = planeProb.shape[2] 55 | numUvPix = NNF.uvPix.ind.shape[0] 56 | 57 | planeProbAcc = np.zeros((numUvPix, numPlane+1), dtype=np.float32) 58 | for i in range(numPlane): 59 | planeProbCur = planeProb[:, :, i].copy() 60 | planeProbAcc[:, i+1] = planeProbCur[np.unravel_index(NNF.uvPix.ind, (NNF.imgH, NNF.imgW), order="F")] 61 | if i != 0: 62 | planeProbAcc[:, i+1] += planeProbAcc[:, i] 63 | 64 | return planeProbAcc 65 | 66 | def init_level(mask, psize, prad): 67 | uvMask = cv2.dilate(mask, np.ones((psize, psize))) 68 | 69 | uvMask[:prad, :] = 0 70 | uvMask[-prad:, :] = 0 71 | uvMask[:, :prad] = 0 72 | uvMask[:, -prad:] = 0 73 | 74 | uvPix = getUvPix(uvMask) 75 | 76 | validMap = (1 - uvMask) 77 | validMap[:prad, :] = 0 78 | validMap[-prad:, :] = 0 79 | validMap[:, :prad] = 0 80 | validMap[:, -prad:] = 0 81 | 82 | validPix = getUvPix(validMap) 83 | 84 | return validPix, uvPix 85 | 86 | def init_nnf(holeMask, modelPlane, modelReg, option): 87 | NNF = type("nnf", (), {}) 88 | NNF.imgH, NNF.imgW = holeMask.shape 89 | NNF.validPix, NNF.uvPix = init_level(holeMask, option.pSize, option.pRad) 90 | 91 | NNF.uvPixN = getUvPixN(NNF, option) 92 | 93 | NNF.trgPatchInd = getTargPathInd(NNF, option) 94 | 95 | uvPlaneIDData = (modelPlane.numPlane - 1) * np.ones((NNF.uvPix.numPix), np.uint8) 96 | 97 | NNF.uvPlaneID = type("uvPId", (), {}) 98 | NNF.uvPlaneID.data = uvPlaneIDData 99 | NNF.uvPlaneID.map = np.zeros((NNF.imgH, NNF.imgW), dtype=np.uint8) 100 | NNF.uvPlaneID.map[np.unravel_index(NNF.uvPix.ind, (NNF.imgH, NNF.imgW), order="F")] = NNF.uvPlaneID.data 101 | NNF.uvPlaneID.planeProbAcc = prep_plane_prob_acc(modelPlane.planeProb, NNF) 102 | NNF.uvPlaneID.mLogLikelihood = -np.log(NNF.uvPlaneID.planeProbAcc) 103 | 104 | # init uvTform 105 | if NNF.validPix.numPix: 106 | randInd = np.random.randint(NNF.validPix.numPix, size=(NNF.uvPix.numPix)) 107 | uvRandSub = NNF.validPix.sub[randInd, :] 108 | else: 109 | uvRandSub = (NNF.imgW / 2) * np.ones((NNF.uvPix.numPix, 2)) 110 | 111 | NNF.uvTform = type("uvTform", (), {}) 112 | NNF.uvTform.data = src_domain_tform(NNF.uvPlaneID.data, modelPlane, modelReg, uvRandSub, NNF.uvPix.sub, 1) 113 | NNF.uvTform.map = np.zeros((NNF.imgH, NNF.imgW, 9), dtype=np.float32) 114 | NNF.uvTform.map = update_uvMap(NNF.uvTform.map, NNF.uvTform.data, NNF.uvPix.ind) 115 | 116 | # init bias 117 | NNF.uvBias = type("uvBias", (), {}) 118 | NNF.uvBias.data = np.zeros((1, 3, NNF.uvPix.numPix), dtype=np.float32) 119 | NNF.uvBias.map = np.zeros((NNF.imgH, NNF.imgW, 3), dtype=np.float32) 120 | 121 | # init cost 122 | NNF.uvCost = type("uvCost", (), {}) 123 | NNF.uvCost.data = np.zeros((NNF.uvPix.numPix, 1), dtype=np.float32) 124 | NNF.uvCost.map = np.zeros((NNF.imgH, NNF.imgW), dtype=np.float32) 125 | 126 | # init distmap 127 | NNF.distMap, _ = ndimage.distance_transform_edt(1 - (holeMask == 0), return_indices=True) 128 | NNF.wPatchR, NNF.wPatchSumImg = prep_dist_patch(NNF.distMap, NNF.uvPix.sub, option) 129 | NNF.uvDtBdPixPos = NNF.distMap[np.unravel_index(NNF.uvPix.ind, (NNF.imgH, NNF.imgW), order="F")].astype(np.double).copy() 130 | 131 | return NNF 132 | 133 | def upsample(holeMask, NNF_L, modelPlane, modelReg, optS): 134 | NNF_H = type("nnf", (), {}) 135 | NNF_H.imgH, NNF_H.imgW = holeMask.shape 136 | NNF_H.validPix, NNF_H.uvPix = init_level(holeMask, optS.pSize, optS.pRad) 137 | 138 | NNF_H.uvPixN = getUvPixN(NNF_H, optS) 139 | 140 | NNF_H.trgPatchInd = getTargPathInd(NNF_H, optS) 141 | 142 | imgH_H = NNF_H.imgH 143 | imgW_H = NNF_H.imgW 144 | imgH_L = NNF_L.imgH 145 | imgW_L = NNF_L.imgW 146 | 147 | sX = imgH_L / imgH_H 148 | sY = imgW_L / imgW_H 149 | 150 | uvPixL = type("uvPixL", (), {}) 151 | 152 | uvPixL.sub = np.array(np.round(NNF_H.uvPix.sub.dot(np.diag([sX, sY])))) 153 | 154 | uvPixL.sub[:, 0] = clamp(uvPixL.sub[:, 0], optS.pRad + 1, imgW_L - optS.pRad) 155 | uvPixL.sub[:, 1] = clamp(uvPixL.sub[:, 1], optS.pRad + 1, imgH_L - optS.pRad) 156 | uvPixL.sub = uvPixL.sub.astype(np.uint) 157 | uvPixL.ind = np.ravel_multi_index([uvPixL.sub[:, 1], uvPixL.sub[:, 0]], 158 | [imgH_L, imgW_L], order='F') 159 | 160 | NNF_H.uvPlaneID = type("uvPlaneID", (), {}) 161 | NNF_H.uvPlaneID.data = uvMat_from_uvMap(NNF_L.uvPlaneID.map, uvPixL.ind) 162 | #print("uvPlaneId: ", np.sum(NNF_H.uvPlaneID.data == 0)) 163 | #NNF_H.uvPlaneID.data[NNF_H.uvPlaneID.data == 0] = 1 164 | NNF_H.uvPlaneID.data = NNF_H.uvPlaneID.data.squeeze() 165 | 166 | NNF_H.uvPlaneID.map = np.zeros((NNF_H.imgH, NNF_H.imgW, 1), dtype=np.uint8) 167 | NNF_H.uvPlaneID.map = update_uvMap(NNF_H.uvPlaneID.map, NNF_H.uvPlaneID.data[..., None], NNF_H.uvPix.ind) 168 | 169 | NNF_H.uvPlaneID.planeProbAcc = prep_plane_prob_acc(modelPlane.planeProb, NNF_H) 170 | NNF_H.uvPlaneID.mLogLikelihood = -np.log(NNF_H.uvPlaneID.planeProbAcc) 171 | 172 | uvTform_L = uvMat_from_uvMap(NNF_L.uvTform.map, uvPixL.ind) 173 | uvTform_L[:, 6: 8] = uvTform_L[:, 6: 8].dot(np.diag([1 / sX, 1 / sY])) 174 | 175 | refineVec = NNF_H.uvPix.sub - uvPixL.sub.dot(np.diag([1 / sX, 1 / sY])) 176 | uvTform_H = trans_tform(uvTform_L, refineVec) 177 | 178 | uvValid_H = check_valid_uv(uvTform_H[:, 6: 8], NNF_H.validPix.mask) 179 | 180 | uvInvalidInd = uvValid_H == 0 181 | nInvalidUv_H = np.sum(uvInvalidInd) 182 | if nInvalidUv_H: 183 | randInd = np.random.randint(NNF_H.validPix.ind.shape[0], size=(nInvalidUv_H)) 184 | uvTform_H[uvInvalidInd.squeeze(), 6: 8] = NNF_H.validPix.sub[randInd, :] 185 | 186 | NNF_H.uvTform = type("uvTform", (), {}) 187 | NNF_H.uvTform.data = uvTform_H 188 | I = np.reshape(np.eye(3), (1, 1, 9), order="F") 189 | 190 | NNF_H.uvTform.map = np.tile(I, (imgH_H, imgW_H, 1)) 191 | NNF_H.uvTform.map = update_uvMap(NNF_H.uvTform.map, NNF_H.uvTform.data, NNF_H.uvPix.ind) 192 | 193 | NNF_H.uvBias = type("uvBias", (), {}) 194 | NNF_H.uvBias.data = uvMat_from_uvMap(NNF_L.uvBias.map, uvPixL.ind) 195 | NNF_H.uvBias.map = np.zeros((imgH_H, imgW_H, 3), dtype=np.float32) 196 | NNF_H.uvBias.map = update_uvMap(NNF_H.uvBias.map, NNF_H.uvBias.data, NNF_H.uvPix.ind) 197 | NNF_H.uvBias.data = np.reshape(NNF_H.uvBias.data.T, [1, 3, NNF_H.uvPix.numPix], order="F") 198 | 199 | NNF_H.uvCost = type("uvCost", (), {}) 200 | NNF_H.uvCost.map = np.zeros((imgH_H, imgW_H, 1), np.float32) 201 | NNF_H.uvCost.data = uvMat_from_uvMap(NNF_L.uvCost.map, uvPixL.ind) 202 | NNF_H.uvCost.map = update_uvMap(NNF_H.uvCost.map, NNF_H.uvCost.data, NNF_H.uvPix.ind) 203 | 204 | NNF_H.distMap, _ = ndimage.distance_transform_edt(1 - (holeMask == 0), return_indices=True) 205 | NNF_H.wPatchR, NNF_H.wPatchSumImg = prep_dist_patch(NNF_H.distMap, NNF_H.uvPix.sub, optS) 206 | NNF_H.uvDtBdPixPos = NNF_H.distMap[np.unravel_index(NNF_H.uvPix.ind, (NNF_H.imgH, NNF_H.imgW), order="F")].astype( 207 | np.double) 208 | 209 | return NNF_H 210 | 211 | def init_lvl_nnf(img, NNF, holeMask, modelPlaneCur, modelRegCur, option): 212 | 213 | if option.iLvl == option.numPyrLvl - 1: 214 | NNF = init_nnf(holeMask, modelPlaneCur, modelRegCur, option) 215 | else: 216 | NNF = upsample(holeMask, NNF, modelPlaneCur, modelRegCur, option) 217 | 218 | trgPatch = prep_target_patch(img, NNF.uvPix.sub, option) 219 | srcPatch = prep_source_patch(img, NNF.uvTform.data, option) 220 | 221 | _, NNF.uvBias.data = patch_cost(trgPatch, srcPatch, modelPlaneCur, NNF.uvPlaneID.data, 222 | NNF.uvPix.sub, NNF.uvTform.data, NNF.uvTform.map[:, :, 6:8], NNF.uvDtBdPixPos, option) 223 | 224 | img = voting(img, NNF, holeMask, option) 225 | 226 | return img, NNF -------------------------------------------------------------------------------- /source/synthesis/patch_cost.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | 5 | def patch_cost_prox(srcPos, trgPos, uvDtBdPixPos, optS): 6 | 7 | d = srcPos - trgPos 8 | d = np.sqrt(np.sum(d ** 2, axis=1)) 9 | 10 | d = d/optS.imgSize 11 | uvDtBdPixPos = uvDtBdPixPos.copy() / optS.imgSize 12 | costProx = d - uvDtBdPixPos - optS.proxThres 13 | costProx[costProx <= 0] = 0 14 | return costProx 15 | 16 | def patch_cost_direct(uvPlaneIDData, trgPos, srcPos, modelPlane, opt): 17 | numUvPix = trgPos.shape[0] 18 | costDirect = opt.lambdaDirect * np.ones((numUvPix, 2), dtype=np.float32) 19 | 20 | for indPlane in range(modelPlane.numPlane): 21 | uvPlaneIndCur = uvPlaneIDData == indPlane 22 | numPlanePixCur = sum(uvPlaneIndCur) 23 | 24 | if indPlane == modelPlane.numPlane - 1: 25 | costDirect[uvPlaneIndCur, :] = opt.imgSize * opt.directThres 26 | else: 27 | rectMat = modelPlane.rectMat[indPlane] 28 | h7 = rectMat[2, 0] 29 | h8 = rectMat[2, 1] 30 | 31 | if numPlanePixCur != 0: 32 | trgPosCur = trgPos[uvPlaneIndCur, :].copy() - 1 33 | srcPosCur = srcPos[uvPlaneIndCur, :].copy() - 1 34 | 35 | for itheta in range(2): 36 | rotMat = modelPlane.rotMat[indPlane][itheta] 37 | 38 | rotRectMat = rotMat 39 | rotRectMat[2, 0] = h7 40 | rotRectMat[2, 1] = h8 41 | rotRectMat = rotRectMat.T 42 | 43 | trgPosCurRect = np.hstack([trgPosCur, np.ones((numPlanePixCur, 1))]).dot(rotRectMat) 44 | trgPosCurRect /= trgPosCurRect[:, 2:3] 45 | 46 | srcPosCurRect = np.hstack([srcPosCur, np.ones((numPlanePixCur, 1))]).dot(rotRectMat) 47 | srcPosCurRect /= srcPosCurRect[:, 2:3] 48 | 49 | costDirect[uvPlaneIndCur, itheta] = np.abs(srcPosCurRect[:, 1] - trgPosCurRect[:, 1]) 50 | 51 | costDirect = np.min(costDirect, axis=1) / opt.imgSize 52 | costDirect[costDirect >= opt.directThres] = opt.directThres 53 | return costDirect 54 | 55 | def patch_cost_plane(mLogLPlaneProb, uvPlaneIDData, trgPixSub, srcPixSub): 56 | H, W, numPlane = mLogLPlaneProb.shape 57 | 58 | srcPixSub = np.round(srcPixSub) 59 | uvPlaneIDData_in = uvPlaneIDData.astype(np.int) 60 | 61 | return mLogLPlaneProb[trgPixSub[:, 1].astype(np.int), trgPixSub[:, 0].astype(np.int), uvPlaneIDData_in] + \ 62 | mLogLPlaneProb[srcPixSub[:, 1].astype(np.int), srcPixSub[:, 0].astype(np.int), uvPlaneIDData_in] 63 | 64 | def patch_cost_app(trgPatch, srcPatch, option): 65 | uvBias = None 66 | 67 | patchDist = trgPatch - srcPatch 68 | 69 | if option.costType == "L1": 70 | patchDist = np.abs(patchDist) 71 | else: 72 | patchDist = patchDist ** 2 73 | 74 | patchDist *= option.wPatch[..., None, None] 75 | costApp = np.squeeze(np.sum(np.sum(patchDist, axis=0), axis=0)) 76 | 77 | return costApp, uvBias 78 | 79 | def patch_cost(trgPatch, srcPatch, modelPlane, uvPlaneIDData, 80 | trgPos, srcTform, srcPosMap, bdPos, option): 81 | 82 | numUvPix = srcPatch.shape[2] 83 | costPatchCand = np.zeros((numUvPix, 5), dtype=np.float32) 84 | 85 | costApp, uvBiasCand = patch_cost_app(trgPatch, srcPatch, option) 86 | 87 | srcPos = srcTform[:, 6:8] 88 | 89 | costPlane = patch_cost_plane(modelPlane.mLogPlaneProb, uvPlaneIDData, trgPos, srcPos) 90 | 91 | costDirect = patch_cost_direct(uvPlaneIDData, trgPos, srcPos, modelPlane, option) 92 | 93 | costProx = patch_cost_prox(srcPos, trgPos, bdPos, option) 94 | 95 | costPatchCand[:, 0] = costApp 96 | costPatchCand[:, 1] = option.lambdaPlane * costPlane 97 | costPatchCand[:, 3] = option.lambdaDirect * costDirect 98 | costPatchCand[:, 4] = option.lambdaProx * costProx 99 | 100 | return costPatchCand, uvBiasCand -------------------------------------------------------------------------------- /source/synthesis/prep_dist_patch.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from .prep_target_patch import prep_target_patch 4 | 5 | def prep_dist_patch(distMap, trgPixPos, option): 6 | imgH, imgW = distMap.shape 7 | wPatchR = prep_target_patch(distMap[..., None], trgPixPos, option) 8 | wPatchR = np.squeeze(wPatchR) 9 | 10 | wPatchR = wPatchR - wPatchR[option.pMidPix, :] 11 | wPatchR = option.wDist[option.iLvl] ** wPatchR 12 | 13 | numUvPix = wPatchR.shape[1] 14 | 15 | wPatchSumImg = np.zeros((imgH, imgW), dtype=np.float32) 16 | indMap = np.reshape(range(imgH * imgW), (imgH, imgW), order="F") 17 | 18 | indPatch = prep_target_patch(indMap[..., None], trgPixPos, option) 19 | indPatch = np.squeeze(indPatch).astype(np.int) 20 | 21 | for i in range(numUvPix): 22 | wPatchSumImg[np.unravel_index(indPatch[:, i], (imgH, imgW), order="F")] += wPatchR[:, i] 23 | 24 | return wPatchR, wPatchSumImg -------------------------------------------------------------------------------- /source/synthesis/prep_source_patch.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | from scipy.interpolate import interp2d 4 | 5 | def prep_source_patch(img, uvTform, option): 6 | numUvPix = uvTform.shape[0] 7 | 8 | c1 = np.reshape(uvTform[:, :3].T, (1, 3, numUvPix), order="F") 9 | c2 = np.reshape(uvTform[:, 3:6].T, (1, 3, numUvPix), order="F") 10 | c3 = np.reshape(uvTform[:, 6:9].T, (1, 3, numUvPix), order="F") 11 | 12 | srcPatchPos = (option.refPatchPos[:, 0][..., None, None] * c1) + \ 13 | (option.refPatchPos[:, 1][..., None, None] * c2) 14 | srcPatchPos += c3 15 | 16 | srcPatchPos /= srcPatchPos[:, 2:3, :] 17 | 18 | srcPatch = cv2.remap(img, srcPatchPos[:, 0, :].astype(np.float32), srcPatchPos[:, 1, :].astype(np.float32), 19 | cv2.INTER_LINEAR) 20 | 21 | srcPatch = srcPatch.transpose((0, 2, 1)) 22 | 23 | return srcPatch -------------------------------------------------------------------------------- /source/synthesis/prep_target_patch.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def prep_target_patch(img, uvPixSub, option): 4 | imgH, imgW, Ch = img.shape 5 | 6 | numUvPix = uvPixSub.shape[0] 7 | 8 | uvPixSub = np.reshape(uvPixSub.T, (1, 2, numUvPix), order="F") 9 | 10 | refPatPos = option.refPatchPos[:, :2][..., None] 11 | trgPatchPos = (refPatPos + uvPixSub).astype(np.int) 12 | 13 | trgPatch = np.zeros((option.pNumPix, Ch, numUvPix)) 14 | for i in range(Ch): 15 | for j in range(numUvPix): 16 | trgPatch[:, i, j] = img[trgPatchPos[:, 1, j], trgPatchPos[:, 0, j], i].copy() 17 | 18 | 19 | return trgPatch -------------------------------------------------------------------------------- /source/synthesis/sc_pass.py: -------------------------------------------------------------------------------- 1 | from .prep_source_patch import prep_source_patch 2 | from .prep_target_patch import prep_target_patch 3 | from .patch_cost import patch_cost 4 | from .update_uvMap import update_uvMap 5 | from .voting import voting 6 | from .update_NNF import update_NNF 7 | 8 | import cv2 9 | import numpy as np 10 | import os 11 | import math 12 | import matplotlib.pyplot as plt 13 | 14 | def imshow(img): 15 | cv2.namedWindow("tmp", cv2.WINDOW_NORMAL) 16 | cv2.imshow("tmp", img) 17 | #cv2.waitKey() 18 | 19 | def sc_pass(img, holeMask, NNF, modelPlaneCur, modelRegCur, option, lockImgFlag): 20 | 21 | for iter in range(option.numIterLvl): 22 | trgPatch = prep_target_patch(img.copy(), NNF.uvPix.sub, option) 23 | srcPatch = prep_source_patch(img.copy(), NNF.uvTform.data, option) 24 | 25 | uvCostcur, NNF.uvBias.data = patch_cost(trgPatch, srcPatch, modelPlaneCur, NNF.uvPlaneID.data, 26 | NNF.uvPix.sub, NNF.uvTform.data, NNF.uvTform.map[:, :, 6:8], 27 | NNF.uvDtBdPixPos, option) 28 | 29 | NNF.uvCost.data = np.sum(uvCostcur, axis=1, keepdims=True) 30 | 31 | if len(NNF.uvCost.map.shape) == 2: 32 | NNF.uvCost.map = NNF.uvCost.map[..., None] 33 | 34 | NNF.uvCost.map = update_uvMap(NNF.uvCost.map, NNF.uvCost.data, NNF.uvPix.ind) 35 | 36 | NNF, nUpdate = update_NNF(trgPatch, img, NNF, modelPlaneCur, modelRegCur, option) 37 | avgPatchCost = np.mean(NNF.uvCost.data, axis=0) 38 | 39 | if not lockImgFlag: 40 | img = voting(img, NNF, holeMask, option) 41 | #imshow(img) 42 | 43 | print("--- {}\t\t\t{}\t\t\t{}\t\t\t{}\t\t\t{}".format( 44 | iter, nUpdate[0], nUpdate[1], nUpdate[2], avgPatchCost[0])) 45 | 46 | return img, NNF -------------------------------------------------------------------------------- /source/synthesis/scale_tform.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def scale_tform(H): 4 | uvTformScale = (H[:, 0] - H[:, 6] * H[:, 2]) * (H[:, 4] - H[:, 7] * H[:, 5]) - \ 5 | (H[:, 3] - H[:, 7] * H[:, 5]) * (H[:, 1] - H[:, 7] * H[:, 2]) 6 | uvTformScale = np.sqrt(np.abs(uvTformScale)) 7 | return uvTformScale -------------------------------------------------------------------------------- /source/synthesis/src_domain_tform.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | from .trans_tform import trans_tform 5 | 6 | eps = 1e-16 7 | 8 | def debug(debuginfo): 9 | print(debuginfo) 10 | print(a) 11 | 12 | def apply_tform_H(x, h7, h8): 13 | y = x[:, 0] * h7 + x[:, 1] * h8 + 1 14 | y = x[:, :2] / (y[..., None] + eps) 15 | return y 16 | 17 | def src_domain_tform(uvPlaneID, modelPlane, modelReg, srcPos, trgPos, sampleRandReg): 18 | 19 | numUvPix = srcPos.shape[0] 20 | 21 | uvTformData = np.zeros((numUvPix, 9), dtype=np.float32) 22 | I = np.eye(3) 23 | 24 | for indPlane in range(modelPlane.numPlane): 25 | rectMat = modelPlane.rectMat[indPlane] 26 | h7 = rectMat[2, 0] 27 | h8 = rectMat[2, 1] 28 | 29 | uvPlaneIndCur = uvPlaneID == indPlane 30 | numPlanePixCur = np.sum(uvPlaneIndCur) 31 | 32 | if numPlanePixCur: 33 | 34 | trgPosCur = trgPos[uvPlaneIndCur, :].copy() 35 | trgPosCur[trgPosCur > 0] -= 1 36 | trgPosCurR = apply_tform_H(trgPosCur, h7, h8) 37 | 38 | if sampleRandReg: 39 | srcPosCur = srcPos[uvPlaneIndCur, :].copy() - 1 40 | 41 | srcPosCur[srcPosCur > 0] -= 1 42 | srcPosCurR = apply_tform_H(srcPosCur, h7, h8) 43 | 44 | dRect = srcPosCurR - trgPosCurR 45 | 46 | else: 47 | dRect = np.zeros((numPlanePixCur, 2), dtype=np.float32) 48 | 49 | numDispVecCur = modelReg.numDispVec[indPlane] 50 | 51 | if numDispVecCur != 0: 52 | randInd = np.random.randint(numDispVecCur, numPlanePixCur, 1) 53 | dRect = modelReg.dispVec[indPlane][randInd, :] 54 | 55 | if dRect.shape[1] != 0: 56 | uvTformCur = np.zeros((numPlanePixCur, 9), dtype=np.float32) 57 | 58 | uvTformCur[:, np.array([0, 3, 6])] = dRect[:, 0][..., None] * np.array([h7, h8, 1])[None, ...] 59 | uvTformCur[:, np.array([1, 4, 7])] = dRect[:, 1][..., None] * np.array([h7, h8, 1])[None, ...] 60 | 61 | dTemp = dRect.dot([h7, h8]) 62 | 63 | uvTformCur[:, np.array([2, 5, 8])] = dTemp[..., None] * -np.array([h7, h8, 1])[None, ...] 64 | 65 | uvTformCur = uvTformCur + I.reshape((1, 9), order="F") 66 | 67 | uvTformData[uvPlaneIndCur, :] = trans_tform(uvTformCur, trgPosCur) 68 | uvTformData[uvPlaneIndCur, 6:8] += 1 69 | 70 | return uvTformData -------------------------------------------------------------------------------- /source/synthesis/synthesis.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import math 5 | import time 6 | 7 | from .init_lvl_nnf import init_lvl_nnf 8 | from .sc_pass import sc_pass 9 | 10 | def synthesis(imgPyr, maskPyr, modelPlane, modelReg, option): 11 | NNF = [] 12 | numIterLvl = option.numIter 13 | 14 | for iLvl in range(option.numPyrLvl-1, -1, -1): 15 | holeMask = maskPyr[iLvl] 16 | H, W = holeMask.shape 17 | 18 | option.iLvl = iLvl 19 | option.imgSize = max(H, W) 20 | 21 | modelPlaneCur = modelPlane[iLvl] 22 | modelRegCur = modelReg[iLvl] 23 | 24 | print("--- Initialize NNF: ") 25 | time0 = time.time() 26 | img, NNF = init_lvl_nnf(imgPyr[iLvl], NNF, holeMask, modelPlaneCur, modelRegCur, option) 27 | print('Done in %6.3f seconds.\n' % (time.time() - time0)) 28 | 29 | numIterLvl = int(max(numIterLvl - option.numIterDec, option.numIterMin)) 30 | option.numIterLvl = numIterLvl 31 | 32 | print("--- Pass... level: {}, #Iter: {}, #uvPixels: {}".format(iLvl, numIterLvl, NNF.uvPix.numPix)) 33 | print("--- #iter\t#PropUpdate\t\t#RandUpdate\t\t#RegUpdate\t\tAvgCost") 34 | print("img size: ", maskPyr[iLvl].shape) 35 | if option.iLvl == option.numPyrLvl - 1: 36 | img, NNF = sc_pass(img, holeMask, NNF, modelPlaneCur, modelRegCur, option, 1) 37 | 38 | img, NNF = sc_pass(img, holeMask, NNF, modelPlaneCur, modelRegCur, option, 0) 39 | else: 40 | img, NNF = sc_pass(img, holeMask, NNF, modelPlaneCur, modelRegCur, option, 0) 41 | 42 | imgPyr[iLvl] = img 43 | cv2.namedWindow("tmp", cv2.WINDOW_NORMAL) 44 | cv2.imshow("tmp", imgPyr[iLvl]) 45 | cv2.waitKey() 46 | return imgPyr -------------------------------------------------------------------------------- /source/synthesis/trans_tform.py: -------------------------------------------------------------------------------- 1 | 2 | eps = 1e-16 3 | 4 | def trans_tform(uvTformV, d_in): 5 | d = d_in.copy() 6 | 7 | uvTform = uvTformV.copy() 8 | 9 | if len(d.shape) == 1: 10 | uvTform[:, 6] = uvTformV[:, 0] * d[0] + uvTformV[:, 3] * d[1] + uvTformV[:, 6] 11 | uvTform[:, 7] = uvTformV[:, 1] * d[0] + uvTformV[:, 4] * d[1] + uvTformV[:, 7] 12 | uvTform[:, 8] = uvTformV[:, 2] * d[0] + uvTformV[:, 5] * d[1] + uvTformV[:, 8] 13 | else: 14 | 15 | uvTform[:, 6] = uvTformV[:, 0] * d[:, 0] + uvTformV[:, 3] * d[:, 1] + uvTformV[:, 6] 16 | uvTform[:, 7] = uvTformV[:, 1] * d[:, 0] + uvTformV[:, 4] * d[:, 1] + uvTformV[:, 7] 17 | uvTform[:, 8] = uvTformV[:, 2] * d[:, 0] + uvTformV[:, 5] * d[:, 1] + uvTformV[:, 8] 18 | uvTform = uvTform / (uvTform[:, 8] + eps)[..., None] 19 | return uvTform 20 | -------------------------------------------------------------------------------- /source/synthesis/update_NNF.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | from .trans_tform import trans_tform 5 | from .uvMat_from_uvMap import uvMat_from_uvMap 6 | from .check_valid_uv import check_valid_uv 7 | from .prep_source_patch import prep_source_patch 8 | from .patch_cost import patch_cost 9 | from .update_uvMap import update_uvMap 10 | from .src_domain_tform import src_domain_tform 11 | from .draw_plane_id import draw_plane_id 12 | from .scale_tform import scale_tform 13 | 14 | def debug(debug_info): 15 | print(debug_info) 16 | print(a) 17 | 18 | def shape(a): 19 | print(a.shape) 20 | print(b) 21 | 22 | def propagate(trgPatch, img, NNF, modelPlane, option, iDirect): 23 | nUpdateTotal = 0 24 | uvPixN = NNF.uvPixN[iDirect] 25 | uvPixActiveInd = uvPixN.validInd.astype(np.int) 26 | 27 | numUpdatePix = NNF.uvPix.numPix 28 | 29 | while numUpdatePix != 0: 30 | uvPix = type("uvPix", (), {}) 31 | uvPix.sub = NNF.uvPix.sub[uvPixActiveInd == 1, :].copy() 32 | uvPix.ind = NNF.uvPix.ind[uvPixActiveInd == 1].copy() 33 | 34 | uvPixNCur = type("uvPixNCur", (), {}) 35 | uvPixNCur.sub = uvPixN.sub[uvPixActiveInd == 1, :].copy() 36 | uvPixNCur.ind = uvPixN.ind[uvPixActiveInd == 1].copy() 37 | 38 | uvDtBdPixPosCur = NNF.uvDtBdPixPos[uvPixActiveInd == 1].copy() 39 | 40 | trgPatchCur = trgPatch[:, :, uvPixActiveInd == 1].copy() 41 | srcPosCur = NNF.uvTform.data[uvPixActiveInd == 1, 6:8].copy() 42 | uvCostCur = NNF.uvCost.data[uvPixActiveInd == 1].copy() 43 | uvPlaneIDCur = NNF.uvPlaneID.data[uvPixActiveInd == 1].copy() 44 | 45 | srcPosMapCur = NNF.uvTform.map[:, :, 6:8].copy() 46 | uvPixActivePos = np.where(uvPixActiveInd == 1)[0] 47 | 48 | uvTformCand = uvMat_from_uvMap(NNF.uvTform.map, uvPixNCur.ind) 49 | uvTformCand = trans_tform(uvTformCand, option.propDir[iDirect, :]) 50 | 51 | uvValidSrcInd = check_valid_uv(uvTformCand[:, 6:8], NNF.validPix.mask) 52 | 53 | diff = np.abs(uvTformCand[:, 6:8] - srcPosCur) 54 | uvValidDistInd = (diff[:, 0:1] > 1) | (diff[:, 1:2] > 1) 55 | 56 | uvValidInd = (uvValidSrcInd == 1) & (uvValidDistInd == 1) 57 | 58 | numUvValid = np.sum(uvValidInd) 59 | 60 | if numUvValid != 0: 61 | uvPixValid = type("uvPixValid", (), {}) 62 | uvPixValid.sub = uvPix.sub[uvValidInd.squeeze() == 1, :].copy() 63 | uvPixValid.ind = uvPix.ind[uvValidInd.squeeze()].copy() 64 | 65 | uvDtBdPixPosCur = uvDtBdPixPosCur[uvValidInd.squeeze()].copy() 66 | trgPatchCur = trgPatchCur[:,:, uvValidInd.squeeze()].copy() 67 | uvTformCand = uvTformCand[uvValidInd.squeeze(), :].copy() 68 | uvCostCur = uvCostCur[uvValidInd.squeeze()].copy() 69 | uvPlaneIDCand = uvPlaneIDCur[uvValidInd.squeeze()].copy() 70 | 71 | uvPixUpdatePos = uvPixActivePos[uvValidInd.squeeze()].copy() 72 | 73 | srcPatch = prep_source_patch(img, uvTformCand, option) 74 | 75 | costPatchCandAll, uvBiasCand = patch_cost(trgPatchCur, srcPatch, modelPlane, uvPlaneIDCand, 76 | uvPixValid.sub, uvTformCand, srcPosMapCur, uvDtBdPixPosCur, 77 | option) 78 | costPatchCand = np.sum(costPatchCandAll, axis=1) 79 | 80 | updateInd = costPatchCand < uvCostCur.squeeze() 81 | 82 | uvPixUpdatePos = uvPixUpdatePos[updateInd.squeeze()] 83 | 84 | numUpdatePix = uvPixUpdatePos.shape[0] 85 | 86 | else: 87 | numUpdatePix = 0 88 | 89 | if numUpdatePix != 0: 90 | nUpdateTotal += numUpdatePix 91 | 92 | NNF.uvTform.data[uvPixUpdatePos, :] = uvTformCand[updateInd, :] 93 | NNF.uvCost.data[uvPixUpdatePos] = costPatchCand[updateInd][..., None] 94 | NNF.uvPlaneID.data[uvPixUpdatePos] = uvPlaneIDCand[updateInd] 95 | 96 | if option.useBiasCorrection: 97 | NNF.uvBias.data[:, uvPixUpdatePos] = uvBiasCand[:, updateInd] 98 | 99 | uvPixValidInd = uvPixValid.ind[updateInd] 100 | NNF.uvTform.map = update_uvMap(NNF.uvTform.map, uvTformCand[updateInd,:], uvPixValidInd) 101 | 102 | NNF.uvCost.map = update_uvMap(NNF.uvCost.map, costPatchCand[updateInd][..., None], uvPixValidInd) 103 | 104 | if len(NNF.uvPlaneID.map.shape) == 2: 105 | NNF.uvPlaneID.map = NNF.uvPlaneID.map[..., None] 106 | NNF.uvPlaneID.map = update_uvMap(NNF.uvPlaneID.map, 107 | uvPlaneIDCand[updateInd][..., None], uvPixValidInd) 108 | 109 | uvPixNextSub = uvPixValid.sub[updateInd, :].copy() 110 | uvPixNextSub = uvPixNextSub + option.propDir[iDirect, :][None, ...] 111 | 112 | updateMap = NNF.uvPix.mask 113 | updateMap[uvPixNextSub[:, 1], uvPixNextSub[:, 0]] = 0 114 | 115 | uvPixActiveInd = updateMap[NNF.uvPix.sub[:, 1], NNF.uvPix.sub[:, 0]] == 0 116 | uvPixActiveInd = (uvPixActiveInd == 1) & (uvPixN.validInd == 1) 117 | return NNF, nUpdateTotal 118 | 119 | def random_search(trgPatch, img, NNF, modelPlane, option): 120 | H, W, Ch = img.shape 121 | 122 | uvPix = NNF.uvPix 123 | numUvPix = uvPix.sub.shape[0] 124 | 125 | searchRad = max(H, W) / 2 126 | nUpdateTotal = 0 127 | 128 | iter = 0 129 | while searchRad > 1: 130 | iter += 1 131 | searchRad = searchRad / 2 132 | if searchRad < 1: 133 | break 134 | 135 | srcPosMapCur = NNF.uvTform.map[:, :, 6:8] 136 | uvTformCandCur = uvMat_from_uvMap(NNF.uvTform.map, uvPix.ind) 137 | 138 | srcPos = uvTformCandCur[:, 6:8] + 2 * searchRad * (np.random.rand(numUvPix, 2) - 0.5) 139 | 140 | uvPlaneIDCand = draw_plane_id(NNF.uvPlaneID.planeProbAcc) 141 | 142 | uvTformCand = src_domain_tform(uvPlaneIDCand.squeeze(), modelPlane, [], srcPos, NNF.uvPix.sub, 1) 143 | 144 | uvTformScale = scale_tform(uvTformCand) 145 | uvValidScaleInd = (uvTformScale.squeeze() > option.minScale) & (uvTformScale.squeeze() < option.maxScale) 146 | uvValidSrcInd = check_valid_uv(uvTformCand[:, 6:8], NNF.validPix.mask) 147 | 148 | uvValidInd = (uvValidSrcInd == 1).squeeze() & (uvValidScaleInd.squeeze() == 1).squeeze() 149 | 150 | uvPixActivePos = np.array(np.where(uvValidInd.squeeze())).squeeze() 151 | 152 | numActPix = uvPixActivePos.shape[0] 153 | 154 | if numActPix != 0: 155 | trgPatchCur = trgPatch[:, :, uvValidInd.squeeze()] 156 | uvCostDataCur = NNF.uvCost.data[uvValidInd] 157 | uvTformCandCur = uvTformCand[uvValidInd, :].copy() 158 | uvPlaneIDCandCur = uvPlaneIDCand[uvValidInd].squeeze() 159 | 160 | uvPixValid = type("uvPixValid", (), {}) 161 | uvPixValid.sub = uvPix.sub[uvValidInd, :] 162 | uvPixValid.ind = uvPix.ind[uvValidInd] 163 | 164 | uvDtBdPixPosCur = NNF.uvDtBdPixPos[uvValidInd].copy() 165 | 166 | srcPatch = prep_source_patch(img, uvTformCandCur, option) 167 | 168 | [costPatchCandAll, uvBiasCand] = patch_cost(trgPatchCur, srcPatch, modelPlane, uvPlaneIDCandCur, 169 | uvPixValid.sub, uvTformCandCur, srcPosMapCur, uvDtBdPixPosCur, option) 170 | costPatchCand = np.sum(costPatchCandAll, axis=1) 171 | updateInd = (costPatchCand.squeeze() < uvCostDataCur.squeeze()) 172 | nUpdate = np.sum(updateInd) 173 | 174 | if nUpdate != 0: 175 | 176 | uvPixActivePos = uvPixActivePos[updateInd] 177 | 178 | nUpdateTotal = nUpdateTotal + nUpdate 179 | 180 | NNF.uvTform.data[uvPixActivePos, :] = uvTformCandCur[updateInd, :].copy() 181 | NNF.uvPlaneID.data[uvPixActivePos] = uvPlaneIDCandCur[updateInd].copy() 182 | 183 | NNF.uvCost.data[uvPixActivePos] = costPatchCand[updateInd][..., None].copy() 184 | if option.useBiasCorrection: 185 | NNF.uvBias.data[:, uvPixActivePos] = uvBiasCand[:, updateInd] 186 | 187 | uvPixValidInd = uvPixValid.ind[updateInd].copy() 188 | NNF.uvTform.map = update_uvMap(NNF.uvTform.map, uvTformCandCur[updateInd,:], uvPixValidInd) 189 | 190 | NNF.uvPlaneID.map = update_uvMap(NNF.uvPlaneID.map, uvPlaneIDCandCur[updateInd][..., None], 191 | uvPixValidInd) 192 | NNF.uvCost.map = update_uvMap(NNF.uvCost.map, costPatchCand[updateInd][..., None], 193 | uvPixValidInd) 194 | 195 | return NNF, nUpdateTotal 196 | 197 | def update_NNF(trgPatch, img, NNF, modelPlane, modelReg, option): 198 | nUpdate = np.zeros((3)) 199 | 200 | for i in range(option.numPassPerIter): 201 | for iDierct in range(4): 202 | NNF, n = propagate(trgPatch, img, NNF, modelPlane, option, iDierct) 203 | nUpdate[0] += n 204 | 205 | NNF, n = random_search(trgPatch, img, NNF, modelPlane, option) 206 | nUpdate[1] += n 207 | return NNF, nUpdate -------------------------------------------------------------------------------- /source/synthesis/update_uvMap.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def update_uvMap(map, data, uvPixInd_in): 4 | uvPixInd = uvPixInd_in.copy() 5 | H, W, Ch = map.shape 6 | 7 | offset = np.array(range(Ch), dtype=np.uint32) * W * H 8 | 9 | uvPixInd = uvPixInd[..., None] + offset[None, ...] 10 | 11 | map[np.unravel_index(uvPixInd, map.shape, order="F")] = data 12 | 13 | return map -------------------------------------------------------------------------------- /source/synthesis/uvMat_from_uvMap.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def uvMat_from_uvMap(map, uvPixInd): 4 | H, W, Ch = map.shape 5 | 6 | offset = np.array(range(Ch), dtype=np.uint32) * W * H 7 | uvPixInd = uvPixInd[..., None] + offset[None, ...] 8 | uvMat = map[np.unravel_index(uvPixInd, map.shape, order="F")].copy() 9 | return uvMat -------------------------------------------------------------------------------- /source/synthesis/voting.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | from .prep_source_patch import prep_source_patch 5 | 6 | def clamp(v, low, high): 7 | v[v < low] = low 8 | v[v > high] = high 9 | return v 10 | 11 | def voting(img, NNF, holeMask, option): 12 | numUvPix = NNF.uvPix.numPix 13 | H, W, Ch = img.shape 14 | 15 | srcPatch = prep_source_patch(img, NNF.uvTform.data, option) 16 | 17 | trgPatchInd = NNF.trgPatchInd 18 | 19 | wPatchR = np.reshape(NNF.wPatchR, (option.pNumPix, 1, numUvPix), order="F") 20 | srcPatch = srcPatch * wPatchR 21 | 22 | srcPatch = np.reshape(srcPatch, (option.pNumPix * Ch, numUvPix), order="F") 23 | 24 | imgAcc = np.zeros((H, W, Ch), dtype=np.float32) 25 | for i in range(numUvPix): 26 | imgAcc[np.unravel_index(trgPatchInd[:, i].astype(np.int), imgAcc.shape, order="F")] += srcPatch[:, i] 27 | 28 | imgAcc /= NNF.wPatchSumImg[..., None] 29 | 30 | img[holeMask == 1, :] = imgAcc[holeMask == 1, :] 31 | 32 | img = clamp(img, 0, 1) 33 | return img -------------------------------------------------------------------------------- /util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/util/__init__.py -------------------------------------------------------------------------------- /vpdetection.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunskyF/StructCompletion-python/e74c8b1add23a127e5f3f7989a1fd5bf207bad7a/vpdetection.exe --------------------------------------------------------------------------------