locked
How to add grayscale effect to a live preview camera capture?

    Question

  • Hello All.

    How can I take the live stream coming from a webcam which is displaying live on in my metro app, allow the user to click a "apply grayscale" button, and then apply a grayscale effect onto the live webcam preview?

    I am starting with the previewing code from the MediaCaptureCPP project.  This will display a box on the screen which shows the live camera feed.

    The code to do this is:

    ...

    m_MediaCaptureMgr->InitializeAsync(m_CaptureInitSettings);

    ...

    m_MediaCaptureMgr->StartPreviewAsync();

    ...

    I have then put a button on the screen which says "Apply Grayscale Effect."  The code for this is just a button handler:

    void SampleApp::MainPage::GrayscaleBtn_click(...)

    {

        m_MediaCaptureMgr->AddEffectAsync(

            Windows:Media::Capture::MediaStreamType::VideoPreview,

            "Microsoft.Samples.GrayscaleEffect",

            nullptr);

    }

    I'm using the same GrayscaleTransform.dll file used in the MediaPluginsCPP project.

    Shouldn't the live feed change to grayscale when I click the button?  What am I missing?  Any help will be greatly appreciated!!!

    Wednesday, February 15, 2012 1:21 AM

Answers

  • Hello Seek,

    You cannot add an effect while the topology is in a "running" or "paused" state. You must make sure that the topology is stopped before adding the effect.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, February 15, 2012 10:04 PM
    Moderator