blob: 3ba24bc4fa7487b39c6aa88dc6602c6ce872cc87 [file] [log] [blame]
Parker Schuh57ba10c2017-03-04 17:46:53 -08001#include "aos/common/logging/implementations.h"
2#include "aos/common/logging/logging.h"
3#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();
30 ::aos::logging::AddImplementation(
31 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}