MediaCapture: : AddVideoEffectAsync to HP IR Camera thrown exception : The data specified for the media type is invalid, inconsistent, or not supported by this object.winRT information: The Input format is unsupported. What should I do

一 郝 0 Reputation points
2024-01-05T07:04:43.8+00:00

On my device has three source group, when switch to the HP IR Camera, MediaCapture: : AddVideoEffectAsync add face detection effect throw exceptions: The data specified for the media type is invalid, inconsistent, or not supported by this object.winRT information: The Input format is unsupported. What should I do

auto definition = ref new FaceDetectionEffectDefinition();

// To ensure preview smoothness, do not delay incoming samples
definition->SynchronousDetectionEnabled = false;

// In this scenario, choose detection speed over accuracy
definition->DetectionMode = FaceDetectionMode::HighPerformance;

// Add the effect to the preview stream
return create_task(m_mediaCapture->AddVideoEffectAsync(definition, Capture::MediaStreamType::VideoPreview))
    .then([this](IMediaExtension^ extension)
{
    _faceDetectionEffect = static_cast<FaceDetectionEffect^>(extension);

    // Register for face detection events
    _faceDetectedEventToken =
        _faceDetectionEffect->FaceDetected += ref new TypedEventHandler<FaceDetectionEffect^, FaceDetectedEventArgs^>(this, &Scenario2_FindAvailableSourceGroups::FaceDetectionEffect_FaceDetected);

    // Choose the shortest interval between detection events
    Windows::Foundation::TimeSpan duration = Windows::Foundation::TimeSpan();
    duration.Duration = 330000; // hundreds of nanoseconds (33ms)
    _faceDetectionEffect->DesiredDetectionInterval = duration;

    // Start detecting faces
    _faceDetectionEffect->Enabled = true;
    return task_from_result();
}).then([](task<void> previousTask) {
    try {
        previousTask.get();
    }
    catch (Platform::COMException^ e) {
        OutputDebugString(e->Message->Data());
    }
});
Developer technologies | Universal Windows Platform (UWP)
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.