《微软:DirectShow开发指南》第5章 Capturing Audio and Video from a Webcam

matlab使用webcam获取摄像头图像 使用的是matlab2016a版本,摄像头驱动需提前下载安装1在循环中获取单个图像本例显示如何使用快照功能从USB摄像头获取实时图像。用于USB摄像头的MATLAB®支持包可将任何符合USB视频类(UVC)的网络摄像头的实时图像带入MATLAB®。识别可用的摄像头webcamlist函数提供了MATLAB®可以访问的当前系统上的网络摄像头单元阵列。camList = webcamlistcamLi... 阅读详情

Webcams have become nearly ubiquitous peripherals for today’s PCs. They’re inexpensive and produce video imagery of varying quality—often dependent on how much the webcam cost or how fast your computer runs. Furthermore, you don’t have to do much to set up a webcam: just plug it into an available port, and you’re ready to go. Windows XP provides desktop-level access to webcams (and all digital cameras attached to the computer) through Windows Explorer; here you can take single frames of video and save them to disk as photographs.

网络摄像头的应用无所不在。本例是将视频的每个单帧存成文件。


A webcam appears as a video input source filter in DirectShow. Like the audio input source filters we covered in the last chapter, the webcam produces a stream of data that can then be put through a DirectShow filter graph. Some webcams—particularly older models—capture only video, relying on a separate microphone to capture audio input. Many recent versions of webcams, including the Logitech webcam I have on my own system, bundle an onboard microphone into the webcam, and this microphone constitutes its own audio capture source filter.

在DirectShow中,webcam表示为视频输入源filter,它能生成数据流并传输给DirectShow的filter graph。以前的摄像头可能只能采集视频,现在的则音视频都可以采集。

 

For this reason, DirectShow applications will frequently treat webcams as if they are two independent devices with entirely separate video and audio capture components. That treatment is significantly different from a digital camcorder, which provides a single stream of multiplexed audio and video data; that single stream of digicam data is demultiplexed into separate streams by DirectShow filters. Although this treatment makes webcams a tiny bit more complicated to work with, their ubiquity more than makes up for any programming hoops you’ll have to jump through.

因此,DirectShow应用程序通常将webcam看作是两个独立的设备:视频捕捉组件和音频捕捉组件。这样的处理方式是明显不同于数字录像机的----它提供的是音频和视频数据合成了的单一流,而且这个流必须使用DirectShow的filter来进行去混合。尽管这样的做法会使webcam的工作稍稍复杂些,但是这种处理方式是很有普遍性。

 

Introducing DSWebcamCap

The DirectShow application DSWebcamCap captures separate video and audio inputs from a Logitech webcam to a file. Although a specific brand of webcam is explicitly specified in the code of DSWebcamCap, it is very easy to modify a few string constants and have the program work with any version of webcam. The application takes the combined streams and puts them into a filter known as the WM ASF Writer. This filter compresses audio and video streams using the powerful Windows Media Video codecs. The encoded content is put into an ASF file, which, according to the Microsoft guidelines, should have either a .WMA or .WMV file extension. (In this case, we’re creating a file with the .ASF extension, which stands for Advanced Systems Format. This file will be functionally identical to a file with a .WMV extension. ASF is a container format, a file type that can contain any of a number of stream formats, including both WMV and WMA, so it’s well suited to this task.) The WM ASF Writer allows you to select a variety of compression levels for the output file, so you can create very small files from a rich video source.

本DirectShow应用DSWebcamCap是从Logitech webcam捕捉分立 的视频和音频输入存成文件。虽然本例使用了一个特定品牌的webcam,但是它可以稍做修改而用到别的地方。本应用程序是将合成流通过WM ASF Writer filter来写文件。这个上filter同时还使用了Windows Media Video codecs来压缩音频和视频流。编码后的数据写到ASF文件,以.WMA或.WMV为扩展名。WM ASF Writer可能根据需要来选择压缩等级。

 

Examining main

As in our earlier examples, nearly all the application’s work is performed inside its main function, as the following code shows:

点击(此处)折叠或打开

  1. int main(int argc, char* argv[])
  2. {
  3.   ICaptureGraphBuilder2 *pCaptureGraph = NULL; // Capture graph builder
  4.   IGraphBuilder *pGraph = NULL; // Graph builder object
  5.   IMediaControl *pControl = NULL; // Media control object
  6.   IFileSinkFilter *pSink = NULL; // File sink object
  7.   IBaseFilter *pAudioInputFilter = NULL; // Audio Capture filter
  8.   IBaseFilter *pVideoInputFilter = NULL; // Video Capture filter
  9.   IBaseFilter *pASFWriter = NULL; // WM ASF File filter
  10.   // Initialize the COM library.
  11.   HRESULT hr = CoInitialize(NULL);
  12.   if (FAILED(hr))
  13.   {
  14.     // We'll send our error messages to the console.
  15.     printf("ERROR - Could not initialize COM library");
  16.     return hr;
  17.   }
  18.   // Create the Capture Graph Builder and query for interfaces.
  19.   hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
  20.   CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,
  21.   (void **)&pCaptureGraph);
  22.   if (FAILED(hr)) // FAILED is a macro that tests the return value
  23.   {
  24.     printf("ERROR - Could not create the Filter Graph Manager.");
  25.     return hr;
  26.   }
  27.   // Use a method of the Capture Graph Builder
  28.   // to create an output path for the stream.
  29.   hr = pCaptureGraph->SetOutputFileName(&MEDIASUBTYPE_Asf,
  30.   L"C:\\MyWebcam.ASF", &pASFWriter, &pSink);
  31.   // Now configure the ASF Writer.
  32.   // Present the property pages for this filter.
  33.   hr = ShowFilterPropertyPages(pASFWriter);
  34.   // Now get the Filter Graph Manager
  35.   // that was created by the Capture Graph Builder.
  36.   hr = pCaptureGraph->GetFiltergraph(&pGraph);
  37.   // Using QueryInterface on the graph builder,
  38.   // get the Media Control object.
  39.   hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
  40.   if (FAILED(hr))
  41.   {
  42.     printf("ERROR - Could not create the Media Control object.");
  43.     pGraph->Release(); // Clean up after ourselves
  44.     CoUninitialize(); // And uninitalize COM
  45.     return hr;
  46.   }
  47.   // Get an audio capture filter.
  48.   // There are several to choose from,
  49.   // so we need to enumerate them, pick one, and
  50.   // then add the audio capture filter to the filter graph.
  51.   hr = GetAudioInputFilter(&pAudioInputFilter, L"Logitech");
  52.   if (SUCCEEDED(hr)) {
  53.     hr = pGraph->AddFilter(pAudioInputFilter, L"Webcam Audio Capture");
  54.   }
  55.   // Now create the video input filter from the webcam.
  56.   hr = GetVideoInputFilter(&pVideoInputFilter, L"Logitech");
  57.   if (SUCCEEDED(hr)) {
  58.     hr = pGraph->AddFilter(pVideoInputFilter, L"Webcam Video Capture");
  59.   }
  60.   // Use another method of the Capture Graph Builder
  61.   // to provide a render path for video preview.
  62.   IBaseFilter *pIntermediate = NULL;
  63.   hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW,
  64.   &MEDIATYPE_Video, pVideoInputFilter, NULL, NULL);
  65.   // Now add the video capture to the output file.
  66.   hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE,
  67.   &MEDIATYPE_Video, pVideoInputFilter, NULL, pASFWriter);
  68.   // And do the same for the audio.
  69.   hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE,
  70.      &MEDIATYPE_Audio, pAudioInputFilter, NULL, pASFWriter);
  71.   if (SUCCEEDED(hr))
  72.   {
  73.     // Run the graph.
  74.     hr = pControl->Run();
  75.     if (SUCCEEDED(hr))
  76.     {
  77.       // Wait patiently for completion of the recording.
  78.       wprintf(L"Started recording...press Enter to stop recording.\n");
  79.       // Wait for completion.
  80.       char ch;
  81.       ch = getchar(); // We wait for keyboard input
  82.     }
  83.     // And stop the filter graph.
  84.     hr = pControl->Stop();
  85.     wprintf(L"Stopped recording.\n"); // To the console
  86.     // Before we finish, save the filter graph to a file.
  87.     SaveGraphFile(pGraph, L"C:\\MyGraph.GRF");
  88.   }
  89.   // Now release everything and clean up.
  90.   pSink->Release();
  91.   pASFWriter->Release();
  92.   pVideoRenderer->Release();
  93.   pVideoInputFilter->Release();
  94.   pAudioInputFilter->Release();
  95.   pControl->Release();
  96.   pGraph->Release();
  97.   pCaptureGraph->Release();
  98.   CoUninitialize();
  99.   return 0;
  100. }

After COM has been initialized, we find ourselves in unfamiliar territory. Instead of instantiating a Filter Graph Manager object, we use CoCreateInstance to create an instance of the Capture Graph Builder object. This object is specifically designed to assist in the construction of filter graphs that capture audio and video input to files, but it can also be used to construct other types of graphs. As soon as the object has been created, we invoke its ICaptureGraphBuilder2::SetOutputFileName method. This method takes a pointer to a media type—in this case, MEDIASUBTYPE_Asf, indicating an ASF file—and creates an output file with the name passed as the next parameter.

在COM初始化后,并不是按照惯例地生成Filter Graph Manager 对象的实例,而是调用CoCreateInstance函数来生成Capture Graph Builder对象的实例。这个对象用来帮助构建捕捉音频和视频成文件的filter graph,但是它也可用来构建其它类型的graph。当这个对象创建成功后,就可以调用 它的ICaptureGraphBuilder2::SetOutputFileName方法。这个方法将会以一个媒体类型指针为参数—本例中为MEDIASUBTYPE_Asf,表示ASF文件----并按后续参数创建一个输出文件。

 

The call to SetOutputFileName creates an instance of a WM ASF Writer filter. A pointer to the filter’s IBaseFilter interface is returned in pASFWriter, and a pointer to the filter’s IFileSinkFilter interface is returned in pSink. We’ll need a pointer to the WM ASF Writer filter, and you might need the IFileSinkFilter interface. For example, if you want to change the name of the output file to some value other than that passed in the call to SetOutputFileName, you need IFileSinkFilter.

SetOutputFileName的调用会创建一个WM ASF Writer filter的实例。pASFWriter是这个filter的IBaseFilter的接口指针,pSink是这个filter的IFileSinkFilter接口指针。有时即需要WM ASF Writer filter的指针,也需要它的IFileSinkFilter接口。例如,当要改变输出文件名时,就不需要通过SetOutputFileName来实现,而用IFileSinkFilter就可以了。

 

If we’d wanted to create an AVI file—as we will in the next chapter when we’re dealing with digital video from a camcorder—we would have passed a pointer to MEDIASUBTYPE_Avi as the first parameter. In that case, instead of returning a pointer to a WM ASF Writer filter, the call would have returned a pointer to an AVI Mux filter, which combines the audio and video streams into an AVI-formatted stream. You’d still need to write that stream to a file by using the File Writer renderer filter, whereas the WM AVI Writer combines both multiplexing and file writing features in a single renderer filter.

当不需要创建AVI文件时—如在下章将要讨论的从camcorder获得是数字视频---就不用将指针MEDIASUBTYPE_Avi作为第一个参数传递,在这种情况下,返回的就不是WM ASF Writer filter指针,而是返回一个AVI Mux filter—它会将音频和视频流合成一个AVI格式的流。这时,还是可以同样使用File Writer renderer filter来将流写到文件。反之,

 

When Should You Compress?

When capturing video, in some scenarios it is preferable to simply save the data without compressing it. Most webcams output some sort of YUV video, although some output RGB, which requires significantly more bandwidth and hard drive space. Depending on the type of video, the size of the video frames, and the speed of your CPU, a compressor might not be able to keep up with the incoming video stream. If you save the uncompressed data in an AVI file by using the AVI Mux and the File Writer, you can come back and compress it later. When the graph’s source data is coming from a file, the compressor (in this case the WM ASF Writer) controls the speed at which the data is processed. In some cases, this might be faster than real time, and in some cases, it might be slower. Either way, no frames will be dropped because the source filter is reading from a local file.

在捕捉视频时,数据更趋向于不经压缩而直接存储。大多数的webcam可以输出YUV格式的视频(也有输出RGB的),这就要求大量的带宽和有磁盘空间。这些数据压不压缩看你实际的使用环境。 

Examining and Changing a Filter’s Property Pages

The WM ASF Writer created by the call to SetOutputFileName has a wide range of options that control how it uses the Windows Media compression algorithms. A file can be highly compressed, which saves space but sacrifices quality, or it can be relatively expansive, consuming valuable hard disk resources but requiring fewer CPU cycles to process. These values can be set internally (which we’ll cover in Chapter 15), or they can be presented to the user in a property page. Many DirectShow filters implement property pages, which are dialog boxes that expose the inner settings of a filter. The ShowFilterPropertyPages function presents the property pages of a filter.

通过调用SetOutputFileName创建的WM ASF Writer有很多的可选项,可以控制Windows Media compression algorithms如何来工作。这些值可以内部进行设置(具体可参见第15章),也可以呈现在用户属性页上。很多DirectShow filter实现了这个属性页,通过ShowFilterPropertyPages函数可以实现它。

点击(此处)折叠或打开

  1. // Show the property pages for a filter.
  2. // This is stolen from the DX9 SDK.
  3. HRESULT ShowFilterPropertyPages(IBaseFilter *pFilter) {
  4.   /* Obtain the filter's IBaseFilter interface. (Not shown) */
  5.   ISpecifyPropertyPages *pProp;
  6.   HRESULT hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages,
  7.                                        (void **)&pProp);
  8.                                        
  9.   if (SUCCEEDED(hr))
  10.   {
  11.     // Get the filter's name and IUnknown pointer.
  12.     FILTER_INFO FilterInfo;
  13.     hr = pFilter->QueryFilterInfo(&FilterInfo);
  14.     IUnknown *pFilterUnk;
  15.     pFilter->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);
  16.     // Show the page.
  17.     CAUUID caGUID;
  18.     pProp->GetPages(&caGUID);
  19.     pProp->Release();
  20.     OleCreatePropertyFrame(
  21.     NULL, // Parent window
  22.     0, 0, // Reserved
  23.     FilterInfo.achName, // Caption for the dialog box
  24.     1, // # of objects (just the filter)
  25.     &pFilterUnk, // Array of object pointers.
  26.     caGUID.cElems, // Number of property pages
  27.     caGUID.pElems, // Array of property page CLSIDs
  28.     0, // Locale identifier
  29.     0, NULL // Reserved
  30.     );
  31.     // Clean up.
  32.     pFilterUnk->Release();
  33.     FilterInfo.pGraph->Release();
  34.     CoTaskMemFree(caGUID.pElems);
  35.   }
  36.   return hr;
  37. }

The ShowFilterPropertyPages function exposes the ISpecificPropertyPages interface of the IBaseFilter passed by the caller and then gets the name of the filter. It also creates an interface to an IUnknown object, which exposes all the interfaces of a given object. That information is passed in a call to OleCreatePropertyFrame, which manages the property pages dialog box for user input. When this function is executed, you should see a property page dialog box that looks something like the one shown in Figure 5-1.

ShowFilterPropertyPages函数使用了IBaseFilter的ISpecificPropertyPages接口,然而获得filter的名字。然后创建了一个IUnknown对象的接口。这些信息都传输给OleCreatePropertyFrame。它管理用户的属性用户页输入。当这个函数执行时,就可以看到这个属性页。

Figure 5-1. Property pages dialog box for the WM ASF Writer

The operating system handles the details of user input, and when the user closes the dialog box, control returns to the function, which cleans itself up and exits.

OS将会处理用户输入的细节,当用户关闭对话框时,控制权将会返回给函数,它将会清除并退出。

 

Some, but not all, DirectShow filters have a property page associated with them, but it’s not a good idea to show the property page to the user. These property pages are designed for testing by the programmer, so they don’t meet Microsoft’s user interface guidelines or accessibility requirements;  they could potentially confuse the user. In this case, however, the property page serves a useful purpose for testing: it allows you to adjust file compression parameters to suit your needs.

属性页有时是不必要的,会搞乱用户,主要在给开发人员调试就可以啦。

 

It’s not necessary to use property pages to change the settings on the WM ASF Writer, and, in fact, you cannot use the filter’s default property page to enable the latest Windows Media 9 Series Audio and Video codecs. But there is a set of COM interfaces that allow you to adjust all the features available to the Windows Media encoder and to make your own property page for end users; these interfaces will be covered in detail in Chapter 15.

用属性页来改变WM ASF Writer的设置是没有必要的,而且,实际上,最新版的Windows Media 9 Series Audio and Video codecs还不支持这种设置调整。

 

Working with the Filter Graph Manager of a Capture Graph

After using the Capture Graph Builder to create the filter graph, we must obtain the IMediaControl interface on the Filter Graph Manager to run, stop, and pause the graph. By calling ICaptureGraphBuilder2::GetFilterGraph, we obtain a pointer to the Filter Graph Manager’s IGraphBuilder interface. We can then use that interface to obtain the IMediaControl interface.

当使用Capture Graph Builder创建了filter graph之后,就必须从Filter Graph Manager上获得IMediaControl接口来Run, pause和pause。通过调用ICaptureGraphBuilder2::GetFilterGraph,就可以获得Filter Graph Manager的接口IGraphBuilder的指针。通过这个接口,就可以获得IMediaControl的接口。

 

The EnumerateAudioInputFilters function used in DSAudioCap has been reworked slightly to create GetAudioInputFilter, which returns an audio input filter with a specific FriendlyName, if it exists. The function is invoked with a request for a filter with the “Logitech” label—a microphone built into the webcam. Changing the value of this string returns a different audio input filter if a match can be found. You’d change this string if you were using another brand of webcam in your own DirectShow programs. (Ideally, you’d write a program that wouldn’t be tied to any particular brand of hardware, allowing the user to select from a list of hardware that had been recognized by DirectShow as being attached to the computer.) Once the appropriate filter is located, it’s added to the filter graph using the IGraphBuilder method AddFilter.

EnumerateAudioInputFilters函数和DSAudioCap中的相似,它用来创建GetAudioInputFilter。

 

Next we do much the same thing with video input devices. We’ve created the GetVideoInputFilter routine, which is nearly a carbon copy of GetAudioInputFilter, except that the GUID for the class enumerator provided in the call to CreateClassEnumerator is CLSID_VideoInputDeviceCategory rather than CLSID_AudioInputDeviceCategory. Once again, the function walks through the list of available capture devices, looking for one that has a FriendlyName that will match the one I’m looking for, which is labeled “Logitech.” An instance of the matching video input filter is returned to the caller, and it’s then added to the filter graph. (Monikers are a fast, cheap way to find a particular filter because DirectShow doesn’t need to create instances of each filter object to determine its FriendlyName or other properties.)

接下来要做的和GetAudioInputFilter很相似,不同的是枚举类的GUID是VideoInputDeviceCategory。它将会列出所有有效的捕捉设备,并找到一个想要的加入到filter。

 

Building the DSWebcamCap Filter Graph

Next we need to add a video renderer to the filter graph so that we can watch the video at the same time we are saving it to disk. To do so, invoke the ICaptureGraphBuilder2 method RenderStream to connect the video renderer to the appropriate pins in the filter graph. RenderStream handles all the filter creation and connection necessary to produce a path from an input stream to a particular renderer. In this case, we want to render a preview (monitor) to the display, so we pass a pointer to PIN_CATEGORY_PREVIEW as the first value, followed by MEDIATYPE_Video, indicating that we’re interested in a video stream. Then we pass two NULL values. The first NULL value tells RenderStream that no intermediate filter needs to be connected in the filter graph. If there is a filter you want to place into the path of the renderer (such as the Smart Tee filter, an encoder, or some other transform filter), supply a pointer to that filter as this argument. The second NULL value allows the RenderStream method to create a monitor window for the video stream, so we can see the video capture on screen while it is being written to file. RenderStream will determine the best path between the input filter and the renderer filter.

为了在监视视频的同时能将它写到文件,就需要在filter graph中添加一个video renderer。激活ICaptureGraphBuilder2的方法RenderStream,并将它连接到filter graph合适的pin就能实现这个功能。RenderStream处理所有filter创建并建立输入流到特定renderer的连接。在本例中,需要提交一个预览给显示器。因此,传送指针PIN_CATEGORY_PREVIEW作为第一个参数,接着的参数是MEDIATYPE_Video—它用来指示感兴趣视频流。然后传递两个NULL参数。第一个NULL是通知RenderStream,在本filter graph不需要中间filter。如果想加入一个filter,则将要插入的filter的参数作为参数传入。第二个NULL参数RenderStream方法可以创建一个流的监视窗口,因此可以在写文件的同时监视。RenderStream会确定输入filter和renderer filter之间的最佳路径。

 

Frequently, calls to RenderStream will result in the addition of transform filters known as Smart Tees to the filter graph. A Smart Tee takes a single stream and converts it into two identical, synchronized streams. One of these streams is designated as the capture stream and presented on the filter’s Capture pin, and the other stream is designated as a preview stream and presented on the filter’s Preview pin.

通常,调用RenderStream将会导致要添加一个额外的transform filter作为Smart Tees插入到filter graph。Smart Tee能够接收一个流,然后转换成两个一样的,同步的流。一个流可以作为捕捉流以给其它的filter作为Capture pin来使用,而另一个流则可以作为预览流给其它的filter作为Preview pin。

 

What makes the Smart Tee so smart? The Smart Tee understands priorities, and it will never cause the capture stream to lose frames. If the CPU starts getting overloaded with video processing, the Smart Tee will detect the overloading and drop frames from the preview display, sacrificing the preview in favor of capture quality. Using the Smart Tee, you might see a jerky preview, but the captured file should be perfect.

Smart Tee是怎么做到的呢?Smart Tee具有优先级,并且它不会造成捕捉流的丢帧。如果CPU在处理视频时过载了,那么Smart Tee能够侦测到这种过载并丢掉预览的帧,牺牲预览有利于捕捉的质量。使用Smart Tee将会看到一个不平稳的预览,但是有一个良好的捕捉文件。

 

To complete the construction of the filter graph, we make two more calls to RenderStream. The first call connects the video capture filter to the WM ASF Writer that’s been created by the ICaptureGraphBuilder2 object. In this case, PIN_CATEGORY_CAPTURE is passed as the first parameter of RenderStream; this parameter tells RenderStream that it should connect the capture stream rather than the preview stream. The Smart Tee filter will be added if needed. After the first call to RenderStream is completed, another call is made to RenderStream, with parameters to specify that the audio stream should be connected to the WM ASF Writer.

为了filter graph的构建,需要再多两个RenderStream的调用。第一个调用是建立视频捕捉filter到WM ASF Writer(由ICaptureGraphBuilder2对象创建)的连接,在本例中,PIN_CATEGORY_CAPTURE是传递给RenderStream的第一个参数。这个参数表示RenderStream,它应当连接是捕捉流,而不是预览流。如果需要的话,Smart Tee filter将会被插入。第二个调用是建立音频流到WM ASF Writer的连接。

 

That concludes the construction of the filter graph. Because we’ve used the Capture Graph Builder to

handle the details of wiring the filters together, it’s taken only a few lines of code to create a functional

filter graph. This filter graph will capture camcorder video and audio streams to a file while providing a

video monitor window on the display. When the application invokes the Filter Graph Manager’s Run

method, a small preview window will open on the display, showing the real-time output of the webcam,

even as the webcam’s video stream is written to a disk file.

 

Summary

In this chapter, we covered video capture with webcams—inexpensive, low-resolution video cameras, which have become nearly ubiquitous PC peripherals. Despite their low-quality imagery, webcams provide an important portal between the real world and the PC. They can turn any PC into a moviemaking workstation and they can send your image around the world in just a few clicks—or a few lines of DirectShow code.

本章主要讲述对摄像头的视频捕捉。虽然摄像头的图像品质很一般,但是的应用还是很广泛的。而DS完全只用几行代码就做进行图像捕捉。

 

Although DSWebcamCap seems very simple, it is the foundation of everything you’d need to add video capture and video e-mail capability to any Internet-based application. All the essentials—video and audio capture, video monitoring, and data compression—are included in this demonstration program. Although the program lacks the nicety of a user interface, line for line it’s an incredibly powerful multimedia authoring application, and it could easily be integrated within any application, including e-mail, a Web browser, a peer-to-peer file sharing program, and so on. DSWebcamCap is a good example of the power that DirectShow brings to the application programmer; many tens of thousands of lines of code are “under the hood,” hidden away in DirectShow filters that we need know nothing about to use them.

尽管DSWebcamCap看起来很简单,但是它可以作为所有需要视频捕捉的基础,如音视频捕捉,视频监控,和数据压缩等。

 

Webcams are the low-tech end in the world of digital video. They’re commonplace but not very powerful. Digital video cameras are the high-end hardware of this world, and it’s now time to examine how to use DirectShow to control these increasingly popular devices.

AcerCrystalEyeWebcamVideoClassCam_v5.7.26.400-1.0_ChiconyWHQL 关于ATIHd2400的显卡驱动,帮助你快速重装系统 立即下载

相关推荐

DirectShow开发指南及源码.part1(共四卷)

《DirectShow开发指南》 作 者: 陆其明(著) 金邦飞(审校) 内容提要:本书以DirectX SDK 9.0版为蓝本,涉及的内容几乎涵盖 了在Windows平台上使用DirectShow进行C++编码的方方面面。 共压缩为四卷

webcam video demo

这是ROS情景下的一个节点,展示了ROS节点的常见格式。代码很简单,单展示了持续视频流的发布,还展示了基本接口的使用。一个 demo,使用 OpenCV,手动操作 webcam,保持相机打开,防止频繁的 开关损坏摄像头硬件。

qq_64338302的博客 392

《DirectShow开发指南及源码》 陆其明 part2

《DirectShow开发指南及源码》 陆其明,书和源代码,非常好的参考资料 共2部分

---WebCam网络摄像头7 cmos--yuv rgb , Format............:V4L2_PIX_FMT_YUYV

颜色系统基本 refer to http://bbs.chinavideo.org/viewthread.php?tid=4143 常见的RGB格式有RGB1、RGB4、RGB8、RGB565、RGB555、RGB24、RGB32、ARGB32 常见的YUV格式有YUY2、YUYV、YVYU、UYVY、AYUV、Y41P、Y411、Y211、IF09、IYUV、YV12、YVU9、YUV411

openCpu 6740

Cocos Creator 3D音频定位实战:从原理到沉浸感实现

3D音频定位是游戏开发中实现沉浸感的关键技术,其核心原理基于HRTF(头部相关传输函数)模型,模拟声音在空间中的传播与双耳感知差异。这项技术通过赋予声音空间坐标、距离衰减和方向属性,将音频从背景元素提升为可交互的环境线索,极大增强了虚拟世界的真实感与玩家的空间认知。在工程实践中,开发者需要深入理解声源、听者、衰减曲线与多普勒效应等基础概念,并合理运用音频池、优先级管理与动态混音等技术手段来平衡效果与性能。对于Cocos Creator开发者而言,无论是使用引擎原生的AudioSource组件构建轻量级方案,

weixin_30972263的博客 294

ELK - CentOS7 安装 elasticsearch 7.17.5

elk elasticsearch 安装

qq_19783793的博客 1462

火车头过滤 css样式_HTML5和CSS3过滤器中的网络摄像头视频捕获

火车头过滤 css样式Webcam Video Capture in HTML5 and CSS3 filters As we know – HTML5 defines a new element called <video> for embedding video. Usually people use this element to embed a video into web p...

cukengwei3786的博客 386

别再为下载速度发愁了!手把手教你给qBittorrent/Transmission添加最新可用Tracker(附2024年实测地址清单)

本文提供2024年BT下载加速实战指南,详细解析Tracker工作原理与速度瓶颈,手把手教你为qBittorrent/Transmission添加最新可用Tracker,并附实测地址清单。通过优化配置和精选Tracker列表,显著提升下载速度和稳定性,解决连接延迟和peer数量限制问题。

weixin_28481133的博客 1263

S3C2410中利用Servfox和Spcaview使用WEBCAM(适用于zc301芯片的摄像头)

源代码下载:http://www.mcuos.com/viewthread.php?tid=262&extra=page%3D1&page=1相关问题讨论:http://www.mcuos.com/viewthread.php?tid=256&extra=&page=1http://yuruxiao.blog.sohu.com/56584795.htmlhttp://blog.chinaunix.

嵌入精灵 7171

Linux-ftrace-双nop机制的实现

linux-ftrace内核追踪-双nop机制的实现原理

qq_43707773的博客 1072

STM32H7 Flash擦除后数据读取异常的缓存问题解析

本文深入分析了STM32H7系列芯片在Flash擦除后数据读取异常的缓存问题,揭示了由于数据缓存(D-Cache)和指令缓存(I-Cache)导致的数据一致性问题。通过详细的解决方案,包括手动维护缓存一致性和操作期间禁用缓存,帮助开发者有效解决这一常见但棘手的嵌入式开发难题。

weixin_29158413的博客 392

使用树莓派Webcam透过Bluemix AlchemyAPI 识别人脸

使用树莓派Webcam透过Bluemix AlchemyAPI 识别人脸作者:陳兆麟 Email:chenlin2@ms9.hinet.netAlchemy API是一套采用深度学习(Deep Learning)所开发的一套非监督式机器学习方法,同时结合图像识别技术,主要是想提供使用者得到更佳的内容转换率。使用者可以任意的分析各式文件,包含推文和电子邮件,来发现文章中关键观念或文章作者的行为推断

chenjaulin的博客 5000

2024年【MCM/ICM】美国大学生数学建模竞赛优秀论文(免费下载)

美国大学生数学建模竞赛(MCM/ICM)由美国数学及其应用联合会主办,是最高的国际性数学建模竞赛,也是世界范围内最具影响力的数学建模竞赛,一般也指数学建模竞赛。赛题内容涉及经济、管理、环境、资源、生态、医学、安全、等众多领域。竞赛要求三人(本科生和研究生均可参加)为一组,在四天时间内,就指定的问题完成从建立模型、求解、验证到论文撰写的全部工作,体现了参赛选手研究问题、解决方案的能力及团队合作精神。为现今各类数学建模竞赛之鼻祖。

weixin_43608857的博客 1841

WebRTC基础实践 - 4. 获取摄像头的视频流

本节内容 在本节课程中, 我们将学习以下知识点: 从摄像头(webcam)获取视频流(video stream) 控制视频内容的回显 通过CSS和SVG处理视频内容。 本节的完整版代码位于 step-01 文件夹中。 HTML代码 在 work 目录下的 index.html 文件中, 增加 video 标签和 script 标签: &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html...

铁锚的优快云博客 1万+

基于STM32设计的温室大棚种植监测系统(onenet+GPRS通信)

当前所设计的温室大棚种植监测系统基于STM32单片机开发,它能够对温室大棚内的温度、湿度、光照强度、土壤湿度、二氧化碳含量等环境参数进行实时监测,并将数据传输至OneNET云平台,实现了远程监测和管理。该系统具有体积小、功耗低、可靠性高等特点,适合在温室大棚等场合使用。

7873

我的世界模组开发——前言

避坑:在开发过程中一定不要过分依赖AI,虽说现在的人工智能很厉害,但是也有很大的弊端,很多AI生成的代码错误百出,还得自己修改,而且像deepseek这种AI的训练数据还停留在一年前,给出的maven仓库地址都是过时的甚至是错误的,开发模组就是要多学习,多看源码,这样开发模组的水平才能越来越高。总而言之,build.gradle文件在我的世界Forge模组开发中扮演了重要的角色,它定义了项目的构建过程、依赖关系和编译选项,为开发者提供了灵活而强大的构建工具。开发工具推荐使用idea,因为可以使用通灵义码。

qq_24992377的博客 2594

基于cv2.VideoCapture 和 OpenCV 得到更快的 FPS之Webcam篇

使用线程处理 I/O 繁重的任务(例如从相机传感器读取帧)是一种已经存在数十年的编程模型。 例如,如果我们要构建一个网络爬虫来抓取一系列网页(根据定义,这个任务是 I/O 绑定的),我们的主程序将生成多个线程来处理并行下载这组页面,而不是仅依靠单个线程(我们的“主线程”)按顺序下载页面。这样做可以让我们更快地抓取网页。 同样的概念也适用于计算机视觉中的从相机读取帧——我们可以简单地通过创建一个新线程来提高我们的 FPS,该线程轮询相机以获取新帧,而我们的主线程处理当前帧。 这是一个简单的概念,但它在 Ope

weixin_43229348的博客 3658

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

HTML5 Camera(摄像头) 和 Video(视频)控制

本文属于吴统威的博客原创文章,转载:http://www.wutongwei.com/front/infor_showone.tweb?id=103 最近写了一个上传头像的功能,主要是使用了HTML5的方法来开发.主要从两个方面处理.一是通过input文件控件,二是通过摄像头,今天我们主要是从摄像头来处理.那我们开始怎么从浏览器中获取摄像头的操作. 首先我们先编写HTML代码 video

tenyit的专栏 6094

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

[J2ME]VideoCoolala(MobileWebCam)设计说明

郑昀@ultrapower 产品名称 产品版本 Keyword: Mobile VideoControl Media 拍照手机 j2me midp midlet  WebCam  java VideoCoolala [MobileWebCam] 1.12.1305 [J2ME] VideoCoolala(MobileWebCam) 设计说明 ...

weixin_34212762的博客 123

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Set up a Webcam with Linux (Ubuntu) - USB 摄像头设置

Set up a Webcam with Linux (Ubuntu) - USB 摄像头设置

程永强 2113

使用Webcam实现拍照功能

开发环境:Grails 3.2.3,jQuery 1.11.3 最近做项目,遇到一个正常但又少见的需求——拍照,于是在Google上搜索“js 拍照”,出现的都是Html5的实现,又搜索“jquery 拍照”,搜出了jQuery的拍照插件。 先看了下《基于html5实现的超酷摄像头(html5-webcam)拍照功能-photobooth...

weixin_33991727的博客 2422

关于 web cam 使用自家的摄像头实现 视频捕捉技术 高级篇

网络上一大堆的视频捕捉代码,比如: 代码 publicclassWebCameraEngine { //showVideocalls [DllImport("avicap32.dll")] publicstaticexternIntPtrcapCreateCaptureWindowA(by...

daxi1047的博客 1313

H5实现调用本地摄像头实现实时视频以及拍照功能

getUserMedia API HTML 5 的getUserMedia API提供了访问媒体的能力, 基于该特性, 开发者可以不依赖任何浏览器插件下去访问视频和音频等设备. 旧版API : navigator.getUserMedia  新版API : navigator.mediaDevices.getUserMedia 旧版语法:getUserMedia(con

T_shiyi的博客 1万+

使用webcam-capture实现的VideoSource

从LiveSwitch示例代码中反编译,没有使用NativeWebcamDevice和NativeWebcamDriver(根据反编译结果,仅能在Windows下使用): /* * To change this license header, choose License Headers in Project Properties. * To change this template...

weixin_30872733的博客 2508

3个很棒的HTML5 WebCam视频演示

只是瞎搞一些HTML5摄像头演示。 这里有最好的3 HTML5网络摄像头视频演示 。 如果你知道了送他们通过! :) HTML5视频要求您接受摄像头的访问和网页时打你应该会提示。 1. HTML5摄像头视频 尝试一下! 2. ASCII摄像头视频 尝试一下! 3.人脸检测摄像头视频 尝试一下! From: https://www.sitepoint.com//html5-webca...

508

html5 摄像头 直播,详解HTML5 使用video标签实现选择摄像头功能

详解HTML5 使用video标签实现选择摄像头功能1. html// jquery reference// //Open WebCamSnap Photo2. javascript//// Elements for taking the snapshotvar canvasPreview = document.getElementById('canvasPreview');var canvasU...

weixin_35348635的博客 835
上一篇: 《微软:DirectShow开发指南》第4章 Capturing Audio with DirectShow
下一篇: 《微软:DirectShow开发指南》第12章 Writing DirectShow Source Filters
北雨南萍
北雨南萍 领域专家: 操作系统技术领域 领域专家: 操作系统技术领域
博客等级 码龄20年 2665粉丝 453原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值