简体   繁体   English

在 Directshow 中替代使用 ISpecifyPropertyPages 进行编程的替代方法

[英]Alternative way to program instead of using ISpecifyPropertyPages in Directshow

To start off I'm terrible at this directshow stuff.首先,我对这种直接表演的东西很糟糕。 I have almost no clue as to how it works.我几乎不知道它是如何工作的。 And I'm trying to access this "value" from a camera that's called Area of Interest x and y, at least that's what it was called in the Camera program that came with the camera.我正在尝试从名为“兴趣区域 x 和 y”的相机访问这个“值”,至少在相机附带的相机程序中是这样调用的。 Basically it moves the the camera's view left to right or top to bottom (The camera does not physically move).基本上它会从左到右或从上到下移动相机的视图(相机不会物理移动)。 Problem is I can't find how to do that in Directshow.问题是我在 Directshow 中找不到如何做到这一点。

But, luckily, I came across a program with a source code that had access to this value using directshow.但是,幸运的是,我遇到了一个带有源代码的程序,该程序可以使用 directshow 访问该值。 So, after looking through the code I found it and the code looked like this..所以,在查看代码后,我找到了它,代码看起来像这样..

case IDC_DEVICE_SETUP:
{
    if(gcap.pVCap == NULL)
        break;

    ISpecifyPropertyPages *pSpec;
    CAUUID cauuid;
    hr = gcap.pVCap->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpec);
    if(hr == S_OK)
    {
         hr = pSpec->GetPages(&cauuid);
         hr = OleCreatePropertyFrame(ghwndApp, 30, 30, NULL, 1,
                        (IUnknown **)&gcap.pVCap, cauuid.cElems,
                        (GUID *)cauuid.pElems, 0, 0, NULL);
         CoTaskMemFree(cauuid.pElems);
         pSpec->Release();
    }
    break;
}

Problem is that this its a button and when you click on it, it creates a window with some of the properties of the camera setting that I don't need access to.问题是这是一个按钮,当您单击它时,它会创建一个窗口,其中包含我不需要访问的某些相机设置属性。 Basically, there is a two problems.基本上,有两个问题。 First, I don't need to want to create a window, I just want to access the value programmatically and second, I only want to access the specific part of the values from this property page.首先,我不需要创建窗口,我只想以编程方式访问值,其次,我只想从该属性页访问值的特定部分。 Is there a way to do that?有没有办法做到这一点?

The IAMCameraControl interface seems to come nearest to what you want, but it's not exactly what you want. IAMCameraControl界面似乎最接近您想要的,但它并不完全是您想要的。 I can't remember that there is a standard DirectShow interface that does what you want.我不记得有一个标准的 DirectShow 界面可以满足您的需求。

The property page you see for the IBaseFilter is implemented by the driver for the filter.您看到的IBaseFilter的属性页是由过滤器的驱动程序实现的。 The driver is free to do whatever he wants with all knowledge about internal interfaces.驱动程序可以根据有关内部接口的所有知识自由地做任何他想做的事情。 There is no need to exhibit these interfaces to external users.无需向外部用户展示这些接口。 If you are lucky then the camera vendor's property page is using a COM interface that the vendor is willing to document so that you can use it.如果您很幸运,那么相机供应商的属性页正在使用供应商愿意记录的 COM 接口,以便您可以使用它。

So I would ask the camera vendor if they provide an official COM interface that you could use.因此,我会询问相机供应商是否提供您可以使用的官方 COM 接口。 If they don't, you could try to reverse engineer what they do (not so easy) and hope that they don't change the interface with the next software release.如果他们不这样做,您可以尝试对他们所做的进行逆向工程(不是那么容易),并希望他们不要在下一个软件版本中更改界面。

Regarding the general question given in the comments:关于评论中给出的一般问题:

COM is a programming interface that defines how to create objects, how to define the interface (eg methods) of these objects and how to call methods on the objects. COM是一个编程接口,它定义了如何创建对象、如何定义这些对象的接口(例如方法)以及如何调用对象上的方法。

DirectShow is based on COM. DirectShow基于 COM。 DirectShow defines several COM interfaces like IFilterGraph as a container for all devices and filters that you use. DirectShow 将多个 COM 接口(如IFilterGraph定义为您使用的所有设备和过滤器的容器。 Another COM interface defined by DirectShow is IBaseFilter which is the base interface for all filters (devices, transformation filters) that you could use. DirectShow 定义的另一个 COM 接口是IBaseFilter ,它是您可以使用的所有过滤器(设备、转换过滤器)的基本接口。

The individual COM objects are sometimes implemented by DirectShow, but device specific objects like the IBaseFilter for your capturing device are implemented by some DLL delivered by the hardware vendor.单个 COM 对象有时由 DirectShow 实现,但设备特定对象(如捕获设备的IBaseFilter由硬件供应商提供的某些 DLL 实现。

In your case gcap.pVCap is the IBaseFilter interface for the capture device.在您的情况下, gcap.pVCap是捕获设备的IBaseFilter接口。 In COM objects can implement multiple interfaces.在 COM 对象中可以实现多个接口。 In your code pVCap is queried ( QueryInterface ) if it supports the interface ISpecifyPropertyPages .在您的代码中,如果ISpecifyPropertyPages支持ISpecifyPropertyPages接口,则它会被查询 ( QueryInterface )。 If this is the case, then the OlePropertyFrame is created which displays the property page which is implemented by the camera object.如果是这种情况,则创建 OlePropertyFrame 以显示由相机对象实现的属性页。 Complete control goes to the camera object which is implementing the ISpecifyPropertyPages interface.完全控制转到实现ISpecifyPropertyPages接口的相机对象。 When the camera object displays the property page it can directly access it's own properties.当相机对象显示属性页时,它可以直接访问它自己的属性。 But it can also make the properties available externally by exporting another interface like IMyCameraSpecificInterface .但它也可以通过导出另一个接口(如IMyCameraSpecificInterface使属性在外部可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM