Programming - page 17

Android: Retrieving the Camera preview as a Pixel Array

Click here to read Android: Retrieving the Camera preview as a Pixel Array

This post explains how to take the live images created by Android’s camera preview feature and return them as a RGB array, that can be used to all sorts of things, like custom effects preview and real-time image filtering. This post used the CameraPreview class that already comes bundled with Android’s SDK because it has everything already set-up, that way is just a matter of inserting more code. The techniques shown here works with Android 2.1 and should work with versions 1.6 and 1.5.

The first thing to do is to import the API Demos project to your Workspace. To do that, in Eclipse, click File -> New -> Android Project. In the dialog that has just opened, give the project a name at the first field (like API Demos 8) and select ‘Create project from existing source’. Now browse to <Android SDK folder>\samples\android-7\ApiDemos. Finally, mark Android 2.1 as the Build Target and click Finish: Continue reading: “Android: Retrieving the Camera preview as a Pixel Array”

Using static variables in Unity3D

Click here to read Using static variables in Unity3D

This post explains how to use static variables when programming scripts for the Unity3D engine. The example scripts in this post are written in C#, but the same guidelines apply for JavaScript.

Before delving deeper into the subject, it goes without saying that static variables should be avoided at all costs, for a great number of reasons that can be easily be found on the internet. It’s better to use a Singleton creational pattern in most cases. with that in mind, here’s a short definition of static variables: they are variables that belong to a class, and not the objects the class creates. This means that static variables retain the same value, regardless of the object from a given class. Another characteristic is that, as long as the class is in the memory, they are still valid references. Static variables are initialized by the compiler right before the class creation, and before any other variables or methods. But what does it mean for Unity3D scripts?

Continue reading: “Using static variables in Unity3D”

Android: Changing the animation between Activities

Click here to read Android: Changing the animation between Activities

This post features how to change Android’s default animation when switching between Activities. Before reading the rest, please know that the code that changes the standard animation be found at the API Demo that comes with the Android SDK. But since there’s a lack of proper documentation regarding this subject and it’s difficult to find a place explaining it, here is a post that helps in aiding these two problems.

So, the code to change the animation between two Activities is very simple: just call the overridePendingTransition() from the current Activity, after starting a new Intent. This method is available from Android version 2.0 (API level 5), and it takes two parameters, that are used to define the enter and exit animations of your current Activity. Here’s an example: Continue reading: “Android: Changing the animation between Activities”

Configuring openFrameworks add-ons in Codeblocks

Click here to read Configuring openFrameworks add-ons in Codeblocks

At some point, when using openFrameworks to create interactive applications, one needs to use some of the bundled add-ons. This post will explain how to configure your Codeblocks project to use these add-ons and how to include the OpenCV add-on to your project. Before continuing, you should know there is an automated tool that helps the programmer in this process, specially designed to easily configure openFrameworks projects and add-ons at Google Code: ofcodeblocksplugin (official forum thread here).

Differently from this tool, this post explains on how to manually include the add-ons to your openFrameworks project. The process described here was done using Codeblocks 10.05 and openFrameworks 0.62 on a computer running Windows.

Continue reading: “Configuring openFrameworks add-ons in Codeblocks”