Posts

Showing posts from 2014

iBeacon heat map test

Image
Generating heat map using iBeacons with android application Intro About a month ago I had an opportunity to play with an iBeacon on the Android platform. My first task was to implement a proximity trigger to Android client for one of our apps at work. As we played with it, we wanted a more precise data such as a heat map. Searching I googled some familiar projects around, bud didn't find a precise app in the Play Store that generates a heat map from actual distances from iBeacons. After visualization the raw accuracies in a graph (picture below) I found this interesting page that nevertheless confirm my results. These are my observations. raw data is not as accurate as I first thought accuracy depends on rotation of iBeacon to the smart phone at some distance, the error is rising rapidly to get more precise data, you have to set a transmit interval and transmit power to the maximum, but that also leads to more battery consumption What I did I created an Android

Bill cropper

Image
Automatic tool for cropping bills from scan What is it? We have this project at work, that is intended for small and medium companies. It covers much more than just simple accounting. It has many cool features that I'm not going to write about, except one. Automatic processing bills/ invoices. You can do it via your mobile client (Android, iOS) or a web application. What to improve? We ran into a problem that people scanned more bills together, instead of one image - one document rule. So I decided to create a small script to recognize and crop these multi-bills images into separate images. Algorithm To crop the bills out of the images I used a few simple preprocessing image methods. First, I remove the noise. After that I convert the image to binary and separate it into white areas. Finally I find enough big white areas and find a bounding box for them. I think the code below is self explaining enough. 1. RESIZE 2. IMOPEN - MORPHOLOGICAL OPERATION 3. IMG TO BINAR

CodeIgniter log

Custom log helper for CodeIgniter framework  For the last few months we were working with the PHP CodeIgniter framework. Every time I was debugging and wanted to write down some variable I had to write this log_messge('error', $tog_this_var ). 18 characters! Horrible. If the variable was boolean, object or array I'd have to write more or add some if statements. So I decided to write a small helper. Maybe you will find it useful. <? if ( !function_exists('l') && !function_exists('l2') && !function_exists('get_parameter_value') ) { function get_parameter_value($param = null) { if (is_null($param)){ return 'NULL'; }else if (!isset($param)){ return "parameter is not SET"; }else if(is_array($param)){ if (empty($param)){ return "empty array()"; }else{ return print_r($param, true); } }else if(is_string($param) || is_float($pa

CI invalid session

Strange session behaviour How does it look like? Lately at work we've ran into a strange behaviour of an irregular logging out. We used CodeIgniter php framework for developing a web application. We noticed this problem earlier on, but we couldn't repeat it on purpose. This behaviour occurred randomly. We didn't know how to repeat it so it was almost impossible to debug it. But one day, we found that if the screen with the map of the POI positions was repeatidly updated in few seconds intervals, this problem occurred more often. What was the problem? The session was not expired as we thought first, the cookie was somehow cut off about 10, 20 symbols. The problem was in CodeIgniter Security class in xss_clean which prevented the cross site scripting. To be exact the offender was regular expression that was trying to filter every onEvent javascript function. So if your generated cookie contained substring "#### on SOMETHING=" it removed the part "SOMET

Nxt drill photo printer

Image
Drill photo using Android and leJOS This project consists of two parts. First is an android application which communicates via bluetooth with the Lego NXT cube v1.0. I update a NXT cube with leJOS firmware so I can write code in Java. Android Android application contains more than a drilling a picture. First it was a controller for all the small programs like follow line, use accelerometer to move with robot, etc. You can also set the type of the robot with according programs. After pairing via bluetooth with NXT cube you can play with it. On pictures below you can see the screen shots of the application. I also try to control the movement of Tribot with colors glued to my hand. I used a phone's back camera to recognize colors with the phone placed on a tripod. I had a playable demo but it wasn't as awesome as I imagined before. Anyway, my first idea was for the robot to recognize hand gestures, but it wasn't giving good results because of the transfer speed (I ne

Auto image rotation

Using Tesseract OCR to autorotate scanned text to right rotation. Problem From time to time, everyone has a bunch images of text that they don't want to rotate one by one to their right orientation. Solution I decided to write a small script that auto detects the orientation of pages based on OCR recognition and dictionary matching. First I used open source tesseract as OCR for parsing text from images. Second, I wrote down a list of most probably occurring words in a text (there are only 5-6 in example below, feel free to write your own). Finally the images rotate and parse every rotation through OCR and test with dictionary. As the OCR accuracy isn't 100% I used some small deviation on comparing words. See code below. Just copy these 3 files listed below into your ~/bin directory and run tesseract_rotate_all Dependencies You need to install perl re::engine::TRE - TRE regular expression engine download here recognize_good_rotation perl script to evaluate