[content_band inner_container="true" no_margin="true" border="top" padding_top="40px" padding_bottom="40px"][custom_headline type="left" level="h3"]glasses.com App with 3Dfit Technology[/custom_headline][gap size="5%"]

[column type="one-fifth"].[/column][column type="three-fifths"]Adopting a new look is tough! Haircut, clothing style, glasses—whatever the change may be, finding the right fit is stressful. Glasses.com set out to improve the experience by providing customers a way of virtually trying on glasses in the comfort of their homes via smart phone or tablet.
The Glasses.com app takes a picture of the user’s face, creates a 3D model of facial features, and virtually places selected frames on the user’s 3D image. The user is then free to view the 3D image from a wide variety of angles.

The application relies on computer vision to recognize the features of a user’s face and to then generate an accurate, high-fidelity, 3D model of that face, such that the eyewear fits properly.

Glasses.com brought our engineers an excellent, fully-functioning version of the application, seeking acceleration. The app took full advantage of the CPU, which would necessitate Glasses.com’s purchasing and managing a large amount of hardware. Further, the application was running at a slow thirty seconds per session, resulting in a sub-optimal user experience. Our engineers were tasked with parallelizing the process and reducing the session runtime.

Glasses.com has several machines they are using in production. Their main setup consists of a Haswell/Ivy Bridge CPU paired with a GTX 690. The machine is able to run 4 processes concurrently. In the past, Glasses.com used a 32 core Intel process with a couple of K20X. They are still using these machines, but they are not the main configuration. They are also making use of the Amazon EC2 instances in case they exceed internal capacity.

We began by analyzing the application and targeting the process which would have the greatest impact on performance.
<blockquote>This app is amazing! It takes a 3D video of your face in just a few steps, and the rendering is spot on! RayBan Aviators are always a little big on me, and the app showed them on my face exactly as they fit in the store! —davidandrew</blockquote>
The most pressing concern was the rendering portion of code, which was running on the CPU. We implemented rendering in ArrayFire, which is specially optimized for CUDA GPUs. Further, we noticed that while the application was rendering-intensive, much of the rendering did not need to be precise—we could make estimations without compromising quality. This estimated rendering speedup operation was critical to the success of the project.

We discovered further opportunities for speedup within the architecture itself. The original app processed each frame in a separate thread; we accelerated this by combining each operation into a single kernel and running that kernel once. By moving the parallelization to the GPU we effectively took advantage of the strength of that architecture.

Ultimately, parallelizing the application and incorporating the ArrayFire software library accelerated the application to about ten seconds per session—roughly three times as fast as the original code, and twice as fast as the target speed. We further exceeded expectations by improving general stability when handling errors. <img class="aligncenter size-full wp-image-6903" src="http://sandbox.arrayfire.com/wp-content/uploads/2014/10/glassesdotcom-benchmarks.jpg" alt="glassesdotcom benchmarks" width="700" height="442" />

The improvements in speed, stability, and user experience have resonated with the application’s target market, resulting in a 3.5/5 star rating in the Apple Store.[/column][column type="one-fifth" last="true"].[/column][/content_band]