blob: 599b4ed649223da2d4a418a8a294205660019db6 [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",
Henry Speisere45e7a22022-02-04 23:17:01 -0800100 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800101 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800102 "//aos:flatbuffer_merge",
103 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800104 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800105 "//aos/network:team_number",
106 "//frc971/vision:v4l2_reader",
107 "//frc971/vision:vision_fbs",
108 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800109 ],
110)
111
112cc_binary(
113 name = "camera_reader",
114 srcs = [
115 "camera_reader_main.cc",
116 ],
117 target_compatible_with = ["@platforms//os:linux"],
118 visibility = ["//y2022:__subpackages__"],
119 deps = [
120 ":camera_reader_lib",
121 "//aos:init",
122 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800123 ],
124)
125
126cc_library(
127 name = "blob_detector_lib",
128 srcs = [
129 "blob_detector.cc",
130 ],
131 hdrs = [
132 "blob_detector.h",
133 ],
134 target_compatible_with = ["@platforms//os:linux"],
135 visibility = ["//y2022:__subpackages__"],
136 deps = [
137 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800138 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800139 "//third_party:opencv",
140 ],
141)
142
milind-u92195982022-01-22 20:29:31 -0800143cc_library(
144 name = "target_estimator_lib",
145 srcs = [
146 "target_estimator.cc",
147 ],
148 hdrs = [
149 "target_estimator.h",
150 ],
151 target_compatible_with = ["@platforms//os:linux"],
152 visibility = ["//y2022:__subpackages__"],
153 deps = [
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800154 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800155 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800156 "//aos/logging",
157 "//aos/time",
158 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800159 "//third_party:opencv",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800160 "@com_google_absl//absl/strings:str_format",
161 "@com_google_ceres_solver//:ceres",
162 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800163 ],
164)
165
166flatbuffer_cc_library(
167 name = "target_estimate_fbs",
168 srcs = ["target_estimate.fbs"],
169 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800170 includes = [
171 ":calibration_fbs_includes",
172 ],
milind-u92195982022-01-22 20:29:31 -0800173 target_compatible_with = ["@platforms//os:linux"],
174 visibility = ["//y2022:__subpackages__"],
175)
176
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800177cc_binary(
178 name = "viewer",
179 srcs = [
180 "viewer.cc",
181 ],
182 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800183 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800184 ],
185 target_compatible_with = ["@platforms//os:linux"],
186 visibility = ["//y2022:__subpackages__"],
187 deps = [
188 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800189 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800190 "//aos:init",
191 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800192 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800193 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800194 ],
195)