Thoughts, Codes and Articles. My Blog

Jamaica Blog Awards 2012 nomination

Me and my friend’s blog were nominated for the Jamaica Blog Awards 2012. You should vote for us at these Urls:

  1. Shawn Mclean - This blog
  2. Romaine Carter - Artificial Intelligence and Algorithms
  3. Rion Jefferson – Personal Blog
Posted in Random

Packt Publishing eBook offer for Christmas

Packt publishing currently has a promotion of reducing the prices of books to $5 USD if a purchase of 2 or more is made. Books such as a Computer Vision cookbook, costing $22 USD, will be on sale for $5, good deal IMO.

This company offers books that tries to keep up with the latest technologies and paradigms of software engineering. They have many books on HTML5, the current trend of technology right now. I suggest browsing their collections every few months/weeks to see what is new.

Visit their promo page for more details: http://www.packtpub.com/news/stock-your-reader-christmas

Posted in Programming, Web Design

Displaying camera output to full screen in windows phone

Sometimes we might need to display the camera output as full screen on our windows phone but due to the difference between aspect ratio of the camera output and the phone screen, this poses as a slight challenge.

The first problem is that the mapped camera output is rotated vertically. The second problem is the aspect ratio.

Code

The following code shows how to solve this:
Xaml
CSharp

The code-behind is a watered down version of setting up a camera. (There are checks to see if camera is supported, etc.)

 Explanation

  1.  Ensure the Canvas you are mapping the camera’s video stream to is Verticalled Stretched.
  2. Set the CompositeTransform’s CenterX and CenterY properties to .5 so when we set the rotation in code, it is done from the center.
  3. In the codebehind, the first thing we do when the camera is initialized is to move processing to the UI thread, hence the this.Dispatcher.BeginInvoke delegate.  this keyword ensures that the code is executed on the thread the CameraView PhoneApplication Page is running under. Without this, if we attempt to modify anything on the UI, we will get a cross thread exception.
  4. We then set the rotation of the canvas to the orientation of the camera.
  5. The final operation is to set the aspect ratio by using the first available resolution supported by the camera to calculate the width of the canvas.
Posted in Uncategorized

Getting started with rake on .NET and visual studio

Rake is normally used as a build tool scripting language (if used for anything else, please do comment). I’ve been using it for almost 2 years in place of NAnt and MSBuild due to its programmability. Executing a concise script to do anything I want for my build process is a great bonus rather than writing complex XML configurations. At work, I hook this script into the team city build server (which supports running rake tasks). My tasks ranges from versioning, unit-tests, deploy to staging and manual click to deploy to production, without having server specific features. Anything the build server can do, I can do it from my machine.

To get started with rake in .NET, here are the steps that easily gets you up and running:

  1. Download ruby and install it. Ruby comes bundled with rake. Ensure they are installed in your Environment PATH. If somehow rake isn’t bundled with ruby, its a gem anyway so install it with:
    gem install rake
  2. Install Albacore gem, a set of rake task made specifically for making building .NET projects easier. Tasks include running NUnit and MSTests, zip, nuget deployments, etc. Getting started found here. To install the gem:
    gem install albacore
  3. Download the visual studio plugin Rake Runner for visual studio 2012+. This allows you to run available rake tasks from the solution explorer.
  4. Create a visual studio project, place your Rakefile in the root folder of your project. This file should show up under Solution Items folder. This is where you write your scripts. Paste this code:
    require 'albacore'
    desc "Build"
    msbuild :build do |msb|
    msb.properties :configuration => :Release
    msb.targets :Clean, :Build
    msb.solution = "YourSolution.sln"
    end

    Replace the name of the solution with yours. Right click your solution, go to rake(Rake Runner extension) and select Build (refresh if not shown). The project should be built and the output shown in the output window pane.

  5. Go read this small tutorial which should help you get off the ground to writing some complex build scripts.
Build automation is a basic software engineering practise, rake is a great introduction for beginners to learn and very powerful and flexible for seasoned engineers. The support for rake in the .NET world is growing as more engineers see the power of rake.
Tagged with: , ,
Posted in .Net Framework

Converted SVN to Git project does not open in visual studio

I had a SVN hosted visual studio project that I just converted to Git. I am using the AnkhSVN plugin for SVN and Git Source Control provider plugin for git. After the conversion, I tried managing the project with `Git Source Control Provider` but visual studio threw this error: The active solution or project is currently controlled by a different source control plugin that the one you have selected. If you change the source control plug-in, the active solution will be closed.

To fix this, apparently AnkhSVN added a pre-selection command to the solution file that tells visual studio to use AnkhSVN as the source control plugin. To fix this, open your solution file and look for the following and remove it:

 
GlobalSection(SubversionScc) = preSolution
    Manager = AnkhSVN - Subversion Support for Visual Studio
    Svn-Managed = True
EndGlobalSection

 

Posted in Visual Studio