blob: 965cc67fb922b2cf5d3f26139b990c11b4f04ed7 [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 = [
92 "//y2022:config",
93 ],
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 = [
154 ":target_estimate_fbs",
155 "//third_party:opencv",
156 ],
157)
158
159flatbuffer_cc_library(
160 name = "target_estimate_fbs",
161 srcs = ["target_estimate.fbs"],
162 gen_reflections = 1,
163 target_compatible_with = ["@platforms//os:linux"],
164 visibility = ["//y2022:__subpackages__"],
165)
166
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800167cc_binary(
168 name = "viewer",
169 srcs = [
170 "viewer.cc",
171 ],
172 data = [
Jim Ostrowski977850f2022-01-22 21:04:22 -0800173 "//y2022:config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800174 ],
175 target_compatible_with = ["@platforms//os:linux"],
176 visibility = ["//y2022:__subpackages__"],
177 deps = [
178 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800179 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800180 "//aos:init",
181 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800182 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800183 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800184 ],
185)