droneBull #2 - using buffer size to identify change of patterns and map a room
Autor: Pedro | Publicado: 2013-12-10T18:53:00-02:00

Get ready to get high without drugs.

UPDATE 2 {
In summa: we have a camera. We have a video stream. We have the size of the video buffer. We have a codec that increases the size of the video buffer every time something changes in the screen. We have walls with well defined patterns. Every time the camera focuses other wall, the buffer size increases because that's how the codec (FFmpeg's codec) works. Capisce?&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }

I realised that the final goal of this project will be something like an autonomous waiter.

"ok, drone, I want a blue Reb Bull"
And the drone flies arround the room (or the house), finds the RB and brings to me.
Once again, my laziness won.

After 'solving' the problem of identify a specified object in a room, I will try to explain my plan to map an entire room with the drone camera.


"mimimi you should use a sonar mimimi maybe an Arduino mimimi use a Kinect"
YES. I KNOW. But I forgot my EZ1 in Brazil (my Arduino is with me. Always.) and I spent my last pounds buying an AR.Drone 2.0 PE (no Kinect for now). The thing is: I need to map a room using just the drone.
Seems easy, right?

No. The drone has a 720p camera.
That's all.
I don't have a Kinect or an Amazon cluster to process my images.

I just had this ideia and tested some minutes ago. The drone wasn't flying, I was holding it and moving it arround the room (my flatmates have exams tomorrow and my AR.Drone is one of the most noisy 'toys' I've ever seen) and I didn't record a video... well... because I'm writing down the ideia and there's nothing special about a guy holding a drone and getting excited with some numbers on the PC screen.

After a lot of mimimi, here's the thing: I'm using FFmpeg and a module called 'stream'. This allows me to stream (really?) images from the drone right to the browser.
Cool, right?

YES, but the coolest thing is one of the arguments of this module:
res.write(buffer);
this beautiful function returns the buffer size as a number! That means that I'm not working with a video anymore and all the complications (required processing power, quality, poor connection) are 'over', because I have a simple number that represents my entire video!

"Ok, cool. But why are you so happy about this? That's just the buffer size and represents pretty much nothing!"
That was what I though untill I remembered some facts about FFmpeg:
1) It reduces the required bandwidth.
2) There're some compression codecs working with FFmpeg.
3) Some inter-frame codecs.
Ok, keep these ideias.

Remembered of our objective? Find the room plan.
A house has walls (u don't say?).
Walls have uniform colors (or well defined patterns).
Ok, keep these ideias.

Imagine the drone flying arround a room. There's at least four walls. Four well defined patterns that change only when there's an intersection with another.

Inter-frame codecs increases the buffer size everytime something change in the image. Analyzing the buffer size, I'm able to predict when a wall ends and when another begins before the drone crashes into a wall!

In theory, the process is simple: the drone takes off in front of a wall, starts moving sideways, stops every 42 cm (it's easy to acess the bottom camera to get horizontal distances), rotates 42º, analise the patterns and finally defines if there's other wall or not.

In the end of the process, you have a map of the room and you can roam arround and try to find your can!

I know, I know... sounds terrible. There's a lot of 'what ifs', but the concept is good and I'll work on it.

What I've done?
I'm already able to identify when the drone goes from one wall to another.

I'll post as soon as I update the project.

UPDATE &nbsp; {
I'm already able to take off, identify when other wall is found and land. AUTONOMOUSLY!

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }