blob: 823462be7963310c9eb4fbb5eeda0b62d4b538d4 [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",
89 ],
90 data = [
91 "//y2022:config",
92 ],
93 target_compatible_with = ["@platforms//os:linux"],
94 visibility = ["//y2022:__subpackages__"],
95 deps = [
milind-u92195982022-01-22 20:29:31 -080096 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080097 ":calibration_data",
98 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -080099 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800100 "//aos:flatbuffer_merge",
101 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800102 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 "//aos/network:team_number",
104 "//frc971/vision:v4l2_reader",
105 "//frc971/vision:vision_fbs",
106 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800107 ],
108)
109
110cc_binary(
111 name = "camera_reader",
112 srcs = [
113 "camera_reader_main.cc",
114 ],
115 target_compatible_with = ["@platforms//os:linux"],
116 visibility = ["//y2022:__subpackages__"],
117 deps = [
118 ":camera_reader_lib",
119 "//aos:init",
120 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800121 ],
122)
123
124cc_library(
125 name = "blob_detector_lib",
126 srcs = [
127 "blob_detector.cc",
128 ],
129 hdrs = [
130 "blob_detector.h",
131 ],
132 target_compatible_with = ["@platforms//os:linux"],
133 visibility = ["//y2022:__subpackages__"],
134 deps = [
135 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800136 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800137 "//third_party:opencv",
138 ],
139)
140
milind-u92195982022-01-22 20:29:31 -0800141cc_library(
142 name = "target_estimator_lib",
143 srcs = [
144 "target_estimator.cc",
145 ],
146 hdrs = [
147 "target_estimator.h",
148 ],
149 target_compatible_with = ["@platforms//os:linux"],
150 visibility = ["//y2022:__subpackages__"],
151 deps = [
152 ":target_estimate_fbs",
153 "//third_party:opencv",
154 ],
155)
156
157flatbuffer_cc_library(
158 name = "target_estimate_fbs",
159 srcs = ["target_estimate.fbs"],
160 gen_reflections = 1,
161 target_compatible_with = ["@platforms//os:linux"],
162 visibility = ["//y2022:__subpackages__"],
163)
164
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800165cc_binary(
166 name = "viewer",
167 srcs = [
168 "viewer.cc",
169 ],
170 data = [
Jim Ostrowski977850f2022-01-22 21:04:22 -0800171 "//y2022:config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800172 ],
173 target_compatible_with = ["@platforms//os:linux"],
174 visibility = ["//y2022:__subpackages__"],
175 deps = [
176 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800177 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800178 "//aos:init",
179 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800180 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800181 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800182 ],
183)