Alex Sciuto

09 Feb 2015

parametric-top

Tweetable summary: OpenFrameworks + Python + Rhino by Alex Sciuto: A physical trace of an object’s previous positions. Record an object’s movement over time and extrude it.

I was at a loss for what to turn into a parametric object. No objects were coming to me that announced, “this could be parametrized in a meaningfully interesting way.” So I expanded my thinking around what a parameter could be. Could it be my own data? Could I give the program I was going to make my location data, and it would output a parametrized shape of my previous month’s location data? This line of thinking intrigued me, but the location data didn’t feel right. My ideas for converting location data into an object were all very abstract and data-vizzy. One interesting idea I did have was to create little objects that could attach to shoe strings that would show off how much I walk.

So I went looking for other unconventional sources of data that could be provide the inputs for a parametrized object. For the ofxAddons assignment, I had wanted to do something with computer vision, but since it was a pre-installed addon, adding in computer vision would just make that assignment more difficult. But in exploring the ofxOpenCV addon, I had seen the cool blob detector example that detects the outlines of objects in the field of vision. I was mesmerized by how they morphed and changed as I moved and twisted my hand. I decided that taking this cool undulations and turning them into a 3d object would be a cool experiement that would allow me to play with ofxOpenCV.

What worked well? I got a printable object. I was able to combine openFrameworks with Rhino using Python scripting. What didn’t work well? The concept was a lot less exciting that I originally thought. Most objects just produce non-descript blobs. If I were to take this project further, I’d need to come up with a better setup for recording blobs.

3D model:

Some Photos:

cvAbove: screen grabs from the hand-tracking application.

Screen Shot 2015-02-09 at 11.18.24 AMAbove: A scissor opening and closing.

Screen Shot 2015-02-09 at 11.21.41 AMAbove: The top of a plate.

Screen Shot 2015-02-09 at 11.24.40 AMAbove: Another view of a hand.

Screen Shot 2015-02-09 at 11.46.46 AMAbove: A ruler waving back and forth.

Github Repo. And finally the RhinoPython script:

#!/usr/bin/env python

import rhinoscriptsyntax as rs
import random
import math
import json


# load the json file that inclues all the points
filePath = "/Users/alex/Documents/of/apps/myApps/opencvexport/bin/data/opencvtest.json"
f = open(filePath, 'rw');
jsonData = json.loads(f.read());


# Get the bounding points for the object, so we can center it later.
minx = 99999
maxx = -999999
miny = 99999
maxy = -999999
for obj in jsonData["data"]:
    for i in obj:
        if(i[0] > maxx):
            maxx = i[0]
        if(i[0] < minx):             minx = i[0]         if(i[1] > maxy):
            maxy = i[1]
        if(i[1] < miny):
            miny = i[1]
        

# Set up the spacing variables
offset = 10
length = offset*len(jsonData["data"])
initialOffset = -.5 * length

width = maxx - minx
print maxx
print minx
widthOffset = -.5 * width


        
# iterate through the frames and create points from blob points. This implementation
# assumes one blob for one frame. I belive Rhino could handle multiple blobs, but I didn't explore this.

planeList = [];
for frame in jsonData["data"]:
    
    blobList = [];
    
    for i in frame:
        pt = (initialOffset, i[0] - widthOffset - 240, 320-i[1] - miny)
        blobList.append(pt)
    
    #close the curve. There is no closeCurve command. You just have to end the curve
    #at the same spot where you began.
    pt = (initialOffset, frame[0][0] - widthOffset - 240, 320-frame[0][1] - miny)
    blobList.append(pt)
        
    planeList.append(blobList)
    
    initialOffset+=offset
        

# Draw the curves and store their IDs in a list.
curvelist = []
for plane in planeList:
    crv = rs.AddCurve(plane)
    curvelist.append(crv)

#These are the methods for creating the lofted shape and removing the unnecessary curves,
#I found I needed to do some editing of the initial and end frames, so I mostly did these commands manually

#loft = rs.AddLoftSrf(curvelist, 0, 2, 1);
#rs.CapPlanarHoles(loft)
#
#rs.DeleteObjects(curvelist)