Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding an ISampleGrabber filter to my current graph
    primarykey
    data
    text
    <p>I am currently trying to add a ISampleGrabber filter to my program. Currently the program captures and displays a preview to my windows form however when i try to add my own ISampleGrabber filter using others examples the webcam section of the program stops working completely.</p> <pre><code> IVideoWindow videoWindow = null; IMediaControl mediaControl = null; IMediaEventEx mediaEventEx = null; IGraphBuilder graphBuilder = null; ICaptureGraphBuilder2 captureGraphBuilder = null; IBaseFilter baseFilterForSampleGrabber; ISampleGrabber sampleGrabber; AMMediaType mediaType; VideoInfoHeader videoInfoHeader; public void capturePreview() { int hr = 0; IBaseFilter baseFilter = null; try { interfaces(); hr = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder); DsError.ThrowExceptionForHR(hr); baseFilter = getListOfDevices(); hr = this.graphBuilder.AddFilter(baseFilter, "Webcam"); DsError.ThrowExceptionForHR(hr); sampleGrabber = new SampleGrabber() as ISampleGrabber; baseFilterForSampleGrabber = (IBaseFilter)new SampleGrabber(); if (baseFilterForSampleGrabber == null) { Marshal.ReleaseComObject(sampleGrabber); sampleGrabber = null; } mediaType = new AMMediaType(); mediaType.majorType = MediaType.Video; mediaType.subType = MediaSubType.RGB24; mediaType.formatType = FormatType.VideoInfo; //int width = videoInfoHeader.BmiHeader.Width; //int height = videoInfoHeader.BmiHeader.Height; //int size = videoInfoHeader.BmiHeader.ImageSize; //mediaType.formatPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(videoInfoHeader)); //Marshal.StructureToPtr(videoInfoHeader, mediaType.formatPtr, false); hr = sampleGrabber.SetMediaType(mediaType); DsUtils.FreeAMMediaType(mediaType); hr = graphBuilder.AddFilter(baseFilterForSampleGrabber, "ISampleGrabber Filter"); DsError.ThrowExceptionForHR(hr); hr = this.captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, baseFilter, baseFilterForSampleGrabber, null); DsError.ThrowExceptionForHR(hr); Marshal.ReleaseComObject(baseFilter); videoWindowSetup(); hr = sampleGrabber.SetBufferSamples(true); DsError.ThrowExceptionForHR(hr); hr = this.mediaControl.Run(); DsError.ThrowExceptionForHR(hr); } catch { MessageBox.Show("Error...Try restart"); } } </code></pre> <p>The above code contains my current graph along with the starting ISampleGrabber code I see repeated in every example, however when I add the commented code this is when the program stops. I do not know where the issue is and presume I should at least get the basics sorted before continuing adding on the graph.</p> <p>If I resolve this problem any further help on what else I require to complete this graph would be very helpful, I aim to convert the frames captured into bitmaps so I can immediately edit them, such as add a crosshair, and show them in the windows form once edited straight away.</p> <p>Any help is appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload