Click here to Skip to main content
15,665,486 members
Home / Discussions / Graphics
   

Graphics

 
QuestionDirectShow Editing Pin
Anilkumar K V24-Jun-08 18:56
Anilkumar K V24-Jun-08 18:56 
QuestionCombining Images Pin
aadilali23-Jun-08 18:18
aadilali23-Jun-08 18:18 
AnswerRe: Combining Images Pin
Tim Craig23-Jun-08 19:02
Tim Craig23-Jun-08 19:02 
AnswerRe: Combining Images Pin
Shog924-Jun-08 12:43
sitebuilderShog924-Jun-08 12:43 
QuestionVRML :: interaction with Inline files Pin
some-121-Jun-08 18:47
some-121-Jun-08 18:47 
QuestionSampleGrabber "failded to get sample" Pin
Sergey Malashenko21-Jun-08 3:35
Sergey Malashenko21-Jun-08 3:35 
AnswerRe: SampleGrabber "failded to get sample" Pin
Dan21-Jun-08 8:01
Dan21-Jun-08 8:01 
GeneralRe: SampleGrabber "failded to get sample" Pin
Sergey Malashenko22-Jun-08 0:26
Sergey Malashenko22-Jun-08 0:26 
This code build a graph. The graph consist of the following filters
m_PDF - the filter which is able to receive the IR stream
m_pSampleGrabber - the SampleGrabber filter
m_pNullRenderer - the NullRenderer filter
   .....
   if (!MakeBuilder())
   {
     TRACE(TEXT("Cannot instantiate graph builder"));
     return E_FAIL;
   }
    // make a filtergraph
    hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, 
                            IID_IGraphBuilder, (void **)&m_pGB);
    hr = m_pBuilder->SetFiltergraph(m_pGB);
    hr = AddRTSPFilter(ip);
    // Create the Sample Grabber and add it to the graph
    hr = AddSampleGrabber();
    // Create the Null Renderer filter and add it to the graph
    hr = AddNullRenderer();
    //Connect filters
    hr = ConnectFilters(m_pGB, m_pDF, m_pSampleGrabber);
    hr = ConnectFilters(m_pGB, m_pSampleGrabber, m_pNullRenderer);
    SetFormat(5); //set up the RAW format Y160 (monochrome Y 16-bit per pixel)
    // Query Interface for the media control 
    IMediaControl *pMC = NULL;
    hr = m_pGB->QueryInterface(IID_IMediaControl, reinterpret_cast<pvoid>(&pMC));
    LONG msTimeout = 1000;
    FILTER_STATE pfs;
    
    long lSize = 0;
    ISampleGrabber* pGrab = NULL;  
    if (m_pSampleGrabber)
    {
        // Get sample grabber filter.
	hr = m_pSampleGrabber->QueryInterface( IID_ISampleGrabber, (void**) &pGrab );
        if ( SUCCEEDED( hr ) )
        {
	   // Set one-shot mode and buffering.
           hr = pGrab->SetOneShot(TRUE);
           hr = pGrab->SetBufferSamples(TRUE);
 	}
    }
    // Start the graph.
    hr = pMC->Run();
    
    long evCode; 
    IMediaEventEx*   m_pEvent;
    hr = m_pGB->QueryInterface(IID_IMediaEventEx, (void **)&m_pEvent);
	m_pEvent->WaitForCompletion(INFINITE, &evCode); // Wait till it's done

    // Find the required buffer size.
    long cbBuffer = 0;
    hr = pGrab->GetCurrentBuffer(&cbBuffer, NULL);
    char *pBuffer = new char[cbBuffer];
    if (!pBuffer) 
    {
      // Out of memory. Return an error code.
    }
    hr = pGrab->GetCurrentBuffer(&cbBuffer, (long*)pBuffer);
		
    if (FAILED(hr))
    {
	// Stop parts that ran
	pMC->Stop();
	SAFE_RELEASE( pMC );
	return hr;
    }
    SAFE_RELEASE( pMC );
    .....
</pvoid>


ip - the IP address of camera
IID_IRTSPConfig - Image streaming is set up through RTSP
HRESULT NULL_Capture::AddRTSPFilter(CString ip)
{
  HRESULT hr = S_OK;
  BOOL bMulticast = true;
	
  hr = CoCreateInstance(CLSID_FLIRRTSP, NULL, CLSCTX_INPROC, 
                          IID_IBaseFilter, (void **)&m_pDF);

  CComPtr<irtspconfig> pCfg;
  hr = m_pDF->QueryInterface(IID_IRTSPConfig, (void **)&pCfg);
  hr = pCfg->SetMulticast(bMulticast);
  hr = m_pGB->AddFilter(m_pDF, L"Video Capture");
  return hr;
}
HRESULT NULL_Capture::AddNullRenderer()
{
	HRESULT hr = S_OK;
	
	hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
		IID_IBaseFilter, (LPVOID*) &m_pNullRenderer);

	hr = m_pGB->AddFilter(m_pNullRenderer, L"NullRenderer");
	
	return hr;
}


HRESULT NULL_Capture::AddSampleGrabber()
{
   HRESULT hr = S_OK;
   AM_MEDIA_TYPE* pmt = NULL;
   ISampleGrabber *pCfg = NULL;
   
   if (m_pSampleGrabber == NULL)
   {
     // Create Sample Grabber filter
     hr = CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,                                                                                                            reinterpret_cast<pvoid>(&m_pSampleGrabber));
     hr = m_pSampleGrabber->QueryInterface(IID_ISampleGrabber, (void **)&pCfg);
     // Add sample grabber filter to graph
     hr = m_pGB->AddFilter( m_pSampleGrabber, L"Grabber");           
     AM_MEDIA_TYPE mt;
     hr = pCfg->GetConnectedMediaType(&mt);
		
     ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
     mt.majortype = MEDIATYPE_Video;
     mt.subtype = GUID_MEDIASUBTYPE_Y160;
     hr = pCfg->SetMediaType(&mt);
     //Stop the graph after one shot
     hr = pGrabber->SetOneShot(TRUE);
     //Use buffered mode
     hr = pGrabber->SetBufferSamples(TRUE);
  }
  return hr;
}

BOOL NULL_Capture::MakeBuilder()
{
  HRESULT hr;
    
  if (m_pBuilder)
     return TRUE;   // we have one already

  hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
	CLSCTX_INPROC, IID_ICaptureGraphBuilder2, 
	(void **)&m_pBuilder);
    
  if ( NULL == m_pBuilder ) {
    return FALSE;
  }
  return TRUE;
}
//set up image streaming formats
//fmt == 5  RAW format Y160 (monochrome Y 16-bit per pixel)
HRESULT NULL_Capture::EnumFormats(int fmt)
{
  HRESULT hr;
  IAMStreamConfig *pVSC = NULL;      // for video cap
  hr = m_pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
     &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void **)&pVSC);
  (fmt >= 0)
  {
    VIDEO_STREAM_CONFIG_CAPS scc;
    AM_MEDIA_TYPE *pmt;
    hr = pVSC->GetStreamCaps(fmt, &pmt, (BYTE*)&scc);
    hr = pVSC->SetFormat(pmt);
    DeleteMediaType(pmt);
  }
  return hr;
}
</pvoid></irtspconfig>

Question[Message Deleted] Pin
EvgeniX19-Jun-08 15:26
EvgeniX19-Jun-08 15:26 
QuestionRe: ELLIPSE radius Pin
Shog920-Jun-08 12:54
sitebuilderShog920-Jun-08 12:54 
QuestionCustom Filters w/ DirectShow (C#) Pin
Ed K19-Jun-08 15:01
Ed K19-Jun-08 15:01 
Questionc++ console graphics Pin
geocyt18-Jun-08 2:19
geocyt18-Jun-08 2:19 
AnswerRe: c++ console graphics Pin
Robert.C.Cartaino18-Jun-08 6:15
Robert.C.Cartaino18-Jun-08 6:15 
AnswerRe: c++ console graphics Pin
Shog919-Jun-08 7:47
sitebuilderShog919-Jun-08 7:47 
GeneralRe: c++ console graphics [modified] Pin
El Corazon19-Jun-08 8:39
El Corazon19-Jun-08 8:39 
GeneralRe: c++ console graphics Pin
Shog919-Jun-08 8:43
sitebuilderShog919-Jun-08 8:43 
GeneralRe: c++ console graphics Pin
El Corazon19-Jun-08 8:49
El Corazon19-Jun-08 8:49 
Questionchange color in image Pin
Member 343561416-Jun-08 23:58
Member 343561416-Jun-08 23:58 
AnswerRe: change color in image Pin
Christian Graus17-Jun-08 4:58
protectorChristian Graus17-Jun-08 4:58 
AnswerRe: change color in image Pin
Tim Craig17-Jun-08 18:22
Tim Craig17-Jun-08 18:22 
QuestionHow to get the Codec Name of the Video using directshow Pin
Kuldeep Bhatnagar13-Jun-08 1:23
Kuldeep Bhatnagar13-Jun-08 1:23 
QuestionBitmap.FromFile(filepath) - exception Out of memory Pin
Krishnraj11-Jun-08 23:43
Krishnraj11-Jun-08 23:43 
AnswerNET Framework Bitmap Pin
Baltoro12-Jun-08 5:39
Baltoro12-Jun-08 5:39 
Question[Solved] Cropping empty space around drawing [modified] Pin
kensai11-Jun-08 0:32
kensai11-Jun-08 0:32 
AnswerRe: [Solved] Cropping empty space around drawing Pin
kensai11-Jun-08 2:27
kensai11-Jun-08 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.