So I recently acquired the Lego Vision Command kit to go with my bot. I need to be able to work/program with it.
And I managed to generate code for it.
So basically people, currently I have a webcam and I have C code that can snap a frame from it and save it to disk (as a bitmap currently, for speed issues I don't care about sizes)
Unfortunately the transition from raw webcam data to a saved webcam may not always be the sweetest.
Let me explain.
I get a raw stream of bytes from the camera. Being a human hence being unable to guess their meaning I dump them to a bitmap with a standard header. It is not pretty. The orientation and the colours seem to be a bit out of place too.

That would be me, by the way.
Fixing the colours is trivial as I just need to reverse the RGB indices, and so I do to get this. Ugly still, but its coloured well.

To fix the upside down thing (although for my application its strictly not needed but what the hell) I simply reverse the bytes order.
Bad idea.

Fixing colours is no problem, but as few bright ones must have noticed, its laterally inverted. I'd really appreciate the left and the right to stay where they are, so reversing bit order is no solution. Did I mention for speed issues I'd like to keep the byte data as unmodified as possible? Reversing really just means reading the pointer backwards.
I finally discovered somehow that bitmap data is allowed to set a negative value for its height in the header. Although most viewers I've got on my machine hate to display an image in such a configuration, my browser, and gimp, allow this.
More like it.

So I'm on a spree and have taken much better shots (the second one not involving me)


Currently I have a program that can grab frames off a webcam, store them wherever required. My next job is to do some processing over these frames to be able to make sense to my bot. I think I should use openCV for this.
I'm hairy.
No comments:
Post a Comment