Powerful and Beautiful Erlang


Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang's runtime system has built-in support for concurrency, distribution and fault tolerance.



  • SimpleDB, a distributed database that is part of Amazon Web Services
  • ejabberd, an Extensible Messaging and Presence Protocol (XMPP) instant messaging server
  • Facebook Chat system was running on ejabberd based servers, before switching to Java.
  • RabbitMQ, an implementation of Advanced Message Queuing Protocol (AMQP)
  • GitHub, a web-based hosting service for software development projects that use the Git version control system. Erlang is used for RPC proxies to ruby processes.
  • WhatsApp, mobile messenger
  • T-Mobile uses Erlang in its SMS and authentication systems.
  • Yahoo! uses it in its social bookmarking service, Delicious, which has more than 5 million users and 150 million bookmarked URLs.





hello_world() -> io:fwrite("hello, world\n").


Node@whatsapp.com ! "Hello Whatsapp" % 没错,就这么简单地向远程机器打了个招呼

read more

Image Feature Extraction and Matching with OpenCV



#include <cstdio>
#include <iostream>
#include <opencv2/opencv.hpp>
#include "feature.h"

using namespace cv;
using namespace std;

int main(int argc, char *argv[])
    if (argc != 3)
        cout << "wrong usage!" << endl;
        cout << "usage: ./bin queryImage trainImage" << endl;
        return -1;

    string detectorType = "SURF";
    string extractorType = "SIFT";
    string detectors[] = {"SIFT", "SURF", "SURF", "MSER", "STAR", "HARRIS", "FAST"};
    string extractors[] = {"SIFT", "SURF", "SIFT", "SIFT", "SIFT", "SIFT", "SIFT"};
    string matchType = "FlannBased";
    string queryImagePath = argv[1];
    string trainImagePath = argv[2];

    Mat queryImage = imread(queryImagePath, CV_LOAD_IMAGE_GRAYSCALE);
    Mat trainImage = imread(trainImagePath, CV_LOAD_IMAGE_GRAYSCALE);
    if (queryImage.empty() || trainImage.empty())
        cout<<"read failed"<< endl;
        return -1;

    for(int i = 0; i < 7; ++i)
        string detectorType = detectors[i];
        string extractorType = extractors[i];

        Feature feature(detectorType, extractorType, matchType);

        vector<KeyPoint> queryKeypoints, trainKeypoints;
        feature.detectKeypoints(queryImage, queryKeypoints);
        feature.detectKeypoints(trainImage, trainKeypoints);

        Mat queryDescriptor, trainDescriptor;

        feature.extractDescriptors(queryImage, queryKeypoints, queryDescriptor);
        feature.extractDescriptors(trainImage, trainKeypoints, trainDescriptor);

        vector<DMatch> matches;
        feature.bestMatch(queryDescriptor, trainDescriptor, matches);

        double max_dist = 0;
        double min_dist = 100;

        for(int i = 0; i < queryDescriptor.rows; ++i)
            double dist = matches[i].distance;
            if(dist < min_dist) min_dist = dist;
            if(dist > max_dist) max_dist = dist;
        //printf("-- Min dist: %f \n", min_dist);
        //printf("-- Max dist: %f \n", max_dist);

        vector< DMatch > good_matches;
        for(int i = 0; i < queryDescriptor.rows; ++i)
            if( matches[i].distance <= max(2*min_dist, 0.02) )
        feature.saveMatches(queryImage, queryKeypoints, trainImage, trainKeypoints, good_matches, "./");
    return 0;

read more

My PHP Android Develop Problem List

The following is some problems what I encountered in the PHP and Android development and solutions.

1. How to upload file to PHP server from Android.

Java code:

HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
	HttpPost httppost = new HttpPost("url");
	FileBody imageBody = new FileBody(new File("file path"));
	StringBody typeBody = new StringBody("image", ContentType.TEXT_PLAIN);
	HttpEntity reqEntity = MultipartEntityBuilder.create()
		.addPart("file", imageBody)
		.addPart("filetype", typeBody).build();
	Log.i("DEBUG", "executing request " + httppost.getRequestLine());
	HttpResponse httpResponse = httpclient.execute(httppost);
	HttpEntity resEntity = httpResponse.getEntity();
	if (resEntity != null) {
		String strResult = EntityUtils.toString(resEntity, "UTF-8");
                Log.i("DEBUG", strResult);
}catch (Exception e) {
	// TODO Auto-generated catch block

read more