×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    While it's quite easy to access preview frames from the camera using the APIs from WP8.0 this is currently not part of the new converged APIs. The only references I could find so far on how to gain access is by writing a custom MFT and that reference is from a part of the MSDN that is targetd at hardware developers, see: https://dev.windowsphone.com/en-US/O...n_managed_code

    Has anyone so far dealt with this issue (the APIs already existed on Win 8 previously)? I'd be happy if a simpler solution existed or perhaps a ready made sample.

  2. #2
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    106

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    Quote Originally Posted by SB Dev View Post
    While it's quite easy to access preview frames from the camera using the APIs from WP8.0 this is currently not part of the new converged APIs. The only references I could find so far on how to gain access is by writing a custom MFT and that reference is from a part of the MSDN that is targetd at hardware developers, see: https://dev.windowsphone.com/en-US/O...n_managed_code

    Has anyone so far dealt with this issue (the APIs already existed on Win 8 previously)? I'd be happy if a simpler solution existed or perhaps a ready made sample.
    I just got it working. I'm sure there are probably other ways to get to the data using some of the other methods from MediaCapture, but I ended up modifying one of the sample MediaFoundation Transforms (Grayscale Transform was the easiest) in the Media Extensions sample for Universal Apps. My app is in C#, but all of the Imaging SDK stuff is done in C++ inside the MF transform. I ended up converting the source byte array to a Nokia Bitmap, applied all my filters, rendered to a new Bitmap using the Yuv420Sp ColorMode (NV12 is what my Lumia 920 likes to output), then copied the IBuffer inside that Bitmap to the native output char array that the MF transform expects.

    In the C# portion, I use the MediaCapture.AddEffectAsync method to add the transform.

    You'll have to manually edit your Manifest file to register the transform with Media Foundation. (open the sample's manifest file in an XML viewer to see how).

    I haven't measured frame rates yet, but it seems maybe a tad faster than the "real-time demo" that's in the wiki? I have no idea yet.

    This is the sample:
    http://code.msdn.microsoft.com/wpapp...ssions#content

    PS - And read the Q & A part of the sample's webpage. There's a weird bug for ARM-Release versions where it won't compile unless you add a namespace with a dummy class in it.

  3. #3
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    106

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    This is a sample video recorded using the CartoonFilter encoded down to QVGA size. I'm still playing with the settings and the Record function uses different sizes than the Preview function. I believe this recorded defaulted to 1080p capture, but I'm betting the downscaling happened before the cartoon transform was applied. The Preview was still running at QVGA resolution with the transform added, so I'm sure I can improve this with some creativity.

    In any case, it's working. I can write up a wiki page for it and post a sample solution when I have a clean one ready later. I need to come up with something cool to do to make it count towards the contest.

    http://1drv.ms/TfSodJ

    EDIT: I'm having problems playing this in SkyDrive's video player... download it and it works fine in VLC.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    Thx a lot for the info. I'm only trying to get access to the info right now to be able to scan for QR codes from a Universal App using ZXing.Net. The ZXing sample for WinRT is far from the performance of the WP8.0 one.

    If you could write a Wiki article on this accompanied by a sample that would definitely be great. I have found the question pop up several times on the Internet but never really a well made answer or a complete sample, so I'd guess that it would help a lot of people who are running into this issue.

  5. #5
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    473

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    If you want camera preview, look here : http://developer.nokia.com/resources...me-filter-demo
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  6. #6
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    106

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    When I was struggling to get my C++ stuff working, I found the CameraImagePreviewSource but it did not occur to me to use it in C#.

    Your solution looks good.

  7. #7
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,540

    Re: Windows Phone 8.1 Windows.Media.Capture API and Preview Frames

    FYI This thread has been featured and you can find details here

Similar Threads

  1. XMPP/Media Library for windows phone 8
    By vinayppatil in forum Windows Phone General
    Replies: 5
    Last Post: 2014-02-12, 07:14
  2. Need to implement auto image capture in windows phone 8
    By sk20 in forum Windows Phone Imaging
    Replies: 7
    Last Post: 2013-11-27, 09:34
  3. Replies: 2
    Last Post: 2013-02-07, 10:58
  4. how to capture screen on windows phone
    By csu_nj in forum Windows Phone General
    Replies: 7
    Last Post: 2012-02-09, 13:40
  5. WEBINAR FEEDBACK: Media playback on Windows Phone platform
    By vphong in forum Windows Phone General
    Replies: 11
    Last Post: 2012-02-02, 19:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×