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.
VideoCaptureDeviceForm form = new VideoCaptureDeviceForm( );
if ( form.ShowDialog( this ) == DialogResult.OK )
{
VideoCaptureDevice videoSource = form.VideoDevice;
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;
}
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(pAVIDecompressor, "XForm Out", render, "VMR Input0");
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 ?