如何同时使用两个CameraCaptureUI (UWP / C++)

How to use two CameraCaptureUI at the same time (UWP / C++)

我正在开发通用 Windows 平台应用程序 (UWP),我在其中使用 C++ 作为主要语言。我想同时从两个相机读取。一个摄像头属于 Kinect RGB 摄像头,另一个摄像头属于 Kinect 深度摄像头。到目前为止,我已经设法使用这段代码读取了一个:

void SDKTemplate::Scenario4_ReproVideo::Grabar_Click(Platform::Object^ 
sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
CameraCaptureUI^ dialog = ref new CameraCaptureUI();
dialog->VideoSettings->Format = CameraCaptureUIVideoFormat::Mp4;

Windows::Foundation::Collections::IPropertySet^ appSettings = ApplicationData::Current->LocalSettings->Values;

concurrency::task<StorageFile^>(dialog->CaptureFileAsync(CameraCaptureUIMode::Video)).then([this](StorageFile^ file) {
    if (file != nullptr) {

        concurrency::task<Streams::IRandomAccessStream^> (file->OpenAsync(FileAccessMode::Read)).then([this] (Streams::IRandomAccessStream^ stream){
            CapturedVideo->SetSource(stream, "video/mp4");
            logger->Text = "recording";
        });
        Windows::Foundation::Collections::IPropertySet^ appSettings = ApplicationData::Current->LocalSettings->Values;

        appSettings->Insert("CapturedVideo", PropertyValue::CreateString(file->Path));
    }
    else {
        logger->Text = "Something went wrong or was cancelled";
    }

});
}

通过这样做,我可以从其中一台摄像机可靠地进行录制。我的问题是我需要同时从两个摄像头进行录制,因为我需要深度和 RGB 来处理视频。

我是并发新手,有没有办法(越简单越好)同时实现两路录音?

在 UWP 应用中,我们可以使用 MediaCapture class which provides functionality for capturing photos, audio, and videos from a capture device. See the topic Basic photo, video, and audio capture with MediaCapture 来拍摄照片和视频。

我们可以初始化多个MediaCapture instances then read frame by using MediaFrameReader Class. see the topic Discover and select camera capabilities with camera profiles and Process media frames with MediaFrameReader and also look into the official sample CameraFrames.

另外还有一个关于UWP多机位采集的类似帖子,大家也可以参考一下: