Archive for the ‘Computer Science and Technology’ Category

Image processing in C#

Basic image processing support in C#:

(Source: codersource.net)

PictureBox class:

ClientRectangle: ClientRectangle is a public property representing a rectangle that represents the client area of the control. It does not include the elements such as scroll bars, borders, title bars, and menus. It only represents the area in which the image is drawn actually.

Image: The public property representation of the Image class to display. The Image property is set to the image to display. You can do this either at design time or at run time.

SizeMode: The property showing how to display the image.

Refresh: Function that forces the control to invalidate its client area and immediately redraw itself and any child controls.

Update: Function that causes the control to redraw the invalidated regions within its client area.

Bitmap Class

(more…)

[LTT App Store] Analog to Digital Simulator

analog to digital simulator

This program was a mini project in my final year Mechatronics course (Specialized in Automation). It simulates A2D converter by drawing a analog sine/cosine waveform, and then digitize it.

Download here: http://www.everbot.com/files/A2DSimulator.exe

Smartphones have dumb owners

android

Google survey suggests many smartphones have dumb owners. I myself also find that my phone is getting smarter. I have never found its full power yet. And each time I discover something new on its capabilities, I’m amazed! How about you? Are you making the most out of your smartphones yet? If not, try to learn using your phone, treasure it. You don’t always need to upgrade to a new phone. Because even the old one possess some great capabilities that you have never found out yet.

So enjoy living in technology world :)

SPB Shell 3D running on my HTC Desire

This video shows the SPB Shell 3D v1.0.2 (which I purchased from Android Market few days ago) running on my HTC Desire. The launcher is really a next generation of user interface. With the price of 19 bucks, the APP is a bit expensive compare to others but it is a good investment. Right now, the launcher performs quite well on my device though I still expect improvement from SPB.

Alright, enuf for boring long words, let’s enjoy the video clip:

Device: HTC Desire (Rooted, S-OFF) running Android 2.3.3 Gingerbread (CyanogenMod-7 V7.0.0-RC4)

Some notes for string handling

Clearing my phone since it is very messy with a lot of files, and found some notes here:

Handling string in C#
List of Numeric Formats

* C or C – For Currency. Uses the cultures currency symbol.
* D or D – Integer types. Add a number for 0 padding eg D5.
* E or e – Scientific notation.
* F or f – Fixed Point.
* G or g – Compact fixed-point/scientific notation.
* N or n – Number. This can be enhanced by a NumberFormatInfo object.
* P or p – Percentage.
* R or r – Round-trip. Keeps exact digits when converted to string and back.
* X or x – Hexadecimal. x – uses abcdef, X use ABCDEF.

Dates can also be specified either using Standard Format strings

* O or o – YYYY-MM-dd:mm:ss:ffffffffzz
* R or r – RFC1123 eg ddd, dd MMM yyyy HH:ss GMT
* s – sortable . yyyy-MM-ddTHH:mm:ss
* u – Universal Sort Date – yyyy-MM-dd HH:mm:ssZ

or Format specifiers. There are too many of those to list here. Example:

using System;
using System.Text;
using System.Globalization;
namespace ex6
{
	class Program
	{
		static void Main(string[] args)
		{
			// Numeric Formatting Examples
			// integer
			int i = 5678;
			string s = string.Format("{0,10:D}", i); // Into a string right aligned 10 width
			Console.WriteLine("{0,10:D}", i); // or output direct
			Console.WriteLine("{0,10:D7}", i); // or output direct with leading 0
			// double and currency in various formats
			double d=47.5;
			double bigd = 19876543.6754;
			Console.WriteLine("{0,15:C2}", d); // In Uk = £47.50 right aligned in 15 width
			Console.WriteLine("{0,15:N10}", bigd); // Number
			Console.WriteLine("{0,15:E3}", d); // Scientific 4.750E+001
			Console.WriteLine("{0,15:F5}", d); // Fixed Point 47.50000
			Console.WriteLine("{0,15:G4}", d); // Compact 47.5
			Console.WriteLine("{0,10:P2}", d/100.0); // %
			Console.WriteLine("{0,15:R}", bigd); // Roundtrip - not a digit lost
			// Hex-a-diddly-decimal
			Console.WriteLine("{0,10:x8}", i); // lowercase 0000162e
			Console.WriteLine("{0,10:X8}", i); // uppercase 0000162E
			// Date formats
			DateTime dt = DateTime.Now;
			// Standards
			Console.WriteLine("{0:O}", dt); // O or o yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzz
			Console.WriteLine("{0:R}", dt); // R or r ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
			Console.WriteLine("{0:s}", dt); // s yyyy'-'MM'-'dd'T'HH':'mm':'ss
			Console.WriteLine("{0:u}", dt); // u yyyy'-'MM'-'dd HH':'mm':'ss'Z'
			// Using date/time specifiers
			Console.WriteLine("{0:t}", dt); // short time
			Console.WriteLine("{0:T}", dt); // long time
			Console.WriteLine("{0:d}", dt); // short date
			Console.WriteLine("{0:D}", dt); // long date
			Console.WriteLine("{0:f}", dt); // long date / short time
			Console.WriteLine("{0:F}", dt); // long date / long time
			Console.WriteLine("{0:g}", dt); // short date / short time
			Console.WriteLine("{0:G}", dt); // short date / long time
			Console.WriteLine("{0:o}", dt); // Round Trip
			// roll your own...
			Console.WriteLine("{0:dd/mm/yyyy HH:MM:ss}", dt); // custom - what most people use (UK)!
			Console.WriteLine("{0:mm/dd/yyyy HH:MM:ss}", dt); // custom - what most people use (US)!
			Console.WriteLine("{0:yyyy/mm/dd HH:MM:ss}", dt); // custom - (Japan) Good for sorting!
			Console.WriteLine("{0:dd MMM yyyy HH:MM:ss}", dt); // custom - month (UK)
			Console.WriteLine("{0:MMM dd yyyy HH:MM:ss}", dt); // custom - month (US)
			Console.WriteLine("{0:yyyy MMM dd HH:MM:ss}", dt); // custom - (Japan)
			Console.ReadKey();
		}
	}
}

C:
Standard: \r\n
(don’t use \n\r)

How to get auto upgrade WordPress on host pipni.cz

Host pipni.cz has some security settings that don’t allow user to access the default temp directory, so we can’t do auto upgrade version for WordPress. Here, I’ll show you how to do auto upgrade by creating our own temp directory.

1) First, add a “tmp” foler under wordpress blog directory.
2) Added the following lines to “wp-config.php” to point wordpress temp directory to it

if ( !defined(‘WP_TEMP_DIR’) )
define(‘WP_TEMP_DIR’, dirname(__FILE__) . ‘/tmp/’);

<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information by
* visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
 
if ( !defined('WP_TEMP_DIR') )
define('WP_TEMP_DIR', dirname(__FILE__) . '/tmp/');
 
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'databasename');
 
/** MySQL database username */
define('DB_USER', 'username');
...
...
...
?>

Note: Remember to DeActive all the Plugins before upgrading WordPress

Computer Vision Demo – line following robots

Line tracking – computer vision demo

In these videos, I’m going to show you my 2 robots equipped with integrated camera following a line. The camera is programmed to track the red color lines using effective image processing. I have accumulate lots of knowledge on computer vision while doing these robotics projects.

Notice how the robot predicts its future direction, as you can see some of the curves of the red line are quite difficult to track. Also, if there is no red line in the view, the robot would turn and search for it :) Everything is autonomous :) Happy watching :)

Please also visit my YouTube channel to see more videos: http://www.youtube.com/user/SquallLTT/

And here we go:
Small tank version:

http://www.everbot.com/uploadedvideoclips/LineFollowing.html

Bigger vehicle version:

http://www.everbot.com/uploadedvideoclips/LineFollowing2.html

Computer vision is a very interesting area. Together with artificial intelligence, once could make something smart. And I hope we can see more intelligent machines in the near future :)

My HTC Viva controls SRV robot

HTC Viva controls SRV robot

Here is the link to the video clip: http://www.everbot.com/uploadedvideoclips/viva.html

Ok, the “HTC Touch Viva” is my favorite Windows Mobile phone. Even though it’s pretty old, I love it so much. I’ve implemented image processing (Canny Edge detection), written a program to operate a robot via WIFI, and much more… :D

Tan Kah Kee Young Inventors’ Award 2009

Ceremony on 23 – 5 –2009

Laser dot detection

The program is written in C#

Using my Creative webcam to get the video feed ^^