ARTKBlender is Python module providing access to ARToolKit library in Blender and Blender Game Engine. Its functionality is focused to fulfill needs for augmented reality support in Blender, therefore it’s quite limited (for now at least). Module’s API mimics structures and interfaces from ARToolKit, simplifying naming where possible.
Main class for data processing. Detects visual markers on images.
ARHandle(ARParam param, int pixelFormat) – creates object from parameter object and pixel format. Available pixel formats are defined in ARPixelFormat enumeration.
pixelFormat: int, read only – type of processed pixel format as defined in constructor.
attachPatt: ARPattHandle, read/write – attached handle for list of detection patterns.
markers: list of ARMarkerInfo, read only – list of detected markers generated by call to detect() method.
detect(image) – detects appearance of patterns in image. If detection failed, returns False. Returning True doesn’t guarantee it has detected any markers. As parameter can be used python buffer or Blender bgl.Buffer object.
Class storing camera parameters.
size: tuple of int, read/write – sizes of camera image (width, height).
matrix: tuple of floats 3×4, read only – camera view matrix.
distFactor: tuple of floats, read only – distorsion factors of camera image.
load(fileName) – loads camera parameters from file. File contains ARToolKit definition of camera parameters. Default file is from ARToolKit, which also provides tool for camera calibration.
Class storing patterns for markers detection.
load(fileName) – loads pattern definition from file (usually has „.patt“ extension). Returns index for loaded pattern or -1 if load failed.
Class storing data for identified marker.
id: int, read only – index of pattern loaded in ARPattHandle object.
cf: float, read only – detection confidence value in range <0.0; 1.0> defines quality of pattern detection. The higher value is better.
Class for calculation of 3D data from detected markers. Transformation matrices calculated in object’s methods can be directly used by blender’s mathutils.Matrix constructor.
AR3DHandle(ARParam param) – creates object from parameter object.
getTransMatSquare(marker, width) – calculates transformation matrix for provided ARMarkerInfo using defined size of pattern square. Returns matrix as tuple of rows of floats or None if calculation failed.
getTransMatSquareCont(marker, width, prevMat) – calculates transformation matrix for provided ARMarkerInfo using defined size of pattern square and previous transformation matrix. Returns matrix as tuple of rows of floats or None if calculation failed. Argument prevMat is tuple of rows of floats, can be prepared from blender’s mathutils.Matrix object.
Enumeration class defining pixel format values:
INVALID, ABGR, ARGB, BGR, BGRA, MONO, NV21, RGB, RGBA, RGBA_4444, RGBA_5551, RGB_565, UYVY, YUY2, _420f, _420v
It’s necessary to use proper pixel format to correctly analyse provided video frames.