《微软: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

《软件工程——实践者的研究方法》重难点复习笔记(第八章——理解需求)

8项需求工程任务 inception 开始 8.1.1 identify stakeholders 定义:从软件开发中收益 例如:市场人员、销售经理、顾客、顾问、维护团队等(P139) 8.1.2 这个阶段的问题是context-free的。有三套(P140) 8.1.3 提到NFR(nonfunctional requirement)和QFD(quality

whooiif的博客 1815

LightRAG实战:从零构建中药知识图谱,解锁六种检索模式效能对比

本文详细介绍了如何使用轻量级RAG框架LightRAG从零构建中药知识图谱的实战过程。通过本地部署环境搭建、开源模型配置与《本草纲目》数据导入,文章重点对比了Naive、Local、Global、Hybrid、Mix和Bypass六种检索模式在中药问答中的效能差异,并提供了可视化图谱与优化心得,为开发者构建专业领域智能问答系统提供了实用指南。

weixin_29096377的博客 176

火车头过滤 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

阿里云大模型 ACP 认证教材内容突变?这些改动藏着通关密码,不看亏大!

【摘要】核心章节大换血,安全合规融入实战场景,大模型微调用数学深度解析,部署章节带来阿里云产品对比实战攻略,甚至整章内容被替换成藏满学习彩蛋的行业趋势指南。这些改动不仅重塑考试重点,更暗藏官方命题风向——安全合规考场景方案,微调原理考几何解析,部署设计考分析框架。无论你是数学小白还是部署新手,这篇攻略都将带你吃透变动逻辑,附赠急救包和考点清单,帮你抓住这些“隐形加分项”,速来解锁通关秘籍!

davidkorhenn的博客 1755

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

保姆级避坑指南:在Ubuntu 22.04上用ROS2 Humble搞定TurtleBot3的SLAM与导航(附5个常见报错解决方案)

本文提供了一份详细的Ubuntu 22.04上使用ROS2 Humble和TurtleBot3进行SLAM建图与导航的避坑指南,涵盖Gazebo启动失败、场景加载问题、环境变量设置、GLIBCXX版本冲突及Nav2参数配置等5个常见报错的解决方案,帮助开发者高效完成机器人导航项目。

weixin_29062823的博客 286

45个经典Linux面试题(非常详细)零基础入门到精通,收藏这一篇就够了

(文件系统分配其中的一些磁盘块用来记录它自身的一些数据,如 i 节点,磁盘分布图,间接块,超级块等。$ chmod 751 file 给 file 的属主分配读、写、执行(7)的权限,给 file 的所在组分配读、执行(5)的权限,给其他用户分配执行(1)的权限。linux命令’hash’管理着一个内置的哈希表,记录了已执行过的命令的完整路径, 用该命令可以打印出你所使用过的命令以及执行的次数。创建文件:典型的如 touch,vi 也可以创建文件,其实只要向一个不存在的文件输出,都会创建文件。

小陈的博客 2071

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

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

chenjaulin的博客 5000

光伏电站发电功率预测实战:从基础物理模型到LSTM时间序列分析

本文系统介绍了光伏电站发电功率预测的实战方法,从基础的物理晴空模型到先进的LSTM时间序列分析。通过结合电工杯等竞赛中常用的代码与模型,详细阐述了如何利用历史数据和数值天气预报构建高精度预测体系,并针对阴雨天气等预测瓶颈提出了分场景建模与模型融合等优化策略,为电站运维和电网调度提供可靠的数据支持。

pp12345的博客 216

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万+

保边滤波之Mean shift filter

保边滤波之Mean shift filter 目录 保边滤波之Mean shift filter 一、算法原理 二、练手实现的算法代码如下: 三、实现结果 一、算法原理 在OpenCV中,meanshift filter函数为 p...

大熊 1561

【图像拼接】论文精读:Content-Preserving Warps for 3D Video Stabilization(CPW)

论文题目:Content-Preserving Warps for 3D Video Stabilization——用于3D视频稳定的内容保持扭曲GSP、SPW、LPC等warp时多个项最小化问题的思想都是来自于这篇论文——CPW视频防抖。我们描述了一种从手持摄像机转换视频的技术,以便它看起来像是用定向相机运动拍摄的。我们的方法调整视频以出现,就好像它是从附近的视点拍摄的,允许模拟 3D 相机运动。通过仅针对感知合理性,而不是准确的重建,我们能够开发能够有效从单个源视频中重建动态场景的算法。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 2万+

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

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

weixin_43229348的博客 3658

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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

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

tenyit的专栏 6094

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

[J2ME]VideoCoolala(MobileWebCam)设计说明

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

weixin_34212762的博客 123

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

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、付费专栏及课程。

余额充值