简体   繁体   English

使用C ++ / python调整视频捕获输入端口

[英]Adjust video capture input port using C++ / python

I am having a video capture device (VCD) that acquires frames from a TV which have various output ports (VGA, HDMI, DVI). 我有一个视频捕获设备(VCD),可从具有各种输出端口(VGA,HDMI,DVI)的电视中获取帧。 I read these frames using C++/OpenCV, process them and then show the output on a C++/Qt QLabel. 我使用C ++ / OpenCV阅读这些框架,对其进行处理,然后在C ++ / Qt QLabel上显示输出。

My problems show up when I change the input port (DVI to HDMI or HDMI to VGA,...), at then I need to manually open the crossbar dialog window for the VCD and switch the input port. 当我更改输入端口(DVI到HDMI或HDMI到VGA,...)时,出现了我的问题,那时我需要手动打开VCD的交叉开关对话框窗口并切换输入端口。

Shows command window with ffmpeg command line + crossbar window for the video capture device 显示带有ffmpeg命令行的命令窗口+视频捕获设备的交叉窗口

Moreover, for each input port, I need to adjust some parameters relating to color range, scaling size and wire's length. 此外,对于每个输入端口,我需要调整一些与颜色范围,缩放比例和导线长度有关的参数。

I need to automate this process of selecting the right input port with the corresponding right parameters using a C++ or python code. 我需要使用C ++或python代码来自动化选择带有相应正确参数的正确输入端口的过程。

I was searching for a way to read all the input pins of the crossbar dialog box for the video capture device and this set/unset the required pins. 我正在寻找一种方法来读取视频捕获设备的交叉开关对话框的所有输入引脚,并设置/取消所需的引脚。

Thanks in advance. 提前致谢。

Here is the example in C++/WinAPI how you can set/unset the VIDEO INPUT pins on settings dialog. 这是C ++ / WinAPI中的示例,说明如何在设置对话框中设置/取消VIDEO INPUT引脚。 This code assumes, that checkboxes are children elements of the main dialog; 这段代码假定复选框是主对话框的子元素。 there can be case, when they are nested inside the tab control "Custom settings", so in this case you need find the that tab at first. 在某些情况下,它们嵌套在选项卡控件“自定义设置”中,因此在这种情况下,您首先需要找到该选项卡。

#include <windows.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>


int main(int, char **)
{
    // Find the dialog
    HWND hwnd = FindWindowA(NULL, "%Your settings dialog caption%");

    if (hwnd == NULL)
    {
        std::cerr << "cannot find settings dialog" << std::endl;
        return 1;
    }

    std::map<std::string, HWND> options;

    // Get first dialog element
    HWND h = GetWindow(hwnd, GW_CHILD);

    char caption[250];

    std::vector<std::string> inputs{
        "1/HDMI",
        "2/DVI-D",
        "3/COMPONENT",
        "DVI",
        "4/VGA",
        "SOG",
        "5/SDI",
        "6/COMPOSITE",
        "7/S-VIDEO",
        "8/AUTO"
    };

    while (h != NULL)
    {
        // Get element text
        if (GetWindowTextA(h, caption, 250))
        {
            std::string scaption(caption);
            // Check the text, if it's in the list of the option, put it into map.
            if (std::find(inputs.begin(), inputs.end(), scaption) != inputs.end())
            {
                options[caption] = h;
            }
        }
        h = GetWindow(h, GW_HWNDNEXT);
    }

    // Check the 4/VGA option.
    SendMessageA(options["4/VGA"], BM_CLICK, 0, 0); 

    return 0;
}

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

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