Thursday, July 19, 2018

I've always wanted to be a cartoon...

Ever wanted to be a cartoon? Where there is a will, there is a way! Today, we are going to show you how you can take any image, and turn it into a cartoon style graphic using Adobe Illustrator. 

1. Open up a new Illustrator file. The dimensions for this tutorial are 1296px by 864px, as they are the dimensions of the image we will be using. You can choose whichever dimensions you like. Click Create once you have selected your dimensions.

2. Once the new file loads, press Cmd+Shift+P on Mac, or Ctrl+Shift+P on Windows on your keyboard, to open up a file directory to access your image. Alternatively, to find the same menu you can go to File > Place.

3. Locate the image in the file directory, then click Place.

4. Place and resize the image to where you would like it on the Artboard.

5. Go to Window > Image Trace to open the Image Trace panel.

6. Now for the Fun! Select the image, and look over to the Image Trace panel we just opened.

7. Click the Preset drop down menu. These are all the settings for the image tracing, of which some will give you further options to tweak once selected. For this tutorial, select Sketched Art.

8. Under Preset, is the View drop down menu. Select Tracing Result.

9. Under View, is the Mode drop down menu. This is where you can select the colour mode. For this tutorial, we are going to select Colour.

10. You will then have Palette options beneath View. We find the most cartoon-like option to be Limited, but feel free to see which suits your image best.

11. You can reduce the amount of colours in the Colors option beneath Palette. For this example, we have set it to 8.

12. Once you have played with the settings and are happy with the image, change View to Tracing Result with Outlines. This gives us outlines of where we are about to colour in.

13. Click the image and go to Object > Expand. Ensure Fill and Stroke are selected, then click OK.

14. Once your object is expanded, colour away! Click a shape you would like to fill, and select a colour you would like.

15. Once you’re done, don’t forget to save the Illustrator file. Go to File > Save As, and navigate to a location on your device.

16. To export your image, go to File > Export > Export As, and navigate to a location on your device. 17. Select the format you wish to export the image as, from the Save as type drop down menu. For this example, we will select PNG. If you have selected PNG, a PNG Options panel will appear. Select the Resolution, Anti-aliasing, and Background Color that suits you, and click OK.

Congratulations! You're a cartoon.

nsquared solutions

Tuesday, July 10, 2018

Mixed reality training materials

In a previous post Adding AI to Mixed Reality, we discussed how we have been helping developers add Artificial Intelligence (AI) to their mixed reality applications.

The hands-on-labs from these events are now public on the Microsoft Mixed Reality Academy. These labs teach you how to add Microsoft Cognitive Services and Machine learning to a Unity application running on HoloLens, or in Microsoft's Mixed Reality Portal.

One of the attendees of a recent event in Redmond wrote about his experiences at a week-long hack, where teams were formed around specific scenarios. You can read Ryan's thoughts on the event here.

We have been working hard to make this training material available to everyone. To help you get started with mixed reality development and design, you can find our Kindle eBook on Amazon, Developing and Designing for Mixed Reality.

'Developing and Designing for Mixed Reality' eBook

We have also put together a LinkedIn Learning course, Mixed Reality Development Fundamentals.

The labs we have been running to teach developers how to add AI to their mixed reality applictions can be found in the Microsoft Mixed Reality Academy.

We hope you can learn from all this content and build some beautiful mixed reality experiences that incorporate AI.

nsquared solutions

Sunday, July 8, 2018

The Joys of Forking

Some programming situations require handing off data processing sub-tasks to different processes, rather than to background threads; the ways in which you can do that are discussed in this blog.

In many programming languages, on many types of CPUs, a single process (or thread) runs on a single CPU core. Threads created by a process, share time on the single CPU core with the main-line of the program. If you have a multi-processor CPU, your application is going to leave all the other cores in the CPU idle if your application is organised as a single process with threads. That might not matter on high powered machines, but it can become an issue on small, slower, devices (e.g. IOT devices, or mobile phones) that might have to do serious data crunching: perhaps in a signal processing, or AI machine learning environment.

Let’s look at some ways of making an application run on multiple CPU cores. For this blog we will use Python, although in a Linux environment most languages have inherited equivalent methods all deriving from the original C implementations.

In Python, there are basically two ways of starting another application from within an initial parent application. You can use the “Popen” method from the “subprocess” module, or the “fork” method from the “os” module. Either method results in a separate process running alongside the parent process, and hopefully, the OS will assign the new process to a CPU core of its own. Each process may need to use the “os” method, “nice”, to set its priority high enough to get a core, or the Linux shell command “taskset” might be required to set the affinity of a process to a specific CPU core.

Using “Popen”, or “fork”, will depend on the amount, and type, of data you need to pass to the child process from the parent process. “Popen” passes command line parameters to the child (which is launched from the file referenced in the command line parameters). On the other hand, “fork” causes the parent process to be duplicated and continue executing from the fork point in the code. This makes “fork” a very interesting mechanism. Let’s look at the code in a typical “fork” scenario:

. application sets up data, class instances, and so on, ready for use by both parent and child
some_data_to be passed_on = [5, 6, 7, 8]
# once the common code is done, we are ready to split into 2 processes
line 1 parent_pid = os.getpid()
line 2 fork_pid = os.fork()
line 3 if fork_pid == 0:
# this branch is running the child process
# the fork method returns 0 in the child process
# we can find out our pid as the child process
line 4 child_pid = os.getpid()
# now we add code which does the tasks required of the child
line 5 else:
# this branch is running in the parent process, the assert below will pass
line 6 assert os.getpid() == parent_pid
# now we add code which does the tasks required of the parent
line 7 # statements following the “if” “else”

The fork operation can be confusing to use, even though it has some extremely useful characteristics, so we need to go through the numbered lines above to make things clear.

At line 1, a variable is set to the process id (pid) of the parent process, which has run through its code down to line 1. At line 2, the fork operation is invoked. The fork copies the current application (which we are calling the parent here) including its working memory, its current stack, and the state of all its open files, and lets the copied application (which we are calling the child process) run from line 3. The original process is still alive, and it also moves on to line 3.

If both the parent and child are the same, and execute the same code, how will the child do something different to the parent? The answer is in the value returned by the fork operation, which is being examined by both the parent and child, at line 3. In the child process, the fork operation returns zero while in the parent, the value returned is non-zero. The outcome is that the child process will execute line 4, after line 3, while the parent process will follow the “else” at line 5 and execute line 6 after line 3.

When there is a need to pass the child process a great deal of information, forking provides the opportunity for any amount of data to be prepared. From the example above, both the child and parent inherit the local variable “some_data_to be passed_on” and its value among all the other variables local and global.

In summary, the fork operation is a very powerful way of passing lots of data to a child process, but it requires some care in its use. BOTH processes (unless they terminate early) will arrive at line 7. Depending on the application design, it may be perfectly fine for both processes to proceed through the code following line 7, but on the other hand it might be an unexpected problem. It’s an unusual mindset for a programmer to look at a single piece of code from the point of view of two (or even more) processes and keep track of what should happen in them at the same time.

nsquared solutions

Monday, July 2, 2018

Mixed Reality

Mixed reality (MR) was defined in 1994 by Paul Milgram and Fumio Kishino as "...anywhere between the extrema of the virtuality continuum". Microsoft has adopted the term for its own platform, Windows Mixed Reality, to help group Virtual and Augmented reality. The technology has been accessible to developers and businesses for a few years now, yet, the clear majority of applications belonging to this not-so-new market are still mainly composed by single person experiences.

This is surely appropriate for a lot of business cases, such as visualisation of data that should only be accessible by the interested party, or training on specific single-user scenarios.

It is also not surprising that a person wearing a headset, gives the impression of “digital isolation” and inspires the idea that MR is more suitable for solo experiences and one-to-environment interactions. An impression that is often misleading.

If we talk about games and entertainment, for example, several multi-player experiences show that it is possible to create immersive and engaging virtual experiences, where users interact with each other and share the same content.

In the business environment, however, not only does there seem to be a resistance for adopting MR, but it is evident to us, that there is a lack of understanding of how this technology could improve collaboration and productivity within teams, possibly involving clients as well.

What could these scenarios be? The list is literally never-ending.

Obviously, any kind of situation that requires cooperation and involves expensive set-ups or dangerous situations, could potentially be recreated in a digital version. Reducing costs and risks is surely an objective of most companies, if not all, and MR could easily be leveraged to achieve better results with lower risks and costs.

Thinking out of the box is paramount for business oriented people (and developers), wishing to work with bleeding edge technologies. Developers who want to engage and experiment in building mixed reality applications, for cooperative scenarios can really go wild, since not much has so far hit the public eye in a significant way. At nsquared, we have brainstormed several scenarios related to what we do best: facilitating cooperation in the work space and improving the outcomes of business meetings.

Our development facility, featuring multiple Microsoft HoloLens’ and immersive headsets allowed us to experiment and develop several ideas and solutions that would be compelling to many businesses using meeting spaces, multi-user interaction, and visual data. Difficult to explain in words, even more difficult to understand the potential of this technology unless you try first hand.

If you are interested in seeing how mixed reality could change the way you do business, contact us and book a hands-on demonstration.

nsquared solutions

3D Printing

3D printing, or more specifically, additive manufacturing, is a manufacturing process the involves building 3D objects by adding layer upon layer of material to create the final product. Fused Deposition Modelling (FDM) is the most common type of additive manufacturing, especially among household printing technologies.

In this blog, we are going to teach you the basics of how to prepare a file for 3D printing using FlashPrint software, which is free. Do not fiddle with the specifics of the settings until you have become more familiar with using the printer.

Extrude: The process of forcing out a thin layer of plastic.
Infill/Fill Density: The percentage of material that is printed inside of the outer shell of an object. There are different shapes that can be used to create the infill pattern inside of solid object.

Filament: The material that is fed out of the printer.
Print bed: The surface that the object is printed onto.
Raft: Layer, or layers, of extruded thermoplastic that is used to stabilise a printed object. A raft helps an object to adhere to the print bed.

File preparation
First you need to create a universal 3D file that the 3D printing software can open. STL is usually the easiest to use but fpp, x3g and obj files are also compatible. Open the 3D file that you have and it will appear in your window. You can pan and rotate around by holding the left or right mouse buttons and scroll to zoom in or out. Make sure that under ‘Print’, the machine type is set as ‘FlashForge Creator Pro’.

Use ‘Move’ to move the object around the bounds of the print area. In this submenu, use ‘On Platform’ to choose a face and select it as the face that is in contact with the platform.

Use ‘Rotation’ to rotate the object in any axis, as well as choose a surface to rotate to the platform.

Use ‘Scale’ to change the scaling of the object.

Use ‘Cut’ to slice the object.

Use ‘Extruder’ to choose to print the object using the left or right extruder.

Supports Options

We recommend using the ‘Linear’ support type, and sticking to the default settings. This will be required if your part has overhang. Click on the ‘Auto Supports’ button and the program will automatically create the required supports for your object. Then click 'Back', click ‘No’, and if you are ready, we can move onto the Print settings.

Print settings

First, make sure the 'Material Left' and 'Material Right' (extruders) are the same as the ones installed onto the printer. At the time of writing, both extruders have ABS filament installed (black and white). 'Supports' can be left on 'Automatch', but it refers to whether supports are printed by the left or right extruder. The 'Raft' setting will enable or disable the raft. If you disable the raft then it is important to monitor the printer during the start of its printing process to ensure that the extrusion is sticking to the bed during the first layer. The 'Resolution' setting tells you how thick each layer will be, and therefore how fine the detail of the print will be.

In the ‘Infill’ tab, you can set the percentage and fill pattern used in the infill. For objects where the internal solid structural strength is important, the higher the infill should be used, up to 100%. We recommend that the minimum infill percentage should be 30%.

Recommended temperatures
Extruder Temperature: ABS: 230C PLA: 200C
Platform Temperature: ABS: 100C PLA: 50C

Once you have chosen your Print settings, click 'OK' to save the file onto an SD card and then you can move onto the Printer setup.

Printer setup
Plug in the SD card and turn on the printer using the switch found at the rear left of the printer. Select ‘Print from SD’ and find the path to the file that you have saved.

Here we have clicked on the file ‘dual test.x3g’. The printer will take some time to begin heating, and will commence printing once the heating process has finished.

It is a good idea to monitor the first layer to verify that it adheres well to the build surface, and then also periodically each hour after that.

nsquared solutions