Close Show/hide page

Webcam image compositor, creating PNG48’s

February 9th, 2009

How it would look if you took a webcam or camera, and captured several frames of the same scene in quick succession, and then essentially averaged them out and composited them into one? My guess was that the resulting image would retain most of its sharpness but lose most of the ‘noise’. I made this quick mini-app with that thought in mind.

Here is an example of my results (before and after). The images were captured with a Logitech Quickcam Pro 9000 at a resolution of 1600×1200 (averaged from 128 (!) still images), and were not scaled or retouched.

Example - single frame Example - composited version
Example - movement...

As a side benefit, if the camera — or something in the foreground of the scene — moves during the image capturing process, you can get photography-like effects that look like a long exposure…

A PNG48 encoder class…

Read the rest of this entry »

Using AMF3 for the cool shit

January 19th, 2009

(A more descriptive but less catchy title would’ve been “Serializing and deserializing value objects with ByteArrays using AMFPHP, PHP, and MySQL.” But that’s ok.)

As we are now in the year 2009, for some reason you feel like there ought to be a way to take your cool shit, send it over the wire and get it back again, without having to resort to 99 searches on Google, a trip to Barnes & Noble for a stack of books with ugly green covers and stupid illustrations of birds and salamanders, and a spare weekend you’d be doing nothing better with anyway. Your cool shit’s in Flash, most likely, and it’s not just text data, presumably, so by a process of elimination we conclude that your shit — not of a lukewarm nature by any means — is most appropriately represented by a series of ones and zeros — in binary format. And that you want to get it on the database. ‘Cuz you can’t create the next viral sensation if you can’t get your cool shit to the database, now can you?

And while many prosaic and generally annoying 3-to-4-letter acronyms exist for the transmission of information across the proverbial ’series of tubes,’ unfortunately, most of them are founded on that most old school of information encoding conventions: the alphabet. (But if it’s in UTF format, maybe we can be a little more forgiving and call it “Alphabet 2.0″). Sure, you could do something like MyCoolAssStaticUtilitiesClass.convertMyCoolShitToBase64($o:Object), but nah, fuckit, it’s the year 2009 damnit, and you’d think there’d be an easy way to take your data – made on a computer – and store it – again, on another computer, without having to first convert it into “human-readable text,” whatever the fuck that means.

Furthermore, if your shit’s actually as cool as you say it is, we must be talking about something that’s not just a single block of binary data like an bitmap, oh no, but a complex data object, full of mixed primitive types, maybe some untyped objects and an array or two, other value objects nested inside of them, and _then_ maybe an image or two. But the main thing is, it’s stuff that you want to just dump into a field in a database record, and get back, without the extra drama of converting to and from XML with a couple extra hundred lines of code…

Anyway, presented here are the important points I learned about using AMFPHP with ByteArrays and VO’s while starting on a new project/experiment thing involving user-generated character animations of 3D models, which naturally involves lots of binary data and complex data types.

:P

Read the rest of this entry »

Mesh Slicer v1.9 (Cube Steak Edition)

December 21st, 2008

Sooner than expected (thanks no doubt to my first snow storm in two years giving me all the excuse I needed to stay in all day), this version covers bullet-point 2 of the previous post:

Adding extra faces to the cut-up meshes to make them closed shapes again would make the whole thing feel more “physical” and less abstract-graphics-demoey…

I’m using Adobe’s Kuler service to generate the color scheme, which I find quite exciting. Because it saves this particular demo from a world of red and black — which are basically the only colors I use when left to my own devices. (Press [C] to cycle through colors) Many thanks to Aden Forshaw for the AS3/Kuler example.

Finally worth noting is that the ‘physics’ have improved a little. I was previously using vertex count as a proxy for mass. Using the volume of the axis-aligned bounding box ends up being a better way of faking it.






Cutting up a mesh (into tiny little pieces)

December 19th, 2008
Thumbnail - Click me

A demonstration of splitting a mesh in two along an arbitrary plane. With some faux-physics for added value. I was thinking about the ‘laser room scene’ in Resident Evil, LOL.

I’ve included the source code of a minimal example showing how to cut up the faces of a mesh along a plane:

PlaneSplitMinimalExample.as | compiled swf

This is the foundation for everything in this demo, and for the following ideas which I think would be nice to see executed in Flash–

  • Making a more advanced intersection test using rectangles (which are bounded) instead of planes (which are infinite). The additional control would open up all sorts of fun possibilities. Projectiles or edge weapons hitting targets that get cleaved in half…
  • Adding extra faces to the cut-up meshes to make them closed shapes again would make the whole thing feel more “physical” and less abstract-graphics-demoey. And make it more useful for practical applications.
  • Maybe adding the ability to cut along an arbitrary path made up of connected line segments (like a cookie cutter)…
  • Make sure to try resetting the scene, pausing (with spacebar), clicking through a mesh several times, and then unpausing..

    Oh yeah, and the usual disclaimer/apologies about how much this demo hates your CPU, and how unoptimized it is (e.g., right now every face in the scene is tested against the plane with every click (ouch!)). Built with the most recent revision of Papervision 3D.

    Also, apologies for the long hiatus. I’ve been busy moving to the NYC. And working a lot. But y’know, whatever..

    UPDATE: John Lindquist has kindly pointed out there’s already a helper function in the Papervision framework for cutting meshes with planes! – MeshUtil.cutTriangleMesh().

    Licensed under a Creative Commons Attribution 3.0 License.

    Robot Arm, Slideshow Viewer

    June 19th, 2008
    Thumbnail - Click me

    This is a slideshow viewer, utilizing the robot arm from this previous post done with Papervision 3D. I created it on the occasion of a presentation I’m preparing for the Flash user group, San Flashcisco. In typical fashion, I’ve spent more time creating the slideshow program than preparing the presentation itself, or the slides for it. :P The slides themselves (dealing with Papervision3D) aren’t of too much value outside of the context of the presentation, but you can choose your own if you like (see below).

    The program uses hotkeys only –

    
      [SPACE/BACKSPACE]  Next/previous slide
      [BRACKET KEYS]     Next/previous slide without transition
      [COMMA]            Zoom in and out of slide, for the fun of it
    
       Also:             [1/Q, 2/W, 3/E, 4/R, 5/T, 6/Y, and 7/U] - Rotate joints
                         [Z,X,C,V] - Moves robot arm to various keyframes/poses
    
    

    How to use this with your own images, from the Desktop…

    Read the rest of this entry »

    Strange 3D objects, Perlin noise

    May 18th, 2008
    Thumbnail - Click me

    Recently I’ve been thinking on ways of programmatically creating curvy and strange, organic-looking shapes in 3D. And reflecting on the fact that I can think of no particular ‘practical’ application for such an endeavor. And concluding that that’s part of what makes it interesting…

    Here’s the high-level recipe:

    Start with a cylinder or sphere-shaped mesh, where the vertices are evenly spaced . The vertices of the mesh can be thought of as a matrix or grid, where the left and right edges are curved 360 degrees until they meet.

    Take an interesting bitmap with varying light and dark areas, whose height and width match the number of rows and columns in the mesh.

    Use brightness (or some other color-derived property) from the pixels of the bitmap as a multiplier value to dictate the distance of the corresponding vertices from the z-axis (center) of the shape.

    That’s basically it. In Flash, the built-in BitmapData.perlinNoise method is perfect for generating interesting gradients. The kicker is that the last parameter of the method allows you to change the x & y offset for each ‘octave’ (think semi-transparent layer), allowing for gradual, random-looking changes over time.

    So on each update, change the offset of each octave of the perlin noise image and recalculate the vertices accordingly. The behavior and properties of Perlin noise does the rest.

    Main class.as | Project.zip (Flex Builder 3)

    Licensed under a Creative Commons Attribution 3.0 License.

    Processing – 3D Spiral Patterns

    May 5th, 2008
    Thumbnail - Click me

    I’ve been getting comfortable with Processing over the last few days by experimenting with what else but … particles. The three-dimensional patterns that emerge by moving the sliders to change the internal parameters can be quite complex and unexpected, and sometimes strange attractor-like.

    The algorithm governing the particle motion is very straightforward. New particles are created with a starting orientation which rotates linearly on 2 axes over time. On each frame, a given amount of x, y, and z rotation is added to each particle and then the particle is translated according to its orientation by a steadily increasing distance.

    Click on the buttons in the bottom right corner to change the order that the x, y, and z rotations are applied (which creates very different results from each other). The 3 sliders on top-left control the amount of rotation added per frame; the two sliders in the middle control the rate of ’spin’ for the initial orientation of new particles; and the slider on the right controls the ’speed’ that particles move away from the point of origin.

    Main class file| Full source code

    Licensed under a Creative Commons Attribution 3.0 License.


    Personal wiki of developer notes

    April 30th, 2008

    Kind-of just for the hell of it as much as for any potential use value, I’ve converted all my notes related to programming, Flash, etc. – which used to live in various text files as various versions on various computers – into a wiki format. And have made it publicly viewable. Because, I figure, why not?

    http://wiki.zeropointnine.com

    Much thanks to Adam Smith for the idea. Have fun in L.A.

    Webcam Digital Video Recorder for AIR, updated

    April 9th, 2008

    Webcam DVR has been updated for compatibility with the release version of Adobe AIR. I didn’t introduce any serious changes with this version. I don’t have the time to self-QA this in the way it deserves, so if you run across any bugs – big or small – please let me know!

    Download (Adobe AIR file, 291K)

    Requires the Adobe AIR runtime.

    See the original post for more info and usage notes.

    Apologies for the cobwebs on this site. I’ve been pretty busy with .. work.

    Testing Kinematics with Papervision3D, Collada

    January 30th, 2008
    Thumbnail - Click me

    A forward kinematics experiment using Papervision3D v2.0 alpha and a Collada 3D model of a robotic arm.

    Hope you enjoy it.

    I don’t want to release any source from this yet, as I want to do some more work on it, relating to the following items…

    Read the rest of this entry »