Tuesday, December 8, 2015

OPENCV on Python on my WIndows 8.1 tablet

I have just installed OPENCV on Python on my WIndows 8.1 tablet and I have been playing with it like crazy. Opencv is a powerful tool to programmatically manipulate an image. It is like a low level version of Photoshop. And what happens when a programmer gets to programmaticaly manipulate an image? The possibilities are endless.

I had skipped the "hello world" part because I am not new to opencv and here is what I have tried to develop as part of my learning: finding the exact location of a small image taken from a larger image.

This ois the large image:

And obviously this is the small piece of image:


 And here is the result:

 
 
And here is the python code I used:
# import the necessary packages
import numpy as np
import cv2

# load the big_image  and small_image  images
big_image = cv2.imread('C:\\Users\\mybook\\Documents\\alpha.jpg')
small_image = cv2.imread('C:\\Users\\mybook\\Documents\\piece.jpg')
(small_imageHeight, small_imageWidth) = small_image.shape[:2]

# find the small_image in the big_image
result = cv2.matchTemplate(big_image, small_image, cv2.TM_CCOEFF)
(_, _, minLoc, maxLoc) = cv2.minMaxLoc(result)

# grab the bounding box of small_image  and extract it from
# the big image
topLeft = maxLoc
botRight = (topLeft[0] + small_imageWidth, topLeft[1] + small_imageHeight)
roi = big_image[topLeft[1]:botRight[1], topLeft[0]:botRight[0]]

# construct a darkened transparent 'layer' to darken everything
# in the big_image except for small_image
mask = np.zeros(big_image.shape, dtype = "uint8")
big_image = cv2.addWeighted(big_image, 0.25, mask, 0.75, 0)

# put the original small_image  back in the image so that it is
# 'brighter' than the rest of the image
big_image[topLeft[1]:botRight[1], topLeft[0]:botRight[0]] = roi

# display the images
cv2.imshow("Big_Image", big_image)
cv2.imshow("Small_Image", small_image)
cv2.waitKey(0)
This may a simple app but it can be useful for game development, or it even be further developed and improved to create an image search engine.

Thursday, December 3, 2015

Using my Windows 8.1 Tablet Pc as Raspberry Pi 2 Model B Monitor

The raspberry pi is a tiny pc running on linux based operating system with gpio pins. It is like having an arduino and a personal computer. Unfortunately, the rpi does not have a builtin screen and having to connect it on a huge monitor does not make it a tiny pc anymore. But more recently, I discovered that I can use my Windows 8.1 tablet as my rpi's monitor and take note, the connection is over wifi.

With this configuration, I can access my rpi anywhere even when I will just leave it at home. To access the rpi from my tablet, I used xming and putty. Both software can be downloaded free of charge from the internet. It only took me a few minutes to figure out how to make it work, thanks to those numerous how-to guides on youtube. Without them my mini project would have never been possible.

Here is my setup:


 
So now, I can some python programming with image processing usin my raspberry pi and the wimdows 8.1 tablet pc during my spare time at work.

Tuesday, November 24, 2015

A Desktop CNC is almost an all-in-one Machine

I have always been dreaming of a machine that can do almost anything I want it to do. For example, I want a fried chicken so all I have to do is put a live chicken into the machine and 1 minute later, it comes out as a perfectly cooked fried chicken. But of course this machine is still light years away from becoming a reality. But as an electronic hobbyist,this machine is almost a reality when it comes to creating an electronic device and this is the Desktop CNC Milling Machine.


The cnc machine can enable me to create a small fully functioning electronic device faster using the materials of my choice. For example, I need to create a robotic gripper, if I dont have this machine with me, I will have to take my file to a laser cutting service provider but it is very seldom that the service is reliable I had found one but they are very far and will not respond to emails which means I will have to go there personally to transact business and that still depends on the availability of their machines and another disadvantage is it will be a lot more expensive not to mention that the material is limited to acryllic. What if I want to use aluminum so the robotic gripper will never become a reality. And what if I made a simple error or need to do small adjustments? It can be worse if I am going to create devices that involves pcb. I really dont like the idea of using Ferric Chloride to get good results.






Friday, September 25, 2015

Ibeacon with thin form factor and that really works!

My ibeacon orders just arrived recently after a few months of bumps and so happy to check whether it really work just as the manufacturer had claimed. So here's the result of my testing and review.

Form Factor and Design.
The ibeacons have rectangular shape with thin form factor. It comes with just one neutral color and that is white. The ibeacons that I ordered are boxed in bundles of ten. My impression is that this ibeacon really means business because the packaging alone is absolutely looks expensive.


The ibeacons with my itag:



 The form factor is well suited for applications such as when it is used to be given away to employees to easily track their movements within certain locations because they can be easily inserted in the wallet or be attached at the back of identification cards. The white color is very neutral and can be easily redecorated with stickers or through silkscreen printing.

It can still be modified further by using a higher capacity battery like the CR2032(240mAH) which stores energy 2.5 times more than the CR2016(90mAH) and this ibeacon casing can be an excellent substitute for the newly modified and upgraded ibeacon:

If the pcb is taken out from the 3.3mm thick casing, its thickness is about 0.8mm including the soldered compoments which means, it can be easily inserted inside any device that one needs to modify. Thinner(0.5mm thick) rechargeable batteries at 0.1mAh capacities can used to power the ibeacon. The 0.1mAh is enough to power the ibeacon for about a few days or more. The thin battery is absolutely fine when you want to hide the ibeacon inside the device that is being modified.

source: Thinergy

Even without the thin battery, the whole ibeacon can be inserted inside a cellphone with plastic casing like Samsung J7. Here's how I did to turn my cellphone into a an ibeacon:



Removing the pcb from the casing is not easy. I almost destroyed the casing when I attempted to open it the first time.

The Hardware.
The ibeacons are powered by Nordic nRF51822. Nordic is a Europen electronics company. They have impressive wireless product lines and of course, nRF51822 chip is one of those. The nRF51822 has an arm-based microcontroller as its core. This should make the ibeacons more responsive. It is also equiped with an excellent power management circuitry that should make it consume less power enabling batteries to last longer.
The internal construction is well thought of design which means it gives the impression that it was not created in a small garage by a bunch of college dropouts.

The Software
Configuration software is easily downloadable from the IOS AppStore and Android Playstore. My main focus in rating whether the software is really working are as follows:
1. Password can be easily changed.
2. The name of the Ibeacon can be changed
3. UUID, Major  Minor can can be changed
4. Transmission Power can be adjusted
5. Advertising Frequency is fully adjustable
6. Should have transmit only mode when already deployed.

All of the above is supported by the software and to add a few more good impressions, the software is very easy to use and provides tips to help newbies to get started quickly.

The configuration software also allows the changing of the measured power. I used to think that this parameter is not that important but when I tried to experiment with it using the Estimote software, I realized that this cool feature should not be ignored. Based on the results of my experiment, as I decreased the value, the Estimote software is able to tell more accurately the distance between the phone and the ibeacon. This feature calibrates the ibeacon.


The Power Consumption
Actual power consumption of the ibeacon is accurately adjusted based on the configured transmission power and the rated I think based on the measured power, the battery(CR2016) will last at least 6 months. Here is the comparison of the 3 ibeacons that I have:

The HM10(IBEACON) and Axaet Ibeacons(ziruzbeacons) and the minew ibeacons(1313_48278) have the following configurations:
1. Configured Transmission Power:

  1. HM10 = -23dBm
  2. Axaet Ibeacons = -23dBm
  3. minew ibeacons = -16dBm

2. Measured Transmission Power:

  1. HM10 = -59dBm
  2. Axaet Ibeacons = -86dBm
  3. minew ibeacons = -59dBm

3. RSSI:

  1. HM10 = -54dBm
  2. Axaet Ibeacons = -85dBm
  3. minew ibeacons = -72dBm

In ths case, the Minew Ibeacon with thin profile is the clear winner in terms of power consumption efficiency.


Overall impressions, the ibeacons are not just gorgeously designed but are really fully functioning devices that does its jobs very efficiently just as it is expected.

Tuesday, June 16, 2015

Customizing the HM-10 BLE Module Firmware

There were a lot of complaints regarding the power consumption of HM-10 ble module during sleep mode. My formula for computing how long the battery will last when the HM-10 is configured as ibeacon is quite close to being accurate but surprisingly in the real world, the module does not performed as described by the manufacturer. As proof I took a screenshot of the HM-10(IBEACON) and an AXAET Ibeacon(ZIRUZBEACONS). Both ibeacons having the identical configuration(TX Power= -23db and Advertising Frequency=1200ms) but the rssi and measured power had huge differences which indicates that the HM-10 is not performing as expected.


There are many work arounds to make the HM-10 consume less power and one of them would be to flash new firmware to the TI CC2541 chip using BlueBasic. Uploading a new firmware is quite risky and very challenging but if you succeed in this endeavor, it will be very rewarding because you can access all of the available resources on the TI CC2541 chip. You can even take the customization further to add buzzer, temperature sensors, heart rate monitors, monitor the current battery charge level and many more without the need of external microcontroller.

Here is how to connect the cc debugger to HM-10 BLE Module:

The downside of this is like saying good bye permanently to the original firmware that came with the ble module but in terms of benefits, it is well worth it.

Wednesday, June 3, 2015

Pass2U Pass Issuance Service Integrated with Ibeacons

I was searching for existing ibeacon apps that offers a complete working system that should allow small shop owners jump start their mobile marketing strategies when I stumbled upon the app Pass2U created by a Taiwan Based Software Development Company MicroMacro Mobile. It fits my search criteria and almost(70%) meet the features I mentioned in my previous article(Ibeacon Apps Must Not Be Unique).

The android app is like an organizer that lets users keep all of their discount coupons, loyalty cards, event coupons, debit cards, boarding passes, movie tickets and other offerings in a single app. The good thing about this is when one of the passes stored was created by a merchant from the same website(pass2u.net) and has enabled the ibeacon feature, the user will receive a notification telling the user that he is near the merchant's shop.

For those who are not yet familiar about digital passes, here is some information about it:

What’s a Pass and How do I Use One?

A pass is a digitally signed document such as a ticket, membership card, or coupon that can be distributed by email or a web download. It can be opened with the Passbook app on iOS or with an app like PassWallet on Android. On iOS, a pass can also be linked to a companion app, for example the Eventbrite app which allows you to buy tickets and add them to your device’s Passbook, but that’s not mandatory.
Apple’s specs outline four main pass types:
  • Boarding passes
  • Event tickets
  • Retail coupons
  • Store cards
There’s also a Generic pass type that covers other purposes, and this the type of pass I’m using here.
Each pass contains various bits of data. Some, such as a member name and bar code are displayed visually on the “front side” of the pass. Other data is located on the “back” of the pass and triggered by the “i” icon. Passes can also contain some hidden information such as a time and location which can be used to display relevant notifications.
Source: sitepoint

I tried to explore the whole system and experimented with their store card to check if it's really working and how easy it is to navigate throughout their system, and I have confirmed that yes, it really works and very easy to use with their very good user interface design. Anybody who can read and write and knows how to click buttons can easily get used to the whole system.

Here is a sample loyalty card created from pass2u.net:



Here is the sample notification I received:

Up to 10 ibeacons can be added for a single pass:


What Pass2U missout is a small app that could be integrated with their android pass wallet app is an ibeacon pass issueing/dispensing app. What it basically do is to give away passes to people who downloaded the app each time they pass by the shop and when their smart phone has detected the ibeacon signal.

Friday, May 29, 2015

HM-10 Over-the-Air Configuration Software from the Manufacturer

About 3 months ago, I attempted to test the available software provided by the manufacturer of HM-10 modules, and I failed to make it work but today, I tried to experiment with it and to my surprise, I was able to make it work! This probably because the software has been updated or it could be that my previous configuration of HM-10 was wrong, but I am quite sure that I used the same configuration as before.

The first step I did was used my configuration as indicated in my previous article(Configuring HM-10 to Support Over-the-Air(OTA) Update). Then, I downloaded the new apk from the manufacturer's website but I dont recommend downloading the software from there because they frequently update the files. Here is the apk file I used for my experiment and testing: http://bit.ly/1FkfwJ3. And check the screentshots below as a result of my successful testing:

The Initial Screen. I pressed the search button. 
The app found my ibeacon, I had to tap the ibeacon to configure:
The configuration screen appeared, The initial status message is "connecting to ibeacon....", so I had to wait until it connects to the ibeacon. This is where my precious testing fails, the app could not connect to the ibeacon. But today, it mysteriously connected successfuly.
I tried to type "AT" on the input text and pressed the send button next to it, and the ibeacon responded "OK":



All AT commands should work with the software except those that will affect the ibeacon module's connectivity.