Namespace for the python scripting package.
Data between c++ and python is transferred through generic a Object. This module provides support for generic data types as well as for various CVB types. Depending on the type, instances are transported either using shared the ownership or a a deep copy. Types may loose the status of some cached members. For pointer based types always the most derived type is used for storage in the object. When retrieving pointer based types always an instance of the most derived type is created and automatically cast to the requested type. Enum classes are stored as 64 bit integer.
- Example
- Using a python for some flexible image processing (process.py). Here pixel format conversion is implmented in python.
import cvb
class Converter:
def __init__(self, src_format, dst_format, size):
self._converter = cvb.PixelFormatConverter(src_format, dst_format)
self._dst_image = cvb.Image.from_pixel_format(size, dst_format)
def run(self, src_image):
self._converter.execute(src_image, self._dst_image)
return self._dst_image
Using the converter form C++ is done like this:
context->AppendToSysPath(processPath);
auto processModule = context->Import(CVB_LIT("process"));
auto typeObj = processModule->Attribute(CVB_LIT("Converter"));
auto converterObj = typeObj->Run(*converterArgs);
auto runMethod = converterObj->Attribute(CVB_LIT("run"));
static ContextPtr CreateOrGet()
Creates a context.
Definition decl_context.hpp:50
static ObjectPtr MakeTuple(T &&...args)
Creates tuple with the given types.
Definition decl_object.hpp:682
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
std::shared_ptr< Image > ImagePtr
Convenience shared pointer for Image.
Definition global.hpp:86
- Interface
- List of supported types to transfer from and to python.
Special type:
- list: dynamic list (see Object for details)
- tuple: argument passing (see Object for details)
Generic types:
- bool: copy 1 byte
- integer: copy 8 byte
- unsigned integer: copy 8 byte
- floating point: copy 8 byte
- string: both byte or wide are supported, with terminator
CVB types:
- Composite: shared as handle
- DataType: copy 4 byte
- DensePointCloud: shared as handle
- Image: shared as handle (includes unsupported child classes)
- MultiPartImage: shared as handle
- PFNCBuffer: shared as handle
- Plane: shared as handle
- SparsePointCloud: shared as handle
- Circle: copy 24 byte
- GenICamDevice: shared as handle (missing resource locator)
- CompositeStream: shared as handle
- ImageStream: shared as handle
- PointCloudStream: shared as handle
- BooleanNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- CategoryNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- CommandNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- EnumEntryNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- EnumerationNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- FloatNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- FloatRegNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- IntRegNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- IntegerNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- Node: receive in c++ only (no NodeMaps, no events, no dependent nodes)
- NodeMap: shared as handle (no name and description, no parent)
- NodeMapEnumerator: shared as handle
- SelectorNode: receive in c++ only (no NodeMaps, no events, no dependent nodes)
- StringNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- StringRegNode: shared as handle (no NodeMaps, no events, no dependent nodes)
- ValueNode: receive in c++ only (no NodeMaps, no events, no dependent nodes)
- AffineMatrix2D: copy Point2D + Matrix2D
- AffineMatrix3D: copy Point3D + Matrix3D
- Angle: copy 9 byte
- Cuboid: copy 3 x ValueRange
- Line2D: copy Point2D + 8 byte
- Matrix2D: copy 4 x 8 byte
- Matrix3DH: copy 16 x 8 byte
- Matrix3D: copy 9 x 8 byte
- Plane3D: copy Point3D + 8 byte
- Point2D: copy 16 byte
- Point3D: copy 24 byte
- Point3DH: copy 32 byte
- PointCloud: receive in c++ only
- Rect: copy 32 byte
- RectLT: copy 32 byte
- Size2D: copy 16 byte
- ValueRange: copy 16 byte