Posts

Showing posts from 2014

Generating a Heat Map Using iBeacons with an Android Application

Image
Introduction About a month ago, I had the opportunity to experiment with iBeacons on the Android platform. My initial task was to implement a proximity trigger for one of our Android apps at work. As we delved deeper into the project, we became curious about obtaining more precise data, such as generating a heat map. Searching for Solutions I began by searching for existing projects and apps that could generate a heat map based on actual distances from iBeacons. Unfortunately, I couldn’t find a precise solution in the Play Store. After visualizing the raw accuracy data on a graph (as shown in the image below), I discovered a helpful page that confirmed some of my findings. Here are my key observations: The raw data from iBeacons is not as accurate as I initially expected. Accuracy varies depending on the orientation of the iBeacon relative to the smartphone. Beyond a certain distance, the margin of error increases significantly. For more precise data, you need to set the transmit inter

Hint

What Is It? Switching between different programming languages and projects daily can be challenging. To make things easier, I decided to create a quick-access utility for storing and retrieving code snippets, examples, and notes. The new features you learn from various frameworks are often useful later—if not for yourself, then for your coworkers. While Googling is an option, it often takes up valuable time. My solution? A small utility that lets you access your notes in less than 2-3 seconds. Recently, I’ve been working extensively with PostgreSQL, so I decided to build this tool using this reliable open-source database. What Can It Do? This utility allows you to quickly search for syntax examples across multiple programming languages. It’s designed to help you find what you need with minimal effort. How Does It Work? The utility is command-line-based and currently supports space-separated search terms. Here’s how it works: Command Line Interface : You enter your search directly into

Automatic Tool for Cropping Bills from Scans

Image
What Is It? At work, we’re developing a project aimed at small and medium-sized businesses that goes beyond simple accounting. It includes many innovative features, but today I want to focus on one in particular: the automatic processing of bills and invoices. Users can take advantage of this feature via a mobile client (Android, iOS) or a web application. The Challenge We encountered an issue where users were scanning multiple bills together in a single image, rather than following the "one image - one document" rule. This made it difficult to process the documents correctly. To address this, I developed a script that automatically detects and crops these multi-bill images into separate, individual images. The Algorithm To separate and crop the bills from a scanned image, I used a series of simple image preprocessing methods: Resize : The image is resized to a standard dimension for consistency. Morphological Operation (IMOPEN) : This step helps in removing noise and refinin

Creating a Custom Log Helper for the CodeIgniter Framework

Over the past few months, we've been working extensively with the PHP CodeIgniter framework. One thing that consistently slowed me down during debugging was the repetitive process of logging variables. Every time I needed to log a variable, I found myself typing out log_message('error', $your_variable) —a lengthy 18 characters every single time! And that’s just for basic variables. If I wanted to log a boolean, object, or array, the process became even more time-consuming, often requiring additional if statements or extra formatting. To simplify this process, I decided to write a small custom log helper. This helper makes logging easier by automatically handling different variable types, allowing for faster and more efficient debugging. If you’re working with CodeIgniter and find logging as tedious as I did, you might find this helper useful too. <? if ( !function_exists('l') && !function_exists('l2') && !function_exists('ge

Unexpected Session Logout Issue in CodeIgniter: A Case Study

The Problem Recently, at work, we encountered a puzzling issue with our web application, which was built using the CodeIgniter PHP framework. Users were being logged out unexpectedly, and the logout behavior was irregular and hard to predict. Although we noticed this problem early on, it was difficult to reproduce consistently, making debugging a challenge. The issue seemed random, but we eventually observed that it occurred more frequently when the screen displaying a map of POI (Points of Interest) positions was refreshed at short intervals, such as every few seconds. What Was the Cause? Initially, we suspected the session was expiring prematurely. However, upon closer inspection, we discovered that the session cookie was being truncated—losing about 10 to 20 characters. This led us to investigate the CodeIgniter Security class, specifically the xss_clean function, which is designed to prevent cross-site scripting (XSS) attacks. The root cause was a regular expression within xss_cle

Creating a Drill-Printing Robot with Android and leJOS

Image
Project Overview This project is an exciting fusion of Android development and robotics, combining an Android application with the LEGO NXT cube (v1.0) enhanced by the leJOS firmware. The result? A robot capable of drilling images, among other things! The project consists of two main components: Android Application : This app communicates with the NXT cube via Bluetooth, acting as a controller for various robotic functions. NXT Robot with leJOS Firmware : The NXT cube is upgraded with leJOS, allowing programming in Java, making it more versatile for complex tasks. Android Application The Android app isn't just for drilling images—it's a comprehensive controller for the NXT robot. Initially, it was designed as a multi-functional tool capable of: Controlling the robot’s movement using different programs, like line-following or accelerometer-based controls. Allowing the user to select the type of robot and the corresponding control programs. After pairing the app with the NXT cube

Automatically Rotating Scanned Text Images with Tesseract OCR

Problem If you've ever had a batch of scanned images with text, you know how tedious it can be to manually rotate each one to the correct orientation. This process can be especially frustrating when dealing with a large number of images. Wouldn't it be great if there were a way to automatically rotate these images so that the text is always upright and readable? Solution To solve this problem, I developed a simple script that automatically detects the correct orientation of text in scanned images using Optical Character Recognition (OCR) and dictionary matching. Here's how it works: OCR Parsing with Tesseract : I used Tesseract, a popular open-source OCR engine, to extract text from the images. Tesseract is powerful and versatile, making it an excellent choice for this task. Dictionary Matching : I created a list of the most commonly occurring words in the text. This list acts as a reference to determine the correct orientation. While my example includes only 5-6 words,