blob: f4b384244d081f43e59af58298668a28e3fe31fc [file] [log] [blame]
Austin Schuh99f7c6a2024-06-25 22:07:44 -07001#include "absl/flags/flag.h"
Yash Maheshwari997b3312024-05-18 17:08:44 -07002#include "opencv2/highgui.hpp"
Maxwell Henderson97d0ab22024-03-16 16:53:10 -07003#include "opencv2/imgproc.hpp"
Maxwell Henderson97d0ab22024-03-16 16:53:10 -07004
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
Austin Schuh99f7c6a2024-06-25 22:07:44 -070013ABSL_FLAG(std::string, node, "orin1", "The node to view the log from");
14ABSL_FLAG(std::string, channel, "/camera0", "The channel to view the log from");
Maxwell Henderson97d0ab22024-03-16 16:53:10 -070015
16int 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
Austin Schuh99f7c6a2024-06-25 22:07:44 -070026 aos::NodeEventLoopFactory *node =
27 factory.GetNodeEventLoopFactory(absl::GetFlag(FLAGS_node));
Maxwell Henderson97d0ab22024-03-16 16:53:10 -070028
29 std::unique_ptr<aos::EventLoop> image_loop = node->MakeEventLoop("image");
30 image_loop->MakeWatcher(
Austin Schuh99f7c6a2024-06-25 22:07:44 -070031 "/" + absl::GetFlag(FLAGS_node) + "/" + absl::GetFlag(FLAGS_channel),
Maxwell Henderson97d0ab22024-03-16 16:53:10 -070032 [](const frc971::vision::CameraImage &msg) {
33 cv::Mat color_image(cv::Size(msg.cols(), msg.rows()), CV_8UC2,
34 (void *)msg.data()->data());
35
36 cv::Mat bgr(color_image.size(), CV_8UC3);
37 cv::cvtColor(color_image, bgr, cv::COLOR_YUV2BGR_YUYV);
38
39 cv::imshow("Replay", bgr);
40 cv::waitKey(1);
41 });
42
43 factory.Run();
44
45 reader.Deregister();
46
47 return 0;
48}