szaszm commented on a change in pull request #1249:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1249#discussion_r800636829



##########
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 looked into it: It stores a reference to an external variable, and the 
result of `cv::imdecode()` is assigned to that variable, so that looks fine




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to