title: PvBuffer (Pleora SDK) to - > Opencv buffer
body: <p>I have an issue converting (Pleora SDK)PvBuffer  into an Opencv buffer and process the stream.</p>
  
  <p>this is a sample code i found in (Pleora SDK C++ sample codes)</p>
  
  <pre><code>while ( !PvKbHit() )
  {
      PvBuffer *lBuffer = NULL;
      PvResult lOperationResult;
      PvBufferWriter lBufferWriter;
  
      // Retrieve next buffer
      PvResult lResult = aStream-&gt;RetrieveBuffer( &amp;lBuffer, &amp;lOperationResult, 1000 );
      if ( lResult.IsOK() )
      {
          if ( lOperationResult.IsOK() )
          {
              PvPayloadType lType;
  
              //
              // We now have a valid buffer. This is where you would typically process the buffer.
              // -----------------------------------------------------------------------------------------
  
              lFrameRate-&gt;GetValue( lFrameRateVal );
              lBandwidth-&gt;GetValue( lBandwidthVal );
  
              // If the buffer contains an image, display width and height.
              uint32_t lWidth = 0, lHeight = 0;
              lType = lBuffer-&gt;GetPayloadType();
  
              cout &lt;&lt; fixed &lt;&lt; setprecision( 1 );
              cout &lt;&lt; lDoodle[ lDoodleIndex ];
              cout &lt;&lt; " BlockID: " &lt;&lt; uppercase &lt;&lt; hex &lt;&lt; setfill( '0' ) &lt;&lt; setw( 16 ) &lt;&lt; lBuffer-&gt;GetBlockID();
  
              if ( lType == PvPayloadTypeImage )
              {
                  // Get image specific buffer interface.
                  PvImage *lImage = lBuffer-&gt;GetImage();
  
                  // Read width, height.
                  lWidth = lBuffer-&gt;GetImage()-&gt;GetWidth();
                  lHeight = lBuffer-&gt;GetImage()-&gt;GetHeight();
  
  
  
                  unsigned char * data = lBuffer-&gt;GetImage()-&gt;GetDataPointer();
  
                  Mat OpencvImg = Mat(Size(lWidth, lHeight), CV_8UC1, data);
  
                  threshold(OpencvImg, OpencvImg, 100, 255, 0);
  </code></pre>
  
  <p>if you check the last 3 lines , I am trying to convert the buffer into a Mat but without success . I also would like to display the stream as well .</p>
  
  <p>Thank you in advance. </p>