Tuesday, September 11, 2018

3.5 inch LCD Display on Raspberry Pi

I received a 3.5 inch LCD display which can be attached to the Raspberry Pi B+ device. It can be attached to the GPIO port of the RPi and use it as a display and as a touch screen for input. Installing drivers for the device was straightforward. Following are the steps I took to get it done.

(1) Download the software from the Github from the following project into a computer. https://github.com/goodtft/LCD-show

(2) Connect the RPi from the computer through SSH and copy the downloaded software into it.

(3) Move into the directory from the terminal and run the following command to install the driver software.

sudo ./LCD35-show

When the commend completes running, it automatically reboots the RPi and get back with the LCD touch screen.

Wednesday, July 11, 2018

A Signature Image for Documents

While filling forms and preparing documents on the computer, I come across needs to put my handwritten signature on the document. In such cases, the printing of the document, signing it by hand and then scanning it to produce the soft copy is too much. It is useful to have an image of the signature which can be easily inserted into documents.

On Linux, we can use the following steps to produce an image file where the handwritten signature stays in a transparent background.

(1) Put the signature on a white paper and take a photograph.

(2) Use a suitable tool to crop the photograph file to remove the unnecessary edges and have only the area covering the signature (e.g., Shotwell Viewer). Let's say the resulting image file is original.jpg.

(3) Run the following command to push the whiter pixels to fully white and darker pixels to fully black.

convert original.jpg -colorspace gray -threshold 28% filtered.png

(4) Run the following command to set the while pixels as transparent.

convert filtered.png -transparent white signature.png

Now, the resulting signature.png file contains the handwritten signature in black color while the background stays as transparent. This file can be used for the purpose of inserting the signature into electronic documents.

Sunday, June 17, 2018

Low Graphics Mode Problem on Ubuntu 16.04 LTS

My laptop, which runs Ubuntu 16.04 LTS, recently started to give me a strange error. When the computer is turned on, it boots into a screen where a message is shown as "Your system is running on low graphics mode". If I proceed to boot the system, the system boots up however the on-board WiFi is not detected. My computer suffered a physical damage lately which may have caused some hardware to malfunction. Anyway, being unable to fix this strange error, I found a somewhat workaround for it in the web.

Following the steps shown below to workaround each time when the "Low Graphics Mode" error occurs on Ubuntu 16.04.

(1) Turn on the computer and wait till it lands on the "Your system is running on low graphics mode" error.

(2) Press the key combination Ctrl + Alt + F1 and login to the virtual terminal it provides.

(3) On this terminal, type the following command.

sudo service lightdm restart

(4) Now, when the GUI login prompt appears, login there and the desktop environment should load now without any issues.

Cheers!

Saturday, April 28, 2018

Installing SETI@home on Ubuntu 16.04 LTS

Searching for alien life is the goal of many space exploration projects for many years. Aliens can come in all shapes and sizes starting with single celled life. Among them, finding intelligent life would be exciting than anything else. Search for Extraterrestrial Intelligence (SETI) is a project which attempts to achieve that goal by listening to their radio transmissions. They have large radio telescopes which collect radio signals from the outer space and then process them to look for any sign of message from an intelligent beings.

Now, here's the issue. The scientists at SETI don't have enough processing power in their computers to process all these data acquired from the radio telescopes. This is obviously a computationally intensive task. That's where we can give a little hand as a good citizen of Earth. We can share a part of our personal computers processing power to process SETI data. I'm writing down the steps to install the required software on a computer running Ubuntu 16.04 LTS and setup everything.

(1) First of all, we need to have an account in the SETI@home website, in order to contribute. Go to the following website and create an account.
 

(2) Now, it's time to install the relevant software on our computer. For a computer running Ubuntu 16.04 LTS, we can easily install the software through the software repositories. Open a terminal and issue the following command for that.

sudo apt update
 
sudo apt install boinc

(3) Open the BOINC software GUI and log into your account. Once you are logged in, you should be able to search for the SETI@home project from the list of projects available and add it.

(4) After a while, the SETI@home client will start taking data from the sever and process them locally. You can view the ongoing tasks on your computer in the GUI client.



Cheers!

Monday, March 19, 2018

SSIM to Measure Image Similarity

There are situations where we need to measure the similarity between two images. For example, when we have an original image and few other images with lower quality, we might need to identify when one is mostly similar to the original image. Bit-wise comparison of the image pixels is not applicable in this kind of scenarios. We need something more sophisticated. Structural similarity index (SSIM) is such a method. It provides a value between 1 and 0 when comparing two images. If two images are exactly similar the SSIM becomes 1. If they are totally different, SSIM becomes 0.

Following Python program implements SSIM to compare between to images. Since we need some extra python libraries for this code to run, we should install following libraries on Ubuntu Linux.

sudo apt install python-skimage

sudo apt install python-opencv

SSIM calculation code is as follows.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
from skimage.measure import structural_similarity as ssim
import cv2

print("Reading files...")
first = cv2.imread("image1.png")
second = cv2.imread("image2.png")

print("Resizing files...")
first = cv2.resize(first, (2576,1125))
second = cv2.resize(second, (2576,1125))

print("Converting files to grayscale...")
first = cv2.cvtColor(first, cv2.COLOR_BGR2GRAY)
second = cv2.cvtColor(second, cv2.COLOR_BGR2GRAY)

print("Calculating SSIM value...")
s = ssim(first, second)

print("first vs second", s)

~*******************~


Thursday, March 1, 2018

Merging Video Files on Linux Terminal

When we need to merge multiple video files into a single file, there's an interesting tool called mkvtoolnix we can us. We can install it using the Linux software repository as follows.

sudo apt install mkvtoolnix

Let's say we have three mp4 video files which we need to merge and build a single mkv file. We can do it in the following way.

mkvmerge -o full-video.mkv part-1.mp4 \+ part-2.mp \+ part-3.mp

Meanwhile, I learned that there's a GUI version of the tool called mkvtoolnix-gui which I should explore later. For the moment, we can install it using the following command.

sudo apt install mkvtoolnix-gui

Cheers!

Kazam Screen Recorder

Recently, when I wanted to create a video demonstration which involves recording my computer screen and the input from my microphone. As an Ubuntu GNU/Linux user, I've tried few different screen recorder software but, the results were not very encouraging. However, in my recent attempt, I found a nice piece of software which could meet my requirements. It's called Kazam screencaster program. I just thought to leave a note about it here so that I can find it when I need it the next time.

It is available on the Ubuntu software repositories and we can install it with the following command.

sudo apt update
sudo apt install kazam