Correctly initialize legacy v4l2 reader image size
Fixes v4l2 crash for raspberry pis.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: I6aaee295af7dadda01ad5470a8af596473425749
diff --git a/frc971/vision/v4l2_reader.h b/frc971/vision/v4l2_reader.h
index 334ad81..85ca475 100644
--- a/frc971/vision/v4l2_reader.h
+++ b/frc971/vision/v4l2_reader.h
@@ -61,7 +61,10 @@
// TODO(Brian): This concept won't exist once we start using variable-size
// H.264 frames.
- size_t ImageSize() const { return rows_ * cols_ * 2 /* bytes per pixel */; }
+ size_t ImageSize() const { return ImageSize(rows_, cols_); }
+ static size_t ImageSize(int rows, int cols) {
+ return rows * cols * 2 /* bytes per pixel */;
+ }
const aos::ScopedFD &fd() { return fd_; };
@@ -132,10 +135,6 @@
class V4L2Reader : public V4L2ReaderBase {
public:
V4L2Reader(aos::EventLoop *event_loop, const std::string &device_name);
-
- private:
- const int rows_ = 480;
- const int cols_ = 640;
};
// Rockpi specific v4l2 reader. This assumes that the media device has been