blob: 027f9dcce2060990b1d22a2c2c6f929e154e3af0 [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();
Parker Schuh57ba10c2017-03-04 17:46:53 -080030
Parker Schuh24ee58d2017-03-11 16:13:23 -080031 aos::vision::CameraParams params;
Parker Schuh57ba10c2017-03-04 17:46:53 -080032
33 if (argc != 2) {
34 fprintf(stderr, "usage: %s path_to_camera\n", argv[0]);
35 exit(-1);
36 }
37 ImageStream stream(argv[1], params);
38
39 aos::events::EpollLoop loop;
40 loop.Add(&stream);
41 loop.Run();
42}