Friday, 14 November 2014

Someone who can't see 3D images uses an Oculus Rift for the first time.

   Last night, at Oxford Hackspace, I had my first try at an Oculus Rift VR headset. It was running one of the Rift demos, an office desk with a lamp and a playing card castle on it. Nothing unusual there, you might say. I'm guessing first Oculus experiences aren't much to write home about these days.
    I am maybe not in Oculus's sights though as a customer, because as I've written here before I was born with a strabismus. I have perfect vision in both eyes, but my left eye looks somewhere around twenty degrees to the left and I can switch my main vision from eye to eye. This means I can see over my left shoulder, keep an eye on the mirror without taking an eye off the road while driving a right hand drive car, and move my left eye independently of my right as a party trick.
    It also means I can't see in 3D in the same way as someone born with both eyes on the same heading. In the few months following my birth when my brain was configuring itself for the world around it, I never acquired the capacity for seeing objects as three-dimensional by combining images from left and right eyes because my eyes didn't deliver images close enough to each other. This doesn't mean I live in a flat two-dimensional world, it simply means I don't process 3D information in the same way as other people. To use an analogy of a modern computer system, I do my 3D processing in software rather than hardware. My brain developed to interpolate 3-dimensional space from a single 2-dimensional image and sometimes by the effect of my movement rather than by comparing two such images from different angles. I live in a 3D world, but sometimes - as for instance when trying to be a batsman in a school cricket team - things happen a little too fast for my 3D processing to follow.
    All of this means that 3D effects designed for people without a strabismus - stereograms, autostereograms, and 3D movies - don't work for me. I will never be able to see an autostereogram, and a 3D movie is for me a 2D movie in which I disregard what's being sent to my left eye. Fine by me, I'm happier to pay less for a 2D showing anyway.
    So I didn't expect much from the Oculus. And yes, once looking into it the feeling was of having a couple of normal 2D screens in front of me. Not too different from my day-to-day workstation, except with full-field vision rather than a pair of LCD monitors.
    The sight of assorted geeks queuing up to flail blindly about a crowded hackspace wearing a headset is mildly amusing. In my case trying to keep my movements to a minimum I started to look around. Looking down, the desk and the lamp were just a 2D picture of a desk surface and a lamp. Switch from eye to eye, nothing changes.
    It was a mild surprise when I moved my head to the left and the card castle came into view. It was a picture of a card castle on a monitor, then suddenly it was a 3D card castle. Swing back to the lamp, and it's a picture of a lamp. Back to the card castle, and it's a 3D object. I was only using my right eye, but I could see inside it as I knelt down.
   So I had one 3D object in otherwise 2D space. Not really Better Than Life, but far more than I expected. What's happening here? In the real world, I interpolate 3D even when I'm not moving because I know something about the environment. I know a teapot in front of me is a 3D object because I have a huge amount of real-world lighting and other visual information. I can reach out and touch it. That knowledge means that when I reach out to take hold of it I know not only roughly where it is, but what size it is so I can grasp its handle with a good expectation of the dimensions my hand will have to close over. If I move around an object the amount of information I have about it increases, and so does my ability to see it in 3D.
    I think that there is an information threshold for me to see something in 3D. A 2D image on a screen or a page does not have enough information from its lighting or how its aspect changes for me to see it as containing 3D objects. I think the lamp and the desk did not pass this information threshold while the card castle did. It had enough complexity for it to provide my brain with the information it needed to cross the threshold as my motion caused the Oculus image to change.
    This opens up the interesting prospect of people with a lifelong strabismus having an ability not shared with most others: that of seeing a 3D image from a single 2D source when that source is coupled with motion sensing. It would be extremely interesting to see if a 3D-rendered-as-2D FPS game could become 3D-immersive for me if it were displayed on an Oculus with its motion sensor controlling in-game movement.
    I am guessing I only have this ability because my strabismus is life-long. I gained it because my brain developed with it, I am therefore guessing someone who grew up with stereoscopic vision but later lost an eye or gained a strabismus through injury would not see a 2D image as 3D in an Oculus headset. I'd be interested to hear whether or not that was the case.
    Some people have a big problem with strabismuses. Parents subject their children to surgery without their consent to have them "corrected". Says more about their insecurities and the desire for "perfect" offspring than it does about the effect of a strabismus. Mine has mostly never been an issue, sometimes it's unnerved people and I'll never play cricket or baseball. I would never subject a child of mine to unnecessary cosmetic procedures, to me a strabismus is just part of who you are. Yesterday's experience added a new angle on my strabismus and for that I'm happy. I can add seeing 2D images in 3D to seeing over my shoulder in the meagre list of super-powers it's given me.

Thursday, 3 July 2014

Bow for nowt

    Last weekend, I made a bow. Not because I've had a hankering for one, but because I spotted the perfect material and had to give it a go.

    My friend Rebecca was replacing her bed. The old one had a lot of very springy plywood slats, far too good to let go to the tip. So I detached them, bound them up with tape, and brought them back home on the back of my bike.

They're too wide to make a bow on their own, the ends of a bow need to be considerably less stiff than the centre where you hold it. And they weren't long enough to make a bow on their own, I'd have to bolt two of them together.

    So I cut two of them on a taper, leaving a section of a few inches intact where they'd be bolted together. I then drilled three holes for the bolts, and applied a layer of No More Nails glue to the joining surfaces before doing up the bolts. This left me with a long and springy bow, but no means to attach a bowstring to it. Out with the saw again to cut a couple of notches at each end. My bowstring - a knotted piece of the orange baler twine that is ubiquitous on farms - simply hooked over the end of the bow into the notches.
Is it a good bow? Not being an archer I have no idea. But It takes the length of my draw without damage, and it feels as though I'm putting quite an effort into it. And it shoots bamboo canes down the lawn rather well. Next up, a pack of cheap arrows from Amazon, I'm not hard-core enough to do my own fletching.

Wednesday, 12 March 2014

Small computer, big data

    This post comes as one of the longest running scripts I've ever created has just finished its work. In the last week of January I set my Raspberry Pi to the task of processing 5 years of news stories into a 20Gb tree of JSON files, and here in the second week of March it's completed the task.
    Given that a PC has done the same job in a couple of days the first question anyone would ask is simply this: Why?
    My Pi runs all day every day, 24/7. It collects the news stories from RSS feeds and stores them in a MySQL database. It uses somewhere under 2 watts, and it will do this no matter what I ask it to do because it's plugged in all the time. I can touch its processor with my finger, it's not hot enough to hurt me. My laptop by comparison with its multi-core Intel processor, board full of support chips, and SATA hard disk, uses somewhere under a hundred watts. I can feel the hot air as its fan struggles to shift the heat from the heatsink. I wouldn't like to hold my finger on its processor, assuming I could get past its heat pipe.
    Thus since I'm in no hurry for the data processing it will use a lot less power and it makes more sense for me to run the script on the Pi. This isn't an exercise in using a Pi for the sake of it, instead the Pi was the most appropriate machine for the task.
    So having run a mammoth script on a tiny computer for a couple of months, how did I do it and what did I learn?
    The first thing I'd like to say is that I'm newly impressed with the robustness of Linux. I've run Linux web servers since the 1990s but I've never hammered any of my Linux boxes in quite this way. Despite stealing most of the Pi's memory and processor power with my script it kept on with its everyday tasks, fetching news stories and storing them as always. I could use its web server - a little slowly it's true -, I could use its Samba share and I could keep an eye on its MySQL server. Being impressed with this might seem odd, but I'm more used to hammering a Windows laptop in this way. I know from experience the Windows box has not been so forgiving running earlier iterations of the same script.
    If anybody else fancies hammering their Pi with a couple of months of big data, here's how I did it. The script itself was written in PHP and called from a shell within an instance of screen. This way I could connect and disconnect at will via ssh without stopping the script running. The data came from the MySQL server and was processed to a 64Gb USB Flash disk. The Flash is formatted as ext4 without journaling, this was judged to be the best combination of speed and size efficiency. An early test with a different FAT formatted drive provided a vivid demonstration of filesystem efficiency as the FAT ended up using 80% of the space after only a short period of processing.
    The bottleneck turned out to be the Flash drive, a Lexar JumpDrive. Reading and writing seems to happen in bursts, the script would run quickly for about 30s and then very slowly for the next 30s purely due to disk i/o. In future I might try the same task with USB-to-SATA hard disk, though I'd lose my power advantage.
    So would I do the same again, and how might I change my approach? I think the Pi was a success in terms of reliable unattended operation and in terms of low power usage on a machine I'd have had running anyway. But in terms of data processing efficiency it could have been a lot better. A faster disk and a faster computer - perhaps something with the Pi's power advantage but a bit more processor grunt such as the CubieBoard - would have delivered the goods more quickly for not a huge extra investment. And the operating system though reliable could probably have been improved. I used a stock Raspbian, albeit with the memory allocation for graphics reduced as low as it would go. Perhaps if I'd built an Arch image with a minimum of dross I would have seen a performance increase.
    I used a Raspberry Pi for this job because it was convenient to do so, it uses very little power and I had one that would have been powered up anyway throughout the period the script was running. The Raspberry Pi performed as well as I expected, but I can not conclude anything other than that it is not the ideal computer for this particular job. It is sometimes tempting when you are an enthusiast for a particular platform to see it as ideal for all applications, well in this case that would be folly.
    The Pi will continue to crunch the data it collects, though on a day-to-day basis as part of the collection process. In that it'll be much more suited to the task, as a cron job running in the middle of the night the extra work of a day's keyword crunching won't be noticed. And there's the value in this exercise, something that used to require a PC, a while of my time and a little bit of code has been turned into an automated process running on a £25 computer using negligible power. I think I call that a result, don't you?

Friday, 24 January 2014

Can you run a small business with the Raspberry Pi?

    There are three Raspberry Pi computers scattered around our flat. A 512k Model B is an application server running my keyword analysis system 24/7, my original 256Mb Model B serves as a Raspbmc set-top-box, and a 256Mb Model A serves as a general purpose hardware and software hacking platform with an attached camera.
    I am a demanding user of the first of those three, the keyword analysis system involves gigabytes of data and processor-hungry scripts. It's not the fastest machine on the block by any means, but after 18 months or so of continuous Raspberry Pi use for this application I am very impressed with how little intervention it has required. After most of a career developing similar coding and database tasks using office Windows server machines I find myself appreciating the Pi for another reason than its low cost and low power: its reliability in both software and hardware terms.
    If you run any kind of business you do not view your computing needs as a home user might, in terms of hardware cost. Instead you price IT as an ongoing investment over the lifetime of the kit, in which the cost of support, licencing and upkeep may significantly outweigh the purchase price of a computer. Looking at my experience with the Pi as an application server I can't help wondering whether its reliability and stability might make it a surprisingly good fit in a business environment, for at least a small business if not in some cases a larger one.
    So what does a small business need from its IT systems? Every business is different of course, but if you were equipping a generic office network for the first time you might reasonably expect to have the following components:
  • Desktop computers
  • A file server
  • Some means of sharing a printer
  • An email server
  • A firewall and internet connection
  • Network infrastructure - let's go with wired Ethernet here and not start talking about Pi-based wireless hotspots
   As a thought exercise it is worth considering how each component might be addressed using a Raspberry Pi, and what if any benefit that choice might bring.
    Desktop computers: One of the first things most people will do with their Raspberry Pi is write a copy of Raspbian to an SD card and type "startx" at the command prompt once they've booted it and logged in. So it's beyond doubt that given a keyboard, mouse, and monitor the Pi is a desktop computer. But how would it perform in a business environment?
    Software's no problem. Raspbian benefits from a huge library of Linux packages. There's no need to fork out to Microsoft for an Office licence when you can run LibreOffice, for example. But I know if I was using my Pi for office work I'd find myself wishing it was a lot faster. I seem to remember an early description of a Pi as being like a Pentium II with a very fast graphics card, but without the ability to make use of its GPU capabilities the Pi's slow speed Achilles heel is only to obvious. Like many Pi users I look forward to receiving stable OS builds featuring the Wayland support we were shown a preview of last year.
    Benefits of a Raspberry Pi business desktop? Low initial cost, low maintenance cost - simply replace defective hardware with a new one for £25 - no software licence fees, low power consumption.
    Disadvantages of a Raspberry Pi business desktop? It may be the fastest desktop you can buy for £25, but undeniably it's not the fastest desktop you'll ever use
    A file server: This is something the Raspberry Pi can do very well. A headless Linux box has no worries about graphics speed so is only held back as a file server by the speed of its network card and disk drive. Plug an external USB drive into a Pi and it's true you don't have an enterprise-class server, but it will still offer perfectly adequate performance for a small office network. This guide to setting up a SAMBA file server uses Arch Linux, but as my keyword tool server proves every time I pick up data from its share with my Windows laptop the same setup works just as well with Raspbian.
    Benefits of a Raspberry Pi file server? Extremely low cost, reliable hardware, low power consumption
    Disadvantages of a Raspberry Pi file server? Some command line admin is required to set it up, especially if your needs extend beyond simple open-to-all file shares.
    Printer sharing: Nowadays you don't have to pay much money for a printer that can already connect to a network, and it probably makes the most sense to do that if you can. After all in a business network the simplest method of getting what you need is more important than the most technically interesting. But this is a piece about using the Raspberry Pi, and a Pi can make a very good network printer sharing device. So here's a tutorial about setting up CUPS on a Pi and sharing it on a network.
    Benefits of a Raspberry Pi print server? Flexibility to print to whatever device - or even software - that you want to set up.
    Disadvantages of a Raspberry Pi print server? Requires command line admin to set up, more complex than using a network printer in the first place.
    Email: Again from a business perspective does it make sense to use a Raspberry Pi as an email server when you can buy any one of a multitude of cloud hosted email products for your organisation? If it were me I would outsource my email every time and gladly pay for it, but for those who really need their email in house here's a tutorial describing a Raspberry Pi email server.
    Benefits of a Raspberry Pi mail server? Reliability, low power consumption, and complete control of your own email.
    Disadvantages of a Raspberry Pi mail server? Significant admin skills required to set up and run.
    Firewall: Here a Pi can undeniably do an extremely good job. Installing OpenWRT on a Raspberry Pi turns it into a very effective firewall. But yet again this is a feature offered at an almost commodity level by almost all domestic and small business routers. As with printer sharing, in business it pays to go for the easiest way to get what you need.
    Benefits of a Raspberry Pi firewall? Huge flexibility that may not be offered by an off-the-shelf router. Any protocol you want to run through it can be set up.
    Disadvantages of a Raspberry Pi firewall? Significantly more complex than an off-the-shelf router firewall, requires admin skills to set up.
    So there's a small business network with Raspberry Pi desktop machines and a Raspberry Pi file server, and all for Raspberry Pi prices. Network printing is probably better built into the printer, the firewall is probably best left to a commercial router, and email is a lot less hassle in the cloud. All that's missing from most business requirements is a business-level portable Raspberry Pi, maybe somebody's working on a professional laptop enclosure as I write this.
    The question is, would I have run my business on a network like this? Would I drop my nice modern laptop with dual boot Windows and Ubuntu to develop on a machine with a lot less speed? Probably not. But if my line of work didn't rely on raw computing power and needed instead some reliable document processing would I consider this as an alternative to a heap of Dells at several hundred quid each, a hefty Windows Server licence bill, and an ongoing relationship with an IT support company?
    I think I'd be silly not to give it a second look, don't you?