Tuesday, December 23, 2014

Installing libgroove and nodejs groove module in Raspbian

As we are working on small internal hobby project turning the Raspberry PI into a music box, I came across the need for building the nodejs groove module which requires a pretty big amount of effort. I'm going to provide you with the instruction for building from source.

UPDATE: If using testing/unstable repo is not a problem for you, an alternative method is available and is much faster by using binary packages. Jump to the "Install using testing/unstable binary packages"  section.

Install from source

This is the shorten version of the build script for Raspbian Wheezy that I think it may be useful for other ones struggling with a similar task.

Note: this is the simplified version of a great guide created by Andrew Kelly: Turn Your Raspberry Pi Into a Music Player Server

# install tools and libs
sudo apt-get install cmake git screen
sudo apt-get install libchromaprint-dev libspeexdsp-dev libasound2-dev libmp3lame-dev libvorbis-dev

# install libebur128 from source
cd
git clone https://github.com/jiixyj/libebur128
cd libebur128/
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
sudo make install
sudo mv /usr/local/lib/arm-linux-gnueabihf/* /usr/local/lib/
sudo rmdir /usr/local/lib/arm-linux-gnueabihf
sudo ldconfig

# install SDL2 from source
cd
wget https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
tar xvf SDL2-2.0.3.tar.gz
cd SDL2-2.0.3/
./configure --enable-audio --disable-video --disable-render --disable-events --disable-joystick --disable-haptic --disable-power --disable-file --disable-timers --disable-loadso --disable-cpuinfo
make
sudo make install

# install libav from source, will takes about 9hrs (!), consider using 'screen'
cd
wget http://www.libav.org/releases/libav-10.1.tar.gz
tar xvf libav-10.1.tar.gz
cd libav-10.1/
./configure --enable-shared --enable-debug --disable-static --enable-gpl --enable-libmp3lame --enable-libvorbis
make
sudo make install
sudo ldconfig

# install libgroove from source
cd
git clone https://github.com/andrewrk/libgroove
cd ~/libgroove/
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
sudo make install
sudo ldconfig
ls /usr/local/lib/

#install newer nodejs ARM, this is optional
get https://github.com/needforspeed/Nodejs-ARM-builder/raw/master/v0.10.33/nodejs_0.10.33-armv6_armhf.deb
sudo dpkg -i nodejs_0.10.33-armv6_armhf.deb
which node


#install nodejs groove
npm install groove -g

Install from testing/unstable binary packages

At the time of writing, the testing repository of Raspbian contains a usable set of binary packages that are sufficient for installing node groove module.

Step 1: switch to testing

Edit the /etc/apt/sources.list to replace wheezy with testing, so that the first line of the file reads:

deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi

Step 2: update and install the libraries

sudo apt-get update
sudo apt-get install libgroove4 libgroove-dev libgroovefingerprinter4 libgroovefingerprinter-dev libgrooveloudness4 libgrooveloudness-dev libgrooveplayer-dev libgrooveplayer4

Step 3: install node groove module

npm install groove -g


Thursday, February 20, 2014

Make your camera DICOM-able with a Raspberry PI

As I'm working on a medical product which includes almost all aspects of medical services, working with DICOM is one of my primary items. I came accross a requirement for integrating standard photo cameras into the system so that photos taken from those cameras can be easily imported into medical results. This initially came from an international clinic where physicians use high resolution EOS cameras to take patient's skin photos.

Our medical solution has a built-in feature that accepts images sent from DICOM compliant devices like ultrasound machines so my primary path for the intergration is to make the cameras DICOM-able. There are however several constraints for the solution:
  • There will be a large set of camera models that we need to support, ranging from low-end ones like the Canon IXUS to something like the 7D series.
  • The solution needs to be independent from the user workstation operation system as the users of our medical product can use different types of OS including Windows, OS X or GNU/Linux.
  • User operation needs to be as simple as possible as we want to avoid any redundant step in manually selecting the files and sending them.
My solution for this was to use a Raspberry PI, loaded with Pidora and custom scripts to work with the camera and send captured photos via the network to the DICOM storage server.

To support different camera models, I used the gphoto2 command line tools to watch camera activities and download photos to the Rasperry PI. The connection between the Raspberry PI and the camera is a USB cable. Downloaded photos will be then converted into DICOM files and sent to the server using the dcmtk command line tools. The following steps provide you with the details on how to get it done:

Step #0:
Prepare your Raspberry PI with Pidora. Connect it to the camera using a USB cable and to the local network using an ethernet cable.

Step #1:
Install necessary tools:

# yum -y install gphoto2 dcmtk

Step #2:
Make a main script that invoke gphoto2 and watch for captured photos

$ nano capture.sh
#!/bin/sh

while :
do
    export CAMERA=`gphoto2 --summary --quiet 2>&1 | grep "Model: " | sed "s/Model: //"`
    if [ "x$CAMERA" = "x" ]; then
        sleep 1
        continue
    fi
    gphoto2 --quiet --capture-tethered --hook-script=camhook.sh
done


Step #3:
Make the script that handles the downloaded photo and send it via DICOM

$ nano camhook.sh
#!/bin/sh

if [ "x$ACTION" = "xdownload" ]; then
    echo "Converting to DICOM..."
    img2dcm -k "PatientName=$ARGUMENT" $ARGUMENT $ARGUMENT.dcm
    echo "Sending to storage..."
    storescu -aet "$CAMERA" --propose-jpeg8 192.168.100.51 9104 "$ARGUMENT.dcm"
    echo "Done."
    rm $ARGUMENT.dcm
fi



After having all the setup done, starting the capture.sh will make your camera now DICOM-able.



Thursday, October 11, 2012

Pencil on Fedora

An exciting news today is that Pencil has been officially approved and made available for Fedora users. Users of Fedora 16, 17 and also 18 (beta) can now easily install Pencil via yum.

Repository information for Pencil in Fedora 17:

# yum info pencil
Loaded plugins: downloadonly, langpacks, presto, refresh-
              : packagekit, versionlock
Available Packages
Name        : pencil
Arch        : noarch
Version     : 2.0.1
Release     : 1.fc17
Size        : 1.4 M
Repo        : updates
Summary     : A sketching and GUI prototyping tool
URL         : http://code.google.com/p/evoluspencil/
License     : GPLv2
Description : Pencil is an open source GUI prototyping and
            : sketching tools released under GPL.

Thursday, March 10, 2011

Top five reasons why I don't use Chrome

As an opensource enthusiast, I love the Chromium project but there are things that keep me away from using Chromium-based web browsers for everyday browsing needs.

Reason #0: Font rendering is ugly
Google Chrome and Chromium (or Chrome for short) do not respect the desktop environment settings for font rendering. They use their own wrapping of freetype to produce a bad kerning and anti-aliasing result. This is not a problem of Webkit since other browsers including Midori do a very good job while using the same core as Chrome.

Google, don't tell me that I do not need to read texts when browsing the web.

Reason #1: Stupid cropping of titles in the tab bar
Chrome failed to render itself as a browser with excellent usability as claimed. By default, Chrome shows the page titles only in the tab for each page. The page titles seem to be always cropped and it's getting really hard for me to read the page title.

Google as a search giant knows very well how important a page title is but with Chrome they imply that "It's not any important, dude. Trust me. You don't want to read it."

Reason #2: No built-in tree-based XML view
I'm a programmer and it's my everyday need to inspect XML resources. Chrome claimed to be a developer-friendly browser but viewing XML files with it is funny.

Reason #3: I hardly see to where a bottom-left link points
For many cases, hovering over a link located a the bottom-left corner of the browser window hides the status bar which is displaying the target URL. This forces me to make a scroll-up to see the link location.

Reason #4: It should be named Chrashium
Yes, it crashes frequently on my desktop regardless it is a Google official build or a Chromium build.

Monday, December 27, 2010

Đọc được trong tự truyện

của Giáo Sư Trần Văn Khê:

"Từ câu chuyện này, tôi muốn nêu ra một thí dụ cụ thể của một người nghệ sĩ lớn ngoài tài nghệ còn có những đức tánh mà bạn trẻ nên noi theo. Một là, khi gặp khó khăn, không bao giờ bó tay mà phải quyết tâm tùy cơ ứng biến để vượt qua. Hai là, phải biết thích nghi với hoàn cảnh. Ba là, nên có lương tâm nghề nghiệp không bao giờ tự mãn với kinh nghiệm của mình mà luôn luôn phải luyện tập nhiều và khi đến một sân khấu lạ cũng cố gắng diễn tập một lần để không bị bỡ ngỡ trước ngoại cảnh khác."

Friday, May 21, 2010

Viettel 3G USB Modem with Fedora

I got myself a Viettel 3G USB stick yesterday for the need of roaming access while I'm off the city. I tried it first with my colleague's Windows machine. The stick worked well with Windows but in ridiculous way. It shown up in a dedicated, silly designed window frame with the ISP heavily branded. That's still acceptable, anyway.

I booted up my laptop which has only Fedora 12 to see how the stick behaves in GNU/Linux. Plugging in the USB in with a really hopeless mind since I know clearly that Linux is not what they are willing to support. And that was clearly documented in the tiny user manual I got when purchasing the stick.

I was right. It did not work. To be honest, it actually worked as a storage device since I found a fake CD-ROM shown up with the name of D-COM.

And that was the interesting clue for me to solve the problem. I googled for the whole day, asked in the forum to have it finally solved in the sweetest way!

To save others' time, here follows a complete guide for Fedora users:

Background

Modems provided Viettel are produced by Huawei and the one I got is the Huawei E1750. Huawei and many other manufactures use a method (which they actually call 'technology') in which the device will behave as a fake CD-ROM when just plugged in. This is to allow the manufacture to ship the installation CD contents right within the device instead of having a real CD-ROM attached.

An autorun application for Windows is included in the fake CD-ROM to start the driver installation process.

After the installation is done the driver is up and to begin the use of the stick as a real modem, a special data sequence is sent by the driver to the device in order to ask it to switch the USB interface into the modem mode. From that on, the USB can be used as a 3G GSM modem. The USB will kept itself switched as long as the power to it is not cut.

This is really clever! A CD-ROM and GSM Modem within just a single USB stick.

Problem with GNU/Linux

The clever part of the device is also the problematic part of it in GNU/Linux. While Huawei GSM modem support is added into the kernel, the activation of the GSM modem mode is however not straightforward.

When the device is plugged in, the OS recognizes it as a storage device only. What we have to find out is how to switch the device into the GMS mode.

Fortunately, a dedicated project was created for just this purpose. The usb_modeswitch program! The latest version of this program is included in the Fedora 12 official repository.

Switching the mode with usb_modeswitch

usb_modeswitch is a helper application that integrates into udev to watch for USB devices. When a device is plugged in, usb_modeswitch lookups the just-plugged-in device vendor and product ID in its internal registry and carries out an appropriate operation in order to switch the device into the GMS modem mode. This perfectly fits our need for the Huawei device. The following steps help you install the switching:

Step 1: Installing usb_modeswitch

usb_modeswitch can be installed easily with yum:

#yum -y install usb_modeswitch

Step 2: Removing wrong udev entries

An important thing that you have to do is to resolve a conflicts in using the device. To do this, find the file at /lib/udev/-modem-modeswitch.rules and comment out the line that mentions the Huawei device (Huawei devices have the vendor:product id of 12d1:1446)

May thanks to Josh for guiding me in this section.

Step 3: Reboot

There may be other ways but this is the most simple one to get udev reloaded.

Configuring the connection

After rebooting and plugging in your device you can now configured the connection using NetworkManager. And this is what I found it is so sweet, the Linux way of configuring network connection. You have a single, united and well designed graphical user interface for all network connections of all types, all kind of devices.

Adding a new connection

Right-click the NetworkManager panel icon, select 'Edit Connections...', select the 'Mobile Broadband' and click 'Add'

The Huawei device should be listed in the device list, select it and click 'Forward'.

Since Vietnam may not be listed in this version of NetworkManager, just select 'My country is not listed' and then 'Forward'

Enter Viettel in the Provider box. This is not a configuration parameter, you can choose another name. However, this will be used in the default connection name so I suggest that you have the ISP name here.

Enter 'e-connect' as the Access Point Name. This is an important configuration parameter. I found it when inspecting the Windows application shipped with the modem. No information for this parameter is officially provided by the ISP.

Click 'Forward'.

Just click 'Apply' in this confirmation screen.

Modify the connection name if you want and click 'Apply'. The configuration is done you can now start using the connection.

Using the connection

Clicking the NetworkManager panel icon you will find that connection is now listed and ready for use:

Select the connection and wait for the modem to get connected, you can now start using the 3G connection!










Tuesday, July 28, 2009

Đối với những người

không nhận ra những gì mình mang cho họ thì đừng mong họ có thể cùng mình làm những việc gì lâu dài hay to lớn.

--Ranh ngôn - Luis De Monkey

Sunday, July 26, 2009

Micro$oft to release Linux driver code in GPL

People's wondering what M$ did the act for:
  • To prove that M$ loves open-source: No, the jumping monkey at M$ stated open-source as its enemy.
  • To have the code merged into the kernel with a trojan horse inside: Absolutely no, M$ can't
The only reason is that if they don't release do the code, they will be violating the GPL!

Friday, July 10, 2009

Have my Fedora 11's cairo and freetype updated

with LCD filter enabled. Font rendering's now sweeeeet!

Some quick comparison:

Before updating, After updating with slight hinting and After updating with medium hinting.

Wednesday, June 10, 2009

Fedora 11

Just upgraded my laptop to Fedora 11. Everything seems OK, except Inkscape and SCIM.

Sunday, March 29, 2009

Microsoft's Guide to Windows Form... WTF?

I have just read this (for the first time): http://msdn.microsoft.com/en-us/library/ms229597(loband).aspx

This is the first article in the series of ones created by MS to help developer get started with Windows Form.

The last code snippet says:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace FormWithButton
{
public class Form1 : Form
{
public Button button1;
public Form1()
{
button1 = new Button();
button1.Size = new Size(40, 40);
button1.Location = new Point(30, 30);
button1.Text = "Click me";
this.Controls.Add(button1);
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
}

If you notice the way the button size and location are specified, you may find it too bad.

Even for the purpose of simplifying the code in a getting started guide, they should not do that way.

WTF? At the very first step to Windows Form, Microsoft leads their developers to the most stupid mistake that any UI developer should avoid.

Wednesday, March 04, 2009

xvnkb for Fedora 10 users

I have just dumped scim-unikey in favor of the old xvnkb. This time I did a plain installation using the traditional ./configure; make; sudo make install for xvnkb from the 0.2.9a source package.

It's normal that after installing, my dear Gimp stopped working. xvnkb and Gimp seem not to play well together and the reason may be that some of the system calls which were overrided by xvnkb preload so don't work with Gimp and cause it to crash.

As noted by Tinh in the installation of xvnkb for Arch, the workaround is to disable xvnkb.so overriding in case of launching Gimp.

The method to disable overriding provided by Tinh does not work in the case that xvnkb is installed using make install. This is simply because the installation script actively disabled the preloading method using env variable. Instead, it created its own entry in the /etc/ld.so.preload for loading its so. With this method, temporarily emptying the LD_PRELOAD variable does not prevent the system to preload the xvnkb.so.

The workaround's workaround is to roll back into using the environment variable based preloading method.

To do this, you have to first remove any xvnkb related entry in the /etc/ld.so.preload file and then put this in a file named xvnkb.sh in the /etc/profile.d
export LD_PRELOAD=/lib/xvnkb.so.0.2.9a
To fix the Gimp problem, in your root terminal, do this:
# cp /usr/bin/gimp-2.6 /usr/bin/gimp-2.6-orig
Create a text file at /usr/bin/gimp-2.6 and put this into that file
#!/bin/sh

export LD_PRELOAD=""
gimp-2.6-orig $1
Go back to your root terminal, add the execution permission to the file
# chmod +x /usr/bin/gimp-2.6
Reboot your box and both xvnkb and Gimp will work (but not together, unfortunately!)

Monday, February 16, 2009

Vi$ta Usability #2: UAC

This tells you how good Microsoft UAC is:



(and also selinux)

Sunday, February 15, 2009

Vi$ta Usability #1: Data listing

Copying some files in Vista using the explorer:



So which file is being copied?
The ugliest data lister working at M$ show me bunch of info but not the simplest thing.

Thursday, January 08, 2009

Is this a movement for cost reduction or software freedom or both?

VietNamNet Bridge – The Ministry of Information and Communications has issued an instruction on using open source software products at state agencies.

Accordingly, by June 30, 2009, 100% of servers of IT divisions of government agencies must be installed with open source software; 100% of staffs at these IT divisions must be trained in the use of these software products and at least 50% use them proficiently.
Original post is at http://english.vietnamnet.vn/tech/2009/01/822425/

Monday, December 29, 2008

Việt Nam!


Wednesday, December 03, 2008

Duo acoustique, by Lull


Found this album today on Jamendo.


It's been 4 years since Lena and Arnaud began to play together. They come from south of France and now live in Paris where they play as often as they can. They are working on a first album and are still looking for a label.


Thursday, September 04, 2008

An independent benchmark of JS engines

An independent benchmarking result is posted today revealed the fact that in a close-to-real-world usage test, Chrome's V8 arrived at the 6th place ahead only the poor IE6's engine. This is totally opposite to the result provided by Google when benchmarking using their own tests.

This is interesting!

(Please note that even with JIT turned ON in FF 3.1b the performance was not improved. This is just because the test concentrates mostly on DOM manipulation, which is much used in real world applications, but the current TraceMonkey doesn't do any JIT for DOM calls.)

Friday, August 22, 2008

Hic, tối nay nhận được một cái email

vui ngất ngây như ở trên mây =))

:-x :-x :-* :-*

Ráng chờ thêm xíu nữa, có thông báo chính thức con_vịt tui sẽ loa loa loa :D :-x

Thursday, August 14, 2008

Tiễn đưa ông già nam bộ...

Nhà văn Sơn Nam mất hôm nay, ngày 13/08/2008. Ông hưởng thọ 82 tuổi.
Văn đàn Việt Nam mất đi một cây đại thụ...