You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/02/03 00:33:23 UTC
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1249: MINIFICPP-1669 Use std::byte for buffers
szaszm commented on a change in pull request #1249:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1249#discussion_r798125860
##########
File path: extensions/opencv/FrameIO.h
##########
@@ -57,18 +57,17 @@ class FrameReadCallback : public InputStreamCallback {
~FrameReadCallback() override = default;
int64_t process(const std::shared_ptr<io::BaseStream>& stream) override {
- int64_t ret = 0;
- image_buf_.resize(stream->size());
- ret = stream->read(image_buf_.data(), static_cast<int>(stream->size()));
- if (ret < 0 || static_cast<std::size_t>(ret) != stream->size()) {
+ std::vector<uchar> image_buf;
+ image_buf.resize(stream->size());
+ const auto ret = stream->read(gsl::make_span(image_buf).as_span<std::byte>());
+ if (ret != stream->size()) {
throw std::runtime_error("ImageReadCallback failed to fully read flow file input stream");
}
- image_mat_ = cv::imdecode(image_buf_, -1);
- return ret;
+ image_mat_ = cv::imdecode(image_buf, -1);
+ return gsl::narrow<int64_t>(ret);
}
private:
- std::vector<uchar> image_buf_;
cv::Mat &image_mat_;
Review comment:
I got rid of this file in my other PR, that's why I tried to keep the changes minimal here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org