Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 1 | load(":fast_gaussian.bzl", "fast_gaussian") |
Brian Silverman | fac9b87 | 2020-02-05 20:07:38 -0800 | [diff] [blame^] | 2 | load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library") |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 3 | |
| 4 | cc_binary( |
| 5 | name = "fast_gaussian_generator", |
| 6 | srcs = [ |
| 7 | "fast_gaussian_generator.cc", |
| 8 | ], |
| 9 | restricted_to = [ |
| 10 | "//tools:k8", |
| 11 | "//tools:armhf-debian", |
| 12 | ], |
| 13 | deps = [ |
| 14 | "//third_party:halide", |
| 15 | "//third_party:halide_gengen", |
| 16 | "//third_party:opencv", |
| 17 | "@com_github_google_glog//:glog", |
| 18 | ], |
| 19 | ) |
| 20 | |
| 21 | py_binary( |
| 22 | name = "fast_gaussian_runner", |
| 23 | srcs = [ |
| 24 | "fast_gaussian_runner.py", |
| 25 | ], |
| 26 | data = [ |
| 27 | ":fast_gaussian_generator", |
| 28 | # TODO(Brian): Replace this with something more fine-grained from the |
| 29 | # configuration fragment or something. |
| 30 | "//tools/cpp:toolchain", |
| 31 | ], |
| 32 | default_python_version = "PY3", |
| 33 | main = "fast_gaussian_runner.py", |
| 34 | restricted_to = [ |
| 35 | "//tools:k8", |
| 36 | "//tools:armhf-debian", |
| 37 | ], |
| 38 | srcs_version = "PY2AND3", |
| 39 | deps = [ |
| 40 | "@bazel_tools//tools/python/runfiles", |
| 41 | ], |
| 42 | ) |
| 43 | |
| 44 | # Each element is [sigma, sigma_name, radius]. |
| 45 | # opencv's default width is calculated as: |
| 46 | # cvRound(sigma1 * (depth == CV_8U ? 3 : 4) * 2 + 1) | 1 |
| 47 | # Pulling that in helps a lot with making it faster (less data to read, and less |
| 48 | # math to do), but if you make it too narrow SIFT quickly freaks out. |
| 49 | sigmas = [ |
| 50 | [ |
| 51 | "1.2262734984654078", |
| 52 | "1p2", |
| 53 | "9", |
| 54 | ], |
| 55 | [ |
| 56 | "1.5450077936447955", |
| 57 | "1p5", |
| 58 | "11", |
| 59 | ], |
| 60 | [ |
| 61 | "1.9465878414647133", |
| 62 | "1p9", |
| 63 | "13", |
| 64 | ], |
| 65 | [ |
| 66 | "2.4525469969308156", |
| 67 | "2p4", |
| 68 | "15", |
| 69 | ], |
| 70 | [ |
| 71 | "3.0900155872895909", |
| 72 | "3p1", |
| 73 | "19", |
| 74 | ], |
| 75 | # TODO(Brian): We only need one of these two for 1280x720. Don't generate |
| 76 | # all the redundant versions for other sizes, and maybe stop doing the one |
| 77 | # we don't actually use. |
| 78 | [ |
| 79 | "1.2489997148513794", |
| 80 | "1p24", |
| 81 | "11", |
| 82 | ], |
| 83 | [ |
| 84 | "1.5198683738708496", |
| 85 | "1p52", |
| 86 | "15", |
| 87 | ], |
| 88 | ] |
| 89 | |
| 90 | sizes = [ |
| 91 | [ |
| 92 | 1280, |
| 93 | 720, |
| 94 | ], |
| 95 | [ |
| 96 | 640, |
| 97 | 360, |
| 98 | ], |
| 99 | [ |
| 100 | 320, |
| 101 | 180, |
| 102 | ], |
| 103 | [ |
| 104 | 160, |
| 105 | 90, |
| 106 | ], |
| 107 | [ |
| 108 | 80, |
| 109 | 45, |
| 110 | ], |
| 111 | ] |
| 112 | |
| 113 | fast_gaussian(sigmas, sizes) |
| 114 | |
Brian Silverman | f119612 | 2020-01-16 00:41:54 -0800 | [diff] [blame] | 115 | cc_library( |
| 116 | name = "sift971", |
| 117 | srcs = [ |
| 118 | "sift971.cc", |
| 119 | ], |
| 120 | hdrs = [ |
| 121 | "sift971.h", |
| 122 | ], |
| 123 | restricted_to = [ |
| 124 | "//tools:k8", |
| 125 | "//tools:armhf-debian", |
| 126 | ], |
| 127 | visibility = ["//visibility:public"], |
| 128 | deps = [ |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 129 | ":fast_gaussian", |
Brian Silverman | f119612 | 2020-01-16 00:41:54 -0800 | [diff] [blame] | 130 | "//third_party:opencv", |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 131 | "@com_github_google_glog//:glog", |
| 132 | ], |
| 133 | ) |
| 134 | |
| 135 | cc_library( |
| 136 | name = "fast_gaussian", |
| 137 | srcs = [ |
| 138 | "fast_gaussian.cc", |
| 139 | ], |
| 140 | hdrs = [ |
| 141 | "fast_gaussian.h", |
| 142 | ], |
| 143 | restricted_to = [ |
| 144 | "//tools:k8", |
| 145 | "//tools:armhf-debian", |
| 146 | ], |
| 147 | deps = [ |
| 148 | ":fast_gaussian_all", |
| 149 | "//third_party:halide_runtime", |
| 150 | "//third_party:opencv", |
| 151 | "@com_github_google_glog//:glog", |
| 152 | ], |
| 153 | ) |
| 154 | |
| 155 | cc_binary( |
| 156 | name = "testing_sift", |
| 157 | srcs = [ |
| 158 | "testing_sift.cc", |
| 159 | ], |
| 160 | restricted_to = [ |
| 161 | "//tools:k8", |
| 162 | "//tools:armhf-debian", |
| 163 | ], |
| 164 | deps = [ |
| 165 | ":fast_gaussian", |
| 166 | "//aos:init", |
| 167 | "//aos/time", |
| 168 | "//third_party:opencv", |
| 169 | "//y2020/vision/sift:sift971", |
| 170 | "@com_github_google_glog//:glog", |
Brian Silverman | f119612 | 2020-01-16 00:41:54 -0800 | [diff] [blame] | 171 | ], |
| 172 | ) |
Brian Silverman | fac9b87 | 2020-02-05 20:07:38 -0800 | [diff] [blame^] | 173 | |
| 174 | flatbuffer_py_library( |
| 175 | name = "sift_fbs_python", |
| 176 | srcs = [ |
| 177 | "sift.fbs", |
| 178 | "sift_training.fbs", |
| 179 | ], |
| 180 | namespace = "frc971.vision.sift", |
| 181 | tables = [ |
| 182 | "Feature", |
| 183 | "Match", |
| 184 | "ImageMatch", |
| 185 | "TransformationMatrix", |
| 186 | "CameraPose", |
| 187 | "ImageMatchResult", |
| 188 | "TrainingImage", |
| 189 | "TrainingData", |
| 190 | ], |
| 191 | ) |
| 192 | |
| 193 | flatbuffer_cc_library( |
| 194 | name = "sift_fbs", |
| 195 | srcs = ["sift.fbs"], |
| 196 | gen_reflections = True, |
| 197 | visibility = ["//visibility:public"], |
| 198 | ) |
| 199 | |
| 200 | flatbuffer_cc_library( |
| 201 | name = "sift_training_fbs", |
| 202 | srcs = ["sift_training.fbs"], |
| 203 | gen_reflections = True, |
| 204 | includes = [":sift_fbs_includes"], |
| 205 | visibility = ["//visibility:public"], |
| 206 | ) |