Palette:camSchnappr

From TouchDesigner Documentation
Revision as of 21:31, 3 July 2019 by Greg (talk | contribs)
Jump to: navigation, search

Summary
[edit]

camSchnappr is a interactive mapping application entirely inspired by MAPAMOK, created by Kyle McDonald at the YCAM Interlab. With Kyle publishing the source code for MAPAMOK, we had a chance to look at it and convert it into TouchDesigner. For the original tool and source have a look here:

Kyle describes the significance of the tool as the use of OpenCV's cameraCalibrate to calibrate a projector via a model of the to be mapped structure instead of using a checkerboard. With TouchDesigner’s integration of Python, we were able to implement the same functionality into a standalone tool which lets you map complex structures in a small amount of time.

See also Palette:kantanMapper, Vioso, Scalable Display TOP, projectorBlend

PythonIcon.pngPalette:camSchnappr Ext


What it does

If you have a physical 3D structure plus a virtual 3D model of that structure, you will be able to project a rendered virtual model onto that physical structure perfectly-aligned. You will be selecting points on your 3D Model and align them with the real world positions as you see them on the projector output. In order to support multiple projectors, the output of blend-masks from multiple camSchnapprs is now supported.

Using your 6 or more alignment points, CamSchnappr will compute the position, rotation, scale and viewing angle of a specified TouchDesigner Camera component used for the rendering. Internally, an openCV function called calibrateCamera will be run and the “intrinsics and extrinsics” of the camera will be calculated and stored in the Camera component.


What you need

  • TouchDesigner
  • a projector. Note: Make sure your projector has all digital transformations like keystone or zoom reset.
  • a physical structure to project on
  • a 3D Model of the to-be-mapped structure


Parameters - camSchnappr Page

Help Help - Opens this page.  

Version Version - Current version of this COMP.  

Project Project - Specify a Camera COMP that will be used as the camera to be calibrated. By default the internal Camera COMP called "project" is being used. When dropping a new Camera COMP onto this parameter, a selection of parameters will be created.  

Geo SOP Geosop - Assign the SOP which holds the geometry you are calibrating. Do not specify a SOP that is a Material SOP or is from a branch with a Material SOP in it as this would break the blending. Instead reference the Texture via the Color Map Parameter.  

Calibration Error Calibrationerror - Displays the calibration Error returned from OpenCV after cv2.calibrateCamera has been executed. That is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints.  

Open Main Window Openmain - Open the camSchnappr editing window.  

Close Main Window Closemain - Close the camSchnappr editing window.  

Output Monitor Monitor - Assign which Monitor the output window will open on. This should be your projector.  

Open Output Open - Open the output window.  

Close Output Close - Close the output window.  

Show Guides Guides - Show the guides on the output monitor.  

Reverse Geo Vertex Reversevertex - Reverse both U and V for the Hull.  

Color Geo Randomly Colorrandom - Color each primitive of the geometry by random. This can be useful when schnapping complex objects.  

Color Map Colormap - Assign a TOP which is used as texture in the editing viewport and the output.  

Texture Alpha Texturealpha - Control the texture alpha.  

Show Wireframe Wireframe - Show or hide the geometrie's wireframe.  

Wireframe Line Width Wirewidth - Control the wireframe strength of the geometry in the output window.  

Clear Clear - Clear the calibration data.  

Backlight Dimmer Blightdimmer - Control the backlight amount of the output window.  

Wireframe Color Wirecolor - - Set the wireframe color of the geometry in the output window.

  • Wireframe Color Wirecolorr -
  • Wireframe Color Wirecolorg -
  • Wireframe Color Wirecolorb -

Backlight Color Blightcolor - - Set the background color of the output window.

  • Backlight Color Blightcolorr -
  • Backlight Color Blightcolorg -
  • Backlight Color Blightcolorb -


Parameters - openCV Page

Near Near - This control allows you to designate the near clipping plane. Geometry closer from the lens than this distance will not be visible.  

Far Far - This control allows you to designate the far clipping planes. Geometry further away from the lens than this distance will not be visible.  

FOV Fov - Specify the initial FOV (field of view) estimation for the camera matrix given to the cv2.calibrateCamera function.  

Intrinsic Guess Intrinsic - the initial cameraMatrix passed to cv2.calibrateCamera contains valid initial values of focal length and principal point that are optimized further. Otherwise, the principal point is initially set to the image center ( imageSize is used), and focal distances are computed in a least-squares fashion. It sets the flag cv2.CALIB_USE_INTRINSIC_GUESS  

Fix Aspect Ratio Fixaspect - This considers only the vertical focal length as a free parameter. This should always be enabled unless you have an unusual projector with non-square pixels. It sets the flag cv2.CALIB_FIX_ASPECT_RATIO  

Zero Tangent Distance Zerotangentdist - Tangential distortion is set to zero. It's enabled by default because most projectors have very little tangential distortion. It sets the flag cv2.CALIB_ZERO_TANGENT_DIST  

Fix Principal Point Fixprincipal - The principal point is not changed during the optimization. You should enable this if you have a high quality lens with zero lens shift. It sets the flag cv2.CALIB_FIX_PRINCIPAL_POINT  

Fix Focal Length Fixfocal -  

Fix K1 Fixk1 - The corresponding radial distortion coefficient is not changed during the optimization. For extremely wide fisheye lenses or lenses with radial distortion try enabling these. It sets the flag cv2.CALIB_FIX_K1  

Fix K2 Fixk2 - The corresponding radial distortion coefficient is not changed during the optimization. For extremely wide fisheye lenses or lenses with radial distortion try enabling these. It sets the flag cv2.CALIB_FIX_K2  

Fix K3 Fixk3 - The corresponding radial distortion coefficient is not changed during the optimization. For extremely wide fisheye lenses or lenses with radial distortion try enabling these. It sets the flag cv2.CALIB_FIX_K3  

Max Iterations Maxiterations - Specify the number of iterations the algorithm should terminate after.  

Precision Precision - Specify the value of accuracy at which, when reaching it, the algorithm should terminate.  


Parameters - Auto Blend Page

The Autoblend feature uses Light COMPs to retrieve overlapping areas by comapring uvs from the lights projection area. Further it uses the Blend, Gamma and Luminance Parameters to adjust the blend region after the principles outlined in Paul Bourke's Paper: http://paulbourke.net/miscellaneous/edgeblend/

camSchnappr Cameras Camschnapprcams - Specify all other camSchnappr Camera COMPs in order to calculate the blend-mask for the projector.  

Blend Blend - Adjust the power of the blend function.  

Gamma Red Gammared - Adjust the gamma for the red channel.  

Gamma Green Gammagreen - Adjust the gamma for the green channel.  

Gamma Blue Gammablue - Adjust the gamma for the blue channel.  

Luminance Luminance - Adjust the luminance for the blend function.  


Parameters - OSC Page

camSchnappr now allows you to control it from a mobile device using TouchOSC Download the TouchOSC layouts for IPad File:camSchnappr.touchosc or IPhone File:camSchnapprIPhone.touchosc. Make sure to turn on Touch Messages (/z) in the TouchOSC options as some of the interactions require this message to be send through.

Active Active - Activate OSC access to camSchnappr via TouchOSC.  

Port Port - Set the portnumber specified in TouchOSC here. MAke sure in TouchOSC incoming and outgoing ports are set to the same value.  


The Viewport

Open the viewport by clicking the Open Main Window parameter.

CamSchnapprMainWindow.jpg

You can interact with the viewport as follows:

  • ctrl + left-mouse click and drag to tumble
  • ctrl + middle-mouse click and drag to zoom
  • ctrl + right-mouse click and drag to pan
  • h to home the geometry
  • create control points by left-mouse clicking on the geometry
  • make control points active by left-mouse clicking on blue spheres
  • delete control points by right-mouse clicking onto spheres
  • tab to cycle through selected points

When you select points a little flag with the point number will be displayed.


The Mapping Viewport

Once you selected the correct output Monitor via the Output Monitor parameter, click the Open Output parameter.

CamSchnapprOutputGuides.jpg

The interface is quite simple:

  • a red crosshair indicates your current cursor position on the screen
  • a dark yellow crosshair indicates an inactive point previously selected to be mapped in the main viewport
  • a yellow crosshair indicates an active point previously selected to be mapped in the main viewport

You can drag points to their real-world position on the screen or use the arrow keys on the keyboard. For faster movement, use alt+arrowkey to move points.

You can also Shift+Left-click onto the viewport to move points directly to their corresponding real-world position.

Tab will cycle through the available points.


Workflow

  • Create a simple render setup with the model of the object you want to map onto.
  • select the camSchnappr Camera COMP.
  • Optional: Drag your Camera COMP onto the Project Parameter of camSchnappr.
  • Drag the SOP containing the geometry of the to be mapped object onto the Geo SOP parameter.
  • Select the number of the output your Projector is connected to via the Output Monitor parameter.
  • Open the Main Window of camSchnappr by clicking the Open Main Window parameter.
  • Open the mapping Viewport by clicking the Open Output parameter, if somehow the output now overlays your main viewport, just hit escape and select a different Monitor Output number via the Output Monitor parameter.
  • In the main viewport align the geometry to the camera so it’s similar to what the projector sees.
  • Select a point in the main viewport and move it in the mapper viewport to the corresponding position on the real world object. You can also hold the Shift key and click in the mapper viewport onto the corresponding real world position.
  • Repeat the last step for at least 6 points total.
  • After you have aligned 6 points, the camera should be calibrated and you should see the projection mapped onto the object.
  • If everything is correct you can close the mapping output and the camSchnappr viewport by clicking the Close Output and Close camSchnappr parameter. The Camera Calibration values are saved inside your camSchnappr Project Camera COMP as 2 Table DATs.
  • If you used an externa Camera COMP as a project, you can now also delete camSchnappr.


Operator Outputs

  • Output 0 - When using multiple camSchnappr cameras, this output will be the blendmask between them.

TouchDesigner Build:

Palette
Palette • Palette:audioSet • Palette:battery • Palette:bloom • Palette:cameraBrowser • Palette:camSchnappr • Palette:changeColor • Palette:changeToColor • Palette:checker • Palette:chromaKey • Palette:colorThreshold • Palette:convolve • Palette:dent • Palette:depthExtract • Palette:dilate • Palette:feedback • Palette:feedbackEdge • Palette:geoPanel • Palette:gestureCapture • Palette:hsvBlur • Palette:imageSearch • Palette:julia • Palette:kantanMapper • Palette:kinectPointcloud • Palette:leapPaint • Palette:lightTunnel • Palette:mandelbrot • Palette:mesh • Palette:monochrome • Palette:motionSense • Palette:moviePlayer • Palette:noise • Palette:particlesGpu • Palette:pixelate • Palette:pixelRelocator • Palette:pointillize • Palette:popDialog • Palette:probe • Palette:pushPins • Palette:puzzle • Palette:radialBlur • Palette:remotePanel • Palette:rgbaBlur • Palette:rgbaDelay • Palette:rgbContrast • Palette:searchReplace • Palette:sharpen • Palette:softenAlpha • Palette:solarize • Palette:stitcher • Palette:stoner • Palette:superFormula • Palette:sweetSpotPreviz • Palette:TDVR • Palette:transitMap • Palette:twirl • Palette:webBrowser • Palette:xyScope

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

An Operator Family that reads, creates and modifies 3D polygons, curves, NURBS surfaces, spheres, meatballs and other 3D surface data.

An Operator Family that associates a shader with a SOP or Geometry Object for rendering textured and lit objects.

Parameters in TouchDesigner are an operator's settings (numbers, menus, flags, strings, paths) which the user can alter. Parameters for any operator can be opened by right-clicking on the operator and selecting "Parameters..." A currently selected operator's parameters can be viewed in a Network Editor by pressing the keyboard shortcut 'p'.

Strictly refers to a window in Microsoft Windows. User-created windows are made with Panels inside Window Components, aside from the TouchDesigner editor window and its dialogs.

An Operator Family that creates, composites and modifies images, and reads/writes images and movies to/from files and the network. TOPs run on the graphics card's GPU.

Each SOP has a list of Points. Each point has an XYZ 3D position value plus other optional attributes. Each polygon Primitive is defined by a vertex list, which is list of point numbers.

A built-in panel in TouchDesigner that contains a library of components and media that can be dragged-dropped into a TouchDesigner network.