blob: 9e9334347987e6030e7a2980c3651b6bf49e6b57 [file] [log] [blame]
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
milind-u92195982022-01-22 20:29:31 -08002
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08003flatbuffer_cc_library(
4 name = "calibration_fbs",
5 srcs = ["calibration.fbs"],
6 gen_reflections = 1,
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08007 target_compatible_with = ["@platforms//os:linux"],
8 visibility = ["//y2022:__subpackages__"],
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08009)
10
11flatbuffer_py_library(
12 name = "calibration_fbs_python",
13 srcs = [
14 "calibration.fbs",
15 ],
16 namespace = "frc971.vision.calibration",
17 tables = [
18 "CalibrationData",
19 "CameraCalibration",
20 "TransformationMatrix",
21 ],
22 target_compatible_with = ["@platforms//os:linux"],
23 visibility = ["//visibility:public"],
24)
25
26py_library(
27 name = "camera_definition",
28 srcs = [
29 "camera_definition.py",
30 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080031 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080032 "//external:python-glog",
33 ],
34)
35
36py_binary(
37 name = "create_calib_file",
38 srcs = [
39 "create_calib_file.py",
40 ],
41 args = [
42 "calibration_data.h",
43 ],
44 data = glob(["calib_files/*.json"]),
45 target_compatible_with = ["@platforms//os:linux"],
46 deps = [
47 ":camera_definition",
48 "//external:python-glog",
49 "//y2022/vision:calibration_fbs_python",
50 "@bazel_tools//tools/python/runfiles",
51 "@opencv_contrib_nonfree_amd64//:python_opencv",
52 ],
53)
54
55genrule(
56 name = "run_calibration_data",
57 outs = [
58 "calibration_data.h",
59 ],
60 cmd = " ".join([
61 "$(location :create_calib_file)",
62 "$(location calibration_data.h)",
63 ]),
64 target_compatible_with = ["@platforms//os:linux"],
65 tools = [
66 ":create_calib_file",
67 ],
68)
69
70cc_library(
71 name = "calibration_data",
72 hdrs = [
73 "calibration_data.h",
74 ],
75 target_compatible_with = ["@platforms//os:linux"],
76 visibility = ["//visibility:public"],
77 deps = [
78 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080079 ],
80)
81
82cc_library(
83 name = "camera_reader_lib",
84 srcs = [
85 "camera_reader.cc",
86 ],
87 hdrs = [
88 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -080089 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080090 ],
91 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -080092 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080093 ],
94 target_compatible_with = ["@platforms//os:linux"],
95 visibility = ["//y2022:__subpackages__"],
96 deps = [
milind-u92195982022-01-22 20:29:31 -080097 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080098 ":calibration_data",
99 ":calibration_fbs",
milind-udb98afa2022-03-01 19:54:57 -0800100 ":geometry_lib",
Henry Speisere45e7a22022-02-04 23:17:01 -0800101 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800102 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 "//aos:flatbuffer_merge",
104 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800105 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800106 "//aos/network:team_number",
107 "//frc971/vision:v4l2_reader",
108 "//frc971/vision:vision_fbs",
109 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800110 ],
111)
112
113cc_binary(
114 name = "camera_reader",
115 srcs = [
116 "camera_reader_main.cc",
117 ],
118 target_compatible_with = ["@platforms//os:linux"],
119 visibility = ["//y2022:__subpackages__"],
120 deps = [
121 ":camera_reader_lib",
122 "//aos:init",
123 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800124 ],
125)
126
127cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800128 name = "geometry_lib",
129 hdrs = [
130 "geometry.h",
131 ],
132 target_compatible_with = ["@platforms//os:linux"],
133 visibility = ["//y2022:__subpackages__"],
134 deps = [
135 "//aos/util:math",
136 "//third_party:opencv",
137 "@com_github_google_glog//:glog",
138 ],
139)
140
141cc_test(
142 name = "geometry_test",
143 srcs = [
144 "geometry_test.cc",
145 ],
146 deps = [
147 ":geometry_lib",
148 "//aos/testing:googletest",
149 ],
150)
151
152cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800153 name = "blob_detector_lib",
154 srcs = [
155 "blob_detector.cc",
156 ],
157 hdrs = [
158 "blob_detector.h",
159 ],
160 target_compatible_with = ["@platforms//os:linux"],
161 visibility = ["//y2022:__subpackages__"],
162 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800163 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800164 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800165 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800166 "//third_party:opencv",
167 ],
168)
169
milind-u92195982022-01-22 20:29:31 -0800170cc_library(
171 name = "target_estimator_lib",
172 srcs = [
173 "target_estimator.cc",
174 ],
175 hdrs = [
176 "target_estimator.h",
177 ],
178 target_compatible_with = ["@platforms//os:linux"],
179 visibility = ["//y2022:__subpackages__"],
180 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800181 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800182 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800183 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800184 "//aos/logging",
185 "//aos/time",
186 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800187 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800188 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800189 "@com_google_absl//absl/strings:str_format",
190 "@com_google_ceres_solver//:ceres",
191 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800192 ],
193)
194
195flatbuffer_cc_library(
196 name = "target_estimate_fbs",
197 srcs = ["target_estimate.fbs"],
198 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800199 includes = [
200 ":calibration_fbs_includes",
201 ],
milind-u92195982022-01-22 20:29:31 -0800202 target_compatible_with = ["@platforms//os:linux"],
203 visibility = ["//y2022:__subpackages__"],
204)
205
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800206cc_binary(
207 name = "viewer",
208 srcs = [
209 "viewer.cc",
210 ],
211 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800212 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800213 ],
214 target_compatible_with = ["@platforms//os:linux"],
215 visibility = ["//y2022:__subpackages__"],
216 deps = [
217 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800218 ":calibration_data",
milind-u92195982022-01-22 20:29:31 -0800219 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800220 "//aos:init",
221 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800222 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800223 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800224 ],
225)