PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
ICCapturingListener.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2  Program: Plus
3  Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4  See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 // ICCapturingListener.cpp: implementation of the ICCapturingListener class.
8 //----------------------------------------------------------------------------
9 
10 #include "PlusConfigure.h"
11 
12 #include "ICCapturingListener.h"
13 #include <iostream>
14 #include <sstream>
15 
16 using namespace DShowLib;
17 
18 //----------------------------------------------------------------------------
20 {
21  this->ICCapturingSourceNewFrameCallback = NULL;
22 }
23 
24 //----------------------------------------------------------------------------
26 {
27 }
28 
29 //----------------------------------------------------------------------------
34 void ICCapturingListener::overlayCallback( Grabber& caller, smart_ptr<OverlayBitmap> pBitmap, const tsMediaSampleDesc& MediaSampleDesc)
35 {
36  if( pBitmap->getEnable() == true ) // Draw only, if the overlay bitmap is enabled.
37  {
38  std::ostringstream ss;
39  ss << MediaSampleDesc.FrameNumber << " ";
40  pBitmap->drawText( RGB(255,0,0), 0, 0, ss.str().c_str() );
41  }
42 }
43 
44 //----------------------------------------------------------------------------
47 void ICCapturingListener::frameReady( Grabber& caller, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
48 {
49  if (this->ICCapturingSourceNewFrameCallback != NULL)
50  {
51  pBuffer->lock();
52  (*ICCapturingSourceNewFrameCallback)( pBuffer->getPtr(), pBuffer->getBufferSize(), currFrame );
53  pBuffer->unlock();
54  }
55 }
56 
57 //----------------------------------------------------------------------------
64 void ICCapturingListener::setBufferSize( unsigned long NumBuffers )
65 {
66  m_BufferWritten.resize( NumBuffers, false );
67 }
68 
69 //----------------------------------------------------------------------------
72 void ICCapturingListener::saveImage( smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
73 {
74  if( currFrame < m_BufferWritten.size() )
75  {
76  std::ostringstream ss;
77  ss << "image" << currFrame << ".bmp";
78  saveToFileBMP( *pBuffer, ss.str().c_str() );
79  m_BufferWritten.at( currFrame ) = true;
80  }
81 }
void saveImage(smart_ptr< DShowLib::MemBuffer > pBuffer, DWORD currFrame)
unsigned long DWORD
Definition: ATC3DGm.h:451
void setBufferSize(unsigned long NumBuffers)
virtual void overlayCallback(DShowLib::Grabber &caller, smart_ptr< DShowLib::OverlayBitmap > pBitmap, const DShowLib::tsMediaSampleDesc &MediaSampleDesc)
virtual void frameReady(DShowLib::Grabber &caller, smart_ptr< DShowLib::MemBuffer > pBuffer, DWORD FrameNumber)