Maxwell Henderson | 97d0ab2 | 2024-03-16 16:53:10 -0700 | [diff] [blame^] | 1 | #include "gflags/gflags.h" |
| 2 | #include "opencv2/imgproc.hpp" |
| 3 | #include <opencv2/highgui.hpp> |
| 4 | |
| 5 | #include "aos/events/logging/log_reader.h" |
| 6 | #include "aos/events/logging/log_writer.h" |
| 7 | #include "aos/events/simulated_event_loop.h" |
| 8 | #include "aos/init.h" |
| 9 | #include "aos/json_to_flatbuffer.h" |
| 10 | #include "aos/logging/log_message_generated.h" |
| 11 | #include "frc971/vision/vision_generated.h" |
| 12 | |
| 13 | DEFINE_string(node, "orin1", "The node to view the log from"); |
| 14 | DEFINE_string(channel, "/camera0", "The channel to view the log from"); |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | aos::InitGoogle(&argc, &argv); |
| 18 | |
| 19 | // open logfiles |
| 20 | aos::logger::LogReader reader( |
| 21 | aos::logger::SortParts(aos::logger::FindLogs(argc, argv))); |
| 22 | |
| 23 | aos::SimulatedEventLoopFactory factory(reader.configuration()); |
| 24 | reader.Register(&factory); |
| 25 | |
| 26 | aos::NodeEventLoopFactory *node = factory.GetNodeEventLoopFactory(FLAGS_node); |
| 27 | |
| 28 | std::unique_ptr<aos::EventLoop> image_loop = node->MakeEventLoop("image"); |
| 29 | image_loop->MakeWatcher( |
| 30 | "/" + FLAGS_node + "/" + FLAGS_channel, |
| 31 | [](const frc971::vision::CameraImage &msg) { |
| 32 | cv::Mat color_image(cv::Size(msg.cols(), msg.rows()), CV_8UC2, |
| 33 | (void *)msg.data()->data()); |
| 34 | |
| 35 | cv::Mat bgr(color_image.size(), CV_8UC3); |
| 36 | cv::cvtColor(color_image, bgr, cv::COLOR_YUV2BGR_YUYV); |
| 37 | |
| 38 | cv::imshow("Replay", bgr); |
| 39 | cv::waitKey(1); |
| 40 | }); |
| 41 | |
| 42 | factory.Run(); |
| 43 | |
| 44 | reader.Deregister(); |
| 45 | |
| 46 | return 0; |
| 47 | } |