"Lung linh bóng nước con đò, Nhớ sao Chợ Mới câu hò thủy chung
Quê tôi miền đất anh hùng, Hôm nay vẫn đẹp vô cùng ai ơi!"

"Giờ thăm lại trường xưa trong khoảnh khắc
Cảnh còn đây người đi mất từ lâu..."

"對我而言台灣留下非常深刻的印象,我所去的每一個地方,我所見過的每一個人,這都是緣分!
再見大家,再見台灣!"

A greeting from Vietnam.

Showing posts with label MachineLearning. Show all posts
Showing posts with label MachineLearning. Show all posts

Friday, December 21, 2018

[CTU project] Self-driving robot with OpenCV

This project is done by Huỳnh Long and Nguyễn Hùng Khanh (IT cohort 40) as their graduation thesis at ICT College, Can Tho University.
Summary: This project focuses on building a self-driving robot model capable of detecting signs, traffic lights, and obstructions. To perform these functions, Haar cascade method was used to identify signs and traffic lights, then trigger the stop or continue command. Moreover, ANN was adopted to determine the movement direction (go straight, turn left, turn right) of robot from a training set of road lines' photos.
List of hardware components:
  • Raspberry pi 3
  • Raspberry Pi Camera
  • Raspberry Pi Battery
  • HC-SR04 Ultrasonic Sensor
  • Robot frame
  • 4 DC Motors & Wheels
  • L298N motor controller



Author: Huỳnh Long, Nguyễn Hùng Khanh
Advisor: Thái Minh Tuấn, Nguyễn Ngọc Mỹ
Year: 2018.

Tuesday, June 23, 2015

libsvm - How to use?

libsvm is a popular library for performing Support Vector Machine algorithm. This library is developed by Chih-Chung Chang and Chih-Jen Lin, professor at National Taiwan University. Next, I will show you how to install the libsvm in MATLAB.

1. Installation

Sunday, April 19, 2015

Useful chunks of MATLAB code for file/folder manipulation

1. Read all file names inside a range of folders

The following code will look into folders, with regarding to the folder name pattern, and read all file names inside the dedicated folder.
Example: Data files are collected from many user, and each user has it own folder with the name u001, u002,...These user folders belong to a root folder (as in the following photo).
The MATLAB code to read all data file names in this case is:

fileCfg=struct(...
            'rootFolder','D:\Experiment\BodyDyn',...
            'userFolderPattern','^u\d+$',... %regular expression for user folder names
            'extension','set'); %File extension filter
userf = dir(fileCfg.rootFolder);
userf = regexpi({userf.name},fileCfg.userFolderPattern,'match');
userf = [userf{:}];
%userf is now a row matrix that holds all user folder names

dataFiles=[];
for i=1:size(userf,2)
    temp=char(strcat(fileCfg.rootFolder,'\',userf(i),'\*.',fileCfg.extension)); %full path to data folder
    temp2 = (dir(temp)); %this will cause error if the file date is empty
    temp2 = { temp2.name };
    dataFiles=[dataFiles; temp2'];
    %dataFiles is now a vector that holds all file names
end
Important functions that you may need to understand: dir (list folder contents), regexpi (match regular expression with case insensitive).

2. Save results to file

In the following code, it will generate the file that packs the variables varX and varY. This file will be saved in the same folder of the current M file.

fileFullPath=mfilename('fullpath');
temp=strsplit(fileFullPath,'\'); %decompose the fullpath into folder parts and file name part
temp(end)=[]; %remove file name part
temp=strjoin(temp,'\'); %temp is now the path to the folder of current M file
filepath=strcat(temp, '\', datestr(now,'yyyymmdd_HHMM'), '_myData.mat');
save(char(filepath),'varX', 'varY'); %save file with timestamp
disp(['File is saved to: ' filepath]);
(Nguyen My - 2015/04/20)

Friday, April 17, 2015

A geometric interpretation of the covariance matrix

Introduction

In this article, we provide an intuitive, geometric interpretation of the covariance matrix, by exploring the relation between linear transformations and the resulting data covariance. Most textbooks explain the shape of data based on the concept of covariance matrices. Instead, we take a backwards approach and explain the concept of covariance matrices based on the shape of data.
In a previous article, we discussed the concept of variance, and provided a derivation and proof of the well known formula to estimate the sample variance. Figure 1 was used in this article to show that the standard deviation, as the square root of the variance, provides a measure of how much the data is spread across the feature space.
Normal distribution
Figure 1. Gaussian density function. For normally distributed data, 68% of the samples fall within the interval defined by the mean plus and minus the standard deviation.
We showed that an unbiased estimator of the sample variance can be obtained by:
(1)   \begin{align*} \sigma_x^2 &= \frac{1}{N-1} \sum_{i=1}^N (x_i - \mu)^2\\ &= \mathbb{E}[ (x - \mathbb{E}(x)) (x - \mathbb{E}(x))]\\ &= \sigma(x,x) \end{align*}