Parker Schuh | 57ba10c | 2017-03-04 17:46:53 -0800 | [diff] [blame] | 1 | #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 | |
| 6 | class ImageStream : public aos::vision::ImageStreamEvent { |
| 7 | public: |
Parker Schuh | 24ee58d | 2017-03-11 16:13:23 -0800 | [diff] [blame] | 8 | ImageStream(const std::string &fname, aos::vision::CameraParams params) |
Parker Schuh | 57ba10c | 2017-03-04 17:46:53 -0800 | [diff] [blame] | 9 | : 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 |
| 28 | int main(int argc, char **argv) { |
| 29 | ::aos::logging::Init(); |
| 30 | ::aos::logging::AddImplementation( |
| 31 | new ::aos::logging::StreamLogImplementation(stdout)); |
| 32 | |
Parker Schuh | 24ee58d | 2017-03-11 16:13:23 -0800 | [diff] [blame] | 33 | aos::vision::CameraParams params; |
Parker Schuh | 57ba10c | 2017-03-04 17:46:53 -0800 | [diff] [blame] | 34 | |
| 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 | } |