blob: a431ac86d73570bc434880d05669fd9549dfefdc [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:
8 ImageStream(const std::string &fname, camera::CameraParams params)
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
28int main(int argc, char **argv) {
29 ::aos::logging::Init();
30 ::aos::logging::AddImplementation(
31 new ::aos::logging::StreamLogImplementation(stdout));
32
33 camera::CameraParams params = {.width = 640 * 2,
34 .height = 480 * 2,
35 .exposure = 10,
36 .brightness = 128,
37 .gain = 0,
38 .fps = 30};
39
40 if (argc != 2) {
41 fprintf(stderr, "usage: %s path_to_camera\n", argv[0]);
42 exit(-1);
43 }
44 ImageStream stream(argv[1], params);
45
46 aos::events::EpollLoop loop;
47 loop.Add(&stream);
48 loop.Run();
49}