DCSIMG
June 2011 - Posts - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

June 2011 - Posts

Sela Dev Days - MTM, Automation and Load Testing Lectures





Yesterday I had the pleasure to give a Full day lecture about Microsoft Test Manager, Unit Tests, Web Test, Coded UI Test and Load Testing.

My Sela Dev-Days Experience

We started with a short talk about ALM and ways to improve your development and Testing process using Agile, CMMI and Scrum, then we apply this to how should we work with Microsoft Test Manager with different methodologies (Scrum etc) to create better Test Coverage and better experience for Tester and Developer alike. 

After we played with Microsoft Test Manager, we move to Test Automation with Visual Studio 2010, Web Performance Test -  we saw couple of ways how Web Testing can save the tester lots of time and effort for Web and Desktop applications – (See Videos)

We moves to Load Testing and talked about the 10 Steps to perform good load testing with Visual Studio 2010 (http://www.codeproject.com/KB/books/LoadTesting.aspx), and of course I’ve showed how to create good, reliable and fast Load Testing with Visual Studio 2010 ultimate, also we talked about create Agents to assist your Load Testing with IP Switching and create much larger load testing scenario.

At the end we talked about Coded UI Testing, the benefit of functional automated testing based on .NET and not some Script language, also the limitation and how to increase some known issues with Coded UI Testing.

I want to say thanks to everyone who attend in Sela Dev Days especially in the ALM sessions, I hope you enjoyed!

Visual Studio ALM Video & Two Updates for TFS/VS You Should Install

Some news for Visual Studio 2010, I’ll start from several updates you should to apply on you TFS and Visual Studio.

KB - TFS 2010 SP1 Cumulative Update 1 – KB2536929

This is the first Update from Microsoft since SP1, and the new concept from Microsoft is to release hot fixes for critical bugs, every once in a while when the development team feels they have critical mass of fixes they will publish new Update includes all hot fixes. – So make sure your Visual Studio and TFS are up to date.

  • This update should be installed on TFS application tiers and build servers. It need not be installed elsewhere (clients or proxies).
  • *IMPORTANT UPDATE* - Don't install this patch on a TFS proxy!

KB - Rollup Update - Testing Tools in Visual Studio 2010 SP1 –  Read KB 

The above update solves several issues in Coded UI Testing:

  • Attempted to access an unloaded AppDomain. (Exception from HRESULT: 0x80131014)
  • "Search may have failed at '<name>' <control type> as it may have virtualized children. If the control being searched is descendant of '<name>' <control type> then including it as the parent container may solve the problem."
  • And More - Read KB

Visual Studio ALM + Team Foundation Server Blog

Esther Fan has released a great list of videos from MSDN about Visual Studio ALM, you will find videos for Testing, Development, Visualization, Modeling, and Architecture, Team Foundation Server and Lab Management.

Article - http://blogs.msdn.com/b/vstsue/archive/2011/06/15/videos-about-visual-studio-alm-team-foundation-server-2010-on-msdn.aspx

A Glimpse:

Testing

Lab Management

Kinect – Create Buttons





In my previous posts about Kinect I’ve showed how to get started, how to change Angles and more cool stuff, but now it’s time to start working on the real things, how to KinectButtonenable Kinect to your environment, I’m talking about PC.

You may say Kinect is not yet perfect and the precision of the Skeleton Tracking system isn’t 100% accurate, and if you have to stand at least 1 meter from the screen how you will be able to see something from that distance? even more how to perform a Click? (Raise the other hand isn’t a good solution but checking the distance of the hand can help us to do that – I’ll show more later.)

Several posts ago I’ve talked about Masking in WPF and showed how to create WP7 The Mask Way– Rating Control and More, in this post I’ll use the same concept to Create Kinect Buttons that can fit for PC.

Download Control Kit

How?

There are several ways to accomplish that, the one I’m going to show is by Timer – same as the XBox Kinect concept you will move the Kinect Cursor over the Button then based on the Time you want the user has to hold the cursor in the same position and if he complete the time period then a Click event will be fired.

Step 1: Create New Control

Create Xaml: I’ve used the same concept as the Rating Control Mask and define the Border Path, Mask and the Fill and also added a Text Block to display the Text on the button.

<Grid x:Name="LayoutRoot">
    <Path x:Name="FillPath" Stretch="Fill" Data="F1 M 113.302,91.7188C 113.302,103.641 103.642,113.299 91.7213,113.299L 21.582,113.299C 9.66146,113.299 7.62939e-006,103.641
            7.62939e-006,91.7188L 7.62939e-006,21.5821C 7.62939e-006,9.66148 9.66146,2.47955e-005 21.582,2.47955e-005L 91.7213,2.47955e-005C 103.642,2.47955e-005 113.302,9.66148
            113.302,21.5821L 113.302,91.7188 Z " Margin="8,8,0,0" Height="113" HorizontalAlignment="Left" Width="113" VerticalAlignment="Top" Fill="{Binding PathFill}">            
    </Path>
 
    <Rectangle x:Name="Mask" Fill="White" Height="121" VerticalAlignment="Top" HorizontalAlignment="Left" Width="129" RenderTransformOrigin="0.5,0.5" >
    </Rectangle>
 
    <Path x:Name="BorderPath" Stretch="Fill" StrokeThickness="0.591467" StrokeLineJoin="Round" Stroke="#FF777677" Data="F1 M 121.384,99.8022C 121.384,111.724 111.724,121.383
            99.8035,121.383L 29.6642,121.383C 17.7436,121.383 8.08218,111.724 8.08218,99.8022L 8.08218,29.6655C 8.08218,17.745 17.7436,8.0835 29.6642,8.0835L 99.8035,8.0835C
            111.724,8.0835 121.384,17.745 121.384,29.6655L 121.384,99.8022 Z M 104.624,0.295738L 24.8439,0.295738C 11.2853,0.295738 0.295734,11.2866 0.295734,24.8439L
            0.295734,104.624C 0.295734,118.181 11.2853,129.172 24.8439,129.172L 104.624,129.172C 118.181,129.172 129.172,118.181 129.172,104.624L 129.172,24.8439C
            129.172,11.2866 118.181,0.295738 104.624,0.295738 Z " HorizontalAlignment="Left" Width="129" Height="129" VerticalAlignment="Top">
        <Path.Fill>
            <LinearGradientBrush StartPoint="0.5,6.51193e-007" EndPoint="0.5,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="#FFDED9D2" Offset="0" />
                    <GradientStop Color="#FF858681" Offset="0.154192" />
                    <GradientStop Color="#FF2D3330" Offset="0.26404" />
                    <GradientStop Color="#FF969997" Offset="0.383313" />
                    <GradientStop Color="#FFFFFFFF" Offset="0.57303" />
                    <GradientStop Color="#FF7F7F7F" Offset="0.735806" />
                    <GradientStop Color="#FF000000" Offset="1" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Path.Fill>
    </Path>
        
    <TextBlock Name="txtHeader" Text="{Binding DisplayText}" Foreground="{Binding DisplayTextColor}" TextAlignment="Center" TextWrapping="WrapWithOverflow" FontSize="38"
VerticalAlignment="Center" HorizontalAlignment="Center" /> </Grid
>

Define the basic properties for your button control, for example I’ve defined some DependencyProperty  for Time Interval, Fill Path Color and Display Text etc…

/// <summary>
/// Timer Interval
/// </summary>
public int Time
{
    get { return (int)this.GetValue(TimeProperty); }
    set { this.SetValue(TimeProperty, value); }
}
public static readonly DependencyProperty TimeProperty = DependencyProperty.Register(
    "Time"typeof(int), typeof(KinectButton), new PropertyMetadata((int)3));
 
/// <summary>
/// Fill Color
/// </summary>
public Brush PathFill
{
    get { return (Brush)this.GetValue(PathFillProperty); }
    set { this.SetValue(PathFillProperty, value); }
}
public static readonly DependencyProperty PathFillProperty = DependencyProperty.Register(
    "PathFill"typeof(Brush), typeof(KinectButton), new PropertyMetadata(Brushes.Yellow));
 
/// <summary>
/// Display Text Color
/// </summary>
public Brush DisplayTextColor
{
    get { return (Brush)this.GetValue(DisplayTextColorProperty); }
    set { this.SetValue(DisplayTextColorProperty, value); }
}
public static readonly DependencyProperty DisplayTextColorProperty = DependencyProperty.Register(
    "DisplayTextColor"typeof(Brush), typeof(KinectButton), new PropertyMetadata(Brushes.Black));
 
/// <summary>
/// Display Text
/// </summary>
public string DisplayText
{
    get { return (string)this.GetValue(TextProperty); }
    set { this.SetValue(TextProperty, value); }
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
    "DisplayText"typeof(string), typeof(KinectButton), new PropertyMetadata("Display Text"));

Step 2: Enter , Leave and Simulate Click Event

Register for MouseEnter and MouseLeave event and define new event for you KinectButton called – ClickHandler

public delegate void ClickHandler(object sender, EventArgs eventArgs);
public event ClickHandler Click;
Now, when the mouse enter to the KinectButton we going to start Fill the button with Color and when the button leave the KinectButton we will remove the fill.
private void SrKinectButtonMouseEnter(object sender, MouseEventArgs e)
{
    StartFill();
}
 
private void SrKinectButtonMouseLeave(object sender, MouseEventArgs e)
{
    RemoveFill();
}
You can put counter and several other technics to show the count down for the user I did a Animation to fill the KinectButton, like that:
void StartFill()
{
    da = new DoubleAnimation(Mask.ActualHeight, MinFillHeight, _duration);
    da.Completed += new EventHandler(da_Completed);
    Mask.BeginAnimation(Canvas.HeightProperty, da);
}
 
void da_Completed(object sender, EventArgs e)
{
    if (Click != null)
        Click(sender, e);
    Mask.BeginAnimation(Canvas.HeightProperty, null);
}
 
void RemoveFill()
{
    da.Completed -= da_Completed;
    da = new DoubleAnimation(Mask.ActualHeight, MaxFillHeight, ReverseDuration);
    Mask.BeginAnimation(Canvas.HeightProperty, da);
}

Step 3: Use It

 <Kit:KinectButton Canvas.Left="565" Canvas.Top="158" DisplayTextColor="Black" PathFill="Red" DisplayText="C" Time="2" Name="btnPlus" Click="btnPlus_Click" />

Download Control Kit


Kinect–How to Apply Smooths Frame Display Using TransformSmoothParameters





In my previous posts about Kinect I’ve talked about getting started with Kinect SDK from Kinect .NET SDK–Getting Started , Kinect – Getting Started – Control Camera Angle and Kinect – Getting Started – Become The Incredible Hulk

Kinect SDK has a lot to over and now I’m going to talk about how to improve Kinect movement by applying TransformSmoothParameters.

Channel 9 Video

The Kinect Nui SDK allow you to apply TransformSmooth  just by calling the SkeletonEngine and set it to true:

_kinectNui.SkeletonEngine.TransformSmooth = true;

But this is not enough because you need to define how smooth it’s doing to be, for that we going to use the TransformSmoothParameters

namespace Microsoft.Research.Kinect.Nui
{     [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 24)]     public struct TransformSmoothParameters     {         public float Smoothing { get; set; }         public float Correction { get; set; }         public float Prediction { get; set; }         public float JitterRadius { get; set; }         public float MaxDeviationRadius { get; set; }     }
}

Here is an example:
var parameters = new TransformSmoothParameters
{     Smoothing = 1.0f,     Correction = 0.1f,     Prediction = 0.1f,     JitterRadius = 0.05f,     MaxDeviationRadius = 0.05f
};
_kinectNui.SkeletonEngine.SmoothParameters = parameters;
Applying TransformSmoothParameters parameters will improve Kinect movement, you will be able to see the pointer isn’t jumping from place to place. 

Microsoft Test Manager – Test Plan – Part 2





In my previous post I talked about the first stages of Test Plan (Part 1), in this post I will talk about Test Plan Properties.

After we created the Test Plan and define basic Suite Structure I switch the view from “Contents” to “Properties”

image

The first section allows you to change the Test Plan name, Description, Area Path and Iteration.

On the right side you can define the Owner of this Test Plan (Like Assigned To), The state of the Test Plan – This allows you to plan future Plans without harming the Reports, and define Start and End date so you can track and see Test Plan progress by Dates.

image


Run Settings:

This is one of the most important sections in Test Plan Properties, the settings here will effect each and every Test Cases running under this Test Plan.

image

Test Settings: (Select how you want to run the Manual or Automated tests and any data to collect)

From the combo box choose “Local Test Run” or create new one and click Open

Test settings use diagnostic data adapters, which specify various types of data to collect when you run manual tests, automated tests, or both. Diagnostic data adapters can also specify how to affect the test machine. For example, a diagnostic data adapter might create an action recording, an action log, a video recording, or collect system information. Additionally, diagnostic data adapters can be used to simulate potential bottlenecks on the test machine or reduce the available system memory. For example, you can emulate a slow network to impose a bottleneck on the system.

Take NoticeData Collectors can get very big (Size) on the TFS Server, Especially Video Recording and IntelliTrace , so Microsoft wrote a tool to clean those heavy attachments from TFS - Test Attachment Cleaner for Visual Studio Ultimate 2010 & Test Professional 2010

How To Create Custom DataCollector In Visual Studio 2010 – Part 1
How To Create Custom DataCollector In Visual Studio 2010 – Part 2

image

If you run your tests using Microsoft Test Manager, you can configure a test plan to use a test setting for all its manual tests, and a test setting for all its automated tests if you need it. In addition, you can select an environment that includes the set of roles in your test settings for all the manual tests, and you must select an environment for all the automated tests in your plan. If necessary, you can override these test settings and environments when you run your tests.

Test Settings Concepts

Configurations:Configuration variables and configurations 

Defining Your Test Matrix Using Test Configurations

A test configuration is a set of configuration variables that specify the correct setup required for testing an application. You can create test configurations for your test plan using Microsoft Test Manager.

The configuration variables include hardware, operating system, software, and any other characteristics that are important to use when you run the tests. Each test configuration can represent an entry in your test matrix.

You can use one or more configuration variables to create a test configuration. Each configuration variable defines one characteristic of the testing environment. For example, a characteristic might be the operating system that you want to use to run your tests and the value might be "Windows XP." This test configuration can represent an entry in your test matrix that you plan to use to run tests. The following illustration shows you how to create configurations from within a new test plan.

In order to create new Test Configuration open: “Configurations In this plan":” and click “Manage” then you can define new Test Configuration from existing variables (4), or you can create new variables (5), Example for variables: MyComponent, Values:1,2,3,4.

image

בואו ללמוד על בדיקות ידניות, אוטומציה ועומסים בכנס המומחים של סלע

בתאריכים ה – 26-30/6 מכללת סלע תערוך כנס עם 25 סדנאות בנות יום מלא, 15 מומחים מובילים בחמישה ימים עם הנושאים החמים ביותר!!!

sela

אני אעביר יום בנושא בדיקות שיכיל את הנושאים הבאים:  בואו להכיר את עולם הבדיקות ב – Visual Studio 2010 ביום אחד מרוכז!

בדיקות ידניות בעזרת Microsoft Test Manager
- ניהול פרוייקט בדיקות במתודולוגית Scrum
 - עבודה עם סביבות וירטואליות
 - איסוף מידע אוטומטי בפתיחת תקלות
 - שליטה ומעקב על התקדמות הבדיקות
 - דוחות
 - ועוד 

- בדיקות Web Test
 - איך אפשר להקליט פרוטוקול http ו – https
 - שליפת נתונים בזמן ריצה
 - ביצוע אימות נתונים חכם
 - שליפה ערכים ממאגרי מידע
 - עבודה עם Fiddler
 - הקלטה של WCF
 - כתיבת תוספים
 - עוד

Load Test – בדיקות עומסים
 - מה זה בדיקות עומסים ולמה זה חשוב
 - איך לתכנן בדיקות עומסים בצורה יעילה
 - איך נזהה נקודות חולשה
 - כתיבת תוספים
 - להרציץ וכמובן לנתח ולהבין תוצאות

Coded UI Testing – בדיקות פונקציונליות
 - הכרות עם הכלי החדש מבית מיקרוסופט לבדיקות פונקציונליות על אפליקציות שולחניות ואתרים
 - ניהול נכון של מאגר אובייקטים
 - עבודה עם מערכות מורכבות
 - הרחבות ל – Coded UI
     - זיהוי של Infragistics, Telerik ו – Janus
 - ועוד

נתראה שם

כניסה ללו”ז

Kinect – Getting Started – Become The Incredible Hulk

In my last two posts I’ve talked about Kinect SDK from Kinect .NET SDK–Getting Started and Kinect – Getting Started – Control Camera Angle, but now it’s time to do some cool things with the Kinect Sensor.

Now I’ll show you how to become The Incredible Hulk using Skeleton Tracking.

image

Download Demo Project

One of the big strengths of Kinect for Windows SDK is its ability to discover the skeleton of joints of an human standing in front of the sensor, very fast recognition system and requires no training to use.

The NUI Skeleton API provides information about the location of up to two players standing in front of the Kinect sensor array, with detailed position and orientation information.

The data is provided to application code as a set of points, called skeleton positions, that compose a skeleton, as shown in the picture below. This skeleton represents a user’s current position and pose.

Applications that use skeleton data must indicate this at NUI initialization and must enable skeleton tracking.

The Vitruvian Man has 20 points that called Joints in Kinect SDK.

imageimage

Step 1:  Register To SkeletonFrameReady

Make sure you Initialize with UseSkeletalTracking, otherwise the Skeleton Tracking will not work.

_kinectNui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
_kinectNui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady);

The Kinect NUI cannot track more than 2 Skeletons,  if (SkeletonTrackingState.Tracked != data.TrackingState) continue;    
means the Skeleton is tracked, untracked Skeletons only gives their position without the Joints, also Skeleton will be rendered if full body fits in frame.

Debugging isn’t a simple task when developing for Kinect – Get Up Each time you want to test it. Smile

Skeleton Joints marked by TrackingID enum that defined its reference position:

public enum JointID
     {
         HipCenter,
         Spine,
         ShoulderCenter,
         Head,
         ShoulderLeft,
         ElbowLeft,
         WristLeft,
         HandLeft,
         ShoulderRight,
         ElbowRight,
         WristRight,
         HandRight,
         HipLeft,
         KneeLeft,
         AnkleLeft,
         FootLeft,
         HipRight,
         KneeRight,
         AnkleRight,
         FootRight,
         Count,
     }

Step 2: Get Joint Position

The Joint position defined in Camera Space, and we need to translate to our Size and Position.

Depth Image Space

Image frames of the depth map are 640x480, 320×240, or 80x60 pixels in size, with each pixel representing the distance, in millimeters, to the nearest object at that particular x and y coordinate. A pixel value of 0 indicates that the sensor did not find any objects within its range at that location. The x and y coordinates of the image frame do not represent physical units in the room, but rather pixels on the depth imaging sensor. The interpretation of the x and y coordinates depends on specifics of the optics and imaging sensor. For discussion purposes, this projected space is referred to as the depth image space.

Skeleton Space

Player skeleton positions are expressed in x, y, and z coordinates. Unlike the coordinate of depth image space, these three coordinates are expressed in meters. The x, y, and z axes are the body axes of the depth sensor. This is a right-handed coordinate system that places the sensor array at the origin point with the positive z axis extending in the direction in which the sensor array points. The positive y axis extends upward, and the positive x axis extends to the left (with respect to the sensor array), as shown in Figure 5. For discussion purposes, this expression of coordinates is referred to as the skeleton space.

image

private Point getDisplayPosition(Joint joint)
{
     float depthX, depthY;
     _kinectNui.SkeletonEngine.SkeletonToDepthImage(joint.Position, out depthX, out depthY);
     depthX = Math.Max(0, Math.Min(depthX * 320, 320)); 
//convert to 320, 240 space
     depthY = Math.Max(0, Math.Min(depthY * 240, 240)); 
//convert to 320, 240 space
     int colorX, colorY;     ImageViewArea iv = new ImageViewArea();

   
// only ImageResolution.Resolution640x480 is supported at this point
     _kinectNui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480, iv,
(int)depthX, (int)depthY, (short)0, out colorX, out colorY);
   
// map back to skeleton.Width & skeleton.Height
     return new Point((int)(imageContainer.Width * colorX / 640.0) - 30, (int)(imageContainer.Height * colorY / 480) - 30); }

Step 3: Place Image Based On Joint Type

A position of type Vector4 (x, y, z, w - The first three attributes define the position in camera space. The last attribute (w) gives the quality level (between 0 and 1)) of the position that indicates the center of mass for that skeleton.

This value is the only available positional value for passive players.

void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
    foreach (SkeletonData data in e.SkeletonFrame.Skeletons)
    { 
        if (SkeletonTrackingState.Tracked != data.TrackingState) continue;

        foreach (Joint joint in data.Joints)
        {
            if (joint.Position.W < 0.6f) return;// Quality check
            switch (joint.ID)
            {
                case JointID.Head:
                    var heanp = getDisplayPosition(joint);

                    Canvas.SetLeft(imgHead, heanp.X);
                    Canvas.SetTop(imgHead, heanp.Y);

                    break;
                case JointID.HandRight:
                    var rhp = getDisplayPosition(joint);

                    Canvas.SetLeft(imgRightHand, rhp.X);
                    Canvas.SetTop(imgRightHand, rhp.Y);
                    break;
                case JointID.HandLeft:
                    var lhp = getDisplayPosition(joint);

                    Canvas.SetLeft(imgLefttHand, lhp.X);
                    Canvas.SetTop(imgLefttHand, lhp.Y);
                    break;
            }
        }
    }
}

Download Demo Project

Enjoy

Kinect – Getting Started – Control Camera Angle

In my last post Kinect .NET SDK–Getting Started I showed how to begin writing for Kinect using the new and cool .NET SDK For Kinect, and as I promised I‘ll keep on writing step by step to allow you to understand and get inside all the cool things in Kinect  - But Step By Step

So in this post I’ll show to easy is to control Kinect Camera Angle (Change the position on the camera).

There is Minimum and Maximum angels you can control but as you can see from the last picture (right) you can move the Kinect Sensor manually and the Angle will change automatically.

imageimageimage

Download Demo Project

Step 1: Create Kinect Application

First you need to create a basic WPF application Kinect .NET SDK–Getting Started.

Now when you initialize the KinectNui you can only use the UseColor option for this demo.

//Open the video and depth streams, and sets up the event handlers that the runtime calls when a video, depth, or skeleton frame is ready
//An application must initialize the Kinect sensor by calling Runtime.Initialize before calling any other methods on the Runtime object. 
_kinectNui.Initialize(RuntimeOptions.UseColor);

Step 2: Obtain Camera Sensor

Create  object from the Kinect Nui after the initialization

Camera _cam;
_cam = _kinectNui.NuiCamera;
txtCameraName.Text = _cam.UniqueDeviceName;
Here is the Camera Definition:
public class Camera     
{
         public static readonly int ElevationMaximum;
         public static readonly int ElevationMinimum;
         public int ElevationAngle { get; set; }
         public string UniqueDeviceName { get; }
         public void GetColorPixelCoordinatesFromDepthPixel(ImageResolution colorResolution, ImageViewArea viewArea,
                                                            int depthX, int depthY, short depthValue, out int colorX,
                                                            out int colorY);     }

Step 3: Up and Down

Now when you do that you can control the camera angel as follow:
To increase the Camera Angel all you need to do is to increase camera ElevationAngle, there is Min and Max angels for the camera that you can control so don’t be afraid to push it to much. Smile
private void BtnCameraUpClick(object sender, RoutedEventArgs e)
{
     try
     {
         _cam.ElevationAngle = _cam.ElevationAngle + 5;
     }
     catch (InvalidOperationException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (ArgumentOutOfRangeException outOfRangeException)
     {
         //Elevation angle must be between Elevation Minimum/Maximum"

         MessageBox.Show(outOfRangeException.Message);
     }
And Down
private void BtnCameraDownClick(object sender, RoutedEventArgs e)
{
     try     {
         _cam.ElevationAngle = _cam.ElevationAngle - 5;
     }
     catch (InvalidOperationException ex)
     {         MessageBox.Show(ex.Message);
     }
     catch (ArgumentOutOfRangeException outOfRangeException)
     {
        
//Elevation angle must be between Elevation Minimum/Maximum"
         MessageBox.Show(outOfRangeException.Message);
     } }
Download Demo Project

Kinect .NET SDK–Getting Started

Today Microsoft (16/06/2011) released the Kinect .NET SDK, I’ve seen it first from Guy Burstein and right away I had to download it and give it a try, and it’s Amazing!!!

As you can see from the picture below I did a simple demo for getting started using Kinect SDK and I’ll go step by step on how to get start using Kinect .NET SDK for Video (NUI), over the next post I’ll also talk about Audio with Kinect.

image

Download Demo Project

Step 1 – Prepare your environment

In order to work with Kinect .NET SDK you need to have the below requirements:

Supported Operating Systems and Architectures

  • Windows 7 (x86 or x64)

Hardware Requirements

  • Computer with a dual-core, 2.66-GHz or faster processor
  • Windows 7–compatible graphics card that supports Microsoft® DirectX® 9.0c capabilities
  • 2 GB of RAM
  • Kinect for Xbox 360® sensor—retail edition, which includes special USB/power cabling

Software Requirements

Step 2: Create New WPF Project

Add reference to Microsoft.Research.Kinect.Nui (locate under - C:\Program Files (x86)\Microsoft Research KinectSDK) and make sure the solution file for the sample targets the x86 platform, because this Beta SDK includes only x86 libraries.

image

An application must initialize the Kinect sensor by calling Runtime.Initialize before calling any other methods on the Runtime object. Runtime.Initialize initializes the internal frame-capture engine, which starts a thread that retrieves data from the Kinect sensor and signals the application when a frame is ready. It also initializes the subsystems that collect and process the sensor data. The Initialize method throws InvalidOperationException if it fails to find a Kinect sensor, so the call to Runtime.Initialize appears in a try/catch block.

Create Windows Load Event and call InitializeNui

private void InitializeNui()
{    
try 
   {        
//Declares _kinectNui as a Runtime object, which represents the Kinect sensor instance
.
         _kinectNui = new Runtime();   



      //Open the video and depth streams, and sets up the event handlers that the runtime calls when a video, depth, or skeleton frame is ready 
        //An application must initialize the Kinect sensor by calling Runtime.Initialize before calling any other methods on the Runtime object.  
        _kinectNui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);    
     //To stream color images:     
    //  • The options must include UseColor. 
        //  • Valid image resolutions are Resolution1280x1024 and Resolution640x480. 
        //  • Valid image types are Color, ColorYUV, and ColorYUVRaw.       
_kinectNui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.ColorYuv);        
      //To stream depth and player index data:         
//  • The options must include UseDepthAndPlayerIndex.        
//  • Valid resolutions for depth and player index data are Resolution320x240 and Resolution80x60.   
      //  • The only valid image type is DepthAndPlayerIndex.     
    _kinectNui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);      

    lastTime = DateTime.Now;       
 
_kinectNui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(NuiVideoFrameReady);   
     _kinectNui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_DepthFrameReady);  
  }
catch (InvalidOperationException ex)
{       
MessageBox.Show(ex.Message);   
} }
And Window Closed Event 
private void WindowClosed(object sender, EventArgs e)
{  

   _kinectNui.Uninitialize(); }

Step 3: Show Video

Both Video and Depth returns PlanarImage and we just need to create new Bitmap and display on the UI.

Video Frame Ready Event Handler
oid NuiVideoFrameReady(object sender, ImageFrameReadyEventArgs e)
{    
PlanarImage Image = e.ImageFrame.Image;    
image.Source = BitmapSource.Create(Image.Width, Image.Height, 96, 96, PixelFormats.Bgr32, null,  Image.Bits, Image.Width * Image.BytesPerPixel);    
     imageCmyk32.Source = BitmapSource.Create(Image.Width, Image.Height, 96, 96, PixelFormats.Cmyk32, null,         Image.Bits, Image.Width * Image.BytesPerPixel);
}
Depth Frame Ready Event Handler
Depth is different because the image you are getting back is 16bit and we need to convert it to 32, I’ve used the same method like in the SDK samples that allows me to convert the image.
void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
{     
var Image = e.ImageFrame.Image;
     var convertedDepthFrame = convertDepthFrame(Image.Bits); 
   depth.Source = BitmapSource.Create(Image.Width, Image.Height, 96, 96, PixelFormats.Bgr32, null, convertedDepthFrame, Image.Width * 4);    
     CalculateFps();
}
// Converts a 16-bit grayscale depth frame which includes player indexes into a 32-bit frame
// that displays different players in different colors
byte[] convertDepthFrame(byte[] depthFrame16)
{     
for (int i16 = 0, i32 = 0; i16 < depthFrame16.Length && i32 < depthFrame32.Length; i16 += 2, i32 += 4)
      {       
int player = depthFrame16[i16] & 0x07;
         int realDepth = (depthFrame16[i16 + 1] << 5) | (depthFrame16[i16] >> 3);  
      // transform 13-bit depth information into an 8-bit intensity appropriate 
        // for display (we disregard information in most significant bit)      
  byte intensity = (byte)(255 - (255 * realDepth / 0x0fff));        

depthFrame32[i32 + RED_IDX] = intensity;        
depthFrame32[i32 + BLUE_IDX] = intensity;       
depthFrame32[i32 + GREEN_IDX] = intensity;    
}  
  return depthFrame32; }
void CalculateFps()
{   
  ++totalFrames; 



   var cur = DateTime.Now;  


  if (cur.Subtract(lastTime) > TimeSpan.FromSeconds(1))  
  {   
      int frameDiff = totalFrames - lastFrames;    
     lastFrames = totalFrames; 
       lastTime = cur;     
   frameRate.Text = frameDiff.ToString() + " fps";
    } }
 
Download Demo Project

TFS API Part 38 – Create Label

In my last post on TFS API I summarize in Index Page include 37 parts -http://blogs.microsoft.co.il/blogs/shair/archive/2011/05/18/tfs-api-index-parts-1-to-37.aspx

And I coming back with more about TFS API, and Today about how to create Label using TFS API.

Download Demo Project

image

image

Step 1: Create Project and Add Reference

Create an WPF/WinForm application and add the following references:

First add reference for

  • Microsoft.TeamFoundation.dll
  • Microsoft.TeamFoundation.Build.Client
  • Microsoft.TeamFoundation.Build.Common.dll
  • Microsoft.TeamFoundation.dll

All files located under - c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\

Step 2: Connect Team Foundation Server

for creating Label the only object we need to obtain is VersionControlServer, everything we need is there.

private void BtnConnectClick(object sender, RoutedEventArgs e)
{     var dp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false);     dp.ShowDialog(); //Display DomainProjectPicker     if (dp.SelectedTeamProjectCollection != null)     {         tfs = dp.SelectedTeamProjectCollection;         //Create VersionControlServer object from TFS         sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));         bg.RunWorkerAsync();     }
}

Step 3: Map Source Control

I’ve already talked about this in the past, so please check this post - TFS API Part 16: Mapping Source Control Using VersionControlServer

(Also in the Demo Project)

Step 4: Create Label

And for the important part, when we draw the source control tree we assigned the Server Path ($/Project/Folder etc) as Tag – and this is very important because this is our Label Scope.

We will start with creating VersionControlLabel contains the VersionControlServer object, Label Name, Owner and Comments.

Then we need to define the ItemSpec for the label – Which Files, Folder we want to Label.

And Finally using VersionControlLabel.CreateLabel with our settings.

private void btnCreateLabel_Click(object sender, RoutedEventArgs e)
{     if (SourceTree.SelectedItem == null || string.IsNullOrEmpty(txtLabelName.Text) ||       
   comboLabelChildOption.SelectedItem == null || comboRecursion.SelectedItem == null) return;     
    //get the full path from the selected file\folder   
var path = ((TreeViewItem)SourceTree.SelectedItem).Tag.ToString(); 
    //Represents a version control label.   
  var versionControlLabel = new VersionControlLabel(sourceControl, txtLabelName.Text, sourceControl.AuthorizedUser,path, txtComments.Text);
    //Represents one or more files or folders on the local machine or in the repository.
   var itemSpec = new ItemSpec(path, (RecursionType)comboRecursion.SelectedItem); 
    // What items should this label apply to? 
   var labelItemSpec = new LabelItemSpec[1]; 
    labelItemSpec[0] = new LabelItemSpec(itemSpec, VersionSpec.Latest, false); 
    //*** LabelChildOption ***   
//If you use Replace, any item that you specify in your request that's already in the label will be  
    //replaced by what you have specified. Anything that's not in the label already will be added to   
   //the label, and existing items that aren't modified by your request will remain as they were.    
//Use Merge to leave unmodified items that are in your request but that already exist in the label. 
    //Any item in your request that's not already in the label will be added to the label, and existing
    //items in the label that aren't specified in your label will remain unchanged. Explaining the Fail    
//option is not easy. Labels have the notion of a scope. The Fail option says that the call to create    
//or update the label should fail if there is at least one label by the same name that exists at a     
//scope that would be below the scope of the new label.    
    var lb = sourceControl.CreateLabel(versionControlLabel, labelItemSpec, (LabelChildOption)comboLabelChildOption.SelectedItem); 
    MessageBox.Show(lb[0].Status.ToString());
}
Download Demo Project
Enjoy.

Change VS 2010 Start Page Recent Projects Count + Custom Start Page With Site

image

In the mood of improving my work couple of days ago I wrote about Wifi Network Backup Manager Utility a utility that allows you to Save and Load Wifi Network Profiles, using Native Wifi API through P/Invoke interop.

Today I decide that I’ll change Visual Studio 2010 Start Page to show things I really wants starting from more Recent Projects, today VS 2010 only shows 10 recent projects, because I have a lot more than 10 recent projects I want to continually open I’ve increased the Max Count of recent projects.

vsixDownload Custom Start Page - regDownload Registry Key

How?

From Tools –> Option –> General – This didn’t worked for me so….. Registry allows works Smile

image

regDownload Registry Key (Set the recent count to 30)

image

The problem is there is not enough place to show all 30 recent projects, so I had to create new Custom Start Page for Visual Studio 2010.

And if I’ve already done that I decide to add additional thing like – Show a specific site when I open Visual Studio.

So I have used RssFeed Context to allow me change the site from the start page, so just enter the site you want and hit the refresh button to apply changes so next time you will automatically see your predefined page.

<TextBlock x:Uid="UriTxt" Text="Start Uri:" Margin="4,7,0,0" HorizontalAlignment="Left" Width="50" Height="25" VerticalAlignment="Top" />
<TextBox x:Name="Uri_TextField_Source" Text="{Binding Rss.RssFeed, Mode=OneWay}" Margin="3,4,2,0" Height="26" VerticalAlignment="Top" Grid.Column="1" />
<vs:ImageButton Margin="0,4,6,0" Click="ImageButtonClick"
                        Focusable="True"
                        Command="{x:Static sp:RssCommands.SetUrl}" CommandParameter="{Binding Text, ElementName=Uri_TextField_Source}"
                        ImageNormal="pack://application:,,,/Microsoft.VisualStudio.Shell.StartPage;component/Images/StartPage/RSSButton.png"
                        ImageHover="pack://application:,,,/Microsoft.VisualStudio.Shell.StartPage;component/Images/StartPage/RSSButtonMouseOver.png"
                        ImagePressed="pack://application:,,,/Microsoft.VisualStudio.Shell.StartPage;component/Images/StartPage/RSSButtonMouseDown.png" HorizontalAlignment="Right" Width="34" Height="25" VerticalAlignment="Top" Grid.Column="2">
</vs:ImageButton>
<Border Grid.Row="1" Grid.ColumnSpan="3" BorderThickness="1" BorderBrush="Gray" CornerRadius="2" Margin="4,0,6,0">
    <WebBrowser Name="webBrowser" />
</Border>
vsixDownload,install and define the start page to – Custom Start Page – Site (Tools –> Options)
image
And Walla! Enjoy and I hope this helps you save time!

image

סיכום מפגש ALM של מכללת סלע

בתאריך ה – 5.6 קיימה מכללת סלע מפגש בנושא Visual Studio 2010 ומוצרי ALM במיקרוסופט רעננה, ראשית אני רוצה להודות לכל האנשים שהגיעו והשתתפו במפגש – קיבלנו פידבקים מצויינים ואנחנו כבר מתכננים עבורכם מפגש נוסף על הנושאים שביקשתם!!!image

בגלל העניין הרב בהרצאות והשתתפות הקהל לא הצלחנו להגיע להרצאה של שמוליק סגל בנושא Team Build 2010 אך בגלל הביקוש הרב מכללת סלע אכן תקיים מפגש נוסף בנושא!

אתם מוזמנים להוריד את המצגות מהמפגש:

Requirement Management using Visual Studio 2010 – מרצה : דן מורגנשטיין - הורדה

Applied Software Testing with Visual Studio 2010 – מרצה : שי רייטן – הורדה

רוצים לשמוע עוד על Team Build, בדיקות ידניות ואוטומטיות,ניהול משימות ופרוייקטים, Scrum ועוד הרבה נושאים בתחום ה – ALM תבדקו ב – Sela Dev Days

sela

שוב תודה לכל המשתתפים ונתראה במפגש הבא!

Wifi Network Backup Manager Utility

After couple of years I was too lazy to do it, each time I format my computer or want to copy Wifi networks between my machine to another I faced a problem, there is easy way to copy network profiles so I’ve created a simple utility that allows you to Save and Load Wifi Network Profiles, using Native Wifi API through P/Invoke interop.wifi.icon

[DllImport("wlanapi.dll")]
public static extern int WlanGetProfile(
	[In] IntPtr clientHandle,
	[In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid,
	[In, MarshalAs(UnmanagedType.LPWStr)] string profileName,
	[In] IntPtr pReserved,
	[Out] out IntPtr profileXml,
	[Out, Optional] out WlanProfileFlags flags,
	[Out, Optional] out WlanAccess grantedAccess);
 
[DllImport("wlanapi.dll")]
public static extern int WlanGetProfileList(
	[In] IntPtr clientHandle,
	[In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid,
	[In] IntPtr pReserved,
	[Out] out IntPtr profileList
);

So here it is, the tool will show you all saved Wifi profiles on your machine and allow you to save one or more to a local xml file.

zip Wifi Backup.zip

image

So when I get to a new computer and I want him to obtain my Wifi network profiles…

image

Open the Wifi Network Backup Manager and load the WiFiBackup file

image

And now the new computer has the entire WiFi network list include passwords!

image

zip Wifi Backup.zip

Enjoy

Microsoft Test Manager – Test Plan – Part 1

As part of Visual Studio 2010 release we get a new tool for Testers called – Microsoft Test Manager (aka: MTM)

Lots of my customer already use this tool and I want the rest will go on the same path, so I’ll write a guide for new users who want to start performing Manual Testing using MTM.

Let’s Start – First thing is to define a Plan, like every other Team, also the Tester needs to start Testing as part of a Plan, Same as Development Team.

So the first part is to create a Test Plan, for some teams it’s depends on the Team Methodology – You can create the Plan with the Iteration \ Sprint \ Version number or for some you can create a Plan called Main or the name of the product.

image

After Creating the Test Plan you will see the Main window, for our guide I’ve split it to three Part.

1. Menu , 2. Contents, 3. Configurations

image

Section 1: Menu

Using MTM menu you can navigate between sections depends on what you want to do right now.

Do you want to Plan your Tests? Run Them? Or track the Bugs and Test Results?

image

Section 2: Contents

This is the base for creating Test Plan, here you will define which Test Cases under different configuration will be run under this Test Plan, you will have several options for placing the Test Cases under various types of Suites.

Suite is basically like a Folder, You have Static Suite (Folder), Requirement Suite (To Increase Coverage) and Query based-Suite to create dynamic Folder that can contain different Test Cases each time (depends on the Query)

image

Copy Suite From Another Test Plan – Select the Test Plan you wish to Copy Suite and select the desire Test Suite\s to copy.

image

Query Based-Suite (Dynamic Suite) – Define the desire Query to select specific Test Cases into your Suite.

image

Section 3: Configurations

To modify Test Suite of Any kind you just need to select it and perform the desire action, for now we can create new Test Case by clicking on the “New” button or adding existing Test Case by Clicking the “Add” button.

In the next post on MTM I’ll talk about Configurations , Assign and Order features that will help you to plan coverage matrix and assignments.

image

On the right upper corner you can define the State of the Suite, In Planning, In Progress or Completed.

This will assist you in TFS Reports, so define the right State of the plan to create reliable reports.

image

Enjoy.

Visual Studio 2010 מכללת סלע ומיקרוסופט שמחות להזמינך למפגש מרתק ללא תשלום בנושא

Application Life Cycle Management with Visual Studio 2010image

במפגש זה תוכלו ללמוד על פתרון ה- ALM המתקדם ביותר ולצפות בדמאויים עשירים.

המפגש מיועד למפתחים ולבודקים ויועבר ע"י מיטב המומחים בנושא.

 

לוח זמנים מתוכנן :

8:30-9:00 – התכנסות ורישום.

9:00-10:00Requirement Management using Visual Studio 2010 – מרצה : דן מורגנשטיין.

10:00-11:00Applied Software Testing with Visual Studio 2010 – מרצה : שי רייטן

11:00-11:15 – הפסקה

11:15-12:00 – סיפור לקוח – חטיבת מוצרי ה- Enterprise של Nice בחברה ב- ALM כפתרון ארגוני.

12:00-12:45 Team Build 2010 – מרצה : שמוליק סגל

12:45-13:00 – שאלות ותשובות.

 

המפגש יתקיים בבית מיקרוסופט , הפנינה 2, רעננה

בתאריך : 5/6

לפרטים נוספים נא ללחוץ כאן

 

המפגשים ללא תשלום אך מחייבים רישום מוקדם

על מנת להירשם לבית הפתוח נא ללחוץ כאן.

 

*מספר המקומות מוגבל

 

נשמח לראותך,

More Posts Next page »