本文整理汇总了C#中ISampleGrabber类的典型用法代码示例。如果您正苦于以下问题:C# ISampleGrabber类的具体用法?C# ISampleGrabber怎么用?C# ISampleGrabber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISampleGrabber类属于命名空间,在下文中一共展示了ISampleGrabber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Build
/// <summary>
/// Creates the filter.
/// </summary>
/// <returns>New filter instance.</returns>
public IBaseFilter Build()
{
sampleGrabber = (ISampleGrabber) new SampleGrabber();
ConfigSampleGrabber(sampleGrabber);
sampleGrabber.SetCallback(filter, SampleGrabberCallbackMethod);
return (IBaseFilter) sampleGrabber;
}
开发者ID:alex-chekhachev,项目名称:WebcamCapture.NET,代码行数:13,代码来源:FilterBuilder.cs
示例2: SampleGrabberHelper
/// <summary>
/// Default constructor for <see cref="SampleGrabberHelper"/> class.
/// </summary>
/// <param name="sampleGrabber">Pointer to COM-interface ISampleGrabber.</param>
/// <param name="buffer_samples_of_current_frame">Flag means should helper store (buffer) samples of current frame or not.</param>
public SampleGrabberHelper(ISampleGrabber sampleGrabber, bool buffer_samples_of_current_frame)
{
m_SampleGrabber = sampleGrabber;
m_bBufferSamplesOfCurrentFrame = buffer_samples_of_current_frame;
// tell the callback to ignore new images
m_PictureReady = new ManualResetEvent(false);
}
开发者ID:robotsrulz,项目名称:Sardauscan,代码行数:14,代码来源:SampleGrabberHelper.cs
示例3: MainForm
public MainForm()
{
InitializeComponent();
graphbuilder = (IGraphBuilder)new FilterGraph();
samplegrabber = (ISampleGrabber)new SampleGrabber();
graphbuilder.AddFilter((IBaseFilter)samplegrabber, "samplegrabber");
mt = new AMMediaType();
mt.majorType = MediaType.Video;
mt.subType = MediaSubType.RGB24;
mt.formatType = FormatType.VideoInfo;
samplegrabber.SetMediaType(mt);
PrintSeconds();
}
开发者ID:sasha237,项目名称:VideoAnalyser,代码行数:14,代码来源:MainForm.cs
示例4: ConfigSampleGrabber
private static void ConfigSampleGrabber(ISampleGrabber sb)
{
// set the media type
var media = new AMMediaType
{
majorType = MediaType.Video,
subType = MediaSubType.RGB24,
formatType = FormatType.VideoInfo
};
// that's the call to the ISampleGrabber interface
sb.SetMediaType(media);
DsUtils.FreeAMMediaType(media);
}
开发者ID:alex-chekhachev,项目名称:WebcamCapture.NET,代码行数:15,代码来源:FilterBuilder.cs
示例5: CaptureForm
public CaptureForm()
{
InitializeComponent();
graph_builder = (IGraphBuilder)new FilterGraph();
media_control = (IMediaControl)graph_builder;
events = (IMediaEventEx)graph_builder;
grabber = (ISampleGrabber)new SampleGrabber();
AMMediaType media_type = new AMMediaType();
media_type.majorType = MediaType.Video;
media_type.subType = MediaSubType.RGB24;
grabber.SetMediaType( media_type );
grabber.SetCallback( this, 1 );
cbDevices.Items.AddRange( GetDevices( FilterCategory.VideoInputDevice ) );
}
开发者ID:pbalint,项目名称:Playground,代码行数:17,代码来源:CaptureForm.cs
示例6: SaveSizeInfo
private void SaveSizeInfo(ISampleGrabber sampGrabber)
{
int hr;
// Get the media type from the SampleGrabber
AMMediaType media = new AMMediaType();
hr = sampGrabber.GetConnectedMediaType(media);
DsError.ThrowExceptionForHR(hr);
if ((media.formatType != FormatType.VideoInfo) || (media.formatPtr == IntPtr.Zero))
{
throw new NotSupportedException("Unknown Grabber Media Format");
}
// Grab the size info
VideoInfoHeader videoInfoHeader =
(VideoInfoHeader) Marshal.PtrToStructure(media.formatPtr, typeof (VideoInfoHeader));
m_videoWidth = videoInfoHeader.BmiHeader.Width;
m_videoHeight = videoInfoHeader.BmiHeader.Height;
m_stride = m_videoWidth*(videoInfoHeader.BmiHeader.BitCount/8);
m_avgtimeperframe = videoInfoHeader.AvgTimePerFrame;
DsUtils.FreeAMMediaType(media);
media = null;
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:25,代码来源:OSDVideo.cs
示例7: SetupGraph
// Build the capture graph for grabber and renderer.</summary>
// (Control to show video in, Filename to play)
private void SetupGraph(string FileName)
{
int hr;
// Get the graphbuilder object
m_FilterGraph = new FilterGraph() as IFilterGraph2;
// Get a ICaptureGraphBuilder2 to help build the graph
ICaptureGraphBuilder2 icgb2 = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
try
{
// Link the ICaptureGraphBuilder2 to the IFilterGraph2
hr = icgb2.SetFiltergraph(m_FilterGraph);
DsError.ThrowExceptionForHR(hr);
// Add the filters necessary to render the file. This function will
// work with a number of different file types.
IBaseFilter sourceFilter = null;
hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
DsError.ThrowExceptionForHR(hr);
// Get the SampleGrabber interface
m_sampGrabber = (ISampleGrabber)new SampleGrabber();
IBaseFilter baseGrabFlt = (IBaseFilter)m_sampGrabber;
// Configure the Sample Grabber
ConfigureSampleGrabber(m_sampGrabber);
// Add it to the filter
hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
// Add the null renderer to the graph
IBaseFilter nullrenderer = new NullRenderer() as IBaseFilter;
hr = m_FilterGraph.AddFilter(nullrenderer, "Null renderer");
DsError.ThrowExceptionForHR(hr);
// Connect the pieces together, use the default renderer
hr = icgb2.RenderStream(null, null, sourceFilter, baseGrabFlt, nullrenderer);
DsError.ThrowExceptionForHR(hr);
// Now that the graph is built, read the dimensions of the bitmaps we'll be getting
SaveSizeInfo(m_sampGrabber);
// Grab some other interfaces
m_mediaEvent = m_FilterGraph as IMediaEvent;
m_mediaCtrl = m_FilterGraph as IMediaControl;
}
finally
{
if (icgb2 != null)
{
Marshal.ReleaseComObject(icgb2);
icgb2 = null;
}
}
#if DEBUG
// Double check to make sure we aren't releasing something
// important.
GC.Collect();
GC.WaitForPendingFinalizers();
#endif
}
开发者ID:hpavlov,项目名称:occurec,代码行数:66,代码来源:DxPlayer.cs
示例8: RunWorker
/// <summary>
/// Worker thread that captures the images
/// </summary>
private void RunWorker()
{
try
{
// Create the main graph
m_igrphbldGraph = Activator.CreateInstance(Type.GetTypeFromCLSID(FilterGraph)) as IGraphBuilder;
// Create the webcam source
m_sourceObject = FilterInfo.CreateFilter(m_sMonikerString);
// Create the grabber
m_isplGrabber = Activator.CreateInstance(Type.GetTypeFromCLSID(SampleGrabber)) as ISampleGrabber;
m_grabberObject = m_isplGrabber as IBaseFilter;
// Add the source and grabber to the main graph
m_igrphbldGraph.AddFilter(m_sourceObject, "source");
m_igrphbldGraph.AddFilter(m_grabberObject, "grabber");
using (AMMediaType mediaType = new AMMediaType())
{
mediaType.MajorType = MediaTypes.Video;
mediaType.SubType = MediaSubTypes.RGB32;
m_isplGrabber.SetMediaType(mediaType);
if (m_igrphbldGraph.Connect(m_sourceObject.GetPin(PinDirection.Output, 0), m_grabberObject.GetPin(PinDirection.Input, 0)) >= 0)
{
if (m_isplGrabber.GetConnectedMediaType(mediaType) == 0)
{
// During startup, this code can be too fast, so try at least 3 times
int retryCount = 0;
bool succeeded = false;
while ((retryCount < 3) && !succeeded)
{
// Tried again
retryCount++;
try
{
// Retrieve the grabber information
VideoInfoHeader header = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.FormatPtr, typeof(VideoInfoHeader));
m_grbrCapGrabber.Width = header.BmiHeader.Width;
m_grbrCapGrabber.Height = header.BmiHeader.Height;
// Succeeded
succeeded = true;
}
catch (Exception retryException)
{
// Trace
Trace.TraceInformation("Failed to retrieve the grabber information, tried {0} time(s)", retryCount);
// Sleep
Thread.Sleep(50);
}
}
}
}
m_igrphbldGraph.Render(m_grabberObject.GetPin(PinDirection.Output, 0));
m_isplGrabber.SetBufferSamples(false);
m_isplGrabber.SetOneShot(false);
m_isplGrabber.SetCallback(m_grbrCapGrabber, 1);
// Get the video window
IVideoWindow wnd = (IVideoWindow)m_igrphbldGraph;
wnd.put_AutoShow(false);
wnd = null;
// Create the control and run
m_imedctrlControl = (IMediaControl)m_igrphbldGraph;
m_imedctrlControl.Run();
// Wait for the stop signal
while (!m_rstevStopSignal.WaitOne(0, true))
{
Thread.Sleep(10);
}
// Stop when ready
// _control.StopWhenReady();
m_imedctrlControl.Stop();
// Wait a bit... It apparently takes some time to stop IMediaControl
Thread.Sleep(1000);
}
}
catch (Exception ex)
{
// Trace
Trace.WriteLine(ex);
}
finally
{
// Clean up
this.Release();
}
}
开发者ID:KrisJanssen,项目名称:SIS,代码行数:99,代码来源:CCDDevice.cs
示例9: ConfigureSampleGrabber
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber)
{
AMMediaType media = new AMMediaType
{
majorType = MediaType.Video,
subType = MediaSubType.RGB24,
formatType = FormatType.VideoInfo
};
// Set the media type to Video/RBG24
int hr = sampGrabber.SetMediaType(media);
DsError.ThrowExceptionForHR(hr);
DsUtils.FreeAMMediaType(media);
// Configure the samplegrabber
hr = sampGrabber.SetCallback(this, 1);
DsError.ThrowExceptionForHR(hr);
}
开发者ID:jmaxxz,项目名称:Ares,代码行数:19,代码来源:DSCapture.cs
示例10: SetupGraph
/// <summary>
/// Configures the DirectShow graph to play the selected video capture
/// device with the selected parameters
/// </summary>
private void SetupGraph()
{
/* Clean up any messes left behind */
FreeResources();
try
{
/* Create a new graph */
m_graph = (IGraphBuilder)new FilterGraphNoThread();
#if DEBUG
m_rotEntry = new DsROTEntry(m_graph);
#endif
/* Create a capture graph builder to help
* with rendering a capture graph */
var graphBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
/* Set our filter graph to the capture graph */
int hr = graphBuilder.SetFiltergraph(m_graph);
DsError.ThrowExceptionForHR(hr);
/* Add our capture device source to the graph */
if (m_videoCaptureSourceChanged)
{
m_captureDevice = AddFilterByName(m_graph,
FilterCategory.VideoInputDevice,
VideoCaptureSource);
m_videoCaptureSourceChanged = false;
}
else if (m_videoCaptureDeviceChanged)
{
m_captureDevice = AddFilterByDevicePath(m_graph,
FilterCategory.VideoInputDevice,
VideoCaptureDevice.DevicePath);
m_videoCaptureDeviceChanged = false;
}
/* If we have a null capture device, we have an issue */
if (m_captureDevice == null)
throw new Exception(string.Format("Capture device {0} not found or could not be created", VideoCaptureSource));
if (UseYuv && !EnableSampleGrabbing)
{
/* Configure the video output pin with our parameters and if it fails
* then just use the default media subtype*/
if (!SetVideoCaptureParameters(graphBuilder, m_captureDevice, MediaSubType.YUY2))
SetVideoCaptureParameters(graphBuilder, m_captureDevice, Guid.Empty);
}
else
/* Configure the video output pin with our parameters */
SetVideoCaptureParameters(graphBuilder, m_captureDevice, Guid.Empty);
var rendererType = VideoRendererType.VideoMixingRenderer9;
/* Creates a video renderer and register the allocator with the base class */
m_renderer = CreateVideoRenderer(rendererType, m_graph, 1);
if (rendererType == VideoRendererType.VideoMixingRenderer9)
{
var mixer = m_renderer as IVMRMixerControl9;
if (mixer != null && !EnableSampleGrabbing && UseYuv)
{
VMR9MixerPrefs dwPrefs;
mixer.GetMixingPrefs(out dwPrefs);
dwPrefs &= ~VMR9MixerPrefs.RenderTargetMask;
dwPrefs |= VMR9MixerPrefs.RenderTargetYUV;
/* Prefer YUV */
mixer.SetMixingPrefs(dwPrefs);
}
}
if (EnableSampleGrabbing)
{
m_sampleGrabber = (ISampleGrabber)new SampleGrabber();
SetupSampleGrabber(m_sampleGrabber);
hr = m_graph.AddFilter(m_sampleGrabber as IBaseFilter, "SampleGrabber");
DsError.ThrowExceptionForHR(hr);
}
IBaseFilter mux = null;
IFileSinkFilter sink = null;
if (!string.IsNullOrEmpty(this.m_fileName))
{
hr = graphBuilder.SetOutputFileName(MediaSubType.Asf, this.m_fileName, out mux, out sink);
DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, m_captureDevice, null, mux);
DsError.ThrowExceptionForHR(hr);
// use the first audio device
var audioDevices = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
//.........这里部分代码省略.........
开发者ID:JayBeavers,项目名称:WPF-MediaKit,代码行数:101,代码来源:VideoCapturePlayer.cs
示例11: Setup
/// <summary>
/// グラフの生成
/// </summary>
/// <param name="output_file">出力ファイル</param>
public virtual void Setup(string output_file)
{
this.Dispose();
try
{
CxDSCameraParam param = this.Param;
// グラフビルダー.
// CoCreateInstance
GraphBuilder = (IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_FilterGraph)));
#region フィルタ追加.
// 画像入力フィルタ.
IBaseFilter capture = CreateVideoCapture(param);
if (capture == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(capture, "CaptureFilter");
IPin capture_out = DSLab.Axi.FindPin(capture, 0, PIN_DIRECTION.PINDIR_OUTPUT);
this.CaptureFilter = capture;
this.CaptureOutPin = capture_out;
// サンプルグラバー.
IBaseFilter grabber = (IBaseFilter)CreateSampleGrabber();
if (grabber == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(grabber, "SampleGrabber");
this.SampleGrabber = (ISampleGrabber)grabber;
#endregion
#region キャプチャビルダー:
{
int hr = 0;
CaptureBuilder = (ICaptureGraphBuilder2)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_CaptureGraphBuilder2)));
hr = CaptureBuilder.SetFiltergraph(GraphBuilder);
if (string.IsNullOrEmpty(output_file))
{
// レンダラー.
IBaseFilter renderer = null;
renderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_NullRenderer)));
if (renderer == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(renderer, "Renderer");
this.Renderer = renderer;
#if true
// IGraphBuilder.Connect の代わりに ICaptureGraphBuilder2.RenderStream を使用する.
// fig) [capture]-out->-in-[sample grabber]-out->-in-[null render]
hr = CaptureBuilder.RenderStream(new Guid(GUID.PIN_CATEGORY_CAPTURE), new Guid(GUID.MEDIATYPE_Video), capture, grabber, renderer);
#else
// ピンの取得.
IPin grabber_in = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_INPUT);
IPin grabber_out = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_OUTPUT);
IPin renderer_in = DSLab.Axi.FindPin(renderer, 0, PIN_DIRECTION.PINDIR_INPUT);
// ピンの接続.
GraphBuilder.Connect(capture_out, grabber_in);
GraphBuilder.Connect(grabber_out, renderer_in);
// ピンの保管.
//SampleGrabberInPin = grabber_in;
//SampleGrabberOutPin = grabber_out;
//RendererInPin = renderer_in;
#endif
}
else
{
IBaseFilter mux = null;
IFileSinkFilter sync = null;
hr = CaptureBuilder.SetOutputFileName(new Guid(GUID.MEDIASUBTYPE_Avi), output_file, ref mux, ref sync);
hr = CaptureBuilder.RenderStream(new Guid(GUID.PIN_CATEGORY_CAPTURE), new Guid(GUID.MEDIATYPE_Video), capture, grabber, mux);
this.Mux = mux;
this.Sync = sync;
}
}
#endregion
#region 保管: フレームサイズ.
VIDEOINFOHEADER vinfo = DSLab.Axi.GetVideoInfo(SampleGrabber);
this.SampleGrabberCB.BitmapInfo = vinfo.bmiHeader;
this.SampleGrabberCB.FrameSize = new Size(
System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biWidth),
System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biHeight)
);
#endregion
#region 保管: デバイス名称.
try
{
if (string.IsNullOrEmpty(param.FilterInfo.Name) == false)
{
this.DeviceName = param.FilterInfo.Name;
}
else
//.........这里部分代码省略.........
开发者ID:cogorou,项目名称:DSLab,代码行数:101,代码来源:CxDSCamera.cs
示例12: SetupSampleGrabber
private void SetupSampleGrabber(ISampleGrabber sampleGrabber)
{
var mediaType = new DirectShowLib.AMMediaType
{
majorType = MediaType.Video,
subType = MediaSubType.RGB24,
formatType = FormatType.VideoInfo
};
int hr = sampleGrabber.SetMediaType(mediaType);
DsUtils.FreeAMMediaType(mediaType);
DsError.ThrowExceptionForHR(hr);
hr = sampleGrabber.SetCallback(this, 0);
DsError.ThrowExceptionForHR(hr);
}
开发者ID:JayBeavers,项目名称:WPF-MediaKit,代码行数:17,代码来源:VideoCapturePlayer.cs
示例13: ConfigureSampleGrabber
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber)
{
AMMediaType media;
int hr;
media = new AMMediaType();
media.majorType = MediaType.Audio;
/*media.subType = MediaSubType.WAVE;
media.formatType = FormatType.WaveEx;*/
hr = sampGrabber.SetMediaType(media);
DsError.ThrowExceptionForHR(hr);
DsUtils.FreeAMMediaType(media);
media = null;
// Configure the samplegrabber
hr = sampGrabber.SetCallback(this, 1); // buffer callback (0 = Sample callback)
DsError.ThrowExceptionForHR(hr);
}
开发者ID:i-e-b,项目名称:HLS---Smooth-Encoder,代码行数:21,代码来源:AudioCapture.cs
示例14: ConfigureSampleGrabber
/// <summary> Set the options on the sample grabber </summary>
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber)
{
AMMediaType media;
int hr;
// Set the media type to Video/RBG24
media = new AMMediaType();
media.majorType = MediaType.Video;
media.subType = MediaSubType.RGB24;
media.formatType = FormatType.VideoInfo;
hr = sampGrabber.SetMediaType(media);
DsError.ThrowExceptionForHR(hr);
DsUtils.FreeAMMediaType(media);
media = null;
// Choose to call BufferCB instead of SampleCB
hr = sampGrabber.SetCallback(this, 1);
DsError.ThrowExceptionForHR(hr);
}
开发者ID:nikolasbe,项目名称:ugent-dma-videoshotdetection,代码行数:21,代码来源:Capture.cs
示例15: SaveSizeInfo
private void SaveSizeInfo(ISampleGrabber sampGrabber)
{
int hr;
// Get the media type from the SampleGrabber
AMMediaType media = new AMMediaType();
hr = sampGrabber.GetConnectedMediaType(media);
DsError.ThrowExceptionForHR(hr);
if ((media.formatType != FormatType.WaveEx) || (media.formatPtr == IntPtr.Zero)) {
throw new NotSupportedException("Unknown Grabber Audio Format");
}
WaveFormatEx infoHeader = (WaveFormatEx)Marshal.PtrToStructure(media.formatPtr, typeof(WaveFormatEx));
m_Channels = infoHeader.nChannels;
m_SampleRate = infoHeader.nSamplesPerSec;
m_BitsPerSample = infoHeader.wBitsPerSample;
DsUtils.FreeAMMediaType(media);
media = null;
}
开发者ID:i-e-b,项目名称:HLS---Smooth-Encoder,代码行数:21,代码来源:AudioCapture.cs
示例16: SaveSizeInfo
// Save the size parameters for use in SnapShot
private void SaveSizeInfo(ISampleGrabber sampGrabber)
{
int hr;
// Get the media type from the SampleGrabber
AMMediaType media = new AMMediaType();
hr = sampGrabber.GetConnectedMediaType(media);
DsError.ThrowExceptionForHR(hr);
try
{
if ((media.formatType != FormatType.VideoInfo) || (media.formatPtr == IntPtr.Zero))
{
throw new NotSupportedException("Unknown Grabber Media Format");
}
// Get the struct
VideoInfoHeader videoInfoHeader = new VideoInfoHeader();
Marshal.PtrToStructure(media.formatPtr, videoInfoHeader);
// Grab the size info
m_videoWidth = videoInfoHeader.BmiHeader.Width;
m_videoHeight = videoInfoHeader.BmiHeader.Height;
m_stride = videoInfoHeader.BmiHeader.ImageSize / m_videoHeight;
m_ImageSize = videoInfoHeader.BmiHeader.ImageSize;
}
finally
{
DsUtils.FreeAMMediaType(media);
media = null;
}
}
开发者ID:hpavlov,项目名称:occurec,代码行数:35,代码来源:DxPlayer.cs
示例17: InitCaptureInterface
private void InitCaptureInterface()
{
// release com object (useless here but can't hurt)
Cleanup(true);
this.fmc = new FilgraphManagerClass();
// create the cg object and add the filter graph to it
Type t = Type.GetTypeFromCLSID(CLSID_CaptureGraphBuilder2);
this.icgb = (ICaptureGraphBuilder2)Activator.CreateInstance(t);
t = Type.GetTypeFromCLSID(CLSID_SampleGrabber);
this.isg = (ISampleGrabber)Activator.CreateInstance(t);
// source filter (the capture device)
this.sf = (IBaseFilter)this.SourceFilterList[this.cbxDevice.SelectedIndex];
// sample grabber filter
this.sgf = (IBaseFilter)this.isg;
object o = null;
this.icgb.RemoteFindInterface(ref PIN_CATEGORY_CAPTURE, ref MEDIATYPE_Video, sf, ref IID_IAMStreamConfig, out o);
this.iamsc = (IAMStreamConfig)o;
// set sample grabber media type
this.SGMediaType = new _AMMediaType();
this.SGMediaType.majortype = MEDIATYPE_Video;
this.SGMediaType.subtype = MEDIASUBTYPE_RGB24;
this.SGMediaType.formattype = FORMAT_VideoInfo;
this.isg.SetMediaType(ref SGMediaType);
this.isg.SetOneShot(0);
this.isg.SetBufferSamples(1);
}
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:33,代码来源:CaptureGraphForm.cs
示例18: ConfigureSampleGrabber
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber)
{
AMMediaType media;
int hr;
// Set the media type to Video/RBG24
media = new AMMediaType();
media.majorType = MediaType.Video;
media.subType = MediaSubType.RGB24;
media.formatType = FormatType.VideoInfo;
sampGrabber.SetBufferSamples(false);
sampGrabber.SetOneShot(false);
hr = sampGrabber.SetMediaType(media);
DsError.ThrowExceptionForHR(hr);
DsUtils.FreeAMMediaType(media);
media = null;
// Configure the samplegrabber
hr = sampGrabber.SetCallback(this, 1);
DsError.ThrowExceptionForHR(hr);
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:22,代码来源:OSDVideo.cs
示例19: SetupGraph
public void SetupGraph(DsDevice dev, bool runOCR, VideoFormatHelper.SupportedVideoFormat selectedFormat, ref float iFrameRate, ref int iWidth, ref int iHeight)
{
try
{
filterGraph = (IFilterGraph2)new FilterGraph();
mediaCtrl = filterGraph as IMediaControl;
capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
samplGrabber = (ISampleGrabber)new SampleGrabber();
int hr = capBuilder.SetFiltergraph(filterGraph);
DsError.ThrowExceptionForHR(hr);
if (Settings.Default.VideoGraphDebugMode)
{
if (rot != null)
{
rot.Dispose();
rot = null;
}
rot = new DsROTEntry(filterGraph);
}
SetupGraphInternal(dev, selectedFormat, ref iFrameRate, ref iWidth, ref iHeight);
// Now that sizes are fixed/known, store the sizes
SaveSizeInfo(samplGrabber);
crossbar = CrossbarHelper.SetupTunerAndCrossbar(capBuilder, capFilter);
latestBitmap = new Bitmap(iWidth, iHeight, PixelFormat.Format24bppRgb);
fullRect = new Rectangle(0, 0, latestBitmap.Width, latestBitmap.Height);
NativeHelpers.SetupCamera(
Settings.Default.CameraModel,
iWidth, iHeight,
Settings.Default.HorizontalFlip,
Settings.Default.VerticalFlip,
Settings.Default.IsIntegrating,
(float)Settings.Default.MinSignatureDiffRatio,
(float)Settings.Default.MinSignatureDiff,
Settings.Default.GammaDiff,
Settings.Default.ForceNewFrameOnLockedRate,
dev.Name,
selectedFormat.AsSerialized(),
selectedFormat.FrameRate);
NativeHelpers.SetupAav(Settings.Default.RecordStatusSectionOnly ? AavImageLayout.StatusSectionOnly : Settings.Default.AavImageLayout, Settings.Default.AavCompression);
ocrEnabled = false;
string errorMessage;
if (runOCR)
{
OcrConfiguration ocrConfig = OcrSettings.Instance[Settings.Default.SelectedOcrConfiguration];
errorMessage = NativeHelpers.SetupBasicOcrMetrix(ocrConfig);
if (errorMessage != null && callbacksObject != null)
callbacksObject.OnError(-1, errorMessage);
else
{
NativeHelpers.SetupOcr(ocrConfig);
ocrEnabled = true;
}
}
else
{
errorMessage = NativeHelpers.SetupTimestampPreservation(false, 0, 0);
if (errorMessage != null && callbacksObject != null)
callbacksObject.OnError(-1, errorMessage);
}
}
catch
{
CloseResources();
if (callbacksObject != null)
callbacksObject.OnError(-1, "Error initialising the camera. The selected video mode may not be supported by the camera.");
throw;
}
}
开发者ID:hpavlov,项目名称:occurec,代码行数:83,代码来源:DirectShowCapture.cs
示例20: Setup
/// <summary>
/// グラフの生成
/// </summary>
public virtual void Setup()
{
this.Dispose();
try
{
// グラフ.
// CoCreateInstance
GraphBuilder = (IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_FilterGraph)));
#region フィルタ追加.
// ファイル入力.
IBaseFilter capture = null;
GraphBuilder.AddSourceFilter(SourceFile, "CaptureFilter", ref capture);
if (capture == null)
throw new System.IO.IOException();
#if false
// DMO ラッパーフィルタ.
// https://msdn.microsoft.com/ja-jp/library/cc371140.aspx
IBaseFilter dmo = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_DMOWrapperFilter)));
if (dmo != null)
{
//// Mpeg4 Decoder DMO
//// F371728A-6052-4D47-827C-D039335DFE0A
//// 4A69B442-28BE-4991-969C-B500ADF5D8A8
//// mpg4decd.dll [C:\Windows\System32, C:\Windows\SysWOW64]
var idmo = (IDMOWrapperFilter)dmo;
idmo.Init(new Guid("F371728A-6052-4D47-827C-D039335DFE0A"), new Guid("4A69B442-28BE-4991-969C-B500ADF5D8A8"));
idmo = null;
this.GraphBuilder.AddFilter(dmo, "Mpeg4 Decoder DMO");
}
#endif
#if false
// Avi Splitter
IBaseFilter splitter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_AVISplitter)));
if (splitter == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(splitter, "Avi Splitter");
// Avi Decompressor
IBaseFilter decompressor = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_AVIDec)));
if (decompressor == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(decompressor, "Avi Decompressor");
#endif
// サンプルグラバー.
IBaseFilter grabber = (IBaseFilter)CreateSampleGrabber();
if (grabber == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(grabber, "SampleGrabber");
// レンダラー.
IBaseFilter renderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_NullRenderer)));
if (renderer == null)
throw new System.IO.IOException();
this.GraphBuilder.AddFilter(renderer, "Renderer");
#endregion
#region ピンの取得.
IPin capture_out = DSLab.Axi.FindPin(capture, 0, PIN_DIRECTION.PINDIR_OUTPUT);
IPin grabber_in = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_INPUT);
IPin grabber_out = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_OUTPUT);
IPin renderer_in = DSLab.Axi.FindPin(renderer, 0, PIN_DIRECTION.PINDIR_INPUT);
#endregion
#region ピンの接続.
GraphBuilder.Connect(capture_out, grabber_in);
GraphBuilder.Connect(grabber_out, renderer_in);
#endregion
#region 保管: インターフェース.
CaptureFilter = capture;
CaptureOutPin = capture_out;
SampleGrabber = (ISampleGrabber)grabber;
SampleGrabberInPin = grabber_in;
SampleGrabberOutPin = grabber_out;
Renderer = renderer;
RendererInPin = renderer_in;
#endregion
#region 保管: フレームサイズ.
VIDEOINFOHEADER vinfo = DSLab.Axi.GetVideoInfo(SampleGrabber);
this.SampleGrabberCB.BitmapInfo = vinfo.bmiHeader;
this.SampleGrabberCB.FrameSize = new Size(
System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biWidth),
System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biHeight)
);
#endregion
#region インタフェースの抽出:
{
DSLab.IGraphBuilder graph = this.GraphBuilder;
//.........这里部分代码省略.........
开发者ID:cogorou,项目名称:DSLab,代码行数:101,代码来源:CxDSMediaPlayer.cs
注:本文中的ISampleGrabber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论