blob: e1d5fc5a783dcf497641c03f281fc41c99aa9f3f [file] [log] [blame]
John Park33858a32018-09-28 23:05:48 -07001#include "aos/logging/implementations.h"
2#include "aos/logging/logging.h"
Parker Schuh57ba10c2017-03-04 17:46:53 -08003#include "aos/vision/events/epoll_events.h"
4#include "aos/vision/image/image_stream.h"
5
6class ImageStream : public aos::vision::ImageStreamEvent {
7 public:
Parker Schuh24ee58d2017-03-11 16:13:23 -08008 ImageStream(const std::string &fname, aos::vision::CameraParams params)
Parker Schuh57ba10c2017-03-04 17:46:53 -08009 : ImageStreamEvent(fname, params) {}
10 void ProcessImage(aos::vision::DataRef /*data*/,
11 aos::monotonic_clock::time_point) override {
12 if (i_ > 20) {
13 exit(0);
14 }
15 ++i_;
16 }
17
18 private:
19 int i_ = 0;
20};
21
22// camera_primer drops the first 20 frames. This is to get around issues
23// where the first N frames from the camera are garbage. Thus each year
24// you should write a startup script like so:
25//
26// camera_primer
27// target_sender
28int main(int argc, char **argv) {
29 ::aos::logging::Init();
Tyler Chatow4b471e12020-01-05 20:19:36 -080030 ::aos::logging::SetImplementation(
Parker Schuh57ba10c2017-03-04 17:46:53 -080031 new ::aos::logging::StreamLogImplementation(stdout));
32
Parker Schuh24ee58d2017-03-11 16:13:23 -080033 aos::vision::CameraParams params;
Parker Schuh57ba10c2017-03-04 17:46:53 -080034
35 if (argc != 2) {
36 fprintf(stderr, "usage: %s path_to_camera\n", argv[0]);
37 exit(-1);
38 }
39 ImageStream stream(argv[1], params);
40
41 aos::events::EpollLoop loop;
42 loop.Add(&stream);
43 loop.Run();
44}