title: Basler Pylon 4 SDK and OPENCV 2.4.9, CPylonImage to Mat
body: <p>I am currently developing a machine vision application using Basler camera acA1300-30gc. For this I am working with Basler Pylon 4 and OPENCV version 2.4.9 and some problems have shown up. I am trying to capture an image using the Pylon SDK and convert it to Mat format for further analysis. Due to processing time restrictions my goal is to avoid saving the image to the hard drive but to analyze it on-the-fly.</p>
  
  <p>In the following code I try to capture the image, convert it to Mat format and display it on a new window, but the window I get is blank. I will be very grateful if some one could help me please identifying my mistake(s), or explaining how could I reach my goal in a different way. (I probably should add that the camera is properly working and that I have been able to save images to the hard drive).</p>
  
  <p>Thanks.</p>
  
  <p>here is my code:</p>
  
  <pre><code>    PylonAutoInitTerm autoInitTerm;
  
      try
      {
          CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
          cout &lt;&lt; "Dispositivo usado:"&lt;&lt;camera.GetDeviceInfo().GetModelName()&lt;&lt;endl;
  
          CGrabResultPtr ptrGrabResult;
  
          camera.GrabOne(500,ptrGrabResult,TimeoutHandling_ThrowException);
  
          if(ptrGrabResult-&gt;GrabSucceeded())
          {
              CPylonImage target;
  
              CImageFormatConverter converter;
              converter.OutputPixelFormat=PixelType_RGB8packed;
              converter.OutputBitAlignment=OutputBitAlignment_MsbAligned;
  
              converter.Convert(target,ptrGrabResult);
  
              Mat image(target.GetWidth(),target.GetHeight(),CV_8UC1,target.GetBuffer(),Mat::AUTO_STEP);
  
              if(image.empty())
              {
                  cout &lt;&lt; "No se pudo cargar la imagen Mat" &lt;&lt; endl;
                  return -1;
              }
              cout &lt;&lt; "La imagen se presenta en la ventana *Captura*" &lt;&lt; endl;
  
              namedWindow("Captura",WINDOW_AUTOSIZE);
              imshow( "Captura", image );
  
          }
          else
          {
              cout&lt;&lt;"Error: "&lt;&lt;ptrGrabResult-&gt;GetErrorCode()&lt;&lt;" "&lt;&lt;ptrGrabResult-&gt;GetErrorDescription()&lt;&lt;endl;
          }
      }
  </code></pre>