Update formatting to clang-format 16 (#5370)

This commit is contained in:
Tyler Veness
2023-05-31 22:10:53 -07:00
committed by GitHub
parent a94a998002
commit 5fac18ff4a
48 changed files with 654 additions and 434 deletions

View File

@@ -22,9 +22,7 @@ class Image {
public:
#ifndef __linux__
explicit Image(size_t capacity) {
m_data.reserve(capacity);
}
explicit Image(size_t capacity) { m_data.reserve(capacity); }
#else
explicit Image(size_t capacity)
: m_data{capacity, default_init_allocator<uchar>{}} {
@@ -39,35 +37,19 @@ class Image {
operator std::string_view() const { // NOLINT
return str();
}
std::string_view str() const {
return {data(), size()};
}
size_t capacity() const {
return m_data.capacity();
}
std::string_view str() const { return {data(), size()}; }
size_t capacity() const { return m_data.capacity(); }
const char* data() const {
return reinterpret_cast<const char*>(m_data.data());
}
char* data() {
return reinterpret_cast<char*>(m_data.data());
}
size_t size() const {
return m_data.size();
}
char* data() { return reinterpret_cast<char*>(m_data.data()); }
size_t size() const { return m_data.size(); }
const std::vector<uchar>& vec() const {
return m_data;
}
std::vector<uchar>& vec() {
return m_data;
}
const std::vector<uchar>& vec() const { return m_data; }
std::vector<uchar>& vec() { return m_data; }
void resize(size_t size) {
m_data.resize(size);
}
void SetSize(size_t size) {
m_data.resize(size);
}
void resize(size_t size) { m_data.resize(size); }
void SetSize(size_t size) { m_data.resize(size); }
cv::Mat AsMat() {
int type;
@@ -90,9 +72,7 @@ class Image {
return cv::Mat{height, width, type, m_data.data()};
}
cv::_InputArray AsInputArray() {
return cv::_InputArray{m_data};
}
cv::_InputArray AsInputArray() { return cv::_InputArray{m_data}; }
bool Is(int width_, int height_) {
return width == width_ && height == height_;
@@ -114,12 +94,8 @@ class Image {
bool IsLarger(const Image& oth) {
return width >= oth.width && height >= oth.height;
}
bool IsSmaller(int width_, int height_) {
return !IsLarger(width_, height_);
}
bool IsSmaller(const Image& oth) {
return !IsLarger(oth);
}
bool IsSmaller(int width_, int height_) { return !IsLarger(width_, height_); }
bool IsSmaller(const Image& oth) { return !IsLarger(oth); }
private:
std::vector<uchar> m_data;

View File

@@ -152,8 +152,8 @@ class CvSink : public ImageSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrame(cv::Mat& image,
double timeout = 0.225) const;
[[nodiscard]]
uint64_t GrabFrame(cv::Mat& image, double timeout = 0.225) const;
/**
* Wait for the next frame and get the image. May block forever.
@@ -163,7 +163,8 @@ class CvSink : public ImageSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrameNoTimeout(cv::Mat& image) const;
[[nodiscard]]
uint64_t GrabFrameNoTimeout(cv::Mat& image) const;
};
inline CvSource::CvSource(std::string_view name, const VideoMode& mode) {

View File

@@ -174,8 +174,8 @@ class RawSink : public ImageSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrame(RawFrame& image,
double timeout = 0.225) const;
[[nodiscard]]
uint64_t GrabFrame(RawFrame& image, double timeout = 0.225) const;
/**
* Wait for the next frame and get the image. May block forever.
@@ -185,7 +185,8 @@ class RawSink : public ImageSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrameNoTimeout(RawFrame& image) const;
[[nodiscard]]
uint64_t GrabFrameNoTimeout(RawFrame& image) const;
};
inline RawSource::RawSource(std::string_view name, const VideoMode& mode) {

View File

@@ -111,7 +111,8 @@ class RawCvSink : public RawSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrame(cv::Mat& image, double timeout = 0.225);
[[nodiscard]]
uint64_t GrabFrame(cv::Mat& image, double timeout = 0.225);
/**
* Wait for the next frame and get the image. May block forever.
@@ -121,7 +122,8 @@ class RawCvSink : public RawSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrameNoTimeout(cv::Mat& image);
[[nodiscard]]
uint64_t GrabFrameNoTimeout(cv::Mat& image);
/**
* Wait for the next frame and get the image.
@@ -132,8 +134,8 @@ class RawCvSink : public RawSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrameDirect(cv::Mat& image,
double timeout = 0.225);
[[nodiscard]]
uint64_t GrabFrameDirect(cv::Mat& image, double timeout = 0.225);
/**
* Wait for the next frame and get the image. May block forever.
@@ -143,7 +145,8 @@ class RawCvSink : public RawSink {
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]] uint64_t GrabFrameNoTimeoutDirect(cv::Mat& image);
[[nodiscard]]
uint64_t GrabFrameNoTimeoutDirect(cv::Mat& image);
private:
RawFrame rawFrame;