# Monday, 14 March 2016
Monday, 14 March 2016 16:05:00 (GMT Standard Time, UTC+00:00)

Generating a thumbnail image from a larger image sounds easy – just shrink the dimensions of the original, right? But it becomes more complicated if the thumbnail image is a different shape than the original. In this case, we will need to crop or distort the original image. Distorting the image tends to look very bad; and when we crop an image, we will need to ensure that the primary subject of the image remains in the generated thumbnail. To do this, we need to identify the primary subject of the image. That's easy enough for a human observer to do, but a difficult thing for a computer to do, which is necessary if we want to automate this process.

This is where machine learning can help. By analyzing many images, Machine Learning can figure out what parts of a picture are likely to be the main subject. Once this is known, it becomes a simpler matter to crop the picture in such a way that the main subject remains.

Project Oxford uses Machine Learning so that you don't have to. It exposes an API to create an intelligent thumbnail image from any picture.

You can see this in action at www.projectoxford.ai/demo/vision#Thumbnail.


Thu01-LiveDemo
Figure 1

With this live, in-browser demo, you can either select an image from the gallery and view the generated thumbnails; or provide your own image - either from your local computer or from a public URL. The page uses the Thumbnail API to create thumbnails of 6 different dimensions.

Thu02-LiveDemo-2
Figure 2

For your own application, you can either call the REST Web Service directly or (for a .NET application) use a custom library. The library simplifies development by abstracting away HTTP calls via strongly-typed objects.

To get started, you will need a free Project Oxford account and you will need to sign into projectoxford.ai with a Microsoft account.

For this API, you need a key. From the Computer Vision API page, (Figure 3); click the [Try for free >] button; then, click the "Show" link under the Primary key of the "Computer Vision" section (Figue 4).

Thu03-ComputerVisionApiPage
Figure 3 

Thu04-ShowKey
Figure 4 

To use the SDK, add the Microsoft.ProjectOxford.Video NuGet package to your project: Right-click on your project, select Manage NuGet Packages, search for "ProjectOxford.Video", select the package from the list, and click the [Install] button, as shown in Figure 5

Thu05-NuGet
Figure 5

This adds a reference to Microsoft.ProjectOxford.Vision.dll, which contains classes that make it easier to call this API.

Add the following statement to the top of a class file to use this library.

using Microsoft.ProjectOxford.Vision;

Now, you can use the methods in the VisionServiceClient class to interact with the API.

Create a VisionServiceClient with the following code:

string subscriptionKey = "15e24a988f484591b17bcc4713aec800";
IVisionServiceClient visionClient = new VisionServiceClient(subscriptionKey);

where “xxxxxxxxxxxxxxxxxxxxxxxxxxx” is your subscription key.

Next, use the GetThumbnailAsync method to generate a thumbnail image. The following code creates a 200x100 thumbnail of a photo of a buoy in Stockholm, Sweden.

string originalPicture = @"https://giard.smugmug.com/Travel/Sweden-2015/i-ncF6hXw/0/L/IMG_1560-L.jpg";
int width = 200;
int height = 100;
bool smartCropping = true;
byte[] thumbnailResult = null;
thumbnailResult = visionClient.GetThumbnailAsync(originalPicture, width, height, smartCropping).Result;

The result is an array of bytes, but you can save the corresponding image to a file with the following code:

string folder = @"c:\test";
string thumbnaileFullPath = string.Format("{0}\\thumbnailResult_{1:yyyMMddhhmmss}.jpg", folder, DateTime.Now);
using (BinaryWriter binaryWrite = new BinaryWriter(new FileStream(thumbnaileFullPath, FileMode.Create, FileAccess.Write)))
{
    binaryWrite.Write(thumbnailResult);
}

Below is the full listing in a Console App to generate a thumbnail; then open both the original image and the saved thumbnail image for comparison.

using System;
using System.Diagnostics;
using System.IO;
using Microsoft.ProjectOxford.Vision;
 
namespace ThumbNailConsole
{
    class Program
    {
        static void Main(string[] args)
        {
 
            string subscriptionKey = "15e24a988f484591b17bcc4713aec800";
            IVisionServiceClient visionClient = new VisionServiceClient(subscriptionKey);
 
            string originalPicture = @"https://giard.smugmug.com/Travel/Sweden-2015/i-ncF6hXw/0/L/IMG_1560-L.jpg";
            int width = 200;
            int height = 100;
            bool smartCropping = true;
            byte[] thumbnailResult = null;
            thumbnailResult = visionClient.GetThumbnailAsync(originalPicture, width, height, smartCropping).Result;
 
            string folder = @"c:\test";
            string thumbnaileFullPath = string.Format("{0}\\thumbnailResult_{1:yyyMMddhhmmss}.jpg", folder, DateTime.Now);
            using (BinaryWriter binaryWrite = new BinaryWriter(new FileStream(thumbnaileFullPath, FileMode.Create, FileAccess.Write)))
            {
                binaryWrite.Write(thumbnailResult);
            }
 
            Process.Start(thumbnaileFullPath);
            Process.Start(originalPicture);
 
            Console.WriteLine("Done! Thumbnail is at {0}!", thumbnaileFullPath);
        }
    }
}

The result is shown in Figure 6 below.

Thu06-Output

One thing to note. The Thumbnail API is part of the Computer Vision API. As of this writing, the free version of the Computer Vision API is limited to 5,000 transactions per month. If you want more than that, you will need to upgrade to the Standard version, which charges $1.50 per 1000 transactions.

But this should be plenty for you to learn this API for free and build and test your applications until you need to put them into production.

The code above can be found on GitHub.

Monday, 14 March 2016 04:01:00 (GMT Standard Time, UTC+00:00)
# Sunday, 13 March 2016

Project Oxford is a set of APIs that take advantage of Machine Learning to provide developers with

These technologies require Machine Learning, which requires a lot of computing power and a lot of data. Most of us have neither, but Microsoft does and has used it to create the APIs in Project Oxford.

Project Oxford provides APIs to analyze pictures and voice and provide intelligent information about them.

There are three broad categories of services: Vision, Voice, and Language.

The Vision APIs analyzes pictures and recognizes objects in those pictures.  For example, several Vision APIs are capable of recognizing  faces in an image. One analyzes each face and deduces that person's emotion; another can compare 2 pictures and decide whether or not 2 photographs are the same person; a third guesses the age of each person in a photo.

The Speech APIs can convert speech to text or text to speech. It can also recognize the voice of a given speaker (if you want to use that for authentication in your app, for example) and infer the intent of the speaker from his words and tone.

The Language APIs seem more of a grab bag to me. A spell checker is smart enough to recognize common proper names and homonyms.

All these APIs are currently in Preview but I've played with them and they appear very solid. Many of theme even provide a confidence factor to let you know how confident you should be in the value returned. For example, 2 faces may represent the same person but it helps to know how closely they match.

You can use these APIs. To get started, you need a Project Oxford account, but you can get one for free at projectoxford.ai.

Each API offers a free option that restricts the number and/or frequency of calls, but you can break through that boundary for a charge.

You can also find documentation, sample code, and even a place to try out each API live in your browser at projectoxford.ai.

You call each one by passing and receiving JSON to a RESTful web service, but some of them offer an SDK to make it easier to make that call from a .NET application.

You can see a couple of fun applications of Project Oxford at how-old.net (which guesses the ages of people in photographs) and what-dog.net (which identifies the breed of dog in a photo).

Sign up today and start building apps. It’s fun and it’s free!

Sunday, 13 March 2016 03:14:12 (GMT Standard Time, UTC+00:00)
# Friday, 11 March 2016

The auditorium darkened. The music began and a small light appeared at the front of the room; then more. Students on stage danced and waved lanterns on ropes for an impressive musical light show to kick off the 2016 SpartaHack hackathon.

 

Students came from all over the world to attend this hackathon on the East Lansing campus. Over 200 universities were represented among the applicants. In addition to a number of international students studying on American campus, I met students who traveled to the hackathon from India, Russia, Germany, and the Philippines.

AnnaMattDavidBrian My colleague Brian Sherwin arrived in East Lansing the day before the hackathon to host an Azure workshop for 30 students - showing them how to use the cloud platform to enhance their applications. Ann Lergaard joined us a day later and we did our best to answer student questions and help them build better projects. Late Friday night, I delivered a tech talk showing off some of the services available in Azure.

Microsoft offered a prize for the best hack using our technology. It was won be 2 students who built an application that allowed users to take a photo of text with their iPhone and, in response to voice commands, read back any part of that text. The project combined Microsoft's Project Oxford OCR API with an Amazon Echo and its Alexa platform, an iPhone app, and a Firebase database.

A couple other cool hacks were:

  • ValU, an app that used Microsoft Excel to analyze historical stock price data using Excel VBA scripts.
  • Spartifai, which modified a driver, allowing a Kinect device to be used with a MacBook.

JazzBand A hackathon is an event at which students and others come together and build software and/or hardware projects in small teams over the course of a couple days. I attend a lot of hackathons and SpartaHack was one of the better organized that I've seen. Over 500 students spent the weekend building a wide variety of impressive projects - often with technology they had not touched prior to that weekend. The organizers also did a great job of providing fun activities beyond just hacking. A jazz band and a rock band each performed a set for students to enjoy during a break; a Super Smash Brothers tournament was scheduled; and a Blind Coding Contest challenged students to write code without compiling or testing to see if it would run correctly the first time in front of an audience. 

Snowman As sponsors of the event, we tried to provide some fun as well. We gave away prizes for building a snowman and for tweeting about open source technology. We also provided some loaner hardware for students; and we spent a lot of time mentoring students, which resulted in a lack of sleep this weekend.

The MSU campus has changed a great deal since I earned my undergraduate degree there decades ago. It has even changed since my son graduated from there 4 years ago. But it still felt like a homecoming for me.

 

 

Friday, 11 March 2016 16:42:00 (GMT Standard Time, UTC+00:00)
# Monday, 07 March 2016
Monday, 07 March 2016 12:52:00 (GMT Standard Time, UTC+00:00)
# Sunday, 06 March 2016

3/6
Today I am grateful to unexpectedly run into Jody​ and David in Chicago yesterday.

3/5
Today I am grateful for new shelves and less clutter in my apartment.

3/4
Today I am grateful for a home-cooked dinner last night.

3/3
Today I am grateful for dinner last night with Kevin.

3/2
Today I am grateful for:
-an overwhelming number of kind messages on Facebook yesterday.
-a birthday lunch with Chris in Grand Rapids yesterday.

3/1
Today I am grateful for my first visit to ann arbor, MI since I sold my house, including: -A personal tour of The Forge by Jeeva -Coffee with Velichka -A great crowd to attend my Azure Mobile Apps talk at Mobile Monday.

2/29
Today I am grateful to the SpartaHack organizers and hackers who contributed to a successful hackathon this past weekend.

2/28
Today I am grateful that this parking ticket was thrown out by the local police.

2/27
Today I am grateful for a day in East Lansing, MI and at Michigan State University.

2/26
Today I am grateful for a good crowd at our Azure Workshop last night at MSU.

2/25
Today I am grateful for the technology that allows me to watch TV and movies when and where I want.

2/24
Today I am grateful to Michael, Chris, Chris, and Murali for helping make yesterday's Cloud Camp a success by bringing real world experience to the presentations.

2/23
Today I am grateful to be able to ride my bike in February in Chicago.

2/22
Today I am grateful to the organizers and participants at HackIllinois who made this weekend's hackathon so successful.

2/21
Today I am grateful to Vanessa, who brought me espresso yesterday each time my energy ran low.

2/20
Today I am grateful for the hundreds of students who came to my Azure talk last night that I re-wrote yesterday afternoon.

2/19
Today I am grateful for this excellent and unexpected moving gift from Betsy

2/18
Today I am grateful for unsolicited praise from a co-worker yesterday.

2/17
Today I am grateful for an unexpected call from my cousin Kevin yesterday.

2/16
Today I am grateful for dinner with Christina last night.

2/15
Today I am grateful for a pristine blanket of snow covering downtown Chicago this morning.

2/14
Today I am grateful for Nyquil, Dayquil, and a Neti Pot.

2/13
Today I am grateful for finally paying off some sleep debt.

2/12
Today I am grateful for: -Lunch yesterday with Matt -A chance to present to a group of University of Chicago students

2/11
Today I am grateful for: -My first day with a personal trainer at the new gym -Attending Founder Institute graduation

2/10
Today I am grateful for my first game at Purdue's Mackey Arena.

2/9
Today I am grateful for the help I received yesterday unpacking dozens of boxes from my move.

2/8
Today I am grateful for an excellent week in Seattle.

Sunday, 06 March 2016 12:51:12 (GMT Standard Time, UTC+00:00)
# Monday, 29 February 2016
Monday, 29 February 2016 17:44:00 (GMT Standard Time, UTC+00:00)
# Wednesday, 24 February 2016

semjs-large When I lived in Michigan, I was a regular attendee of the Southeast Michigan JavaScript meetup – a local user group that attracted close to a hundred attendees each month and excellent speakers from all over the country.

One thing I admired about this meetup is their habit of recording meeting presentations. 

Those recordings are now available on Microsoft’s Channel 9 site. You can view dozens of these presentations at https://channel9.msdn.com/Blogs/semjs.

In the past 2 weeks, over 50,000 people have watched these videos on Channel 9.

Below are some of the more popular presentations:

 
 
 
Wednesday, 24 February 2016 21:11:23 (GMT Standard Time, UTC+00:00)
# Tuesday, 23 February 2016
# Tuesday, 16 February 2016

I spent years as a software consultant and I wrote a lot of web applications during that time.

I remember when I first discovered Active Server Pages  (which we now call "Classic ASP") and I remember how excited I was by this technology. It empowered me to write dynamic applications that the whole world could see.

When Microsoft introduced ASP.NET, I quickly embraced it and when ASP.NET evolved to MVC, I was excited to move to this new paradigm.

I even wrote a bit of JavaScript, enhancing my web applications with client-side validation and interactivity. I wrote even more JavaScript after discovering how jQuery made the DOM manipulation easier to write, debug, and maintain.

But, about 5 years ago, I stopped writing web applications. It wasn't because I disliked anything about them; it was only because my customers were looking for different solutions. So, for a few years, I wrote middleware services and web services and rich client applications and I built databases and I set up continuous integrations systems and I barely looked at web development.

But Web Development technologies did not stand still; if anything, they changed faster than almost any other area of software.

Web Development has moved largely from the server to the client. Interactions that were once handled by a form post and full page refresh are now done using Ajax calls to a web service and client-side DOM manipulation. An asynchronous callback from the server to client triggers a JavaScript function to update elements on the page, eliminating the need for a disruptive repainting of an entire page.

The user experience of a Single Page Application tends to be far superior to the older multi-page applications, so users are demanding more and developers are now writing large, complex applications that run almost entirely inside a browser.

JavaScript wasn't designed with this complexity in mind, so a number of JavaScript frameworks emerged to help developers manage this complexity. These frameworks take care of things like data binding, DOM manipulation, input validation, and separation of concerns, freeing developers to focus their efforts on business logic and other features unique to their own applications.

These frameworks help, but they come at a cost. It takes time to learn a new framework and each framework has its own set of rules and idiosyncrasies.

Even more challenging is the speed at which these frameworks are released. A year after the popularity of ember.js and backbone.js peaked, developers began flocking to Angular.js. Last year, Angular seemed to lose ground to React.js. It's hard to tell what will be the next hot JavaScript framework (Angular 2.0? Aurelia? Something else?), but the rate at which new frameworks appear is accelerating.

Of course, it is not practical to re-write every application every year, simply because you discover a new framework - even one with advantages over your existing framework of choice. And most of us don't have the time to become familiar with a new framework every few months. We have to balance the increased productivity of a new framework against the time spent learning (as opposed to building).

This is the world in which I now find myself as I return to Web Development after a half decade absence. Everything has changed and continues to change at a startling rate.

In many ways this constant innovation is exciting and energizing. But it can also be overwhelming as I try to select the appropriate tools from a plethora of options and as I spend the time and effort learning how to use these tools.

meerkats I feel like I'm in a science fiction movie where the hero departs the Earth at light speed; then returns to discover the planet is ruled by talking meerkats: All the rules have changed while I was gone and I need to adapt. Quickly.

The approach I've taken is to pick a JavaScript framework, learn it, and build an application with it. I chose Angular to start - partly because I had heard good things about it and partly because its popularity ensured I would be able to find samples, tutorials, videos, and other reference materials to assist me. Next, I'll rebuild this functionality in ReactJs, followed by some other framework, until I have a feel for the paradigms involved in JavaScript development and for the relative strengths of each framework.

You can track my progress at https://github.com/DavidGiard/tvdg and on this blog.

So far, I'm enjoying the ride.

Tuesday, 16 February 2016 14:41:04 (GMT Standard Time, UTC+00:00)