After presenting my progress in Nature of Code last week, I continued experimenting with the Trace Modeler software from Interactive Fabrication. The software uses OpenCV to do blob detection, and draws a point cloud around the perimeter of the blob in 3D space over time. There are a lot of useful features you can set, like the distance between the planes in Z-space, the smoothness of the surface mesh, and the capture rate controlling the amount of frames it plots.
In order to get the Trace Modeler software working correctly, you need to have OpenFrameworks running on your computer. OpenFrameworks is an opensource library for developing C++ applications. You also need a development environment like XCode installed. As it says in the “Read Me” text, the Trace Modeler software requires the following addons – ofxVectorMath, ofxSTL, ofxDelaunay, ofxMSAInteractiveObject, ofxXmlSettings, ofxSimpleGuiToo, and ofxOpenCv. Download these additional libraries and place them in the add-ons folder inside the OpenFrameworks folder in your Documents. It should probably go without saying at this point, but I’m on Mac OSX Snow Leopard. In order for the program to export the STL files, you need to change the file path in the traceModel.cpp file to correspond with the bin folder of the the application on your computer. I didn’t specify any path, just stlExporter.saveModel(“testBin.stl”); and that seemed to work fine. When you press the Capture button it saves an .STL file to the folder.
Test to see if the application is running by pressing the “Build and Run” green button at the top of the XCode window. Once it’s running, you can see the camera view in the upper left of the screen, and the contrasted camera view doing the blob tracking in the upper right. The red material being drawn to the main screen is the 3D model being written. It helps to have a contrasted background in order for the blob tracking to work to the best of its ability. If the object or person being tracked is lighter, then a black background works well, and if the object is darker a light background works. Lighting also helps darker objects contrast against a black backdrop, which seems to absorb shadows. Once the background, camera view, and lighting are set, make sure nothing is in the camera view and press the “Learn Background” button on the application, which sets the reference frame. Then start experimenting with the settings for Threshold (sets the threshold for the blob tracking), Z-Index (sets the distance in 3D space between the perimeters), and Capture Rate (the time in milliseconds between each camera draw). Smoothing also affects the smoothness of the polygons. When you’re satisfied with the shape (or just want to see what it looks like), press “Export Model,” or “Clear Shape” if you want to start over once the settings are how you want them.
Next I opened up the STL file in MeshLab to see how the model looked in 3D. Since the mesh was already made in OpenFrameworks, I only had to make surfaces for the two ends. This proved to be the trickiest part. Many thanks to Miguel Bermudez for his expertise with 3d-modeling.