Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I never typically have struggled in C# until I came across video. It seems one trial after another.

Capturing using a crossbar 8820 device
camera produces PAL video
worse yet video is interlaced
need to grab a frame at a time from the video.


So in Aforge, I can get everything I need, get it all up and running, except interlacing. I have the DeInterlace.ax registered and it can work in directshow, but I get stuck on how to mix the two worlds.
C#
 VideoCaptureDeviceForm form = new VideoCaptureDeviceForm( );

            if ( form.ShowDialog( this ) == DialogResult.OK )
            {
                // create video source
                VideoCaptureDevice videoSource = form.VideoDevice;

                // open it
                OpenVideoSource( videoSource );
            }
private void videoSourcePlayer_NewFrame(object sender, ref Bitmap img)
        {


This is over simplified ofcourse. Now say I want to add a deinterlace filter in ? it seems I can't do it in the Aforge.Video world ? Seems to force me to directshow ? Where I have to fight crossbar, and a host of fun things

<pre lang="c#">        
void buildUSB2820()
{
   InitilizeDirectShow();
   IBaseFilter usb2820 = DirectShowLib.Utils.FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.VideoInputDevice, "USB 2820 Device");
   IBaseFilter crossbar = DirectShowLib.Utils.FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.AMKSCrossbar, "WDM 2820 Crossbar");
  bool success = DirectShowLib.Utils.FilterGraphTools.RenderPin(graphBuilder, crossbar, "0: Video Decoder Out");
  FinishGraph(ref usb2820, "Capture");
 }

private void InitilizeDirectShow()
{
   cleanupCom();
   int hr = 0;
   graphBuilder = (IGraphBuilder)(new FilterGraph());
   captureGraphBuilder = (ICaptureGraphBuilder2)(new CaptureGraphBuilder2());
   hr = captureGraphBuilder.SetFiltergraph(graphBuilder);
   DsError.ThrowExceptionForHR(hr);
   mediaControl = (IMediaControl)graphBuilder;
   videoWindow = (IVideoWindow)graphBuilder;
   mediaEventEx = (IMediaEventEx)graphBuilder;
   // send notification messages to the control window  
   //hr = mediaEventEx.SetNotifyWindow(this.Handle, 0x00008001, IntPtr.Zero);  
   //DsError.ThrowExceptionForHR(hr);  
}

void FinishGraph(ref IBaseFilter filterName, string pinName)
{
  IBaseFilter pAVIDecompressor = null;
  if (deInterlace.Checked)
  {
    IBaseFilter lace = addIbaseFilter(CLSID_delace, "lace");
    connectPins(filterName, pinName, lace, "Input");
    pAVIDecompressor = addIbaseFilter("AVIDecoder", (IBaseFilter)new AVIDec());
    connectPins(lace, "Output", pAVIDecompressor, "XForm In");
  }
  else
  {
    pAVIDecompressor = addIbaseFilter("AVIDecoder", (IBaseFilter)new AVIDec());
    connectPins(filterName, pinName, pAVIDecompressor, "XForm In");
  }

  //IBaseFilter render = addIbaseFilter(CLSID_VideoRenderer, "Renderer");
           // connectPins(color, "XForm Out", render, "VMR Input0");

 IBaseFilter render = addIbaseFilter(CLSID_VideoRenderer, "Renderer");
 connectPins(pAVIDecompressor, "XForm Out", render, "VMR Input0");
            
 // try and add to panel video
 connectRenderToForm(render);
            
 mediaControl.Run();
}


So it seems I get stuck in one world or another. In Aforge, I have no way to add the interlace filter in that I know of. In directShow, I can easily add the deinterlace, but I have a hard time grabbing a frame. I got close adding sampleGrabber in, but got an incompatible pins error trying to connect SampleGrabber to the renderer.

In a simple world I would then connect the directshow to the Aforge VideoSourcePlayer object and I would be super happy. Any ideas ?
Posted

1 solution

hmm, so no ideas ? no comments ?

I guess only thing I can think of is Aforge is opensource, maybe figureout how their videosource works and if I can add a filter myself or something.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900