Saturday, 24 November 2012

LBP for object recognition

So I finally got around to trying out my LBP-P (pixel) classifier algorithm for the task of object recognition. This is the one i've mentioned in numerous previous posts which i've applied with moderate success to the problem of object detection.

I don't have any code or numbers to publish at this time but if I haven't made a mistake it appears to work much better than histogram/block-based LBP algorithm (which is one of the algorithms implemented in OpenCV) with a similar sized descriptor on the data i'm testing. Computational cost is somewhat lower too - particularly if one can delve into some assembly language and the cpu has a vtbl (NEON) like instruction. I have still yet to incorporate scale into the calculation, but i can only assume that could improve it: if I can work out how to combine the probabilities in a meaningful way.

Given that it works at all as a detector means it has to have a pretty good false-positive rate, and so I thought it should work quite well at the recognition task too.

And as I now know how to generate ROC curves ... one day I will do this for the object detector; but that is something for another day, as today is hot, and I am lazy.

I've also been trying various other LBP code variations.

The LBP 8,1 u2 code I started with is is still clearly the best of the rest, but I found that the CS-LBP variation - centre-symmetric - usually works at least or good or even better in many cases. This is pretty significant as it's only a 4-bit code which means classifiers and/or descriptors can be 1/4 the size of the 59-code (~6 bit) LBP 8,1 u2 encoding. Rather than do 8 comparisons around a centre pixel this just does 4 comparisons against opposite pixels: n/s, ne/sw, e/w, se/nw.

For the LBP histogram algorithm I generally had no luck trying to pre-process the images - usually anything I did adversely affected the results - although that depended on the image size. The size of the image seems to have more of an impact on the LBP histogram algorithms. And surprisingly a fairly small image had the strongest result: I suspect that scale is doing some of the pre-processing for me in this case. Unless i'm missing something, for LBP based algorithms I never understood why anyone would perform any intensity based normalisation (histogram equalisation and so on) as I don't see how they could affect the results as the LBP code is a local gradient operator and scaling couldn't affect that (that's kind of the whole point of using them).

Although i'm now quite a fan of the LBP, I should also get a chance to try a similar set of algorithms using wavelets: it will be interesting to see how they perform, and even if they aren't as good they might be useful if the individual results aren't correlated too closely. Although given they also perform localised directional gradient measures, I suspect they will correlate. Still, they'd have to be quite a bit better to justify the increased processing required.

Update: Ahh bummer, when I did a more valid study the LBP-P classifier isn't quite as good as my first results suggested. That's a pity. I can still get a decent result, but it starts to take a lot of training and/or too much memory to get really good results.

Thursday, 15 November 2012

Community is Exclusion

I've been meaning to write something along these lines for a while. But I finally pulled my thoughts together with the help of many thousand millions of tireless, beautiful, and unique yeast cells, and am finally ready to have a crack at it.

Community blah

Community this, and community that - it seems to be the 'meme' of anything to do with any project or movement or idea these days. Do anything, start a community.

But I don't like the word, it's just a bullshit and divisive word.

On the surface, a community is all about inclusion, but in reality it is precisely the opposite: it is all and only about exclusion. And exclusion only means one thing: division and the politics thereof1.

So when people talk about the "Linux community", "Ubuntu/Fedora/etc community", the "FOSS/FLOSS/Open Sauce(tm) community", or even "Free Software Community" they are really talking about a group who identifies themselves just as much by who they don't consider fellow members as who they do.

Once you identify with a particular "community" and are able to label another's, you tend to huddle together and treat those with different labels as 'forners', to be distrusted as a direct threat to you and your homies. An analogous situation is the wearing of religious paraphernalia in an attempt to isolate yourself from your fellow human beings on purpose to provoke a reaction. Or wearing gang colours or tramp stamps.

Even within so-called "communities" there are stark divides. For example, for several years I have forced my browser to a fixed font type and size and so didn't realise Groklaw had at some point directly separated the 'haves' and the 'have nots' by deliberately de-emphasising anonymous posters from those with name accounts by using a tiny font for the former. I was utterly shocked at this insidious behaviour from a site purporting to be about freedom and legal rights.

And mailing lists and on-line forums all suffer from even worse problems: say something out of line and you are simply banished. Rather than starve the true trolls who will eventually leave (or seek medication), or simply use them for entertainment, they simply punish any and all divergent views in precisely the same way a cult would.

You're standing in it

Here's a better word: World.

The GNU/Linux World. The Free Software World. And so on.

World is an all-inclusive word that encompasses not only all of humanity, but also all other known living entities and the entirety of the system on which we depend for our fragile existence.

World is a word which recognises a whole spectrum of opinions: not merely a black or white, true or false, the simple and stupidly stark 0 or 1 result of binary state which is all a machine can cope with.

World also implies there are issues and complications which sometimes simply cannot be solved at all, let alone on internet time-frames.

World also goes beyond the bronze-age tribal nonsense we've been saddled with since then - and it's about time we evolved socially to cope as the next stage of human evolution least we perish.

There's been some recent noise about the dangers of the "cult of personality" that infests the tech world - but I think in the case of GNU/Linux the problem is more simply a plain old "cult" based on community based tribal identification (Microsoft and Apple and any other multi-national with a strong brand presence are also well in on the act - but that is on purpose and for marketing reasons). I suggest that this leads directly to a tribal "herd" mentality and ultimately the "group think" which simply silences dissenting voices rather than acknowledge the breadth of human experience.

This situation is simply not healthy - and downright embarrassing after 100 000 years of so-called human "progress".

I think it's about time to grow up out of this tribal bronze age absurdity and call it out for the archaic and worthless nonsense it is.

1. Politics goes well beyond who we do or do not vote for on polling day. As soon as you have more than one person in a room: you have politics.

Mailing lists. Or the lack of self censoring shame

I'm subscribed to a few developer mailing lists, not that I post too much anymore but I scan them occasionally. I also 'hang out' on a couple of OpenCL forums, or at least keep an eye out for something interesting going on.

Lazy kids of today

I'm a bit shocked at how little shame people have in asking obviously idiotic, lazy, indolent, somnolent, and torpid questions. I presume they are mostly students trying to get the internet to do their homework, which is bad enough to start with. But when they clearly don't have the faintest idea about basic software development, let alone advanced concepts such as parallel programming, you'd think they'd have the personal shame to get off their lazy fucking arses and try to learn a bit more on their own before begging experts for help and showing to the world just what a waste of space they are.

Being a newbie is one thing, we were all one once (although when I was a hacking newbie, I had no modem and no internet, so nobody to annoy but myself). But being a noisy, lazy, selfish, idiot is another matter entirely.

Particularly today - with such an enormous amount of quality information at our fingertips INSTANTLY. Doesn't anybody try to learn on their own? It works much more effectively than getting someone else to do the work ...

It seems that the easier it gets, the lazier people are.

Maybe it's too many single child or two-parents-working families - kids these days don't seem to even know how to eat properly with knives and forks or chew with closed mouths. Probably because they never have a sit-down meal with the old's as they're either working or out or don't care themselves. Or too many molly-coddling parents too scared to tell young Bruce or young Doreen that they aren't acting in an acceptable manner or that they fucked something up, least they hurt his or her feelings.

The arsehole brigade

Then there's the other type - someone who asks a question in such a way to imply that they're a bit lost and after some help. Then any advice given is bluntly and rudely rejected because they 'know' the real problem and you have it all WRONG. Yeah, that's why they came asking questions in the first place ... obviously.

Show us the sauce?

And everyone seems to think their crappy fucked up and not working piece of shit routine is so precious they wont post any of the source code - and then expect someone to blindly determine why it isn't working/isn't running fast enough/wont solve world hunger. If you're lucky they post some small chunk of some unimportant routine and even then miss the actually important bits.

I'm getting a bit sick of it to be honest - and tending to be less involved in the various forums as a result. What's the point? There's no peer-to-peer communication going on with the sharing knowledge and building of 'community' (whatever that's supposed to be) - it's all just a one way street of me me me, take take take. Particularly on forums for multi-national bodies and companies - they can pay someone to do that shit. At least they should have someone with some authority to tell people to get a clue or to grow up. Regularly.

Unfortunately when such policing exists it seems far more worried about 'top posting' in replies than anything else, which just goes to lower the tone even further. It's about fucking time people got over that by now. They've probably forgotten the reason they're even still complaining about it.

Disabling Focus in JavaFX

Had the need to disable focus on a ScrollPane (in the image viewer of the previous post) - for simplicity I wanted to keep the focus elsewhere.

Although one can set FocusTraversable to false and the TAB key will no longer iterate through it, it still gets focus when you click on it.

I had to sub-class the ScrollPane and override requestFocus to NO-OP.

  scroll = new ScrollPane() {
    public void requestFocus() { }

Obviously something to use judiciously, as it removes the ability for keyboard control of that Node.

Wednesday, 7 November 2012

Quick and Dirty image viewer: Eye of FX

Although it's pretty bare of features given it's long development, one of the tools I use quite often is Eye of GNOME. It feels like an Amiga tool - i.e. it's a GUI tool which is easily used from either the command line or in a GUI context. One of the more useful features is to give it a list of only a few files which you can flick through - rather than being forced to navigate through a complete directory listing as in other tools.

Well, where it is available - Image viewers seem to have a strange habit of disappearing from distributions because "mature with no bugs" seems to be interpreted by distribution vendors as "unmaintained". Sigh.

This is not a post about that ... but it is about a quick and dirty multiple-image viewer I needed for a project which I easily turned into a similar tool. I called it EOFX in homage to eog, even if Federico was the one who confusingly decided "Recents" was the most useful way to open a Save file requester in gtk+ applications (until that started showing up, I never new Recents even existed).

Although it's rather bare, it's functional and could be extended fairly easily. Scroll-wheel zooms, pointer pans, you can sort of navigate with the keyboard (if the slider has focus).

I used a trick to get the scrollbars to work properly - by placing the ImageView inside a Group inside the ScrollPane, zooming resizes the layout and forces the scrollbars as appropriate. Without that setting the zoom factor merely changes the rendering of the ImageView, and it doesn't work properly. And then you must restort to other nasty hacks to get it to size like binding dimensions and so on - which seems to be the method de jour in JavaFX circles, even if it just doesn't work properly (it still causes issues with automatic layouts). Unfortunately Group's also interfere with automatic layout so it might not work if I wanted to fix some of the zooming issues.

But one thing i've noticed about using JavaFX so far is that it just doesn't take much code to do common things. Although it isn't the prettiest or nicest implementation of it, this image viewer allows pan and zoom and flicking through a set of images in only a handful of lines of code. Just getting a basic version of this going in Swing (or any other toolkit i've used) requires a lot of custom code and faffing about.

As a bonus, I wrote the argument passing in a way which allows one to give it arbitrary URLs as well as files, it uses a file requester if no arguments are given (so can be launched by a desktop os), and it remembers the last visited directory if using the file requester (a pet peeve of many a similar application).

I've checked it into EOFX in MediaZ/fxperiments.

I can feel a JavaFX coming on ...

The project i'm working on has changed direction again, and part of that is a desktop version of some android stuff - and this gives me an opportunity to explore JavaFX more seriously. I guess I will soon see how it really stacks up.

Sunday, 4 November 2012

Mythbusting for novices

One of the Mozilla guys had a go at mythbusting for HTML5.

Hint: Don't start busting your first myth by agreeing that it is true!

And worse, then proceed to try to make excuses!

And worse again, claiming that it isn't their fault!

I made a couple of long comments on the blog and from one he accused me of 'standing in the way' of the project. I would think that trying to pretend that there aren't technical problems that need to be overcome is more likely to hinder a project than comments from the peanut gallery.

The adversarial attitude was a bit of a surprise actually - from a guy who is paid to be liked and to make people like his employer. He just made me want to troll!

It's not a political problem, it's a technical one

Unfortunately I didn't notice the 'evangalist' tag: the guy's just a talker. But no amount of talking will fix the technical problems in making a browser a viable application platform.

But I think given how much money and time has been poured into it already, one might reasonably come to the conclusion that the whole task is simply an engineering feat beyond the technology being used.

For example, although you could conceivably take an every day sedan and turn it into a usable armoured vehicle: this is just not "the way you do it" - at least, if you want to do it in a technically competent and cost effective manner.

This is how I see HTML5. Although you can do all sorts of amazing and tricky stuff with it, it's not the way you would choose to do it if you had a free choice in the matter and a wide experience of the options available.

Stick to your strengths (or, "The world is not enough?")

The delivery of information and entertainment through the world wide web was a revolution which has impacted all of our lives.

Should they not be satisfied with that?

This "holy grail" of a web delivery of desktop-style applications through a platform delivered by multiple vendors is an expensive experiment which looks set to continue.