In our earlier blog post, we introduced the image morphing desktop application, which uses C++ AMP for computations internally. That sample demonstrates how to blend the C++ AMP code into a C# application.
In this blog post, we revisit the same sample. We have made it more interesting this time with an interactive UI by converting into a Windows Store Application, while we still continued to use the same core parallel algorithm. Using C++/CX, we created the UI. The following are the different snapshots of the application:
Loading Images Screen:
Adding Additional Lines Screen:
Face Morphed Screen:
Error Message Screen:
- In this application, we have integrated the FaceSDK provided by Microsoft Research Team. The SDK provides APIs to detect the faces in the given image.
- The application can capture the images using Camera and use them for face morphing. It also provides option to save the morphed image.
- The application consists of three pages mainly – Start, Edit, Final. For each page, the application preserves the state associated with each page, in case the application is suspended. If a page has a previous state, then the application will resume from the previous state.
- The application uses DirectX interop apis to share the resources (computed morphed image) between C++ AMP implementation of Morphing algorithm and the XAML rendering.
- Instead of performing Morphing algorithm on the entire image at once, the application performs the Face Morphing algorithm on chunks of image to avoid TDRs, UI unresponsiveness during computation. The chunk sizes are determined dynamically based on the previous chunk execution time. The execution in chunks also helps in tracking the progress of the morphing. The below are the two intermittent images that I captured on a high performing graphic card and on
a low performing graphics card to demonstrate the changes in the sizes of chunk :
a) on NVIDIA GTX 580 b) on WARP
Please download the sample project and try it yourself.
If you have any questions or comments, feel free to voice out below or in our MSDN forum.
The attached sample code is released under the MS-RSL license.