Skip to content

Touch-to-pay: the wearable killer app

October 19, 2014

My wallet is perhaps a little behind the times. My debit cards do not have touch-to-pay, I have a credit card with that feature, but it got rejected a couple of times and I honestly didn’t investigate why, I simply lost faith in using that method to pay.

Enter – Barclays bPay band.

I’m not sure were I heard of this now, but I did and I signed up. Barclays will send you one for free.

What is it?
Well, I describe it as sort of like an Oyster card, in so far as you manage it online, and use whatever card you like to send it money and configure ‘auto-top up’ when it drops below certain thresholds. Unlike Oyster you can use it anywhere that tap-to-pay is accepted, not just on the london underground etc. (it can be used there as well, so it is a complete replacement for oyster in that sense)

Also unlike oyster, and indeed unlike any touch-to-pay debit card. The ‘card’ here is very small, less than 1/4 the size of a debit card, and comes in a ‘band’ for you to wear on your wrist.
The band is just rubber, the magic is a card which can easily be extracted…more on that later.

For those unaware – touch-to-pay is a system that lets you pay for transactions of 20 pounds or less. So tube fares, coffee, lunch etc.

The result of this is that in places that accept touch-to-pay you can simply reach your arm out and tap the band to the reader and you’re done. This is not just faster and easier than debit cards, it is faster and easier than cash. I don’t have to get my wallet out, fumble with cards/cash change receipts and whatever I’m buying. I can just use my hands to take the goods. (I mostly decline receipts if I can for these kinds of low value purchases)

I’m aware that Apple is launching its Apple Watch, and one of the features of this is the ability to use it as the thing that you touch to reader when paying via their equivalent system. In this I think they’ve also realised this is one of the killer features that can be put on your wrist. Though personally I think the bPay band is better since it is focussed on just that, and was free…

The bPay band has 2 major flaws.

1) As yet not everywhere accepts touch-to-pay. It is very common in London, but in my home town I’ve only found 2 retailers that accept it. And of course if you can’t rely on it being taken then it diminishes the value a little. Hopefully this will become less of a problem over time.

2) the rubber band it comes in is cheap and uncomfortable.

For the first week that I had it, I just kept it in my pocket, and looped it over my fingers when I was preparing to pay. At this point it was really no different to a touch-to-pay card etc. There was the step of ‘preparing’ that I needed to take, just because it was not something I would just wear.

Over the weekend I fixed that issue.
I ordered a leather ‘cuff’ from Etsy, it is just a simple thick leather strap with some poppers so you can secure it around your wrist. Its the sort of thing that I’m fairly happy to just wear. it is comfortable and doesn’t look particularly out of place. I’m sure it won’t be to everyone’s taste, but the basic principle of customisation can be applied to anything that you are happy to wear on your wrist.

image

I then hacked a flap in the back of the leather strap, I made a slightly messy job of it. I bought two so I may try a different approach on the other.

image

Having cut a flap, I glued the edges back down and left myself with a small pocket in the edge of the strap that just snugly fits the card from the bPay Band.

image

Now I can wear this as a matter of course, and not really think about it until I need to pay for something.

My first use was in a W.H.Smiths, which is one of the two places in my town that accept touch-to-pay, the cashier was taken by surprise when I just pressed my wrist against the reader and paid. It was the first time she’d seen anything like it. I suspect it will not be the last, as I feel the convenience of being able to pay this way will catch on.

So I had to remove the saftey guard…

September 27, 2014

As someone that spends a lot of time in my workshop, using tools and making things, these words echo in my memory.
“Well I had to remove the safety guard to get a better angle…”
Maybe my memory is unreliable, but that is how I remember my father explaining how he had caught his thumb with an angle grinder, and later a router.
I believe to this day he has some loss of feeling in that thumb, but he is otherwise intact. That he very calmly stated ‘I think you’re going to need to drive me to the hospital’ to my mum is another prominent feature of this memory.

It has served me well as a long term reminder that tools are dangerous, and before I turn them on I take a moment to think about where my hands will be, where I’ll be moving and generally considering the dangers that may exist. Sometimes I still wind up cursing myself for not thinking things through a little more, typically ‘when this force is applied what is the most likely path things will take’ is a question I sometimes forget to answer, but a hammer to the thumb will quickly remind you that forces such as those associated with a swinging hammer will not necessarily all get neatly imparted onto your target, sometimes it’s considerably easier to bounce to one side and deposit the remaining force onto a soft digit.
Another question I occasionally have forgotten to ask ‘when this spinning cutter hits this material, where will the shavings/dust/sparks want to fly? and is it at my face?’ at times like this I’m glad to be wearing my full face mask, but it’s still an unwelcome shock to have a shower of sparks flying towards your face.

Remember kids, a full face mask isn’t just an awesome fashion statement that shows you mean business, it is also a great way to compensate for failing to think everything through clearly enough.

So it is with all these thoughts in mind that I have embarked on a project to turn my circular saw into a table saw. Once again inspired by Matthias Wandel or woodgears, I previously attempted to copy his idea for a wooden latch for my bathroom.

I have previously made this same conversion in a rather quick and dirty way, I dubbed the result ‘the table saw of death’ just to serve as additional reminder that this was easily the most dangerous tool in the workshop. I held the guard open with the table top, and the table itself was very short, being constructed of just what scraps I had available at the time. It served well for a few specific jobs that were just not plausible in other ways. However it took time to set up, and adjust that made it not terribly efficient. And of course with the trigger locked in the on position, once plugged in it was running until unplugged or switched off at the wall. Before every use I very very carefully thought through the whole cut, and where I would need to move and put my feet etc. Ultimately I disassembled it, always thinking I’d maybe make a nicer job of the idea one day.

Seeing Matthias’ table saw conversion I felt it was time to try again and generally try to steal/learn from how others have done similar. I now have the space to support a much larger table and the patience to try and make a nice, safe, job of it.

That said, this is a project that essentially starts with ‘take off the blade guard because it will just get in the way….’ And whilst doing so I couldn’t help but think of my dad. One of my key goals in the construction is to try to replicate as many of the safety features of a proper table saw as I can.

I know, I could just buy a proper table saw. I know I will never ever get the kind of results from this that I could get from a proper table saw, and I know that by the time I’m done spending money on materials and time fiddling it might even have been more practical to buy a table saw. But as with so many things I do or make, it’s not really about having a table saw, I have no particular pressing need for one. It’s about *making* a table saw. And whilst my CNC router is dismantled and waiting for me to figure out a whole new build, this will keep me entertained.

Here are a couple of early pics where I’m attaching the plywood from which the rest of the structure will build.
image

image

Matthias has had time to consider what he would do differently, and one of those was screw one of the mounts directly to the casing to get a better alignment and secure holding. So I did exactly that and I’ll see how that goes.

The Maker’s Den – Converting a box room into a home office/electronics workbench

August 29, 2014

image

The major works of our new house are still waiting for things like planning permission, and quotes from various suppliers. Oddly one issue seems to be how busy they are, since one company couldn’t even come give us a quote since they are booked solid for the next 4 months!

In anycase this leaves me still able to focus on the smaller jobs, and next on the list is the box room. Having turned one of our rooms into a study for my wife, the box room is mine. You might suggest that it is a little extravagant to have a study each, but my wife’s study is a very personal space for her, and whilst she lets me use it to work from home, she does so grudgingly ;-) Also I have a couple of specific requirements which don’t really fit well with sharing the study.

In our previous place I had a very small ‘workbench’ setup across two bed side cabinets in the corner of our guest bedroom. literally just a sheet of mdf painted white and balanced with just enough room to get a chair at it. It was just enough to prop up an oscilloscope, a soldering iron, and some boxes of components etc.
This time I have a whole box room to make my own (in addition to the garage, but that is another matter entirely) and for the sake of differentiation we’re calling it the ‘studio’. Mostly in reference to the fact that if I work from home it needs to be a good environment to take a video call from.
image

Most of the work was very similar to the study. That is, stripping wallpaper, removing the radiator to decorate behind it, several coats of white paint. a feature wall, mine is a deep purple, new laminate floor to replace the old carpet. new skirting etc. I also had to add a set of blinds as this room didn’t already have them.

The main point that things get different is the workbench. For the study we already had a desk which has done good service. For my studio I had to decide what I wanted. I looked at desk options, but ultimately decided that to serve as desk for home working and workstation for electronics etc, I would have a bench rather than a desk. Basically with no fixed feet/cupboard beneath it, I can sit the chair at any point along its length.

This decision meant that I could splash out a little on a nice solid walnut worktop, but not spend crazy amounts. The worktop is just mounted on some batons that run along the edges, and a single support near the front, this is what the support frame looks like.
image

Pretty simple construction, screwed to the walls at regular intervals, arguably the 2.2 metre span could use more support in the front centre than is provided by the basic frame, but we’ll see how it responds to use. mostly the heavy things will be near the corners/back, with only keyboard/trackball nearer the front.

Here it is with the worktop resting in place to check the fit
image

One feature is the provision of power onto the desk top without cluttering wires everywhere. For this I got myself a hole cutter as large as I could find and I cut a hole in each back corner of the workbench. Just below that point I mounted multi-way adapters. I used a hole cutter so that I could potentially use the plug to mostly refill the hole, or generally hold the wired in place.
image

Using a hole cutter on a workbench is pretty tricky. You really need to get the plunge very straight and perpendicular to the surface, and slight deviation means that the sides of the hole cutter start to rub against the sides of the hole they’re cutting. This quickly adds up to enough friction to stall the whole thing. It took me a while and several adjustments to get the cutter to plunge all the way through my worktop.

I found a decent deal on 3.5 metres of work top, which was over a metre more than I needed. So I was able to use the remainder to make a set of three shelves above the bench. This is one of those places that a bandsaw really helps. though I guess a table saw would do the job also. Stripping >1m lengths of 38mm thick walnut is not something I’d like to try with a handsaw.

Results
Here are pictures of the finished room. I’m really very happy with how it has turned out.

image

image

The walnut is finished with a few coats of Danish oil, this was pretty easy to apply, however I did have some trouble where I’d been moving the workbench around with hot sweaty hands, I should have used gloves or cloth to protect the bare wood, as it made it harder to get the oil to absorb evenly. I took better care when handling the shelves and it was much easier.

Now I just need to unpack my random collection of stuff into the room. I’m going to have to come up with some organisation solutions to try to keep things from getting very messy. I’m not a tidy person by nature.

Custom shelving

August 16, 2014

Last time I wrote about redecorating the study in our new house. I sort of claimed that this was finished at the point that we moved the desk in and it could function as a study. However, the truth of course is that a study is incomplete until the copious books can be unpacked onto shelves. In our rented house we had a few standalone bookshelves, but what is the point of owning a house if you don’t put up wall hung shelves?

Obviously it is fairly easy to buy shelf brackets and shelves and relative quick to install. However this needed to be more than just some shelves in stock sizes. My wife wanted a shelf spanning the entire back wall and coming around partially along another wall in a L shape. This pushes us into the real of custom made shelves specifically to fit an exact set of measurements.

The first decision was to go with a rail and bracket system. Last time I did wall hung shelves, I went with floor to ceiling, narrow shelves for dvds and small books, and I used individual brackets each mounted directly to the wall. 3 holes per bracket, I actually lost count of how many brackets, it was a lot. I vowed then that next time I’d just go with rails which can support brackets along their height.

So here are the rails installed and some brackets set in place

image

That part is fairly easy. we chose how far off the ground we wanted the lowest shelf, in this case dictated by the height of someone sitting on our futon which will eventually go in here (once the living room is redecorated) and then the length of each rail was dictated by how close to the ceiling we might want a top shelf.
Then you need to figure out the spacing, this is dictated by the material you intend to use for a shelf, different materials have different loading capacities and support requirements. If the supports are too far apart for the material you chose then they will sag, maybe not immediately, but with time.
Choice of materials is varied, last time I did this I used mdf, this time I decided to try something different and went with plywood. 18mm plywood has a maximum span between supports of about 60cm. I didn’t want to hit the maximum and I also wanted to have things evenly spaced across the wall.
Another factor was the L shape of the shelf, I wanted to have a support underneath the join point in the corner. My wife wanted the shelves to be 30cm deep, so I wanted a bracket around 20cm from the side wall. To make things look neat I put another at the same spacing from the opposite wall, then just divided the space between those two points into an even spacing that was less than 60cm.

The spacing on the other length actually had a slightly different considerations, where the end wall is an external brick wall, the side wall is internal and only a partition wall. For maximum strength I wanted to make sure I screwed into the studs, so I let that dictate the position of the rails. unsurprisingly the studs where similarly spaced to my requirements anyway, a little closer together.
With all that decided, it was time to measure the first rail into place, use a spirit level to get it vertical, and get it screwed in place. Once the first was up, every subsequent rail was measured relative to the previous one, getting the equivalent height using a spirit level from the base of the rail next to it.
This is important. You could mark out every rail based on the same height from the floor at each position, and achieve the same thing…right? well no, there is a very good chance the floor is not actually level over the span of the room. I could also have gone around marking out every position using my spirit level to match one marking to the next. However the thing about drilling into walls, is that things don’t always go absolutely perfectly where they should, maybe the drill wanders around a particularly hard bit, maybe you just don’t hold everything perfectly. In any case the actually fitted rail might be slightly off from the marked height, by measuring the next rail based on the actually fitted rail next to it, you constantly adapt for any slight variation. This does mean that you could wind up a little off over the span of the shelves, but never by very much in any given neighbouring pair, so everything should look ok in the end.

Hanging the rails is the easy part really, as now I needed to make shelves. My brother pointed out that it would be much much faster to just buy ready made shelves, but as I mentioned that is not going to fit exactly my space requirements. So I bought myself a few 2400×1200 sheets of 18mm plywood, and got cutting. My bandsaw is awesome, and 30cm is actually slightly deeper than it is really supposed to cut, however there is just enough room to setup a 30cm wide cut. So with help from my wife to position the sheets and support them through the cut, we quickly stripped out all the lengths we needed.
That was pretty straight forward, next though I had to use my router to cut away a section of overlap for where two shelves join at the L. Whilst this is not difficult, it is a little time consuming to set up a rail to work against to keep me routing in the correct area. By cutting this section of overlap, I could support that end of both shelf lengths on the same bracket.
Once that was done I then had to setup the shelves in their L shape in the garage so that I could round over the shelf edge and in particular around the inside corner where the shelves meet. This was not too bad, if a little precariously setup on anything I could grab to support the shelves. When repeated 4 time for each L shelf pair this all took a couple of days to work through. Though obviously I wasn’t exactly going at it full time.
image

image

At this point things look pretty good, all the shelves fit in place, and could almost be finished. If you didn’t mind the bare plywood look, you could load up the shelves and call it a day.
However, in my case the shelves were to be painted satinwood white. This means, at least one coat of primer, and at least one coat of satinwood. I got some nice stuff so that is all that was required, however it could easily have required multiple coats of each. Painting the shelves took perhaps 5-10 minutes per side per shelf per coat. The elapsed time of this effort is much higher than the spent time. You can only do one side of a shelf at once, allowing that coat to dry enough before you turn the shelf over to paint the other side. In the case of the satinwood coat, it has a drying time of 16 hours! With limited space to lay out shelves for painting I couldn’t do them all at once either. All in all a week or so of evenings and a couple of weekends was required to make my way through all the painting.
In addition I had issues with the supposedly furniture grade plywood from Wickes. Namely small voids in some of the layers. Good quality plywood is not supposed to have any. But this did, so along the cut edges there were little gaps and holes. Not too many, but enough that I needed to use some wood filler to fill them in. Sand it all down and paint over.
image

image

image

And finally they are done. Making your own shelves is a lot of work, it takes a long time. It is worth it. As with all such endeavours I get no small satisfaction from the knowledge that I built something essentially from scratch. That I know every mm of it, for better or worse, from my own attempt to make it as well as I can. Plus of course it is exactly to specification. My wife got to pick exactly how deep she wanted the shelves, precisely where on the wall they should finish, what kind of radius on the end corner, how chamfered to make the edges, how high and how far apart.

And finally, the study looks the part with full shelves :-)
image

Redecorating the study

August 2, 2014

Having recently moved, I’m back to the wonderful world of having lots of DIY to be getting on with. So much that is is hard to chose where to start!
Ultimately our decision was to get my wife’s study sorted first. She works from home one day per week, so it is helpful to have it finished for her. Also it was one of the relatively unchallenging rooms, no major works, wall removals etc. Just a medium sized room to be completely redecorated.

Foolishly I forgot to take pictures of the room before I started, it had wallpaper with a repeating pattern of dots. a thick red carpet, some old scrapy shelves. that needed to be removed, and a fairly dated and yellowing light fitting.

We decided to strip the wallpaper off,  which sadly was hung behind the radiator, so I had to take the radiator off also. That wasn’t so bad, except that there was a thermostatic valve on it which requires you to swap it out for a shut-off cap to be sure the valve is shut. These caps are provided with the thermostatic valve kits, however of course this is an old house and I did not fit the valve, so I did not have the cap. I did some searching to see if I could buy one on its own, but ultimately bought a cheap thermostatic valve kit just to get the shut off cap it came with.

Stripping wallpaper is a fairly horrible job. Even if it goes smoothly it is messy. but this room made me work for practically every inch of paper coming off. One wall was fairly amenable ot just peeling off, but the rest required me to scrub with a wire brush, and soak with a wall paper stripping solution, then scrape off in ribbons. It took me about 4 days to completely strip the room.
image

That was the hardest part, really, lifting the carpet was trivial enough, though it had been glued around the edges. My wife wanted laminate flooring down, so I made the decision to rip off the skirting board and replace it on top of the flooring. The exisitng skirting had been nailed to the walls with long masonry nails. This made life a little difficult getting it off, particularly behind the radiator pipes. Here I used my brand new bosh oscillating multi-tool to easily slice through the skirting just behind the pipes and allow me to pry it off in sections.
image

We gave the bare plaster 1 very diluted base coat, and about 3 other coats of basic white emulsion, followed by 2 coats of an extra reflective white paint top coat, except for the feature wall, which is a bold orange. It looks really good in the otherwise white room.
image

I replaced the light fitting with something a little more modern, always an interesting job, particularly when the instructions say ‘you will need an assistant’… pah! you just need something that can support the light fitting near the ceiling whilst you are wiring things in. I used one of the (plentiful) cardboard boxes in our house and balanced that on the step ladder to support the fitting. It worked fine.

The laminate floor went down pretty fast, it took most of a Sunday, but I got the whole floor down, and the new skirting fitted. I decided to use pre-finished skirting which really does save a lot of time and hasstle. That last day was pretty great, since the room goes from looking like a shell, to looking pretty finished very quickly. We moved the desk back in and I called that essentially ‘done’ for the decorating.
image

image

However, I know it isn’t really done until the shelving is up, and my wife wanted to go with wall hung shelves rather than the free-standing units she had when we were renting. So that work has just begin, brackets are up, but now I need to actually make the shelves to fit…

All in all its been a lot of hard work, but in truth I love it. It’s great to be back in a house which I own which I can improve as I see fit and change to meet our exact needs.

Total cost so far…~700GBP though in that I’m including some costs which have leftovers that will go into the next room (my study)

New House – new workshop

July 7, 2014

I’ve been a little quiet on the blog for a little while, because we’ve been in the process of moving house. Lots of packing and worrying about logistics etc.
Of course the biggest question mark was the moving of the workshop!

image

View from our new bedroom

Well now we’re finally in. The new house is amazing, and we’ve had a super sunny first week to really enjoy the new area we’re living in. One of the attractions of the house is that actually it needs redecorating throughout, so we still have boxes everywhere and a daunting task ahead to figure out what to do first and what exactly it is we want to do in every room.

The process of moving was, as always, massively frustrating and fraught with stress. Every time I go through it I wind up feeling two things strongly.
1) I’m never going to move again.
2) The whole industry of estate agents and solicitors is ripe to be completely revolutionised and swept away with maybe one big player intent to make it a modern process.

The first is fairly simple, and I really do not have any intention of moving again at this point. This house is perfect, and it was good enough for the previous owners to live in for 30 years, I consider that a challenge and am aiming to beat their high score.

The second always fades as I realise that I’m not planning on moving again. which I guess is what everyone does which is why it is still a horrific experience to try buying a house and why solicitors and estate agents get to operate as if the internet age essentially hasn’t happened.
There is really no excuse as to why initial introduction with solicitor doesn’t involve agreeing on a secure online form of communication which subsequently allows you to authorise all documents electronically. no need to post bits of dead tree around with ‘wet ink’ on them. Right there you could wipe a few weeks off the process.

If you are in any way inclined in the space of solicitors/conveyancing I really think the market is wide open for you to totally dominate the house moving market. I wish someone would, but that someone will not be me.

I am now just really happy to know I no longer have to deal with estate agents, with the small exception of recovering what I can of my deposit on the rental we moved out of. I sold off the house I was renting a while ago, but now I live in my own house again I really feel the full force of no more random calls with urgent repairs required by my tenant, and no more having to go through a lazy, inefficient estate agency to get anything fixed in my own property.

Just as moving out the workshop was a big consideration, now that we’re in, a big consideration is that I am once again faced with the chance to design my workshop layout. Last time I had restrictions of not bolting anything to the walls, since I was only renting. This time I can hopefully give myself much more decent bench space. Also last time I decided to put my lathe in the middle of the space, I felt previously I’d been a little restricted having it bolted to a wall particularly trying to hollow items. The swing of the tool would clash with the wall. However I think I really just need to give it a little more space out from the wall, it doesn’t need to be in the middle taking up more space. Of course this time around I know that I want to rebuild my cnc machine, so I will have to allot space in the plan for that. And  consider if I’m going to aim for a slightly larger build for this iteration.
image

There is so much to do in the workshop that I need to remember that first there are other priorities in the house itself. There may come a point of chicken and egg, there are good reasons to get some of the rooms in the house done first, however doing them will require tools which are currently buried in boxes in the garage, so may necessitate a certain amount of workshop sorting to get at them.

So, where to start? we have walls to strip of wallpaper, carpet to rip up and replace with various flooring, bathrooms to replace, a window we’d like to turn into a door,  a kitchen to replace, a fireplace to remodel, a workshop to set up…
Any tips or tricks I should consider? pitfalls to look out for? let me know!

Pan and tilt webcam – face tracking

May 10, 2014

So last week I wrote about building a pan and tilt webcam, and at the end of that I mentioned that the next thing was to come up with some kind of software control on the pc to allow it to be easily moved around.
This is a little google auto-awesome montage of how well things went

Software – processing.org
I wound up checking out processing.org after watching a video from SVSeeker that showed them using the same to control their in-development under water ROV.

I was very impressed by how easy everything was to pull together, over the course of perhaps 3 hours I achieved everything I set out to do.
I downloaded the processing.org environment and started to play.

First thing was to alter the interaction to the arduino based on some examples of a state machine interaction to select options. so you can just send a string of numbers divided by slashes, so for instance /3/2/9/170/, is interpreted as 3rd top level option (servo control), 2nd control within servo control, (write a value), use pin 9, set value 170. This immediately made things more flexible.

Capturing video from webcam

Second job was to get the camera feed from the webcam, this was straight forward with the video library, just get a list of connected webcams as an array, not that within this is an enumeration of the various resolutions and frame rates supported by each camera. For me I gout about 40 options, 20 for the webcam on the laptop I was using, and 20 for the external webcam mounted to my pan/tilt. I did think about putting a picker in to allow dynamic selection, but to get going I just hard coded the number of the one I wanted to use.

void setup(){
    String[] cameras = Capture.list();
    if (cameras.length == 0) {
        println("There are no cameras available for capture.");
        exit();
    } else {
        println("Available cameras:");
        for (int i = 0; i < cameras.length; i++) {
            println(i + ":" +cameras[i]);
        }
        // For the moment hardcoded to the one I know I want
        cam = new Capture(this, cameras[21]);
        cam.start();
    }
}

void draw() {
    boolean faceDetect=false;
    background(0);  // background black
    if (cam.available() == true) {
        cam.read();
    }
    image(cam, 0, 0);
}

Manual control

Next job was to put some controls on the screen, I found the ControlP5 library that provided a bunch of simple controls, each one you can just add specifying the name of the control, the range of values it should control and the deafult you want it to start at. Along with simple x,y and width,height values for placing the control.
Once added controls being moved triggers events to a handler method, just look up the name of the control in the event name and act accordingly.

tilt = controlP5.addSlider("Tilt",tiltMin,tiltMax,60,10,10,10,400);
pan= controlP5.addSlider("Pan",panMin,panMax,90,50,10,400,10);

So in a jiffy I had two sliders, one for the tilt control up the left side of the screen and one for the pan across the top. a little wiring up and now I can click around the controls on the screen and move my pan and tilt. Hurrah!

void controlEvent(ControlEvent theEvent) {
    if(theEvent.isController()) {
        if(theEvent.controller().name()=="Tilt") {
            tiltValue=round(theEvent.controller().value());
            myPort.write("/3/2/9/"+tiltValue+"/");
        }
        if(theEvent.controller().name()=="Pan") {
            panValue = round(theEvent.controller().value());
            myPort.write("/3/2/10/"+panValue+"/");
        }
    }
}

At this point I had basically done what I really though I was going to do and it had taken very little time. So I started to get creative with other features I could add.

Auto Pan

First thought was that it would be cool to have an auto-pan mode where it will just sweep back and forth based on some value to set how quickly it should do so. I decided to set it as another slider which sets how many seconds between individual increments of turn, so the fastest it will turn is one increment every 1 second, and the slowest would be really slow, 1 increment every 5 minutes. To control this I added a toggle button, and another slider to set the value. I considered here using an input box to allow any number to be set, but I quite like the interaction being entirely mouse driven with no keyboard input. plus no need to validate inputs etc.

if (autopan){
    //check when last move made
    if (millis() > lastMove+(moveDelay*1000)){
        lastMove=millis();
        println("Auto-move step");
        if(autoMoveLeft){
            panValue=panValue-1;
            if (panValue160){
                panValue=160;
                autoMoveLeft=true;
            }
        }
    //this line triggers the event handler which in turn writes to the arduino
    pan.setValue(panValue);
    }
}

To make this work I just keep track of when I last moved, and every time through the draw loop check the amount of time passed since that last movement, once I go over the set value I move again and set that as the last movement point. There is a little extra complexity which is which direction you’re travelling. I decided to keep it simple, always start out panning left, then when you get to the max value, flip a direction boolean and start heading right, until you hit the min value, flip again and repeat forever.

This worked nicely and immediately led to the obvious next option… take time lapse images. This is another set of controls very similar to the auto-pan. I want a value to set how often to take a picture, and a toggle to switch that mode on and off.

Timelapse

From an implementation point of view it turns out to be very simple to get a frame of the video as an image. There is even a mode that will auto-increment filenames for you, however I found it was using some internal frame counter such that whilst the filenames did increment in order, they were not sequential numbers. This caused problems for the app I downloaded to stitch images together into a little video so I decided to just keep track of my own frame counter. Plus a little logic to handle creating different folders every time you switch the mode on so they don’t overwrite each other.

if (timelapse){
    if (millis() > lastCapture+captureDelay*1000){
        lastCapture=millis();
        //
        //take picture to be stitched later
        //
        saveFrame("C:\\Users\\d.would\\Videos\\timelapses\\timelapse"+timelapseCount+"\\timelapse-"+frame+".png");
        frame++;
    }
}

Again so simple that I realised I still had plenty of time to carry on and this is when I got ambitious…face tracking.

Face detection

I’ve seen this kind of thing on youtube so it is hardly novel, however it is pretty freakin’ cool so I guess it was inevitable to try it. Going in I had no idea how hard it might be handling face tracking, and O.M.G. this stuff is so easy now as to be ridiculous.

Library – opencv. this library existed and was easily available to download from within the processing.org interface. Import the library, create the object and tell it you want the face identification mode (it seems like it has a few options for doing thinigs like filtering out moving objects from an otherwise stationary scene) Then just pass it frames from your video feed. In return it passes back an array of detected face objects. Its empty if it can’t find any.
For each face in the array you basically get given the bounding box within which the face exists. So x,y of the top left corner and width,height.
By iterating through the array looking for the ‘widest’ face you get a proxy for the closest face.

if (cam.available() == true) {
    cam.read();
    opencv.loadImage(cam);
}
Rectangle[] faces = opencv.detect();
int closestFace=0;
int widestFace=0;
faceRectX=0;
faceRectY=0;
faceRectW=0;
faceRectH=0;//use width as proxy for closeness, pick the one which is widest and follow it.
for (int i = 0; i  widestFace){
        closestFace=i;
        widestFace=faces[i].width;
    }
}

if(faces.length >=closestFace+1){
    faceRectX=faces[closestFace].x;
    faceRectY=faces[closestFace].y;
    faceRectW=faces[closestFace].width;
    faceRectH=faces[closestFace].height;
}
//draw frame from webcam
image(cam, 0, 0);
//draw rectangle at co-ordinates for face
noFill();
stroke(0, 255, 0);
strokeWeight(3);
rect(faceRectX, faceRectY, faceRectW, faceRectH);

So that was impossibly straight forwards, by using those values to draw a rectangle you can visually see on the screen where it has recognised faces.
That alone is crazily cool, when you think about what must be involved in detecting faces from an image.

Face Tracking

But once I have this information turning it into tracking controls is pretty easy. Basically I want to put the face in roughly the middle of the the screen. So I figure out the middle of the bounding box of the ‘closest’ face, then determine how far off centre on the x and y planes that is.
Anything outside of about 20 pixels of centre and I send a command to the arduino to pan or tilt in the appropriate direction to shift the face closer to centre.

if (faceTracking){
    int xpos = faces[closestFace].x + (faces[closestFace].width/2);
    int ypos = faces[closestFace].y + (faces[closestFace].height/2);
    if (xpos<(width/2) -10){
        //move camera slightly left
        if (panValue(width/2)+10){
        if (panValue>panMin){
            panValue--;
        }
    }
    if (ypos<(height/2) -20){
        if (tiltValue(height/2) +20){
        if (tiltValue>tiltMin){
            tiltValue--;
        }
    }
    pan.setValue(panValue);
    tilt.setValue(tiltValue);
}

There is something pretty compelling about building a device that reacts to you in the environment, moving to follow you. This is already very cool, but what I found was that it is fairly slow to keep up, and easy to move a little too fast for it. To remedy this I needed to scale the movement reaction based on how far off centre the face is. the farther from centre, the larger the movement it sends to the arduino. Close to centre yields single steps of corrective movement. right near the edge of video and it moves the camera in larger steps. This meant that the camera could do a better job of keeping up, though it is still fairly easy to outpace it.

Optimising performance

So this is all working great, however I realised that face detection was slowing things down a lot, I knocked up a quick FPS counter and sure enough doing detection on every frame drops the frame rate to about 4 frames per second. Which is pretty terrible considering the camera is producing 30fps.
So I played around with doing face detection on different fractions of the frame rate, it turns out that actually just doing it on alternate frames is enough to make a big difference, I got right back up to 20-25fps, and the face detection handling 10-14 updates per second, which is a lot better than the 4 I was getting trying to do it every frame.

Summary

This was crazily easy. from never having used processing.org or its libraries before, to a full interactive UI with manual controls and auto-pan, timelapse and face tracking modes in about 3 hours.

Now to set it up to take some interesting long duration panning time-lapses. I’ll have to think of suitable places to set it up, possibly in the workshop whilst I’m making other things.

Follow

Get every new post delivered to your Inbox.

Join 103 other followers