Monday, April 21, 2014

IMAGE COMPOSITION 2

The main aim while constructing the bookshelf image was to preserve the actual dimensions of the books. To do this, the height of the book in pixels is calculated. The resolution of the kindle is 1024X768 pixels. The height in this case is 1024 pixels, so the books that have a height higher than that should lay flat as they would in a regular bookshelf.

Worldcat.org had most of the heights of books that I wanted. The book name, file name and the heights were recorded in a csv file and read into variables in a bash script. One thing I noticed is that the size of the kindle screen is way smaller than almost all the books I scanned. So, the point is, what we think as a device that resembles a book, is very much smaller than the actual book.

Now, because of this, all the heights had to be scaled down while still showing the differences in heights among them. The height of the resized images and the file names are stored in a separate csv file. The file is read and if the height in pixels is greater than 1024, the spine image is rotated 90 degrees. Images which are rotated 90 degrees are all stacked up horizontally whereas the remaining spine images are stacked vertically. The Image Magick commands that does this are

convert input +append output (verical)
convert input -append output (horizontal)

Now the two final images are appended together vertically, and are converted to grayscale. They are then split into the number of kindles in the system and sent to them. 

SPINE IMAGES

The real problem that I ran into was to find spine images of books. They were not scanned in most online libraries and I had to take pictures of book spines and store them on the server for using it later. 

Some images are here


 These images were then scaled to their original size and appended.


Monday, April 14, 2014

IMAGE COMPOSITION

The image of the bookshelf that has to be displayed on the Kindle has to be composed of different spine images of books rather than the front covers. Spine images are really hard to get, so I had to take photographs of spines of books that I wanted on the image, scan some books and download some already scanned images from the internet. 

For composing the basic image on the display I used ImageMagick commands in shell scripts running on the server. Spine images of books were collected by photographs and other online resources. The images were first appended to each other. This step assumes that all the spines are off comparable dimensions. So it just puts together all the spine images into a single image. The resolution of the Kindle Paperwhite is 1024X768 and it can display only Grayscale images. So the resolution of the composed image is modified accordingly using the resize command to fit the screen. For the Grayscale conversion, the convert command is used. So, now the composed imaged is altered to display on a single paperwhite 2. 

After the image is composed, the script on the kindle just pulls it up and displays it. When a new book has to be added, the spine image of the book is first loaded on the server and then the script is executed again to include this new image in composing the bigger picture. The new spine images are stored in a particular name format so all the names associated with a particular naming vocabulary is extracted to compose the picture.

This is the basic version of image composition and does not take into picture the size, height and width of books. These are considered as the project advances.

Tuesday, March 25, 2014

SOFTWARE DESIGN

The software for the system consists of two parts, one part running in the kindle and the other one in the server.

In the kindle, a script is written to run at boot. The script pulls up an image from a URL and displays it full screen at boot and refreshes it periodically using crontab. The image is first downloaded from the URL, stored in the server and then pulled up in the kindle. While refreshing, the previously downloaded image is deleted, new image is downloaded (even if it is still the previous one) and displayed. The period to be refreshed can be anywhere between 10 minutes to 5 hours. This is the simplest version of the software that can be thought of. This is executed in multiple kindles, with a different image loaded on each one, together produces on large image. Thus, a different script runs on different kindles to pull up different parts of one image.

On the server, the images can be refreshed to reflect a change in the display. A python script which imports ImageMagick libraries can do this. The server side script takes up book-spine pictures, orders the list of images. Then, the pictures are organized in order to compose an image which is split into the number of kindles, each split image having the same dimensions. Now the images are sent to the respective kindles to display them. This can be considered as the second version of the software where spines of books are retrieved from various sources to compose a picture and then display it.

The final version of the software will display the image more accurately. For example, tall books cast a shadow on the shorter ones. Image manipulations will be done to make it look exactly like a physical bookshelf. Portions of the image will be shaded to implement this. And, also, furthermore into it, books need not lie on the bookshelf in exact vertical positions, it can be bent on other books or lying flat with the spine being visible. These changes will be done through ImageMagick commands.

Friday, February 28, 2014

System Architecture

The system has a simple design with ‘N’ kindles, a server in the back-end and an Arduino to integrate all the e-ink controllers. It  consists of an array of kindles in a particular orientation which displays an image of a bookshelf. The kindles are hard coded to display an image that is sent via a USB cord.  Each kindle in the array receives a part of the image to display. The displays are all integrated by an Arduino connected to the e-ink controllers on the kindle motherboards.

In the server, a cron is initialized to run a script at regular intervals to refresh the content on the display to pull out new data from the server which runs the program. Any changes in the code is reflected on the display. Two attributes are defined, one for the orientation of the kindle, vertical and horizontal, and the other one addresses a particular kindle in the array. For example, if the 3rd kindle in the array is horizontal, the respective part of the image is sent to it and refreshed periodically. The program in the server is used to control the display without interfering with the kindles.

Alternatively, a web application can be used to control the display, requesting through http. This will cause the image to be refreshed each time the request is made.

Tuesday, February 18, 2014

Developing Kindlets

Kindlets are applications that you can run on your kindle. They have .azw format which is an extension of a Jar file. The back-end development of Kindlets are done in Java and the resulting jar file is exported into the kindle in e-book format(.azw). 

The basics of kindle development can be found in Kindle developer's Corner on mobileread.com. The code is executed against the kindle libraries which are provided by Amazon. There are many ways to obtain these libraries, but the easiest way is to obtain it manually from the opt folder in the root. As mentioned in my previous post, the kindle has to be rooted(jailbreak) to access the apps that we develop. The jailbreak basically installs a developer's certificate in the device so we can access the root and perform any operation. 

Once the code is generated, we need to sign the application with the developer keys, change the format of the resulting jar file to kindle content and transfer it to the Documents folder in the root. Thus the interactive kindlet is ready for use. Another method is to install the usb-networking(after the jail-break) on the kindle and ssh into it from the computer. This helps in executing code on the Kindle.

For the project, I'm building a java code to implement a bookshelf app that can hold books with spines on shelves rather than the front covers. Once the app is deployed on the Kindle Paperwhite, I should be able to test it with different sizes of books. 



Tuesday, February 11, 2014

Kindle Hack to display an image

The Kindle Paperwhite is one of the best e-ink readers in the market. The fact that it is light on the eye and the battery that stays on for weeks are some features that it can boast of, and which are not present in any other e-readers.

The idea of displaying books as spines on a large e-ink display, gave rise to some experiments on how to display customized images in each kindle display. First the Paperwhite had to be rooted for installing screen savers or third party apps. This can be achieved by installing the jailbreak in the root folder and updating the kindle. The words 'JAILBREAK' appears in the bottom of the screen. The jailbreak files can be found here:  http://www.mobileread.com/forums/showthread.php?t=186645

Once it is jail broken, we can install custom hacks or run any third party app on it. The project required displaying an image on the Paperwhite (a portion of an image of a digital bookshelf). The screensaver hack provided this functionality. Using photo shop a digital bookshelf image was cropped, converted to grey-scale and displayed as a screensaver. If the other portions of the image are sent to other kindles and they are all integrated, a large e-ink digital bookshelf can be visualized.

This provides just the display, but the touch feature cannot be harnessed. An interactive display is the final product that I'm aiming at and this hack does not foresee that. The next steps are figuring how to make the display interactive or developing an application for the paperwhite that resembles a bookshelf app in android or IOS.