简体   繁体   中英

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). I read these frames using C++/OpenCV, process them and then show the output on a 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.

Shows command window with ffmpeg command line + crossbar window for the video capture device

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.

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. 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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