blob: 676a4b966e14fa3d210b153218a69c2324ff9df4 [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",
Henry Speisere45e7a22022-02-04 23:17:01 -080099 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800100 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800101 "//aos:flatbuffer_merge",
102 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800103 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800104 "//aos/network:team_number",
105 "//frc971/vision:v4l2_reader",
106 "//frc971/vision:vision_fbs",
107 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800108 ],
109)
110
111cc_binary(
112 name = "camera_reader",
113 srcs = [
114 "camera_reader_main.cc",
115 ],
116 target_compatible_with = ["@platforms//os:linux"],
117 visibility = ["//y2022:__subpackages__"],
118 deps = [
119 ":camera_reader_lib",
120 "//aos:init",
121 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800122 ],
123)
124
125cc_library(
126 name = "blob_detector_lib",
127 srcs = [
128 "blob_detector.cc",
129 ],
130 hdrs = [
131 "blob_detector.h",
132 ],
133 target_compatible_with = ["@platforms//os:linux"],
134 visibility = ["//y2022:__subpackages__"],
135 deps = [
136 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800137 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800138 "//third_party:opencv",
139 ],
140)
141
milind-u92195982022-01-22 20:29:31 -0800142cc_library(
143 name = "target_estimator_lib",
144 srcs = [
145 "target_estimator.cc",
146 ],
147 hdrs = [
148 "target_estimator.h",
149 ],
150 target_compatible_with = ["@platforms//os:linux"],
151 visibility = ["//y2022:__subpackages__"],
152 deps = [
153 ":target_estimate_fbs",
154 "//third_party:opencv",
155 ],
156)
157
158flatbuffer_cc_library(
159 name = "target_estimate_fbs",
160 srcs = ["target_estimate.fbs"],
161 gen_reflections = 1,
162 target_compatible_with = ["@platforms//os:linux"],
163 visibility = ["//y2022:__subpackages__"],
164)
165
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800166cc_binary(
167 name = "viewer",
168 srcs = [
169 "viewer.cc",
170 ],
171 data = [
Jim Ostrowski977850f2022-01-22 21:04:22 -0800172 "//y2022:config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800173 ],
174 target_compatible_with = ["@platforms//os:linux"],
175 visibility = ["//y2022:__subpackages__"],
176 deps = [
177 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800178 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800179 "//aos:init",
180 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800181 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800182 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800183 ],
184)