title: OpenCV GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
body: <p>I am using OpenCV and MPI to edit images (it is for a class) I am breaking the image into n pieces, each of which will be send to a core for processing, the image will be recombined later. So far I am trying to decompose and recompose the image and I get this error</p>
  
  <pre><code>GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
  </code></pre>
  
  <p>many times then I see the first of n sections of the image and a lot of black squares popup.</p>
  
  <p>My main loop consists of </p>
  
  <pre><code>image_descriptor id;    
                  id.process_type = processingType;
                  id.work_row_start = 0;
                  id.work_row_stop = localcount[irank] - 1;
                  id.cols = image.cols;
                  id.rows = localcount[irank];
                  imageCells[irank] = id;
                  y += localcount[irank];
  
                  std::vector&lt;byte&gt; img = matToBytes( image(cv::Rect(x, localstart[irank], image.cols, localcount[irank])) );
  
                  cv::Mat reconImg = bytesToMat(img, image.cols, localcount[irank]);
  
                  cout &lt;&lt; reconImg.rows &lt;&lt; "x" &lt;&lt; reconImg.cols &lt;&lt; endl;
  
                  std::stringstream ss;
  
                  ss &lt;&lt; irank;
  
                  cv::namedWindow("Original Image" + ss.str(), cv::WINDOW_AUTOSIZE );
                  cv::imshow("Image" ,reconImg);
                  cvWaitKey(1000);
  </code></pre>
  
  <p>Where for my image 720x601 <code>localstart</code> will be 0, 180, 360, 540 and <code>localstop</code> is that plus <code>localcount</code> which is always 180 (in this case).</p>
  
  <p>If I simply use </p>
  
  <pre><code>image(cv::Rect(x, localstart[irank], image.cols, localcount[irank]))
  </code></pre>
  
  <p>my image is nicely split into 4 even sections, it is only when I try to convert it to a vector of bytes and back that the error comes up.</p>
  
  <p>My conversion methods are as follows:</p>
  
  <pre><code>    std::vector&lt;byte&gt; matToBytes(cv::Mat image)
  {
      int size = image.total() * image.elemSize();
      std::vector&lt;byte&gt; img_bytes(size);
      std::memcpy(img_bytes.data(),image.data,size * sizeof(byte));
      return img_bytes;
  }
  
  cv::Mat bytesToMat(vector&lt;byte&gt; bytes,int width,int height)
  {
      cv::Mat image = cv::Mat(height,width,CV_8UC3,bytes.data()).clone();
      return image;
  }
  </code></pre>
  
  <p>With these changes to my conversion methods, my image is properly segmented and reconstructed, but I still get that weird error.</p>