blob: 5b99411694a43d312fb1fb77ccfbfe93324669e3 [file] [log] [blame]
Brian Silverman3fec6482020-01-19 17:56:20 -08001load(":fast_gaussian.bzl", "fast_gaussian")
Brian Silvermanfac9b872020-02-05 20:07:38 -08002load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
Brian Silverman3fec6482020-01-19 17:56:20 -08003
4cc_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
21py_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.
49sigmas = [
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
90sizes = [
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
113fast_gaussian(sigmas, sizes)
114
Brian Silvermanf1196122020-01-16 00:41:54 -0800115cc_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 Silverman3fec6482020-01-19 17:56:20 -0800129 ":fast_gaussian",
Brian Silvermanf1196122020-01-16 00:41:54 -0800130 "//third_party:opencv",
Brian Silverman3fec6482020-01-19 17:56:20 -0800131 "@com_github_google_glog//:glog",
132 ],
133)
134
135cc_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
Brian Silvermane4664162020-02-15 15:27:46 -0800155cc_test(
156 name = "fast_gaussian_test",
157 srcs = [
158 "fast_gaussian_test.cc",
159 ],
160 restricted_to = [
161 "//tools:k8",
162 "//tools:armhf-debian",
163 ],
164 deps = [
165 ":fast_gaussian",
166 "//aos/testing:googletest",
167 "//third_party:opencv",
168 ],
169)
170
Brian Silverman3fec6482020-01-19 17:56:20 -0800171cc_binary(
172 name = "testing_sift",
173 srcs = [
174 "testing_sift.cc",
175 ],
176 restricted_to = [
177 "//tools:k8",
178 "//tools:armhf-debian",
179 ],
180 deps = [
181 ":fast_gaussian",
182 "//aos:init",
183 "//aos/time",
184 "//third_party:opencv",
185 "//y2020/vision/sift:sift971",
186 "@com_github_google_glog//:glog",
Brian Silvermanf1196122020-01-16 00:41:54 -0800187 ],
188)
Brian Silvermanfac9b872020-02-05 20:07:38 -0800189
190flatbuffer_py_library(
191 name = "sift_fbs_python",
192 srcs = [
193 "sift.fbs",
194 "sift_training.fbs",
195 ],
196 namespace = "frc971.vision.sift",
197 tables = [
198 "Feature",
199 "Match",
200 "ImageMatch",
201 "TransformationMatrix",
202 "CameraPose",
203 "ImageMatchResult",
204 "TrainingImage",
205 "TrainingData",
206 ],
207)
208
209flatbuffer_cc_library(
210 name = "sift_fbs",
211 srcs = ["sift.fbs"],
212 gen_reflections = True,
213 visibility = ["//visibility:public"],
214)
215
216flatbuffer_cc_library(
217 name = "sift_training_fbs",
218 srcs = ["sift_training.fbs"],
219 gen_reflections = True,
220 includes = [":sift_fbs_includes"],
221 visibility = ["//visibility:public"],
222)