title: Access output of a c++ code which is called in python with suprocess.check_output
body: <p>I have a python code which is worked on images. for some performance reasons, I decided to use a C++ program which has a function that hasn't any input argument but its output is an image data in cv::mat format.</p>
  
  <p>I want to access to this output data from my python code.</p>
  
  <p>I call this c++ code using subprocess.check_output.</p>
  
  <p>how can I access the image data from my python code?</p>
  
  <p>this is part of my python's code:</p>
  
  <pre><code>        s1 = subprocess.check_output("g++ watermark.cpp `pkg-config --cflags --libs opencv` -lm  -o out2;./out2",
                                       shell=True)
  
          print("TYPE ==&gt; ", type(s1), " size : ", sys.getsizeof(s1))
  
          print(s1.decode("utf-8"))
  
  </code></pre>
  
  <p>and this is my c++ code:</p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  
  #include &lt;iostream&gt;
  
  
  using namespace std;
  using namespace cv;
  
  Mat watermark()
  {
          cout &lt;&lt; " This is a simple watermark !";
          Mat source_img, watermark_img;
          source_img = imread("source.jpg");
          watermark_img = imread("my_logo.png");
  
          int width = watermark_img.size().width;
          int height = watermark_img.size().height;
          int x_pos = rand() % (source_img.size().width - width - 10) + 10;
          int y_pos = rand() % (source_img.size().height - height - 10) + 10;
  
          cv::Rect pos = cv::Rect(x_pos, y_pos, width, height);
          double alpha = 0.5;
  
          addWeighted(source_img(pos), alpha, watermark_img, 1 - alpha, 0.0, source_img(pos));
  
          return source_img;
  }
  
  
  int main()
  {
          Mat new_image = watermark();
          return 0;
  }
  
  
  </code></pre>
  
  <p>I want to access to new_image data in main function.</p>
  
  <p>when I run my python code, it is worked completely and I see this message: " This is a simple watermark !"</p>
  
  <p>but I don't know how to access image data to use it in my python's code to show it.</p>
  
  <p>Does anybody have any idea to help me?</p>