Tuesday, October 29, 2013

make IRC go (and stay going)

Liveblogging figuring out IRC?! Okay.

Adam and his old grad school buddies have a channel. Adam checks it by going to a server somewhere and looking at it in a terminal. He's always idling in there or somethign so he gets to read the history and see what people were doing when he wasn't looking at it. I've been using IRC through Adium a little bit, but it's not the same.
Hello, Adium...
The first couple steps are just about running an IRC client on a server... which I happen to have already. And then the last steps apply to anyone who is kind of an IRC noob like me, regardless of how they got into the IRC chatroom. (In addition to a chat client like Adium for mac, there are also webpages that let you connect to freenode IRC rooms.) (For web, try this one: https://webchat.freenode.net/ Just put #channelname in the box with the hashtag in front.)

1. SSH into a remote server. I have an amazon box through EC2 or something. One of the tiny ones. It runs the sketchabit webpage.

2. Run a screen. "screen -R" I love screen so much, it lets me do work and have things keep running and reconnect later even when I close my ssh connection.

3. Try to use Irssi, which is a linux IRC client. Find it installed! Learn it is because Adam installed it on my server an hour ago because he anticipated this desire of mine. You probably will need to install it yourself. 

4. /connect chat.freenode.net

5. /nick kaflurbaleen
(to change my username because "kathleen" was taken)

6. /join #adadevacademy

7. /names
(to see who's around... oh look, the version of me signed in on Adium is there.)

8. Detach with the magical screen detach command that is muscle memory now. Ctrl-A (let go) D

9. Apparently I can cycle between irssi windows with Esc (let go) [left or right Arrow Keys]
I can also do /win 1 and /win 2 to cycle

Other things Adam is telling me right now:
/me is some action where I would say
/me is a kitty! and it would say "* kaflurbaleen is a kitty"

10. Private message someone by saying /msg <their name, which you can tab complete> <the message> which will make another window that you can get to with tip #9 above. Quit that with /q 

Chat box in the terminal! Yeah!

11. Try it from my iPhone, where I can log into my amazon box using ServerAuditor.

OpenCV is whack

After my last blog post questioning the behavior of a certain OpenCV method, a colleague pointed me at the source code for OpenCV and the method in question. Turns out, in addition to supposedly (but not reliably) finding a nice transformation between two matching pairs of points, it can also find a transformation between IMAGES by computing optical flow and finding features and doing RANSAC and A BILLION OTHER RIDICULOUS things. Things I don't want it to do!

Bad computer! BAD OpenCV!! I know exactly what math needs to be done, and I don't know if you noticed, but your documentation for that particular function strongly suggests it does some least squares optimization thing.

Objective: solve for the matrix that lets you transform original grumpy cat image to aligned grumpy cat image.
Now that's what I'm talkin' about! And I even got to put the eyebrow markers by her little cat eyebrows.

So, I finally rewrote the damn alignment code: https://gist.github.com/ktuite/7225703

The secret objective of this post is actually to profess my love for C/C++ libraries like GSL (the GNU Scientific Library). (I also like the Approximate Nearest Neighbor Library ANN.) It's kind of hard to learn, with matrix multiplies looking kinda like this: gsl_blas_dgemm(CblasNoTrans, CblasTrans, 1.0, m_gsl_dst, m_gsl_src, 0.0, A); but it's sooooo reliable! And fast! And educational! OpenCV constantly disappoints me, but these other libraries feel like wielding sharp swords forged by the elders.

I basically learned linear algebra from trying to decode and use that part of GSL. If you look at my alignment code, you'll see my (wo-)man-handling of matrices to get my answer.  I think there's another way to do it with a least-squares solver, but that's something I still need to look into/teach myself/get my hands dirty with.

Friday, October 25, 2013

estimateRigidTransform breaks sometimes

Am I crazy? This problem and it's complete lack of documentation on the internet make me feel kind of crazy.

I have some points on two different images and I use estimateRigidTransform from OpenCV to find a [2x3] matrix to apply to one image to make it like the other one. It USUALLY works. But sometimes it doesn't.

So, I have the 27 x,y pixel coordinates on a default/"canonical" face:

"Canonical" configuration of points that all faces get aligned to.  Or something very similar to it.

I also have 27 x,y pixel coordinates on a face I want to align to the canonical face.
Detected face landmarks
I use that function and hopefully get a matrix like this, telling me how to rotate, scale, and translate the image to make it fit.

[1.475374961267126, 0.2485045944873411, -43.47119271840103;
  -0.2485045944873411, 1.475374961267126, 174.3608289828719]

Automatically cropped and aligned based on landmarks

This works for MOST images, but sometimes it just flips out and returns a 2x3 matrix of all zeros! This is why you see obnoxious solid colored squares in the Face Frontier sometimes, because it makes the whole cropped face just be the color in the top corner.

Damn you, solid color square faces...

Here are two of the latest point vectors that make this function wuss out:

[220, 298; 427, 313; 297, 374; 244, 457; 379, 469; 176, 257; 278, 244; 191, 282; 230, 276; 214, 324; 256, 315; 383, 252; 489, 266; 392, 318; 424, 288; 432, 338; 474, 307; 288, 319; 337, 323; 277, 354; 323, 357; 266, 386; 347, 396; 298, 409; 298, 425; 298, 443; 300, 457]

[198.24593, 218.48312; 301.75409, 218.48312; 250, 288.72064; 196.73442, 335.1088; 303.26559, 335.1088; 152.62563, 206.89514; 220.81578, 196.98947; 180.65184, 221.26352; 196.88483, 213.14243; 197.29204, 224.76518; 212.424, 220.57774; 279.18423, 196.98947; 347.37439, 206.89514; 287.57602, 220.57774; 303.11517, 213.14243; 302.70798, 224.76518; 319.34818, 221.26352; 234.78632, 222.358; 265.21368, 222.358; 227.47029, 264.40878; 272.52972, 264.40878; 216.52325, 288.04016; 283.47675, 288.04016; 250, 329.29788; 250, 337.32162; 250, 347.60889; 250, 361.46271]

I've been ignoring the problem, but I have an image of Grumpy Cat that I really need to re-align.

Has anyone else EVER seen it do this?

Friday, October 18, 2013

I think I'm doing grad school wrong

"Wombat" is the term I've adopted for when I'm in fighting-with-servers mode instead of research and design mode.

How to (not?) do grad school:

Step 0: ??? (meander, do stuff that's cool, do stuff that's not cool)
Step 1: Embark on kinda large project to make a game and crowdsource some stuff
Step 2: Build a crappy prototype (ooh yeah, you're learning all about the computer vision algorithms!)
Step 3: Build a pretty slick prototype (learn about hella systems and web things, put that computer vision system in a website! Now it's accessible! I love that!)
Step 4: Iterate on a prototype and get excited about its future potential to take over the world! (Repeat step 4 a lot and change the design a lot)
Step 5: Decide IT IS TIME. TO SEND YOUR BABY INTO THE WORLD. (I know very little about babies.)
Step 6: Aaaaand.... (before it's even released) Fill up all your hard drive space.* No world domination here. Nope. Feel defeated.
Step 7: Sleepily ponder alternatives. Not alternatives to grad school... alternatives to fixing your stupid research project.

Repeat entire process least twice. 

(Luckily, I've been hoarding disk space from the PhotoCity days. I miss that project so much, even though it has the exact same issues [but worse, I like to believe] as I'm having right now. But the thought of snuggling up in those 117G feels so cozy and familiar. Also, I'm tired.)

*The harddrive space is not the only issue. When that part gets sorted out, I'll get to find out how hilariously unprepared my other little servers and worker services are. 

Dear company(ies) with hella infrastructure. I would like you to pay me to do these kinds of projects and I want you to take care of the servers for me. I would also prefer to work with other people and not be quite so independent. 

Saturday, October 12, 2013

Sci-fi books that my brain thinks about long after I read them

Books books books! I'm taking a short break from work to tell you about some books I've read, the links between the fictional book world tech and the real world, and based on random things I remember (and can't forget) about the books, maybe why you should read them, too!

1. The Diamond Age by Neal Stephenson

I discovered some friends working on education apps hadn't read this book! I checked on Goodreads and a lot of folks there have read it, so good job. Maybe you loved it, maybe you're confused by the ending, maybe my 'review' will reveal that I forgot a large chunk of what happened. No matter! Here's what I do remember:

There are these electronic book things (the Young Lady's Illustrated Primer) that some kids get that are like an adaptive, interactive, fancy-schmancy textbook for learning all the things that a child ought to learn. Like reading and arithmetic and different animals and construction machines. So it can read aloud to the kid and then teach the kid to read and be kind of wikipedia-like in teaching about whatever the kid is interested in. No teacher? This book can do it! Or maybe it augments a teacher? I don't really remember, because the main character girl who was not in the right socioeconomic group to get one (or school) did actually get her hands on one. It (kind of) made me think of the plan to drop OLPCs all over Africa and have kids teach themselves computers. Then there's another main character of the book, the woman who does the reading aloud and communicating through the book, who winds up getting to know the little girl using the book as she grows up.

Basically, it's like you need Siri to be more intelligent, but she's not, so you have your app plug into Mechanical Turk and get a human to take care of it. Kind of like VizWiz, the app that lets blind people take a picture and have a turker tell them what they're looking at. But then some of those workers start getting paired with the same app users and they might wind up getting involved in each other's lives! The human touch! It's important! Will artificial intelligence ever be advanced enough to give us that emotional connection? Is the the human element necessary for learning? Stephenson seems to think so!

Also, the idea of adaptive learning is what's hot in education (and game design for education) these days.

I think people want something like the Illustrated Primer... interactive, personalized, unbounded learning. In your pocket! We're already headed in that direction with tablets and interactive e-books (like Al Gore's climate book... are there more? Why is that the only one I can remember?) and interactive data visualizations (like in the NYT) and MOOCs making education more widely available and universal. There are a lot of kinks still to work out, though. The biggest one I know/care about is how "interactive" content is still pretty static, like someone has to design the levels for the math game or the widgets for the website or the homework for the MOOC. But that is why Adam and friends are working on design automation! And that is why I build things that let humans contribute new content!

Anyway. Don't wait to read The Diamond Age on your own Illustrated Primer in 20 years! Read it now!

P.S. I had just finished Anathem on my Kindle and I asked Adam to suggest another Neal Stephenson book, and he was like, "Oh, you should totally read the Diamond Age because it's about a girl with an electronic book like you have there."

2. All 4 books in the Hyperion series by Dan Simmons, especially the last 3 books

The story for me reading these books is that I was in the Twice Sold Tales on 45th and the Ave, perusing books with Adam when I was fresh into grad school, and he pointed out Hyperion and said, "Mike said that was good". It is good! I think it might have been the first "people living all over space" (not just Mars) book I read, since I tend to relate all other space colonization books (see the next two on this list) to this series. My review is not going to do it justice.

My memory of the first book: Spaceship tree! Religious quest that I don't understand. Woman who comes from a planet with higher gravity that makes her short and stocky. The SHRIKE is SCARY. Guy with baby who's getting younger and younger every day. Drunk poet guy.

The next few books: I finally get to know and appreciate more of the characters. There's a spaceship with a personality. People are all over space! They live on different planets, but thanks to the some fancy-shmancy technology, they can connect the planets together. One guy (the drunk poet) has a house with different rooms on different planets. There's a main street and a river that are connected in a huge multi-planet loop. One of the books involves traveling on a raft through down this river (and all over space!), which is like that Escher staircase that always flows downhill but manages to connect in a big cycle.

3. 2312 by Kim Stanley Robinson

Speaking of humans all over space, they're all over the place in this book, too! And they travel between planets in hollowed out asteroids called terraria, that each have a different ecosystem inside. Some are savannas or full of water or totally dark.. not having been to Burning Man, I imaging different terraria offering all kinds of different experiences like different BM camps. They also keep pretty much all of Earth's animals in different terraria zoos because Earth is getting pretty run down and the animals would go extinct there. What would it be like to take a run-down Earth and put all the animals back?? Read the book to find out!

In addition to the terraria, there's also some crazy artificial intelligence that might be getting too intelligent. 

In true Kim Stanley Robinson fashion, there's a lot of drawn out boring aspects of the book, too.

The prologue about sun-walkers on Mercury is really neat, though, so you should at least get the Kindle book sample from Amazon and read that.

4. A Deepness In The Sky by Vernor Vinge

Ah, people are all over space again! But there's one planet that has not been colonized by humans, but it has some smart creatures on it, and they're going through their own technological enlightenment when the humans show up. It's all these smart, inspired characters paralleling a lot of technological advancements of the real Earth (like nuclear scientists) but at an accelerated pace! A warning, though, if you don't like spiders, maybe this book isn't for you.

Compared to the books above, this Vinge book was the most satisfying and fun to read. It's not laced with weird Stephenson sub-plots, nor is it 4 books long. You should read the Diamond Age for its historical (and future-ical) relevance, but you should read A Deepness in the Sky because it's a great story. And you should read the other books if you have time and want to think about what it would be like to live all over space.

What other books do I need to read? Ones that will CHANGE MY OUTLOOK ON LIFE??