title: std::vector of cv::Mat
body: <p>Continuing with my computer vision stuff I get to a point where I am computing descriptors for one patch in N cameras.
  The problem is when I do the computation of the descriptor the function in OpenCV is</p>
  
  <pre><code>descriptor.compute(image, vecKeypoints, matDescriptors);
  </code></pre>
  
  <p>where <strong>vecKeypoints</strong> is a vector of <code>cv::KeyPoints</code> and <strong>matDescriptors</strong> is a <code>cv::Mat</code> that, according to OpenCV's doc it gets populated with the computed descriptors.</p>
  
  <p>As I have N cameras, I compute several descriptors per camera, so I am storing K descriptors per each of the N cameras. Therefore I created an vector of descriptors (i.e. matrices)</p>
  
  <pre><code>std::vector&lt;cv::Mat&gt; descriptors;
  </code></pre>
  
  <p>At each iteration I compute a new <strong>matDescriptors</strong> and push it to the vector <code>descriptors</code>. The problem I'm seeing is that the address where the data is stores for each of the <strong>matDescriptors</strong> is the same for every element in the vector <strong>descriptors</strong></p>
  
  <p>As far as I know, when I do <code>vector.push_back(arg)</code> a copy of the arg is made and stored in the vector, then, why am I having the same address? Shouldn't <code>&amp;(descriptors[0].data)</code> be different than <code>&amp;(descriptors[1].data)</code>?</p>
  
  <p>Heres a general view of the code</p>
  
  <pre><code>std::vector&lt;Pixel&gt; patchPos;
  std::vector&lt;Pixel&gt; disparityPatches;
  
  //cv::Ptr&lt;cv::DescriptorExtractor&gt; descriptor = cv::DescriptorExtractor::create("ORB");
  cv::ORB descriptor(0, 1.2f, 8, 0);
  std::vector&lt;cv::Mat&gt; camsDescriptors;
  std::vector&lt;cv::Mat&gt; refsDescriptors;
  
  uint iPatchV = 0;
  uint iPatchH = 0;
  
  // FOR EACH BLOCK OF PATCHES (there are 'blockSize' patches in one block)
  for (uint iBlock = 0; iBlock &lt; nBlocks; iBlock++)
  {
      // FOR EACH PATCH IN THE BLOCK
      for(uint iPatch = iBlock*blockSize; iPatch &lt; (iBlock*blockSize)+blockSize; iPatch++)
      {
          // GET THE POSITION OF THE upper-left CORNER(row, col) AND
          // STORE THE COORDINATES OF THE PIXELS INSIDE THE PATCH
          for (uint pRow = (iPatch*patchStep)/camRef-&gt;getWidth(), pdRow = 0; pRow &lt; iPatchV+patchSize; pRow++, pdRow++)
          {
              for (uint pCol = (iPatch*patchStep)%camRef-&gt;getWidth(), pdCol = 0; pCol &lt; iPatchH+patchSize; pCol++, pdCol++)
              {
                  patchPos.push_back(Pixel(pCol, pRow));
              }
          }
  
          // KEYPOINT TO GET THE DESCRIPTOR OF THE CURRENT PATCH IN THE REFERENCE CAMERA
          std::vector&lt;cv::KeyPoint&gt; refPatchKeyPoint;
          //          patchCenter*patchSize+patchCenter IS the index of the center pixel after 'linearizing' the patch
          refPatchKeyPoint.push_back(cv::KeyPoint(patchPos[patchCenter*patchSize+patchCenter].getX(),
                                                  patchPos[patchCenter*patchSize+patchCenter].getY(), patchSize));
  
          // COMPUTE THE DESCRIPTOR OF THE PREVIOUS KEYPOINT
          cv::Mat d;
          descriptor.compute(Image(camRef-&gt;getHeight(), camRef-&gt;getWidth(), CV_8U, (uchar*)camRef-&gt;getData()),
                             refPatchKeyPoint, d);
          refsDescriptors.push_back(d); // This is OK, address X has data of 'd'
  
          //FOR EVERY OTHER CAMERA
          for (uint iCam = 0; iCam &lt; nTotalCams-1; iCam++)
          {
              //FOR EVERY DISPARITY LEVEL
              for (uint iDispLvl = 0; iDispLvl &lt; disparityLevels; iDispLvl++)
              {
                  ...
                  ...
  
                  //COMPUTE THE DISPARITY FOR EACH OF THE PIXEL COORDINATES IN THE PATCH
                  for (uint iPatchPos = 0; iPatchPos &lt; patchPos.size(); iPatchPos++)
                  {
                      disparityPatches.push_back(Pixel(patchPos[iPatchPos].getX()+dispNodeX, patchPos[iPatchPos].getY()+dispNodeY));
                  }
              }
  
              // KEYPOINTS TO GET THE DESCRIPTORS OF THE 50.DISPAIRED-PATCHES IN CURRENT CAMERA
              ...
              ...
              descriptor.compute(Image(camList[iCam]-&gt;getHeight(), camList[iCam]-&gt;getWidth(), CV_8U, (uchar*)camList[iCam]-&gt;getData()),
                                 camPatchKeyPoints, d);
              // First time this executes is OK, address is different from the previous 'd'
              // Second time, the address is the same as the previously pushed 'd'
              camsDescriptors.push_back(d);
  
              disparityPatches.clear();
              camPatchKeyPoints.clear();
          }
      }
  }
  </code></pre>