Archive for September, 2009

Sep 27 2009

Bad movies

Published by Dougal under Films, Friends, Reviews

Last weekend Mat invited us round for an evening of bad — nay, terrible — movies, centred around his bargain purchase of Mega Shark versus Giant Octopus. We also saw a bit of Batman & Robin that was telly at the time, and I Know Who Killed Me, a horror movie.

Mega Shark really was as bad as we all imagined. The acting was just short of terrible, but the overall artistic vision was disastrous. It’s amazing how many “armed guards” there were in this movie, standing in the background in laboratories and offices, all wearing dark glasses despite the moody lighting.

I took particular enjoyment from the “science” scene, in which the marine biologists mixed arbitrary liquids in test tubes until they found that right combination that luminesced. (Don’t worry, it wasn’t all taxing science in the laboratory: there was time for a sex scene in the supply cupboard. Unusually, it’s legitimate to say that it was a necessary part of the plot.)

The shark and octopuses were a bit lacklustre. I was hoping for some old-school giant rubber tentacles reaching over boat decks and maybe some stop-motion or something. Instead we were treated to the same three clips of shark swimming, shark fighting octopus, octopus swimming, in various combinations. It was just like watching Saturday morning cartoons again.

The sizes and capabilities of the monsters are ludicrous to say the least. How fast does a shark have to be swimming when it leaves the water in order to overtake — and maul — a cruising 747? Answers on a postcard.

The title Mega Shark versus Giant Octopus doesn’t hide any aspect of the film from you. It’s exactly as you imagine. I Know Who Killed Me is another daft title but this one was apparently meant with all sincerity. Lindsay Lohan is abducted by a serial killer and then Lindsay Lohan turns up a few days later claiming to be a different Lindsay Lohan but bearing all the wounds which identify this particular serial killer.

This film wasn’t as bad as I expected. I don’t know if that’s because of drastically lowered expectations, or whether the elements of goodness shone through the rubbishness. Lohan did win two Golden Raspberry Awards for it, tying first and second place for Worst Actress, which I think is a bit harsh. She was far from the worst thing about this film.

Last night I saw a pilot for a modern version of the 80s classic Knight Rider. It was about as rubbish as you’d imagine, though the Hoff got a little cameo as the main dude’s absent father. And they ended on the original theme tune. But the rest of it was still crap. Reimagined, reworked and rebooted series can work very well — see Star Trek: TNG, Battlestar Galactica — but the real work is not done by the computer graphics people. You need good stories, believable plots, interesting characters! Wikipedia reveals that the series had one (shortened) season and was dropped. Hardly surprising.

I’m looking for more so-bad-it’s-good movies if you have something to recommend(!). Fixed in my mind is Battlefied Earth. Any others?

2 responses so far

Sep 16 2009

ComicBake 0.0 sneaks out the door!

Published by Dougal under Culture, Programming

It’s not what any sensible person would call usable, but I’m now announcing the appearance of ComicBake, which is what I’m calling my app for creating web comics.

ComicBake is a CLI tool for making web comics. I shall demonstrate a quick example to let you understand. (This example also appears in the source repository so you can actually recreate it too.)

Example Comic: The Conversation

The first thing you need is an image, preferably with characters who can do some talking. I’ve chosen this image from Flickr of two people having a conversation. I don’t know who they are but it’s a nice photo and it’s suitably licensed so I can manipulate it as I please.

Then you need a script file which tells the compiler all about the action in the scene.

-- A Conversation
-- A Series of Examples
-- 05 September 2009
-- Dougal Stanton
 
-- Photo CC-licenced from:
-- http://www.flickr.com/photos/clairity/154640125/
 
Scene 1. <scenes/conversation.png>
 
Woman: This is just a simple demonstration.
 
Man: Is that because it breaks
     with anything longer?

Ignore the first half-dozen lines as they’re just commentary (though I plan to use them in the future). The important points to note are:

  1. The scene description (including file path to image)
  2. The dialogue.

There are two characters here, and we can easily tell who is who but the computer needs more help. Next up is an image map, which associates names with co-ordinates:

<img src="conversation.png" width="500" height="306" border="0" usemap="#map" />
 
<map name="map">
<!-- #$-:Image map file created by GIMP Image Map plug-in -->
<!-- #$-:GIMP Image Map plug-in by Maurits Rijk -->
<!-- #$-:Please do not edit lines starting with "#$" -->
<!-- #$VERSION:2.3 -->
<!-- #$AUTHOR:Dougal Stanton -->
<area shape="rect" coords="46,29,108,88" href="woman" />
<area shape="rect" coords="426,9,494,73" href="man" />
</map>

This is just the raw file produced by The GIMP when you use its HTML image map feature. The link name for each area (href="...") doubles as the character name. Thankfully you’ll only ever have to do this once for any given image.

Pull all that together and you get:

Getting it, Using it

The code is in the usual place:

darcs get --partial http://www.dougalstanton.net/code/comicbake

To build it use the cabal-install tool. This sets the default install to be your home dir rather than system-wide:

cabal configure --prefix=$HOME --user
cabal build

That should get all dependencies except for gtk2hs+cairo, which is a real pain and something I’m planning to abandon before long. The best bet is to see whether your distro has a package for it…

Running it is simple. It only take one argument, the script file. So if you want to execute the example script:

./comicbake example/conversation.script

This will save a frame1.png into the current working directory.

Bugs

I’m still in active hacking at the moment — not even really alpha as it’s a bit of a mess. But I figured that if I didn’t release something now I would forget about it and it would disappear eventually. Which would be a shame because I think it’s quite a neat idea with some interesting potential.

  • The most obvious problem is that if you give it anything more than a couple of speech bubbles to place it can’t find space for them and bails out. The error message you see will be: Prelude.head: empty list. This needs sorted.

  • The Diagrams package I’m using is not as suited to the job as I’d hoped, for two reasons. One is that I can’t know how big my speech bubbles will be before I place them, so I’m using conservative guesswork which has so far been quite successful. But it’s not a solution.

  • The other problem is that accurate placement of the resulting objects is something that the Diagrams package doesn’t do very well. It doesn’t think in terms of absolute pixel sizes, so things tend to grow and shrink depending on the space needed.

  • There are a lot of similar-looking tuples littering the code which should be more strictly separated. It would make the code easier to read and reason about, and the type checker would help me more.

The first thing I need to do is sort out my bubble placement algorithm which is clearly not as effective as I’d thought. Then I’ll be replacing Diagrams with GD, I think.

After that there are “to do” items which may happen if it falls easily into my schedule.

  • Neaten up the script parser some more to allow multi-paragraph speeches and some unnamed characters to represent narration or offstage voices.

  • Make the script preamble more explicit. At the moment I don’t use the author’s name or date or any of that stuff yet but it’s there for the future. It would be better if they existed as named fields rather than just being free-form.

  • Write a proper parser for the image maps. I’m currently depending on Neil Mitchell’s TagSoup library for simple HTML parsing. But as I’m already using Parsec elsewhere it seems foolish to depend on them both. Why take two parser frameworks into the shower?

  • Proper command line support. Multiple arguments, let the user choose filenames, maybe some help or useful error messages.

Later on there are some things which I would really like to do. These are actual features which are pretty neat:

  • Stitch the various scenes together in some formation, eg 2x2 or 3x1, so they can be published as a single unit. The author name and comic strip title obviously become more important at this point as it brings all the images together into a story.

  • An alternative that is also pretty good is converting the same story into a flickbook comic, using anim gifs or similar to show the progress.

If anyone has any good ideas just say so! Also if you want me to actually explain how it works I’ll make a detailed post later. Hopefully when it’s closer to working! :-)

8 responses so far

Sep 07 2009

This is an excuse. I’ve been busy. Okay?

Published by Dougal under Culture, Friends

You see, this is why you should never announce intentions, never announce that you’re going to do something imminently because the only possible outcome of that kind of promise is that (a) you then find life carries you away to do a million other things and you have no time to do the last few things you meant to do or (b) you realise what a horrible mess you’ve made and dive back into the project in order to fix it.

I have been suffering a little from (a) and a little from (b) this weekend. Thankfully I’ve got Monday and Tuesday off work in which to make some amends, though really I’m using that time to whip the house into some neater shape for The Student, and tomorrow we’re away to Glasgow. I’m managing to snatch minutes here and there and I’m slowly getting close to something I’d be happy to release.

Last night was the final night of the Edinburgh International Festival, with a concert and firework display above Princes’ Street Gardens. We had Kate and Ben around for dinner and we peered out the window at the fireworks, listening to the performance streamed from the Forth One website. Unfortunately there’s a row of chimney pots that block a good chunk of the view, so we could only see the top half of the higher explosions. (So we couldn’t see the waterfall, but it’s always rubbish I think anyway.) Hilariously the radio stream was several seconds behind the display. At one interlude the radio commentator was still talking while the first fireworks exploded in the distance. I wonder if that was a special delay for those using the intarwebs or if the radio was also slightly behind.

Meal was good though and we had good chat. Kate and Helen had a knitting session while Ben and I looked on, slightly aghast. For the first time that I remember we managed to get everything prepared ahead of schedule and weren’t fretting as people arrived. We must be grown-ups now. Maybe I should start keeping stamps in my wallet.

4 responses so far

Sep 04 2009

It’s like a comic for people who can’t draw

Published by Dougal under Culture, Programming

I discovered Dinosaur Comics a few years and I think it’s great. It’s a bit strange but you soon get used to the idea. The scene is always the same from comic to comic but the dialogue changes. (Sometimes this repetition is even mentioned in the stories.) Dinosaur Comics is not the only comic in this style, but it’s the first I read and the only one I come back to regularly.

I wondered how these comics were constructed. Most of the comic writers who do this use graphics programmes — Photoshop or Inkscape or something similar. I got to wondering if all that overhead was necessary. The only real changes from episode to episode is the text, which can surely be written just as well in a text file as anywhere else. Is there not a program that can insert today’s script into the scene?

(Now I fully admit that there is a great skill in lettering and bubble placement when making comics. But something I have come to notice recently is that something which is 90% of the way there, or right-on 90% of the time, can be incredibly useful. And let’s not shoot down this project before it’s really airborne, eh?)

Speech Bubble
Speech Bubble
© Alper Çuğun

I did a bit of search and found some fascinating work, but nothing that seemed to come close to what I was thinking. The coolest thing I did find in the right area was automatic film-to-comic translation research. Using the screenplay and the movie side-by-side, the researchers’ program could extract relevant frames from the movie and place the correct dialogue in speech bubbles next to the actors. One of the authors has written an excellent page showing what their program does and has example scenes from a number of mainstream movies. Naturally, no source code is published. :-(

I decided in the end that any prior art on this subject was too well-hidden for me to find with Google. There were many fits and starts. My first attempts were almost immediately shelved because I was attempting to interface directly with Cairo to draw text and speech bubbles onto images. As nice as Cairo is, it’s not the right level of abstraction for this job.

Later on Brent Yorgey started his Diagrams project, building a functional combinator approach to drawing. This was exactly the approach I needed to get started, and I made some contributions so that it supported text. My sincere thanks to Brent for unwittingly kickstarting this project. I spent some time playing around with Diagrams and getting a feel for the best way to do things. I made a number of examples which could draw speech bubbles and place them on images at some desired location.

After a lot of thinking, and producing altogether too many doodles to be considered healthy, I finally got down to some serious procrastination. My problem was that I didn’t know where to start — I couldn’t see what shape the program was meant to be, and I didn’t work it out for a long time. But since I’m getting close to actually releasing the first version, I can say a good deal more about the structure and construction of the program.

First of all, it does indeed create “comics” out of written scripts. That you can be assured of. To create a three-panel comic strip you will need:

  1. A script with three scenes.
  2. At least one image, referenced in the script, which depicts the “scene” in the comic strip.
  3. A file which gives the co-ordinates of any characters that appear in the scene.

I apologise for the requirement (3) but it’s best way that I know to ensure the speech bubbles can be attached to people in the scene, and to make sure bubbles don’t land in middle of a person’s face. And the idea is that you only have to write this file once. It will always be true for that image. I’ve also made it slightly easier because the parser expects the actual co-ordinate data to be in the form of an HTML image map as exported by any number of graphics programs. You can load your images into The GIMP and save out an image map with each character boxed and tagged. It’s cheap and it works.

On the inside it’s modelled pretty like a compiler. The source file is the script file which is pretty close to the script you’d find for a stage or screenplay. There are a number of obvious differences — specifying filenames, for example — but I’ve tried to minimise the amount of non-story-writing an author would do on a regular basis.

Found
Found
© Alan Woo

The script is loaded in and does two separate things. First it reads through the script itself, noting down the names of characters and everything that they say in each scene. Obviously we want to know what the characters are saying, but knowing who is in a scene is also important. The program finds all the background images whose filenames are stored in the script. At the moment I can only handle .png files but this may change. It then looks for a .map file with the same name and loads that to see which characters appear in that image. If there’s a speaking character in the script who doesn’t have a location in any of the images we have a problem! So it’s important to know who we expect to find and to know that it’s accurate.

All along the way we’re noting down all this information for each scene — who is speaking? where are they? what are they saying? Once we know all this we can start placing speech bubbles around these characters. The canonical method of placing speech bubbles is left-to-right and top-to-bottom (I presume this changes for other languages which read right-to-left or vertically?) so we try that in a very simple way. We create a big margin around every character, like a thick frame, which is where bubbles can be placed. Each time we place a bubble we make sure that previous bubbles are placed “above” or “left” of the current location to keep the sense of the conversation.

Lastly we convert all this abstract data of locations and text and images into concrete files, which are written out to disk: frame1.png, frame2.png, frame3.png. At time of writing there are a few annoying problems, the most important being the bubbles have really rubbish tails. Creating good speech bubbles programmatically — and pointing the tails towards the speaker — is a problem I have not solved. The bubbles are a bit crap right now.

I hope to publish the code and some examples within the next couple of days. Look out for it!

2 responses so far