src/p/y/py_examples-HEAD/opencv/CVtypes.py py_examples(Download)
# --- Importe ---------------------------------------------------------------- import ctypes, os from ctypes import Structure, Union, POINTER, SetPointerType, CFUNCTYPE, cdll, byref from ctypes import c_char_p, c_double, c_float, c_byte, c_ubyte, c_int, c_void_p, c_ulong from ctypes import c_uint32, c_short, c_char, c_longlong
class CvMatNDdata(Union):
_fields_ = [("ptr", POINTER(c_ubyte)),
("s", POINTER(c_short)),
("i", POINTER(c_int)),
("fl", POINTER(c_float)),
("db", POINTER(c_double))]
class CvMatNDdim(Structure):
("next", c_void_p)]
# Memory storage
_lpCvMemStorage = POINTER("CvMemStorage")
class CvMemStorage(Structure):
_fields_ = [("signature", c_int),
("bottom", c_void_p),
("block_max", c_void_p),
("ptr", c_void_p),
("delta_elems", c_int),
("storage", POINTER(CvMemStorage)),
("free_blocks", c_void_p),
("first", c_void_p)]
class CvConnectedComp(_Structure):
_fields_ = [('area', c_double),
('value', CvScalar),
('rect', CvRect),
('contour', POINTER(CvSeq))]
class CvMOMENTS(Structure):
# --- 1.1 Initialization -----------------------------------------------------
# Creates header and allocates data
cvCreateImage = cfunc('cvCreateImage', _cxDLL, POINTER(IplImage),
('size', CvSize, 1), # CvSize size
('depth', c_int, 1), # int depth
('channels', c_int, 1), # int channels
)
# Allocates, initializes, and returns structure IplImage
cvCreateImageHeader = cfunc('cvCreateImageHeader', _cxDLL, POINTER(IplImage),
# Releases header
cvReleaseImageHeader = cfunc('cvReleaseImageHeader', _cxDLL, None,
('image', ByRefArg(POINTER(IplImage)), 1), # IplImage** image
)
# Releases header and image data
cvReleaseImage = cfunc('cvReleaseImage', _cxDLL, None,
('image', ByRefArg(POINTER(IplImage)), 1), # IplImage** image
)
# Initializes allocated by user image header
cvInitImageHeader = cfunc('cvInitImageHeader', _cxDLL, POINTER(IplImage),
('image', POINTER(IplImage), 1), # IplImage* image
)
# Makes a full copy of image
cvCloneImage = cfunc('cvCloneImage', _cxDLL, POINTER(IplImage),
('image', POINTER(IplImage), 1), # const IplImage* image
)
# Sets channel of interest to given value
cvSetImageCOI = cfunc('cvSetImageCOI', _cxDLL, None,
('image', POINTER(IplImage), 1), # IplImage* image
# Returns index of channel of interest
cvGetImageCOI = cfunc('cvGetImageCOI', _cxDLL, c_int,
('image', POINTER(IplImage), 1), # const IplImage* image
)
# Sets image ROI to given rectangle
cvSetImageROI = cfunc('cvSetImageROI', _cxDLL, None,
('image', POINTER(IplImage), 1), # IplImage* image
# Releases image ROI
cvResetImageROI = cfunc('cvResetImageROI', _cxDLL, None,
('image', POINTER(IplImage), 1), # IplImage* image
)
# Returns image ROI coordinates
cvGetImageROI = cfunc('cvGetImageROI', _cxDLL, CvRect,
('image', POINTER(IplImage), 1), # const IplImage* image
)
# Creates new matrix
cvCreateMat = cfunc('cvCreateMat', _cxDLL, POINTER(CvMat),
)
# Creates new matrix header
cvCreateMatHeader = cfunc('cvCreateMatHeader', _cxDLL, POINTER(CvMat),
('rows', c_int, 1), # int rows
('cols', c_int, 1), # int cols
('type', c_int, 1), # int type
)
# Deallocates matrix
cvReleaseMat = cfunc('cvReleaseMat', _cxDLL, None,
('mat', ByRefArg(POINTER(CvMat)), 1), # CvMat** mat
)
# Initializes matrix header
cvInitMatHeader = cfunc('cvInitMatHeader', _cxDLL, POINTER(CvMat),
('mat', POINTER(CvMat), 1), # CvMat* mat
('rows', c_int, 1), # int rows
('cols', c_int, 1), # int cols
('type', c_int, 1), # int type
('data', c_void_p, 1, None), # void* data
('step', c_int, 1), # int step
)
# Creates matrix copy
cvCloneMat = cfunc('cvCloneMat', _cxDLL, POINTER(CvMat),
# Creates matrix copy
cvCloneMat = cfunc('cvCloneMat', _cxDLL, POINTER(CvMat),
('mat', POINTER(CvMat), 1), # const CvMat* mat
)
# Creates multi-dimensional dense array
cvCreateMatND = cfunc('cvCreateMatND', _cxDLL, POINTER(CvMatND),
('dims', c_int, 1), # int dims
('sizes', POINTER(c_int), 1), # const int* sizes
)
# Creates new matrix header
cvCreateMatNDHeader = cfunc('cvCreateMatNDHeader', _cxDLL, POINTER(CvMatND),
('dims', c_int, 1), # int dims
('sizes', POINTER(c_int), 1), # const int* sizes
('type', c_int, 1), # int type
)
# Initializes multi-dimensional array header
cvInitMatNDHeader = cfunc('cvInitMatNDHeader', _cxDLL, POINTER(CvMatND),
('mat', POINTER(CvMatND), 1), # CvMatND* mat
('dims', c_int, 1), # int dims
('sizes', POINTER(c_int), 1), # const int* sizes
)
# Creates full copy of multi-dimensional array
cvCloneMatND = cfunc('cvCloneMatND', _cxDLL, POINTER(CvMatND),
('mat', POINTER(CvMatND), 1), # const CvMatND* mat
)
# Retrieves low-level information about the array
cvGetRawData = cfunc('cvGetRawData', _cxDLL, None,
('arr', c_void_p, 1), # const CvArr* arr
('data', POINTER(POINTER(c_byte)), 1), # uchar** data
('step', POINTER(c_int), 1, None), # int* step
('roi_size', POINTER(CvSize), 1, None), # CvSize* roi_size
)
# Returns matrix header for arbitrary array
cvGetMat = cfunc('cvGetMat', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('header', POINTER(CvMat), 1), # CvMat* header
('coi', POINTER(c_int), 1, None), # int* coi
)
# Returns image header for arbitrary array
cvGetImage = cfunc('cvGetImage', _cxDLL, POINTER(IplImage),
('arr', c_void_p, 1), # const CvArr* arr
('image_header', POINTER(IplImage), 1), # IplImage* image_header
)
# Creates sparse array
cvCreateSparseMat = cfunc('cvCreateSparseMat', _cxDLL, POINTER(CvSparseMat),
('dims', c_int, 1), # int dims
('sizes', POINTER(c_int), 1), # const int* sizes
# Deallocates sparse array
cvReleaseSparseMat = cfunc('cvReleaseSparseMat', _cxDLL, None,
('mat', ByRefArg(POINTER(CvSparseMat)), 1), # CvSparseMat** mat
)
# Creates full copy of sparse array
cvCloneSparseMat = cfunc('cvCloneSparseMat', _cxDLL, POINTER(CvSparseMat),
('mat', POINTER(CvSparseMat), 1), # const CvSparseMat* mat
# --- 1.2 Accessing Elements and sub-Arrays ----------------------------------
# Returns matrix header corresponding to the rectangular sub-array of input image or matrix
cvGetSubRect = cfunc('cvGetSubRect', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('submat', POINTER(CvMat), 2), # CvMat* submat
('rect', CvRect, 1), # CvRect rect
)
# Returns array row or row span
cvGetRows = cfunc('cvGetRows', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('submat', POINTER(CvMat), 1), # CvMat* submat
)
# Returns array column or column span
cvGetCols = cfunc('cvGetCols', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('submat', POINTER(CvMat), 1), # CvMat* submat
('start_col', c_int, 1), # int start_col
('end_col', c_int, 1), # int end_col
)
# Returns one of array diagonals
cvGetDiag = cfunc('cvGetDiag', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('submat', POINTER(CvMat), 1), # CvMat* submat
# Return number of array dimensions and their sizes or the size of particular dimension
cvGetDims = cfunc('cvGetDims', _cxDLL, c_int,
('arr', c_void_p, 1), # const CvArr* arr
('sizes', POINTER(c_int), 1, None), # int* sizes
)
cvGetDimSize = cfunc('cvGetDimSize', _cxDLL, c_int,
cvPtr1D = cfunc('cvPtr1D', _cxDLL, c_void_p,
('arr', c_void_p, 1), # const CvArr* arr
('idx0', c_int, 1), # int idx0
('type', POINTER(c_int), 1, None), # int* type
)
cvPtr2D = cfunc('cvPtr2D', _cxDLL, c_void_p,
('arr', c_void_p, 1), # const CvArr* arr
('idx0', c_int, 1), # int idx0
('idx1', c_int, 1), # int idx1
('type', POINTER(c_int), 1, None), # int* type
('idx0', c_int, 1), # int idx0
('idx1', c_int, 1), # int idx1
('idx2', c_int, 1), # int idx2
('type', POINTER(c_int), 1, None), # int* type
)
cvPtrND = cfunc('cvPtrND', _cxDLL, c_void_p,
('arr', c_void_p, 1), # const CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
('type', POINTER(c_int), 1, None), # int* type
('create_node', c_int, 1, 1), # int create_node
('precalc_hashval', POINTER(c_uint32), 1, None), # unsigned* precalc_hashval
cvGetND = cfunc('cvGetND', _cxDLL, CvScalar,
('arr', c_void_p, 1), # const CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
)
# Return the particular element of single-channel array
cvGetRealND = cfunc('cvGetRealND', _cxDLL, c_double,
('arr', c_void_p, 1), # const CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
)
# Change the particular array element
cvSetND = cfunc('cvSetND', _cxDLL, None,
('arr', c_void_p, 1), # CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
('value', CvScalar, 1), # CvScalar value
)
cvSetRealND = cfunc('cvSetRealND', _cxDLL, None,
('arr', c_void_p, 1), # CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
('value', c_double, 1), # double value
)
# Clears the particular array element
cvClearND = cfunc('cvClearND', _cxDLL, None,
('arr', c_void_p, 1), # CvArr* arr
('idx', POINTER(c_int), 1), # int* idx
# --- 1.4 Transforms and Permutations ----------------------------------------
# Changes shape of matrix/image without copying data
cvReshape = cfunc('cvReshape', _cxDLL, POINTER(CvMat),
('arr', c_void_p, 1), # const CvArr* arr
('header', POINTER(CvMat), 1), # CvMat* header
('new_cn', c_int, 1), # int new_cn
('header', c_void_p, 1), # CvArr* header
('new_cn', c_int, 1), # int new_cn
('new_dims', c_int, 1), # int new_dims
('new_sizes', POINTER(c_int), 1), # int* new_sizes
)
# Fill destination array with tiled source array
# Calculates average (mean) of array elements
cvAvgSdv = cfunc('cvAvgSdv', _cxDLL, None,
('arr', c_void_p, 1), # const CvArr* arr
('mean', POINTER(CvScalar), 1), # CvScalar* mean
('std_dev', POINTER(CvScalar), 1), # CvScalar* std_dev
('mask', c_void_p, 1, None), # const CvArr* mask
)
## ]
cvMinMaxLoc = cfunc('cvMinMaxLoc', _cxDLL, None,
('image', POINTER(IplImage), 1),
('min_val', POINTER(c_double), 2),
('max_val', POINTER(c_double), 2),
('min_loc', POINTER(CvPoint), 2),
('max_loc', POINTER(CvPoint), 2),
cvTransform = cfunc('cvTransform', _cxDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('transmat', POINTER(CvMat), 1), # const CvMat* transmat
('shiftvec', POINTER(CvMat), 1, None), # const CvMat* shiftvec
)
# Performs perspective matrix transform of vector array
cvPerspectiveTransform = cfunc('cvPerspectiveTransform', _cxDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('mat', POINTER(CvMat), 1), # const CvMat* mat
# Calculates covariation matrix of the set of vectors
cvCalcCovarMatrix = cfunc('cvCalcCovarMatrix', _cxDLL, None,
('vects', POINTER(c_void_p), 1), # const CvArr** vects
('count', c_int, 1), # int count
('cov_mat', c_void_p, 1), # CvArr* cov_mat
('avg', c_void_p, 1), # CvArr* avg
# --- 2.1 Memory Storages ----------------------------------------------------
# Creates memory storage
cvCreateMemStorage = cfunc('cvCreateMemStorage', _cxDLL, POINTER(CvMemStorage),
('block_size', c_int, 1, 0), # int block_size
)
# Creates child memory storage
cvCreateChildMemStorage = cfunc('cvCreateChildMemStorage', _cxDLL, POINTER(CvMemStorage),
('parent', POINTER(CvMemStorage), 1), # CvMemStorage* parent
# Releases memory storage
cvReleaseMemStorage = cfunc('cvReleaseMemStorage', _cxDLL, None,
('storage', POINTER(POINTER(CvMemStorage)), 1), # CvMemStorage** storage
)
# Clears memory storage
cvClearMemStorage = cfunc('cvClearMemStorage', _cxDLL, None,
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Allocates memory buffer in the storage
cvMemStorageAlloc = cfunc('cvMemStorageAlloc', _cxDLL, c_void_p,
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
# Allocates text string in the storage
cvMemStorageAllocString = cfunc('cvMemStorageAllocString', _cxDLL, CvString,
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('ptr', c_char_p, 1), # const char* ptr
('len', c_int, 1), # int len
)
# Saves memory storage position
cvSaveMemStoragePos = cfunc('cvSaveMemStoragePos', _cxDLL, None,
('storage', POINTER(CvMemStorage), 1), # const CvMemStorage* storage
('pos', POINTER(CvMemStoragePos), 1), # CvMemStoragePos* pos
# Restores memory storage position
cvRestoreMemStoragePos = cfunc('cvRestoreMemStoragePos', _cxDLL, None,
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('pos', POINTER(CvMemStoragePos), 1), # CvMemStoragePos* pos
)
# --- 2.2 Sequences ----------------------------------------------------------
# Creates sequence
cvCreateSeq = cfunc('cvCreateSeq', _cxDLL, POINTER(CvSeq),
('seq_flags', c_int, 1), # int seq_flags
('header_size', c_int, 1), # int header_size
('elem_size', c_int, 1), # int elem_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Sets up sequence block size
cvSetSeqBlockSize = cfunc('cvSetSeqBlockSize', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Adds element to sequence end
cvSeqPush = cfunc('cvSeqPush', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('element', c_void_p, 1, None), # void* element
)
# Removes element from sequence end
cvSeqPop = cfunc('cvSeqPop', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Adds element to sequence beginning
cvSeqPushFront = cfunc('cvSeqPushFront', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('element', c_void_p, 1, None), # void* element
)
# Removes element from sequence beginning
cvSeqPopFront = cfunc('cvSeqPopFront', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Pushes several elements to the either end of sequence
cvSeqPushMulti = cfunc('cvSeqPushMulti', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('elements', c_void_p, 1), # void* elements
('count', c_int, 1), # int count
('in_front', c_int, 1, 0), # int in_front
)
# Removes several elements from the either end of sequence
cvSeqPopMulti = cfunc('cvSeqPopMulti', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Inserts element in sequence middle
cvSeqInsert = cfunc('cvSeqInsert', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('before_index', c_int, 1), # int before_index
('element', c_void_p, 1, None), # void* element
)
# Removes element from sequence middle
cvSeqRemove = cfunc('cvSeqRemove', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Clears sequence
cvClearSeq = cfunc('cvClearSeq', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
)
# Returns pointer to sequence element by its index
cvGetSeqElem = cfunc('cvGetSeqElem', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
def CV_GET_SEQ_ELEM(TYPE, seq, index):
result = cvGetSeqElem(seq)
return cast(result, POINTER(TYPE))
# Returns index of concrete sequence element
cvSeqElemIdx = cfunc('cvSeqElemIdx', _cxDLL, c_int,
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
('element', c_void_p, 1), # const void* element
('block', POINTER(POINTER(CvSeqBlock)), 1, None), # CvSeqBlock** block
)
# Copies sequence to one continuous block of memory
cvCvtSeqToArray = cfunc('cvCvtSeqToArray', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
)
# Constructs sequence from array
cvMakeSeqHeaderForArray = cfunc('cvMakeSeqHeaderForArray', _cxDLL, POINTER(CvSeq),
('seq_type', c_int, 1), # int seq_type
('header_size', c_int, 1), # int header_size
('elem_size', c_int, 1), # int elem_size
('elements', c_void_p, 1), # void* elements
('total', c_int, 1), # int total
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('block', POINTER(CvSeqBlock), 1), # CvSeqBlock* block
)
# Makes separate header for the sequence slice
cvSeqSlice = cfunc('cvSeqSlice', _cxDLL, POINTER(CvSeq),
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
('slice', CvSlice, 1), # CvSlice slice
('storage', POINTER(CvMemStorage), 1, None), # CvMemStorage* storage
('copy_data', c_int, 1, 0), # int copy_data
)
# Removes sequence slice
cvSeqRemoveSlice = cfunc('cvSeqRemoveSlice', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Inserts array in the middle of sequence
cvSeqInsertSlice = cfunc('cvSeqInsertSlice', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('before_index', c_int, 1), # int before_index
('from_arr', c_void_p, 1), # const CvArr* from_arr
)
# Reverses the order of sequence elements
cvSeqInvert = cfunc('cvSeqInvert', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
# Sorts sequence element using the specified comparison function
cvSeqSort = cfunc('cvSeqSort', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('func', CvCmpFunc, 1), # CvCmpFunc func
('userdata', c_void_p, 1, None), # void* userdata
)
# Searches element in sequence
cvSeqSearch = cfunc('cvSeqSearch', _cxDLL, c_void_p,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('elem', c_void_p, 1), # const void* elem
('func', CvCmpFunc, 1), # CvCmpFunc func
('is_sorted', c_int, 1), # int is_sorted
('elem_idx', POINTER(c_int), 1), # int* elem_idx
('userdata', c_void_p, 1, None), # void* userdata
)
# Initializes process of writing data to sequence
cvStartAppendToSeq = cfunc('cvStartAppendToSeq', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # CvSeq* seq
('writer', POINTER(CvSeqWriter), 1), # CvSeqWriter* writer
('seq_flags', c_int, 1), # int seq_flags
('header_size', c_int, 1), # int header_size
('elem_size', c_int, 1), # int elem_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('writer', POINTER(CvSeqWriter), 1), # CvSeqWriter* writer
)
# Finishes process of writing sequence
cvEndWriteSeq = cfunc('cvEndWriteSeq', _cxDLL, POINTER(CvSeq),
('writer', POINTER(CvSeqWriter), 1), # CvSeqWriter* writer
# Updates sequence headers from the writer state
cvFlushSeqWriter = cfunc('cvFlushSeqWriter', _cxDLL, None,
('writer', POINTER(CvSeqWriter), 1), # CvSeqWriter* writer
)
# Initializes process of sequential reading from sequence
cvStartReadSeq = cfunc('cvStartReadSeq', _cxDLL, None,
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
('reader', POINTER(CvSeqReader), 1), # CvSeqReader* reader
# Returns the current reader position
cvGetSeqReaderPos = cfunc('cvGetSeqReaderPos', _cxDLL, c_int,
('reader', POINTER(CvSeqReader), 1), # CvSeqReader* reader
)
# Moves the reader to specified position
cvSetSeqReaderPos = cfunc('cvSetSeqReaderPos', _cxDLL, None,
('reader', POINTER(CvSeqReader), 1), # CvSeqReader* reader
# --- 2.3 Sets ---------------------------------------------------------------
# Creates empty set
cvCreateSet = cfunc('cvCreateSet', _cxDLL, POINTER(CvSET),
('set_flags', c_int, 1), # int set_flags
('header_size', c_int, 1), # int header_size
('elem_size', c_int, 1), # int elem_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Occupies a node in the set
cvSetAdd = cfunc('cvSetAdd', _cxDLL, c_int,
('set_header', POINTER(CvSET), 1), # CvSet* set_header
('elem', POINTER(CvSetElem), 1, None), # CvSetElem* elem
cvSetAdd = cfunc('cvSetAdd', _cxDLL, c_int,
('set_header', POINTER(CvSET), 1), # CvSet* set_header
('elem', POINTER(CvSetElem), 1, None), # CvSetElem* elem
('inserted_elem', POINTER(POINTER(CvSetElem)), 1, None), # CvSetElem** inserted_elem
)
# Removes element from set
cvSetRemove = cfunc('cvSetRemove', _cxDLL, None,
('set_header', POINTER(CvSET), 1), # CvSet* set_header
# Clears set
cvClearSet = cfunc('cvClearSet', _cxDLL, None,
('set_header', POINTER(CvSET), 1), # CvSet* set_header
)
# --- 2.4 Graphs -------------------------------------------------------------
# Creates empty graph
cvCreateGraph = cfunc('cvCreateGraph', _cxDLL, POINTER(CvGraph),
('header_size', c_int, 1), # int header_size
('vtx_size', c_int, 1), # int vtx_size
('edge_size', c_int, 1), # int edge_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Adds vertex to graph
cvGraphAddVtx = cfunc('cvGraphAddVtx', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('vtx', POINTER(CvGraphVtx), 1, None), # const CvGraphVtx* vtx
('inserted_vtx', POINTER(POINTER(CvGraphVtx)), 1, None), # CvGraphVtx** inserted_vtx
# Removes vertex from graph
cvGraphRemoveVtx = cfunc('cvGraphRemoveVtx', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('index', c_int, 1), # int index
)
# Removes vertex from graph
cvGraphRemoveVtxByPtr = cfunc('cvGraphRemoveVtxByPtr', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* vtx
# Adds edge to graph
cvGraphAddEdge = cfunc('cvGraphAddEdge', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('start_idx', c_int, 1), # int start_idx
('end_idx', c_int, 1), # int end_idx
('edge', POINTER(CvGraphEdge), 1, None), # const CvGraphEdge* edge
('inserted_edge', POINTER(POINTER(CvGraphEdge)), 1, None), # CvGraphEdge** inserted_edge
)
# Adds edge to graph
cvGraphAddEdgeByPtr = cfunc('cvGraphAddEdgeByPtr', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('start_vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* start_vtx
cvGraphAddEdgeByPtr = cfunc('cvGraphAddEdgeByPtr', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('start_vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* start_vtx
('end_vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* end_vtx
('edge', POINTER(CvGraphEdge), 1, None), # const CvGraphEdge* edge
('inserted_edge', POINTER(POINTER(CvGraphEdge)), 1, None), # CvGraphEdge** inserted_edge
)
# Removes edge from graph
cvGraphRemoveEdge = cfunc('cvGraphRemoveEdge', _cxDLL, None,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
# Removes edge from graph
cvGraphRemoveEdgeByPtr = cfunc('cvGraphRemoveEdgeByPtr', _cxDLL, None,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('start_vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* start_vtx
('end_vtx', POINTER(CvGraphVtx), 1), # CvGraphVtx* end_vtx
)
# Finds edge in graph
cvFindGraphEdge = cfunc('cvFindGraphEdge', _cxDLL, POINTER(CvGraphEdge),
('graph', POINTER(CvGraph), 1), # const CvGraph* graph
)
# Finds edge in graph
cvFindGraphEdgeByPtr = cfunc('cvFindGraphEdgeByPtr', _cxDLL, POINTER(CvGraphEdge),
('graph', POINTER(CvGraph), 1), # const CvGraph* graph
('start_vtx', POINTER(CvGraphVtx), 1), # const CvGraphVtx* start_vtx
('end_vtx', POINTER(CvGraphVtx), 1), # const CvGraphVtx* end_vtx
)
# Counts edges indicent to the vertex
cvGraphVtxDegree = cfunc('cvGraphVtxDegree', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # const CvGraph* graph
# Finds edge in graph
cvGraphVtxDegreeByPtr = cfunc('cvGraphVtxDegreeByPtr', _cxDLL, c_int,
('graph', POINTER(CvGraph), 1), # const CvGraph* graph
('vtx', POINTER(CvGraphVtx), 1), # const CvGraphVtx* vtx
)
# Clears graph
cvClearGraph = cfunc('cvClearGraph', _cxDLL, None,
('graph', POINTER(CvGraph), 1), # CvGraph* graph
)
# Clone graph
cvCloneGraph = cfunc('cvCloneGraph', _cxDLL, POINTER(CvGraph),
# Clone graph
cvCloneGraph = cfunc('cvCloneGraph', _cxDLL, POINTER(CvGraph),
('graph', POINTER(CvGraph), 1), # const CvGraph* graph
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Creates structure for depth-first graph traversal
cvCreateGraphScanner = cfunc('cvCreateGraphScanner', _cxDLL, POINTER(CvGraphScanner),
('graph', POINTER(CvGraph), 1), # CvGraph* graph
('vtx', POINTER(CvGraphVtx), 1, None), # CvGraphVtx* vtx
# Makes one or more steps of the graph traversal procedure
cvNextGraphItem = cfunc('cvNextGraphItem', _cxDLL, c_int,
('scanner', POINTER(CvGraphScanner), 1), # CvGraphScanner* scanner
)
# Finishes graph traversal procedure
cvReleaseGraphScanner = cfunc('cvReleaseGraphScanner', _cxDLL, None,
('scanner', POINTER(POINTER(CvGraphScanner)), 1), # CvGraphScanner** scanner
# Initializes tree node iterator
cvInitTreeNodeIterator = cfunc('cvInitTreeNodeIterator', _cxDLL, None,
('tree_iterator', POINTER(CvTreeNodeIterator), 1), # CvTreeNodeIterator* tree_iterator
('first', c_void_p, 1), # const void* first
('max_level', c_int, 1), # int max_level
)
# Returns the currently observed node and moves iterator toward the next node
cvNextTreeNode = cfunc('cvNextTreeNode', _cxDLL, c_void_p,
('tree_iterator', POINTER(CvTreeNodeIterator), 1), # CvTreeNodeIterator* tree_iterator
# Returns the currently observed node and moves iterator toward the previous node
cvPrevTreeNode = cfunc('cvPrevTreeNode', _cxDLL, c_void_p,
('tree_iterator', POINTER(CvTreeNodeIterator), 1), # CvTreeNodeIterator* tree_iterator
)
# Gathers all node pointers to the single sequence
cvTreeToNodeSeq = cfunc('cvTreeToNodeSeq', _cxDLL, POINTER(CvSeq),
('first', c_void_p, 1), # const void* first
('header_size', c_int, 1), # int header_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
# Fills polygons interior
cvFillPoly = cfunc('cvFillPoly', _cxDLL, None,
('img', c_void_p, 1), # CvArr* img
('pts', POINTER(POINTER(CvPoint)), 1), # CvPoint** pts
('npts', POINTER(c_int), 1), # int* npts
('contours', c_int, 1), # int contours
('color', CvScalar, 1), # CvScalar color
# Fills convex polygon
cvFillConvexPoly = cfunc('cvFillConvexPoly', _cxDLL, None,
('img', c_void_p, 1), # CvArr* img
('pts', POINTER(CvPoint), 1), # CvPoint* pts
('npts', c_int, 1), # int npts
('color', CvScalar, 1), # CvScalar color
('line_type', c_int, 1, 8), # int line_type
('shift', c_int, 1, 0), # int shift
)
# Draws simple or thick polygons
cvPolyLine = cfunc('cvPolyLine', _cxDLL, None,
('img', c_void_p, 1), # CvArr* img
('pts', POINTER(POINTER(CvPoint)), 1), # CvPoint** pts
cvPolyLine = cfunc('cvPolyLine', _cxDLL, None,
('img', c_void_p, 1), # CvArr* img
('pts', POINTER(POINTER(CvPoint)), 1), # CvPoint** pts
('npts', POINTER(c_int), 1), # int* npts
('contours', c_int, 1), # int contours
('is_closed', c_int, 1), # int is_closed
('color', CvScalar, 1), # CvScalar color
# Initializes font structure
cvInitFont = cfunc('cvInitFont', _cxDLL, None,
('font', POINTER(CvFont), 2), # CvFont* font
('font_face', c_int, 1), # int font_face
('hscale', c_double, 1), # double hscale
('vscale', c_double, 1), # double vscale
('img', c_void_p, 1), # CvArr* img
('text', c_char_p, 1), # const char* text
('org', CvPoint, 1), # CvPoint org
('font', POINTER(CvFont), 1), # const CvFont* font
('color', CvScalar, 1), # CvScalar color
)
# Retrieves width and height of text string
cvGetTextSize = cfunc('cvGetTextSize', _cxDLL, None,
('text_string', c_char_p, 1), # const char* text_string
('font', POINTER(CvFont), 1), # const CvFont* font
('text_size', POINTER(CvSize), 1), # CvSize* text_size
('baseline', POINTER(c_int), 1), # int* baseline
# Draws contour outlines or interiors in the image
cvDrawContours = cfunc('cvDrawContours', _cxDLL, None,
('img', c_void_p, 1), # CvArr* img
('contour', POINTER(CvSeq), 1), # CvSeq* contour
('external_color', CvScalar, 1), # CvScalar external_color
('hole_color', CvScalar, 1), # CvScalar hole_color
('max_level', c_int, 1), # int max_level
('image', c_void_p, 1), # const CvArr* image
('pt1', CvPoint, 1), # CvPoint pt1
('pt2', CvPoint, 1), # CvPoint pt2
('line_iterator', POINTER(CvLineIterator), 1), # CvLineIterator* line_iterator
('connectivity', c_int, 1, 8), # int connectivity
('left_to_right', c_int, 1, 0), # int left_to_right
)
# Clips the line against the image rectangle
cvClipLine = cfunc('cvClipLine', _cxDLL, c_int,
('img_size', CvSize, 1), # CvSize img_size
('pt1', POINTER(CvPoint), 1), # CvPoint* pt1
('pt2', POINTER(CvPoint), 1), # CvPoint* pt2
('angle', c_int, 1), # int angle
('arc_start', c_int, 1), # int arc_start
('arc_end', c_int, 1), # int arc_end
('pts', POINTER(CvPoint), 1), # CvPoint* pts
('delta', c_int, 1), # int delta
)
# --- 4 Data Persistence and RTTI --------------------------------------------
# --- 4.1 File Storage -------------------------------------------------------
# Opens file storage for reading or writing data
cvOpenFileStorage = cfunc('cvOpenFileStorage', _cxDLL, POINTER(CvFileStorage),
# Opens file storage for reading or writing data
cvOpenFileStorage = cfunc('cvOpenFileStorage', _cxDLL, POINTER(CvFileStorage),
('filename', c_char_p, 1), # const char* filename
('memstorage', POINTER(CvMemStorage), 1), # CvMemStorage* memstorage
('flags', c_int, 1), # int flags
)
# Releases file storage
cvReleaseFileStorage = cfunc('cvReleaseFileStorage', _cxDLL, None,
('fs', POINTER(POINTER(CvFileStorage)), 1), # CvFileStorage** fs
# Starts writing a new structure
cvStartWriteStruct = cfunc('cvStartWriteStruct', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('name', c_char_p, 1), # const char* name
('struct_flags', c_int, 1), # int struct_flags
('type_name', c_char_p, 1, None), # const char* type_name
('attributes', CvAttrList, 1), # CvAttrList attributes
)
# Ends writing a structure
cvEndWriteStruct = cfunc('cvEndWriteStruct', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
# Writes an integer value
cvWriteInt = cfunc('cvWriteInt', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('name', c_char_p, 1), # const char* name
('value', c_int, 1), # int value
)
# Writes a floating-point value
cvWriteReal = cfunc('cvWriteReal', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
# Writes a text string
cvWriteString = cfunc('cvWriteString', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('name', c_char_p, 1), # const char* name
('str', c_char_p, 1), # const char* str
('quote', c_int, 1, 0), # int quote
)
# Writes comment
cvWriteComment = cfunc('cvWriteComment', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
# Starts the next stream
cvStartNextStream = cfunc('cvStartNextStream', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
)
# Writes user object
cvWrite = cfunc('cvWrite', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
# Writes multiple numbers
cvWriteRawData = cfunc('cvWriteRawData', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('src', c_void_p, 1), # const void* src
('len', c_int, 1), # int len
('dt', c_char_p, 1), # const char* dt
)
# Writes file node to another file storage
cvWriteFileNode = cfunc('cvWriteFileNode', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('new_node_name', c_char_p, 1), # const char* new_node_name
('node', POINTER(CvFileNode), 1), # const CvFileNode* node
# --- 4.3 Reading Data -------------------------------------------------------
# Retrieves one of top-level nodes of the file storage
cvGetRootFileNode = cfunc('cvGetRootFileNode', _cxDLL, POINTER(CvFileNode),
('fs', POINTER(CvFileStorage), 1), # const CvFileStorage* fs
('stream_index', c_int, 1, 0), # int stream_index
)
# Finds node in the map or file storage
cvGetFileNodeByName = cfunc('cvGetFileNodeByName', _cxDLL, POINTER(CvFileNode),
('fs', POINTER(CvFileStorage), 1), # const CvFileStorage* fs
('map', POINTER(CvFileNode), 1), # const CvFileNode* map
)
# Returns a unique pointer for given name
cvGetHashedKey = cfunc('cvGetHashedKey', _cxDLL, POINTER(CvStringHashNode),
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('name', c_char_p, 1), # const char* name
('len', c_int, 1), # int len
('create_missing', c_int, 1, 0), # int create_missing
)
# Finds node in the map or file storage
cvGetFileNode = cfunc('cvGetFileNode', _cxDLL, POINTER(CvFileNode),
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('map', POINTER(CvFileNode), 1), # CvFileNode* map
cvGetFileNode = cfunc('cvGetFileNode', _cxDLL, POINTER(CvFileNode),
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('map', POINTER(CvFileNode), 1), # CvFileNode* map
('key', POINTER(CvStringHashNode), 1), # const CvStringHashNode* key
('create_missing', c_int, 1, 0), # int create_missing
)
# Returns name of file node
cvGetFileNodeName = cfunc('cvGetFileNodeName', _cxDLL, c_char_p,
('node', POINTER(CvFileNode), 1), # const CvFileNode* node
# Decodes object and returns pointer to it
cvRead = cfunc('cvRead', _cxDLL, c_void_p,
('fs', POINTER(CvFileStorage), 1), # CvFileStorage* fs
('node', POINTER(CvFileNode), 1), # CvFileNode* node
('attributes', POINTER(CvAttrList), 1, None), # CvAttrList* attributes
)
# Reads multiple numbers
cvReadRawData = cfunc('cvReadRawData', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # const CvFileStorage* fs
('src', POINTER(CvFileNode), 1), # const CvFileNode* src
# Initializes file node sequence reader
cvStartReadRawData = cfunc('cvStartReadRawData', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # const CvFileStorage* fs
('src', POINTER(CvFileNode), 1), # const CvFileNode* src
('reader', POINTER(CvSeqReader), 1), # CvSeqReader* reader
)
# Initializes file node sequence reader
cvReadRawDataSlice = cfunc('cvReadRawDataSlice', _cxDLL, None,
('fs', POINTER(CvFileStorage), 1), # const CvFileStorage* fs
('reader', POINTER(CvSeqReader), 1), # CvSeqReader* reader
# Registers new type
cvRegisterType = cfunc('cvRegisterType', _cxDLL, None,
('info', POINTER(CvTypeInfo), 1), # const CvTypeInfo* info
)
# Unregisters the type
cvUnregisterType = cfunc('cvUnregisterType', _cxDLL, None,
('type_name', c_char_p, 1), # const char* type_name
)
# Returns the beginning of type list
cvFirstType = cfunc('cvFirstType', _cxDLL, POINTER(CvTypeInfo),
)
# Finds type by its name
cvFindType = cfunc('cvFindType', _cxDLL, POINTER(CvTypeInfo),
('type_name', c_char_p, 1), # const char* type_name
)
# Returns type of the object
cvTypeOf = cfunc('cvTypeOf', _cxDLL, POINTER(CvTypeInfo),
# Releases the object
cvRelease = cfunc('cvRelease', _cxDLL, None,
('struct_ptr', POINTER(c_void_p), 1), # void** struct_ptr
)
# Makes a clone of the object
# Loads object from file
cvLoad = cfunc('cvLoad', _cxDLL, c_void_p,
('filename', c_char_p, 1), # const char* filename
('memstorage', POINTER(CvMemStorage), 1, None), # CvMemStorage* memstorage
('name', c_char_p, 1, None), # const char* name
('real_name', POINTER(c_char_p), 1, None), # const char** real_name
)
# Load and cast to given type
def cvLoadCast(filename, ctype):
'''Use cvLoad and then cast the result to ctype'''
return ctypes.cast(cvLoad(filename), ctypes.POINTER(ctype))
# Splits sequence into equivalency classes
cvSeqPartition = cfunc('cvSeqPartition', _cxDLL, c_int,
('seq', POINTER(CvSeq), 1), # const CvSeq* seq
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('labels', POINTER(POINTER(CvSeq)), 1), # CvSeq** labels
('is_equal', CvCmpFunc, 1), # CvCmpFunc is_equal
cvRedirectError = cfunc('cvRedirectError', _cxDLL, CvErrorCallback,
('error_handler', CvErrorCallback, 1), # CvErrorCallback error_handler
('userdata', c_void_p, 1, None), # void* userdata
('prev_userdata', POINTER(c_void_p), 1, None), # void** prev_userdata
)
# Provide standard error handling
# Registers another module
cvRegisterModule = cfunc('cvRegisterModule', _cxDLL, c_int,
('module_info', POINTER(CvModuleInfo), 1), # const CvModuleInfo* module_info
)
# Retrieves information about the registered module(s) and plugins
cvGetModuleInfo = cfunc('cvGetModuleInfo', _cxDLL, None,
('module_name', c_char_p, 1), # const char* module_name
('version', POINTER(c_char_p), 1), # const char** version
('loaded_addon_plugins', POINTER(c_char_p), 1), # const char** loaded_addon_plugins
# Refines corner locations
cvFindCornerSubPix = cfunc('cvFindCornerSubPix', _cvDLL, None,
('image', c_void_p, 1), # const CvArr* image
('corners', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* corners
('count', c_int, 1), # int count
('win', CvSize, 1), # CvSize win
('zero_zone', CvSize, 1), # CvSize zero_zone
('image', c_void_p, 1), # const CvArr* image
('eig_image', c_void_p, 1), # CvArr* eig_image
('temp_image', c_void_p, 1), # CvArr* temp_image
('corners', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* corners
('corner_count', POINTER(c_int), 1), # int* corner_count
('quality_level', c_double, 1), # double quality_level
('min_distance', c_double, 1), # double min_distance
cvGetQuadrangleSubPix = cfunc('cvGetQuadrangleSubPix', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('map_matrix', POINTER(CvMat), 1), # const CvMat* map_matrix
)
# Resizes image
cvWarpAffine = cfunc('cvWarpAffine', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('map_matrix', POINTER(CvMat), 1), # const CvMat* map_matrix
('flags', c_int, 1), # int flags
('fillval', CvScalar, 1), # CvScalar fillval
)
# Calculates affine matrix of 2d rotation
cv2DRotationMatrix = cfunc('cv2DRotationMatrix', _cvDLL, POINTER(CvMat),
('center', CvPoint2D32f, 1), # CvPoint2D32f center
('angle', c_double, 1), # double angle
('scale', c_double, 1), # double scale
('map_matrix', POINTER(CvMat), 1), # CvMat* map_matrix
cvWarpPerspective = cfunc('cvWarpPerspective', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('map_matrix', POINTER(CvMat), 1), # const CvMat* map_matrix
('flags', c_int, 1), # int flags
('fillval', CvScalar, 1), # CvScalar fillval
)
# Calculates perspective transform from 4 corresponding points
cvGetPerspectiveTransform = cfunc('cvGetPerspectiveTransform', _cvDLL, POINTER(CvMat),
('src', POINTER(CvPoint2D32f), 1), # const CvPoint2D32f* src
('dst', POINTER(CvPoint2D32f), 1), # const CvPoint2D32f* dst
('map_matrix', POINTER(CvMat), 1), # CvMat* map_matrix
('anchor_x', c_int, 1), # int anchor_x
('anchor_y', c_int, 1), # int anchor_y
('shape', c_int, 1), # int shape
('values', POINTER(c_int), 1, None), # int* values
)
# Deletes structuring element
cvReleaseStructuringElement = cfunc('cvReleaseStructuringElement', _cvDLL, None,
('element', POINTER(POINTER(IplConvKernel)), 1), # IplConvKernel** element
cvErode = cfunc('cvErode', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('element', POINTER(IplConvKernel), 1, None), # IplConvKernel* element
('iterations', c_int, 1, 1), # int iterations
)
# Dilates image by using arbitrary structuring element
cvDilate = cfunc('cvDilate', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('element', POINTER(IplConvKernel), 1, None), # IplConvKernel* element
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('temp', c_void_p, 1), # CvArr* temp
('element', POINTER(IplConvKernel), 1), # IplConvKernel* element
('operation', c_int, 1), # int operation
('iterations', c_int, 1, 1), # int iterations
)
cvFilter2D = cfunc('cvFilter2D', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('kernel', POINTER(CvMat), 1), # const CvMat* kernel
('anchor', CvPoint, 1), # CvPoint anchor
)
# Implements image segmentation by pyramids
cvPyrSegmentation = cfunc('cvPyrSegmentation', _cvDLL, None,
('src', POINTER(IplImage), 1), # IplImage* src
('dst', POINTER(IplImage), 1), # IplImage* dst
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('comp', POINTER(POINTER(CvSeq)), 1), # CvSeq** comp
('new_val', CvScalar, 1), # CvScalar new_val
('lo_diff', CvScalar, 1), # CvScalar lo_diff
('up_diff', CvScalar, 1), # CvScalar up_diff
('comp', POINTER(CvConnectedComp), 1, None), # CvConnectedComp* comp
('flags', c_int, 1, 4), # int flags
('mask', c_void_p, 1, None), # CvArr* mask
)
# Finds contours in binary image
cvFindContours = cfunc('cvFindContours', _cvDLL, c_int,
('image', c_void_p, 1), # CvArr* image
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('first_contour', POINTER(POINTER(CvSeq)), 1), # CvSeq** first_contour
('header_size', c_int, 1), # int header_size
('mode', c_int, 1), # int mode
# Initializes contour scanning process
cvStartFindContours = cfunc('cvStartFindContours', _cvDLL, CvContourScanner,
('image', c_void_p, 1), # CvArr* image
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('header_size', c_int, 1), # int header_size
('mode', c_int, 1), # int mode
('method', c_int, 1), # int method
('offset', CvPoint, 1), # CvPoint offset
)
# Finds next contour in the image
cvFindNextContour = cfunc('cvFindNextContour', _cvDLL, POINTER(CvSeq),
# Replaces retrieved contour
cvSubstituteContour = cfunc('cvSubstituteContour', _cvDLL, None,
('scanner', CvContourScanner, 1), # CvContourScanner scanner
('new_contour', POINTER(CvSeq), 1), # CvSeq* new_contour
)
# Finishes scanning process
cvEndFindContours = cfunc('cvEndFindContours', _cvDLL, POINTER(CvSeq),
('scanner', POINTER(CvContourScanner), 1), # CvContourScanner* scanner
# Calculates all moments up to third order of a polygon or rasterized shape
cvMoments = cfunc('cvMoments', _cvDLL, None,
('arr', c_void_p, 1), # const CvArr* arr
('moments', POINTER(CvMOMENTS), 1), # CvMoments* moments
('binary', c_int, 1, 0), # int binary
)
# Retrieves spatial moment from moment state structure
cvGetSpatialMoment = cfunc('cvGetSpatialMoment', _cvDLL, c_double,
('moments', POINTER(CvMOMENTS), 1), # CvMoments* moments
# Retrieves central moment from moment state structure
cvGetCentralMoment = cfunc('cvGetCentralMoment', _cvDLL, c_double,
('moments', POINTER(CvMOMENTS), 1), # CvMoments* moments
('x_order', c_int, 1), # int x_order
('y_order', c_int, 1), # int y_order
)
# Retrieves normalized central moment from moment state structure
cvGetNormalizedCentralMoment = cfunc('cvGetNormalizedCentralMoment', _cvDLL, c_double,
('moments', POINTER(CvMOMENTS), 1), # CvMoments* moments
# Calculates seven Hu invariants
cvGetHuMoments = cfunc('cvGetHuMoments', _cvDLL, None,
('moments', POINTER(CvMOMENTS), 1), # CvMoments* moments
('hu_moments', POINTER(CvHuMoments), 1), # CvHuMoments* hu_moments
)
# --- 1.8 Special Image Transforms -------------------------------------------
# Finds lines in binary image using Hough transform
cvHoughLines2 = cfunc('cvHoughLines2', _cvDLL, POINTER(CvSeq),
)
# Finds circles in grayscale image using Hough transform
cvHoughCircles = cfunc('cvHoughCircles', _cvDLL, POINTER(CvSeq),
('image', c_void_p, 1), # CvArr* image
('circle_storage', c_void_p, 1), # void* circle_storage
('method', c_int, 1), # int method
('dst', c_void_p, 1), # CvArr* dst
('distance_type', c_int, 1), # int distance_type
('mask_size', c_int, 1, 3), # int mask_size
('mask', POINTER(c_float), 1, None), # const float* mask
('labels', c_void_p, 1, None), # CvArr* labels
)
# --- 1.9 Histograms ---------------------------------------------------------
CV_HIST_ARRAY = 0
CV_HIST_SPARSE = 1
# Creates histogram
cvCreateHist = cfunc('cvCreateHist', _cvDLL, POINTER(CvHistogram),
# Sets bounds of histogram bins
cvSetHistBinRanges = cfunc('cvSetHistBinRanges', _cvDLL, None,
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
('ranges', ListPOINTER2(c_float), 1), # float** ranges
('uniform', c_int, 1, 1), # int uniform
)
# Releases histogram
cvReleaseHist = cfunc('cvReleaseHist', _cvDLL, None,
('hist', ByRefArg(POINTER(CvHistogram)), 1), # CvHistogram** hist
# Clears histogram
cvClearHist = cfunc('cvClearHist', _cvDLL, None,
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
)
# Makes a histogram out of array
cvMakeHistHeaderForArray = cfunc('cvMakeHistHeaderForArray', _cvDLL, POINTER(CvHistogram),
('dims', c_int, 1), # int dims
('sizes', POINTER(c_int), 1), # int* sizes
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
('data', POINTER(c_float), 1), # float* data
# Finds minimum and maximum histogram bins
cvGetMinMaxHistValue = cfunc('cvGetMinMaxHistValue', _cvDLL, None,
('hist', POINTER(CvHistogram), 1), # const CvHistogram* hist
('min_value', POINTER(c_float), 2), # float* min_value
('max_value', POINTER(c_float), 2), # float* max_value
('min_idx', POINTER(c_int), 2), # int* min_idx
('max_idx', POINTER(c_int), 2), # int* max_idx
)
# Normalizes histogram
cvNormalizeHist = cfunc('cvNormalizeHist', _cvDLL, None,
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
# Thresholds histogram
cvThreshHist = cfunc('cvThreshHist', _cvDLL, None,
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
('threshold', c_double, 1), # double threshold
)
# Compares two dense histograms
cvCompareHist = cfunc('cvCompareHist', _cvDLL, c_double,
('hist1', POINTER(CvHistogram), 1), # const CvHistogram* hist1
('hist2', POINTER(CvHistogram), 1), # const CvHistogram* hist2
('method', c_int, 1), # int method
)
# Copies histogram
cvCopyHist = cfunc('cvCopyHist', _cvDLL, None,
('src', POINTER(CvHistogram), 1), # const CvHistogram* src
('dst', POINTER(POINTER(CvHistogram)), 1), # CvHistogram** dst
# Calculate the histogram
cvCalcHist = cfunc('cvCalcArrHist', _cvDLL, None,
('image', ListPOINTER(POINTER(IplImage)), 1), # IplImage** image
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
('accumulate', c_int, 1, 0), # int accumulate
('mask', c_void_p, 1, None), # CvArr* mask
)
# Calculates back projection
cvCalcBackProject = cfunc('cvCalcArrBackProject', _cvDLL, None,
('image', ListPOINTER(POINTER(IplImage)), 1), # IplImage** image
('back_project', POINTER(IplImage), 1), # IplImage* back_project
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
# Divides one histogram by another
cvCalcProbDensity = cfunc('cvCalcProbDensity', _cvDLL, None,
('hist1', POINTER(CvHistogram), 1), # const CvHistogram* hist1
('hist2', POINTER(CvHistogram), 1), # const CvHistogram* hist2
('dst_hist', POINTER(CvHistogram), 1), # CvHistogram* dst_hist
('scale', c_double, 1, 255), # double scale
('distance_func', CvDistanceFunction, 1, None), # CvDistanceFunction distance_func
('cost_matrix', c_void_p, 1, None), # const CvArr* cost_matrix
('flow', c_void_p, 1, None), # CvArr* flow
('lower_bound', POINTER(c_float), 1, None), # float* lower_bound
('userdata', c_void_p, 1, None), # void* userdata
)
# --- 2 Structural Analysis --------------------------------------------------
# --- 2.1 Contour Processing Functions ---------------------------------------
# Approximates Freeman chain(s) with polygonal curve
cvApproxChains = cfunc('cvApproxChains', _cvDLL, POINTER(CvSeq),
('src_seq', POINTER(CvSeq), 1), # CvSeq* src_seq
# Approximates Freeman chain(s) with polygonal curve
cvApproxChains = cfunc('cvApproxChains', _cvDLL, POINTER(CvSeq),
('src_seq', POINTER(CvSeq), 1), # CvSeq* src_seq
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('method', c_int, 1), # int method
('parameter', c_double, 1, 0), # double parameter
('minimal_perimeter', c_int, 1, 0), # int minimal_perimeter
('recursive', c_int, 1, 0), # int recursive
)
# Initializes chain reader
cvStartReadChainPoints = cfunc('cvStartReadChainPoints', _cvDLL, None,
('chain', POINTER(CvChain), 1), # CvChain* chain
('reader', POINTER(CvChainPtReader), 1), # CvChainPtReader* reader
# Gets next chain point
cvReadChainPoint = cfunc('cvReadChainPoint', _cvDLL, CvPoint,
('reader', POINTER(CvChainPtReader), 1), # CvChainPtReader* reader
)
# Approximates polygonal curve(s) with desired precision
cvApproxPoly = cfunc('cvApproxPoly', _cvDLL, POINTER(CvSeq),
('src_seq', c_void_p, 1), # const void* src_seq
('header_size', c_int, 1), # int header_size
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
)
# Creates hierarchical representation of contour
cvCreateContourTree = cfunc('cvCreateContourTree', _cvDLL, POINTER(CvContourTree),
('contour', POINTER(CvSeq), 1), # const CvSeq* contour
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('threshold', c_double, 1), # double threshold
)
# Restores contour from tree
cvContourFromContourTree = cfunc('cvContourFromContourTree', _cvDLL, POINTER(CvSeq),
('tree', POINTER(CvContourTree), 1), # const CvContourTree* tree
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
# Compares two contours using their tree representations
cvMatchContourTrees = cfunc('cvMatchContourTrees', _cvDLL, c_double,
('tree1', POINTER(CvContourTree), 1), # const CvContourTree* tree1
('tree2', POINTER(CvContourTree), 1), # const CvContourTree* tree2
('method', c_int, 1), # int method
('threshold', c_double, 1), # double threshold
)
# --- 2.2 Computational Geometry ---------------------------------------------
# Finds bounding rectangle for two given rectangles
cvMaxRect = cfunc('cvMaxRect', _cvDLL, CvRect,
('rect1', POINTER(CvRect), 1), # const CvRect* rect1
# Finds bounding rectangle for two given rectangles
cvMaxRect = cfunc('cvMaxRect', _cvDLL, CvRect,
('rect1', POINTER(CvRect), 1), # const CvRect* rect1
('rect2', POINTER(CvRect), 1), # const CvRect* rect2
)
# Initializes point sequence header from a point vector
cvPointSeqFromMat = cfunc('cvPointSeqFromMat', _cvDLL, POINTER(CvSeq),
('seq_kind', c_int, 1), # int seq_kind
('mat', c_void_p, 1), # const CvArr* mat
('contour_header', POINTER(CvContour), 1), # CvContour* contour_header
('block', POINTER(CvSeqBlock), 1), # CvSeqBlock* block
('param', c_double, 1), # double param
('reps', c_double, 1), # double reps
('aeps', c_double, 1), # double aeps
('line', POINTER(c_float), 1), # float* line
)
# Finds convex hull of point set
cvConvexHull2 = cfunc('cvConvexHull2', _cvDLL, POINTER(CvSeq),
)
# Finds convexity defects of contour
cvConvexityDefects = cfunc('cvConvexityDefects', _cvDLL, POINTER(CvSeq),
('contour', c_void_p, 1), # const CvArr* contour
('convexhull', c_void_p, 1), # const CvArr* convexhull
('storage', POINTER(CvMemStorage), 1, None), # CvMemStorage* storage
# Finds circumscribed rectangle of minimal area for given 2D point set
cvMinAreaRect2 = cfunc('cvMinAreaRect2', _cvDLL, CvBox2D,
('points', c_void_p, 1), # const CvArr* points
('storage', POINTER(CvMemStorage), 1, None), # CvMemStorage* storage
)
# Finds circumscribed circle of minimal area for given 2D point set
cvMinEnclosingCircle = cfunc('cvMinEnclosingCircle', _cvDLL, c_int,
('points', c_void_p, 1), # const CvArr* points
('center', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* center
('radius', POINTER(c_float), 1), # float* radius
# Calculates pair-wise geometrical histogram for contour
cvCalcPGH = cfunc('cvCalcPGH', _cvDLL, None,
('contour', POINTER(CvSeq), 1), # const CvSeq* contour
('hist', POINTER(CvHistogram), 1), # CvHistogram* hist
)
# --- 2.3 Planar Subdivisions ------------------------------------------------
# Inserts a single point to Delaunay triangulation
cvSubdivDelaunay2DInsert = cfunc('cvSubdivDelaunay2DInsert', _cvDLL, POINTER(CvSubdiv2DPoint),
('subdiv', POINTER(CvSubdiv2D), 1), # CvSubdiv2D* subdiv
# Inserts a single point to Delaunay triangulation
cvSubdiv2DLocate = cfunc('cvSubdiv2DLocate', _cvDLL, CvSubdiv2DPointLocation,
('subdiv', POINTER(CvSubdiv2D), 1), # CvSubdiv2D* subdiv
('pt', CvPoint2D32f, 1), # CvPoint2D32f pt
('edge', POINTER(CvSubdiv2DEdge), 1), # CvSubdiv2DEdge* edge
('vertex', POINTER(POINTER(CvSubdiv2DPoint)), 1, None), # CvSubdiv2DPoint** vertex
)
# Finds the closest subdivision vertex to given point
cvFindNearestPoint2D = cfunc('cvFindNearestPoint2D', _cvDLL, POINTER(CvSubdiv2DPoint),
('subdiv', POINTER(CvSubdiv2D), 1), # CvSubdiv2D* subdiv
# Calculates coordinates of Voronoi diagram cells
cvCalcSubdivVoronoi2D = cfunc('cvCalcSubdivVoronoi2D', _cvDLL, None,
('subdiv', POINTER(CvSubdiv2D), 1), # CvSubdiv2D* subdiv
)
# Removes all virtual points
cvClearSubdivVoronoi2D = cfunc('cvClearSubdivVoronoi2D', _cvDLL, None,
('subdiv', POINTER(CvSubdiv2D), 1), # CvSubdiv2D* subdiv
)
# Segments whole motion into separate moving parts
cvSegmentMotion = cfunc('cvSegmentMotion', _cvDLL, POINTER(CvSeq),
('mhi', c_void_p, 1), # const CvArr* mhi
('seg_mask', c_void_p, 1), # CvArr* seg_mask
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
('prob_image', c_void_p, 1), # const CvArr* prob_image
('window', CvRect, 1), # CvRect window
('criteria', CvTermCriteria, 1), # CvTermCriteria criteria
('comp', POINTER(CvConnectedComp), 1), # CvConnectedComp* comp
)
# Finds object center, size, and orientation
cvCamShift = cfunc('cvCamShift', _cvDLL, c_int,
('prob_image', c_void_p, 1), # const CvArr* prob_image
('window', CvRect, 1), # CvRect window
('criteria', CvTermCriteria, 1), # CvTermCriteria criteria
('comp', POINTER(CvConnectedComp), 2), # CvConnectedComp* comp
('box', POINTER(CvBox2D), 2), # CvBox2D* box
# Changes contour position to minimize its energy
cvSnakeImage = cfunc('cvSnakeImage', _cvDLL, None,
('image', POINTER(IplImage), 1), # const IplImage* image
('points', POINTER(CvPoint), 1), # CvPoint* points
('length', c_int, 1), # int length
('alpha', POINTER(c_float), 1), # float* alpha
('beta', POINTER(c_float), 1), # float* beta
('gamma', POINTER(c_float), 1), # float* gamma
('curr', c_void_p, 1), # const CvArr* curr
('prev_pyr', c_void_p, 1), # CvArr* prev_pyr
('curr_pyr', c_void_p, 1), # CvArr* curr_pyr
('prev_features', POINTER(CvPoint2D32f), 1), # const CvPoint2D32f* prev_features
('curr_features', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* curr_features
('count', c_int, 1), # int count
('win_size', CvSize, 1), # CvSize win_size
('level', c_int, 1), # int level
('status', c_char_p, 1), # char* status
('track_error', POINTER(c_float), 1), # float* track_error
# --- 3.5 Estimators ---------------------------------------------------------
# Allocates Kalman filter structure
cvCreateKalman = cfunc('cvCreateKalman', _cvDLL, POINTER(CvKalman),
('dynam_params', c_int, 1), # int dynam_params
('measure_params', c_int, 1), # int measure_params
('control_params', c_int, 1, 0), # int control_params
)
# Deallocates Kalman filter structure
cvReleaseKalman = cfunc('cvReleaseKalman', _cvDLL, None,
('kalman', POINTER(POINTER(CvKalman)), 1), # CvKalman** kalman
)
# Estimates subsequent model state
cvKalmanPredict = cfunc('cvKalmanPredict', _cvDLL, POINTER(CvMat),
('kalman', POINTER(CvKalman), 1), # CvKalman* kalman
('control', POINTER(CvMat), 1, None), # const CvMat* control
)
cvKalmanUpdateByTime = cvKalmanPredict
# Adjusts model state
cvKalmanCorrect = cfunc('cvKalmanCorrect', _cvDLL, POINTER(CvMat),
('kalman', POINTER(CvKalman), 1), # CvKalman* kalman
('measurement', POINTER(CvMat), 1), # const CvMat* measurement
cvKalmanUpdateByMeasurement = cvKalmanCorrect
# Allocates ConDensation filter structure
cvCreateConDensation = cfunc('cvCreateConDensation', _cvDLL, POINTER(CvConDensation),
('dynam_params', c_int, 1), # int dynam_params
('measure_params', c_int, 1), # int measure_params
('sample_count', c_int, 1), # int sample_count
)
# Deallocates ConDensation filter structure
cvReleaseConDensation = cfunc('cvReleaseConDensation', _cvDLL, None,
('condens', POINTER(POINTER(CvConDensation)), 1), # CvConDensation** condens
# Initializes sample set for ConDensation algorithm
cvConDensInitSampleSet = cfunc('cvConDensInitSampleSet', _cvDLL, None,
('condens', POINTER(CvConDensation), 1), # CvConDensation* condens
('lower_bound', POINTER(CvMat), 1), # CvMat* lower_bound
('upper_bound', POINTER(CvMat), 1), # CvMat* upper_bound
)
# Estimates subsequent model state
cvConDensUpdateByTime = cfunc('cvConDensUpdateByTime', _cvDLL, None,
('condens', POINTER(CvConDensation), 1), # CvConDensation* condens
# --- 4.1 Object Detection ---------------------------------------------------
# Loads a trained cascade classifier from file or the classifier database embedded in OpenCV
cvLoadHaarClassifierCascade = cfunc('cvLoadHaarClassifierCascade', _cvDLL, POINTER(CvHaarClassifierCascade),
('directory', c_char_p, 1), # const char* directory
('orig_window_size', CvSize, 1), # CvSize orig_window_size
)
# Releases haar classifier cascade
cvReleaseHaarClassifierCascade = cfunc('cvReleaseHaarClassifierCascade', _cvDLL, None,
('cascade', POINTER(POINTER(CvHaarClassifierCascade)), 1), # CvHaarClassifierCascade** cascade
)
# Detects objects in the image
cvHaarDetectObjects = cfunc('cvHaarDetectObjects', _cvDLL, POINTER(CvSeq),
('image', c_void_p, 1), # const CvArr* image
('cascade', POINTER(CvHaarClassifierCascade), 1), # CvHaarClassifierCascade* cascade
('storage', POINTER(CvMemStorage), 1), # CvMemStorage* storage
def ChangeCvSeqToCvRect(result, func, args):
'''Handle the casting to extract a list of Rects from the Seq returned'''
res = []
for i in xrange(result[0].total):
f = cvGetSeqElem(result, i)
r = ctypes.cast(f, ctypes.POINTER(CvRect))[0]
res.append(r)
return res
cvHaarDetectObjects.errcheck = ChangeCvSeqToCvRect
# Assigns images to the hidden cascade
cvSetImagesForHaarClassifierCascade = cfunc('cvSetImagesForHaarClassifierCascade', _cvDLL, None,
('cascade', POINTER(CvHaarClassifierCascade), 1), # CvHaarClassifierCascade* cascade
# Runs cascade of boosted classifier at given image location
cvRunHaarClassifierCascade = cfunc('cvRunHaarClassifierCascade', _cvDLL, c_int,
('cascade', POINTER(CvHaarClassifierCascade), 1), # CvHaarClassifierCascade* cascade
('pt', CvPoint, 1), # CvPoint pt
('start_stage', c_int, 1, 0), # int start_stage
)
# Projects 3D points to image plane
cvProjectPoints2 = cfunc('cvProjectPoints2', _cvDLL, None,
('object_points', POINTER(CvMat), 1), # const CvMat* object_points
('rotation_vector', POINTER(CvMat), 1), # const CvMat* rotation_vector
('translation_vector', POINTER(CvMat), 1), # const CvMat* translation_vector
('intrinsic_matrix', POINTER(CvMat), 1), # const CvMat* intrinsic_matrix
('distortion_coeffs', POINTER(CvMat), 1), # const CvMat* distortion_coeffs
('image_points', POINTER(CvMat), 1), # CvMat* image_points
('dpdrot', POINTER(CvMat), 1, None), # CvMat* dpdrot
('dpdt', POINTER(CvMat), 1, None), # CvMat* dpdt
('dpdf', POINTER(CvMat), 1, None), # CvMat* dpdf
('dpdc', POINTER(CvMat), 1, None), # CvMat* dpdc
('dpddist', POINTER(CvMat), 1, None), # CvMat* dpddist
# Finds perspective transformation between two planes
cvFindHomography = cfunc('cvFindHomography', _cvDLL, None,
('src_points', POINTER(CvMat), 1), # const CvMat* src_points
('dst_points', POINTER(CvMat), 1), # const CvMat* dst_points
('homography', POINTER(CvMat), 1), # CvMat* homography
)
# Finds intrinsic and extrinsic camera parameters using calibration pattern
cvCalibrateCamera2 = cfunc('cvCalibrateCamera2', _cvDLL, None,
('object_points', POINTER(CvMat), 1), # const CvMat* object_points
('image_points', POINTER(CvMat), 1), # const CvMat* image_points
('point_counts', POINTER(CvMat), 1), # const CvMat* point_counts
('image_points', POINTER(CvMat), 1), # const CvMat* image_points
('point_counts', POINTER(CvMat), 1), # const CvMat* point_counts
('image_size', CvSize, 1), # CvSize image_size
('intrinsic_matrix', POINTER(CvMat), 1), # CvMat* intrinsic_matrix
('distortion_coeffs', POINTER(CvMat), 1), # CvMat* distortion_coeffs
('rotation_vectors', POINTER(CvMat), 1, None), # CvMat* rotation_vectors
('translation_vectors', POINTER(CvMat), 1, None), # CvMat* translation_vectors
('flags', c_int, 1, 0), # int flags
)
# Finds extrinsic camera parameters for particular view
cvFindExtrinsicCameraParams2 = cfunc('cvFindExtrinsicCameraParams2', _cvDLL, None,
('object_points', POINTER(CvMat), 1), # const CvMat* object_points
('image_points', POINTER(CvMat), 1), # const CvMat* image_points
cvFindExtrinsicCameraParams2 = cfunc('cvFindExtrinsicCameraParams2', _cvDLL, None,
('object_points', POINTER(CvMat), 1), # const CvMat* object_points
('image_points', POINTER(CvMat), 1), # const CvMat* image_points
('intrinsic_matrix', POINTER(CvMat), 1), # const CvMat* intrinsic_matrix
('distortion_coeffs', POINTER(CvMat), 1), # const CvMat* distortion_coeffs
('rotation_vector', POINTER(CvMat), 1), # CvMat* rotation_vector
('translation_vector', POINTER(CvMat), 1), # CvMat* translation_vector
)
# Converts rotation matrix to rotation vector or vice versa
cvRodrigues2 = cfunc('cvRodrigues2', _cvDLL, c_int,
('src', POINTER(CvMat), 1), # const CvMat* src
('dst', POINTER(CvMat), 1), # CvMat* dst
('jacobian', POINTER(CvMat), 1, 0), # CvMat* jacobian
cvUndistort2 = cfunc('cvUndistort2', _cvDLL, None,
('src', c_void_p, 1), # const CvArr* src
('dst', c_void_p, 1), # CvArr* dst
('intrinsic_matrix', POINTER(CvMat), 1), # const CvMat* intrinsic_matrix
('distortion_coeffs', POINTER(CvMat), 1), # const CvMat* distortion_coeffs
)
# Computes undistorion map
cvInitUndistortMap = cfunc('cvInitUndistortMap', _cvDLL, None,
('intrinsic_matrix', POINTER(CvMat), 1), # const CvMat* intrinsic_matrix
('distortion_coeffs', POINTER(CvMat), 1), # const CvMat* distortion_coeffs
cvFindChessboardCorners = cfunc('cvFindChessboardCorners', _cvDLL, c_int,
('image', c_void_p, 1), # const void* image
('pattern_size', CvSize, 1), # CvSize pattern_size
('corners', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* corners
('corner_count', POINTER(c_int), 1, None), # int* corner_count
('flags', c_int, 1), # int flags
)
# Renders the detected chessboard corners
cvDrawChessboardCorners = cfunc('cvDrawChessboardCorners', _cvDLL, None,
('image', c_void_p, 1), # CvArr* image
('pattern_size', CvSize, 1), # CvSize pattern_size
('corners', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* corners
# --- 5.2 Pose Estimation ----------------------------------------------------
# Initializes structure containing object information
cvCreatePOSITObject = cfunc('cvCreatePOSITObject', _cvDLL, POINTER(CvPOSITObject),
('points', POINTER(CvPoint3D32f), 1), # CvPoint3D32f* points
('point_count', c_int, 1), # int point_count
)
# Implements POSIT algorithm
cvPOSIT = cfunc('cvPOSIT', _cvDLL, None,
('posit_object', POINTER(CvPOSITObject), 1), # CvPOSITObject* posit_object
('image_points', POINTER(CvPoint2D32f), 1), # CvPoint2D32f* image_points
# Deallocates 3D object structure
cvReleasePOSITObject = cfunc('cvReleasePOSITObject', _cvDLL, None,
('posit_object', POINTER(POINTER(CvPOSITObject)), 1), # CvPOSITObject** posit_object
)
# Calculates homography matrix for oblong planar object (e.g. arm)
cvCalcImageHomography = cfunc('cvCalcImageHomography', _cvDLL, None,
('line', POINTER(c_float), 1), # float* line
('center', POINTER(CvPoint3D32f), 1), # CvPoint3D32f* center
('intrinsic', POINTER(c_float), 1), # float* intrinsic
('homography', POINTER(c_float), 1), # float* homography
# Calculates fundamental matrix from corresponding points in two images
cvFindFundamentalMat = cfunc('cvFindFundamentalMat', _cvDLL, c_int,
('points1', POINTER(CvMat), 1), # const CvMat* points1
('points2', POINTER(CvMat), 1), # const CvMat* points2
('fundamental_matrix', POINTER(CvMat), 1), # CvMat* fundamental_matrix
('method', c_int, 1), # int method
('param1', c_double, 1, 1), # double param1
('param2', c_double, 1, 0), # double param2
('status', POINTER(CvMat), 1, None), # CvMat* status
# For points in one image of stereo pair computes the corresponding epilines in the other image
cvComputeCorrespondEpilines = cfunc('cvComputeCorrespondEpilines', _cvDLL, None,
('points', POINTER(CvMat), 1), # const CvMat* points
('which_image', c_int, 1), # int which_image
('fundamental_matrix', POINTER(CvMat), 1), # const CvMat* fundamental_matrix
('correspondent_lines', POINTER(CvMat), 1), # CvMat* correspondent_lines
cvCreateTrackbar = cfunc('cvCreateTrackbar', _hgDLL, c_int,
('trackbar_name', c_char_p, 1), # const char* trackbar_name
('window_name', c_char_p, 1), # const char* window_name
('value', POINTER(c_int), 1), # int* value
('count', c_int, 1), # int count
('on_change', CvTrackbarCallback, 1), # CvTrackbarCallback on_change
)
# --- 2 Loading and Saving Images --------------------------------------------
# Loads an image from file
cvLoadImage = cfunc('cvLoadImage', _hgDLL, POINTER(IplImage),
('filename', c_char_p, 1), # const char* filename
('iscolor', c_int, 1, 1), # int iscolor
)
# --- 3 Video I/O functions --------------------------------------------------
# Initializes capturing video from file
cvCreateFileCapture = cfunc('cvCreateFileCapture', _hgDLL, POINTER(CvCapture),
('filename', c_char_p, 1), # const char* filename
)
# Initializes capturing video from camera
cvCreateCameraCapture = cfunc('cvCreateCameraCapture', _hgDLL, POINTER(CvCapture),
# Releases the CvCapture structure
cvReleaseCapture = cfunc('cvReleaseCapture', _hgDLL, None,
('capture', POINTER(POINTER(CvCapture)), 1), # CvCapture** capture
)
# Grabs frame from camera or file
cvGrabFrame = cfunc('cvGrabFrame', _hgDLL, c_int,
('capture', POINTER(CvCapture), 1), # CvCapture* capture
)
# Gets the image grabbed with cvGrabFrame
cvRetrieveFrame = cfunc('cvRetrieveFrame', _hgDLL, POINTER(IplImage),
('capture', POINTER(CvCapture), 1), # CvCapture* capture
)
# Grabs and returns a frame from camera or file
cvQueryFrame = cfunc('cvQueryFrame', _hgDLL, POINTER(IplImage),
('capture', POINTER(CvCapture), 1), # CvCapture* capture
)
def CheckNonNull(result, func, args):
if not result:
raise RuntimeError, 'QueryFrame failed'
return args
# Gets video capturing properties
cvGetCaptureProperty = cfunc('cvGetCaptureProperty', _hgDLL, c_double,
('capture', POINTER(CvCapture), 1), # CvCapture* capture
# Sets video capturing properties
cvSetCaptureProperty = cfunc('cvSetCaptureProperty', _hgDLL, c_int,
('capture', POINTER(CvCapture), 1), # CvCapture* capture
('property_id', c_int, 1), # int property_id
('value', c_double, 1), # double value
)
# Creates video file writer
cvCreateVideoWriter = cfunc('cvCreateVideoWriter', _hgDLL, POINTER(CvVideoWriter),
# Releases AVI writer
cvReleaseVideoWriter = cfunc('cvReleaseVideoWriter', _hgDLL, None,
('writer', POINTER(POINTER(CvVideoWriter)), 1), # CvVideoWriter** writer
)
# Writes a frame to video file
cvWriteFrame = cfunc('cvWriteFrame', _hgDLL, c_int,
('writer', POINTER(CvVideoWriter), 1), # CvVideoWriter* writer
('image', POINTER(IplImage), 1), # const IplImage* image
# Initializes HighGUI
cvInitSystem = cfunc('cvInitSystem', _hgDLL, c_int,
('argc', c_int, 1), # int argc
('argv', POINTER(c_char_p), 1), # char** argv
)
CV_CVTIMG_SWAP_RB = 2
src/b/r/brash-HEAD/windef.py brash(Download)
#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #OTHER DEALINGS IN THE SOFTWARE. from ctypes import c_void_p, c_int64, c_uint64, c_int32, c_uint32, c_int16, c_uint16, c_int8, c_uint8, c_float, c_char, c_char_p, c_wchar, c_wchar_p, HRESULT, POINTER, WINFUNCTYPE, Structure, Union, windll import winlitecfg _dll = windll.ntdll
LPCVOID = LPVOID = c_void_p BOOL = c_int32 LPBOOL = PBOOL = POINTER(BOOL) BYTE = c_uint8 LPBYTE = PBYTE = POINTER(BYTE) UCHAR = c_uint8 PUCHAR = POINTER(UCHAR) WORD = c_uint16 LPWORD = PWORD = POINTER(WORD)
LPWORD = PWORD = POINTER(WORD) USHORT = c_uint16 PUSHORT = POINTER(USHORT) INT = c_int32 LPINT = PINT = POINTER(INT) UINT = c_uint32 PUINT = POINTER(UINT) FLOAT = c_float PFLOAT = POINTER(FLOAT)
PSZ = c_char_p LONG = c_uint32 LPLONG = PLONG = POINTER(LONG) DWORD = c_uint32 LPDWORD = PDWORD = POINTER(DWORD) ULONG = c_uint32 PULONG = POINTER(ULONG)
# typed defined in basetsd.h INT8 = c_int8 PINT8 = POINTER(INT8) INT16 = c_int16 PINT16 = POINTER(INT16) INT32 = c_int32 PINT32 = POINTER(INT32) INT64 = c_int64 PINT64 = POINTER(INT64) UINT8 = c_uint8 PUINT8 = POINTER(UINT8) UINT16 = c_uint16 PUINT16 = POINTER(UINT16)
UINT16 = c_uint16 PUINT16 = POINTER(UINT16) UINT32 = c_uint32 PUINT32 = POINTER(UINT32) UINT64 = c_uint64 PUINT64 = POINTER(UINT64) LONG32 = c_int32 PLONG32 = POINTER(LONG32) ULONG32 = c_uint32 PULONG32 = POINTER(ULONG32) DWORD32 = c_uint32 PDWORD32 = POINTER(DWORD32) LONG64 = c_int64 PLONG64 = POINTER(LONG64)
LONG64 = c_int64 PLONG64 = POINTER(LONG64) ULONG64 = c_uint64 PULONG64 = POINTER(ULONG64) DWORD64 = c_uint64 PDWORD64 = POINTER(DWORD64) INT_PTR = c_int32 PINT_PTR = POINTER(INT_PTR) UINT_PTR = c_uint32 PUINT_PTR = POINTER(UINT_PTR) LONG_PTR = c_uint32 PLONG_PTR = POINTER(LONG_PTR)
LONG_PTR = c_uint32 PLONG_PTR = POINTER(LONG_PTR) ULONG_PTR = c_uint32 PULONG_PTR = POINTER(ULONG_PTR) DWORD_PTR = c_uint32 PDWORD_PTR = POINTER(DWORD_PTR) MAXINT_PTR = 0x7fffffff MININT_PTR = 0x80000000 MAXUINT_PTR = 0xffffffff HALF_PTR = c_int16 PHALF_PTR = POINTER(HALF_PTR)
HALF_PTR = c_int16 PHALF_PTR = POINTER(HALF_PTR) UHALF_PTR = c_uint16 PUHALF_PTR = POINTER(UHALF_PTR) MAXUHALF_PTR = 0xffff MAXHALF_PTR = 0x7fff MINHALF_PTR = 0x8000 SSIZE_T = LONG_PTR PSSIZE_T = POINTER(SSIZE_T) SIZE_T = ULONG_PTR PSIZE_T = POINTER(SIZE_T)
PSIZE_T = POINTER(SIZE_T) KAFFINITY = ULONG_PTR PKAFFINITY = POINTER(KAFFINITY) # types defined in winnt.h PVOID = PVOID64 = c_void_p BOOLEAN = BYTE PBOOLEAN = POINTER(BOOLEAN) CHAR = c_char PCHAR = POINTER(CHAR)
PSHORT = c_uint16 WCHAR = c_wchar PWCHAR = POINTER(WCHAR) LONGLONG = c_int64 PLONGLONG = POINTER(LONGLONG) ULONGLONG = c_uint64 PULONGLONG = POINTER(ULONGLONG) DWORDLONG = LONGLONG PDWORDLONG = POINTER(DWORDLONG)
else:
TCHAR = WCHAR
PTCHAR = PTSTR = LPTSTR = PCTSTR = LPCTSTR = POINTER(TCHAR)
# TEXT is a macro for converting constant strings on windows, but here a string type will do nicely
TEXT = LPTSTR
CCHAR = c_char
LCID = DWORD
PLCID = POINTER(LCID)
# HRESULT = ctypes.HRESULT HANDLE = c_void_p PHANDLE = LPHANDLE = POINTER(HANDLE) FCHAR = BYTE FSHORT = WORD
('LowPart', DWORD),
('HighPart', LONG),
]
PLUID = POINTER(LUID)
#end winnt.h types
WPARAM = UINT_PTR
LPARAM = LONG_PTR
LRESULT = LONG_PTR
ATOM = WORD
COLORREF = DWORD
LPCOLORREF = POINTER(DWORD)
HICON = HANDLE HINSTANCE = HANDLE HKEY = HANDLE PHKEY = POINTER(HKEY) HKL = HANDLE HMENU = HANDLE HMETAFILE = HANDLE
('cx', LONG),
('cy', LONG),
]
PSIZE = LPSIZE = POINTER(SIZE)
SIZEL = SIZE
PSIZEL = LPSIZEL = POINTER(SIZEL)
class POINT(Structure):
_fields_ = [
('x', LONG),
('y', LONG),
]
PPOINT = LPPOINT = POINTER(POINT)
('x', LONG),
('y', LONG),
]
PPOINTL = POINTER(POINTL)
class POINTS(Structure):
_fields_ = [
('x', SHORT),
('y', SHORT),
]
PPOINTS = LPPOINTS = POINTER(POINTS)
('dwLowDateTime', DWORD),
('dwHighDateTime', DWORD),
]
PFILETIME = LPFILETIME = POINTER(FILETIME)
class RECT(Structure):
_fields_ = [
('left', LONG),
('top', LONG),
('right', LONG),
('bottom', LONG),
]
PRECT = LPRECT = LPCRECT = POINTER(RECT)
('right', LONG),
('bottom', LONG),
]
PRECTL = LPRECTL = LPCRECTL = POINTER(RECTL)
if winlitecfg.aw == 'W':
from ctypes import create_unicode_buffer as create_tchar_buffer
src/m/a/magickwand-0.2/magickwand/api/types.py magickwand(Download)
from ctypes import ( c_int,
c_uint,
c_ubyte,
c_ushort,
c_double,
c_long,
c_longlong,
( 'description', STRING ),
( 'exceptions', c_void_p ),
( 'relinquish', MagickBooleanType ),
( 'semaphore', POINTER( SemaphoreInfo ) ),
( 'signature', c_ulong ),
]
ExceptionInfo = _ExceptionInfo
( 'pad', size_t ),
( 'min_is_white', MagickBooleanType ),
( 'pack', MagickBooleanType ),
( 'semaphore', POINTER( SemaphoreInfo ) ),
( 'signature', c_ulong ),
]
QuantumInfo = _QuantumInfo
class _StringInfo( Structure ): pass
_StringInfo._fields_ = [
( 'path', c_char * 4096 ),
( 'datum', POINTER( c_ubyte ) ),
( 'length', size_t ),
( 'signature', c_ulong ),
]
( 'register_module', CFUNCTYPE( c_ulong ) ),
( 'load_time', time_t ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _ModuleInfo ) ),
( 'next', POINTER( _ModuleInfo ) ),
( 'signature', c_ulong ),
]
( 'path', STRING ),
( 'name', STRING ),
( 'target', STRING ),
( 'magic', POINTER( c_ubyte ) ),
( 'length', size_t ),
( 'offset', MagickOffsetType ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _MagicInfo ) ),
( 'next', POINTER( _MagicInfo ) ),
( 'tag', STRING ),
( 'message', STRING ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _LocaleInfo ) ),
( 'next', POINTER( _LocaleInfo ) ),
( 'signature', c_ulong ),
]
_ProfileInfo._fields_ = [
( 'name', STRING ),
( 'length', size_t ),
( 'info', POINTER( c_ubyte ) ),
( 'signature', c_ulong ),
]
ProfileInfo = _ProfileInfo
( 'rows', c_ulong ),
( 'depth', c_ulong ),
( 'colors', c_ulong ),
( 'colormap', POINTER( PixelPacket ) ),
( 'background_color', PixelPacket ),
( 'border_color', PixelPacket ),
( 'matte_color', PixelPacket ),
( 'gravity', GravityType ),
( 'compose', CompositeOperator ),
( 'dispose', DisposeType ),
( 'clip_mask', POINTER( _Image ) ),
( 'scene', c_ulong ),
( 'delay', c_ulong ),
( 'ticks_per_second', c_long ),
( 'client_data', c_void_p ),
( 'cache', c_void_p ),
( 'attributes', c_void_p ),
( 'ascii85', POINTER( Ascii85Info ) ),
( 'blob', POINTER( BlobInfo ) ),
( 'filename', c_char * 4096 ),
( 'magick_filename', c_char * 4096 ),
( 'magick', c_char * 4096 ),
( 'magick_columns', c_ulong ),
( 'magick_rows', c_ulong ),
( 'exception', ExceptionInfo ),
( 'debug', MagickBooleanType ),
( 'reference_count', c_long ),
( 'semaphore', POINTER( SemaphoreInfo ) ),
( 'semaphore', POINTER( SemaphoreInfo ) ),
( 'color_profile', ProfileInfo ),
( 'iptc_profile', ProfileInfo ),
( 'generic_profile', POINTER( ProfileInfo ) ),
( 'generic_profiles', c_ulong ),
( 'signature', c_ulong ),
( 'previous', POINTER( _Image ) ),
( 'list', POINTER( _Image ) ),
( 'next', POINTER( _Image ) ),
( 'interpolate', InterpolatePixelMethod ),
( 'black_point_compensation', MagickBooleanType ),
( 'transparent_color', PixelPacket ),
( 'mask', POINTER( _Image ) ),
( 'artifacts', c_void_p ),
]
#------------------------------------------------------------------------------
StreamHandler = CFUNCTYPE( size_t, POINTER( Image ), c_void_p, size_t )
#------------------------------------------------------------------------------
class _ImageInfo( Structure ): pass
ImageInfo = _ImageInfo
( 'view', STRING ),
( 'authenticate', STRING ),
( 'channel', ChannelType ),
( 'attributes', POINTER( Image ) ),
( 'options', c_void_p ),
( 'progress_monitor', MagickProgressMonitor ),
( 'client_data', c_void_p ),
( 'cache', c_void_p ),
( 'stream', StreamHandler ),
( 'file', POINTER( FILE ) ),
( 'magick', STRING ),
( 'name', STRING ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _CoderInfo ) ),
( 'next', POINTER( _CoderInfo ) ),
( 'signature', c_ulong ),
]
( 'thread_support', MagickBooleanType ),
( 'spawn', MagickBooleanType ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _DelegateInfo ) ),
( 'next', POINTER( _DelegateInfo ) ),
( 'signature', c_ulong ),
]
( 'key', STRING ),
( 'value', STRING ),
( 'compression', MagickBooleanType ),
( 'previous', POINTER( _ImageAttribute ) ),
( 'next', POINTER( _ImageAttribute ) ),
]
ImageAttribute = _ImageAttribute
( 'compliance', ComplianceType ),
( 'color', MagickPixelPacket ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _ColorInfo ) ),
( 'next', POINTER( _ColorInfo ) ),
( 'signature', c_ulong ),
]
( 'name', STRING ),
( 'value', STRING ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _ConfigureInfo ) ),
( 'next', POINTER( _ConfigureInfo ) ),
( 'signature', c_ulong ),
]
( 'metrics', STRING ),
( 'glyphs', STRING ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _TypeInfo ) ),
( 'next', POINTER( _TypeInfo ) ),
( 'signature', c_ulong ),
]
( 'type', GradientType ),
( 'bounding_box', RectangleInfo ),
( 'gradient_vector', SegmentInfo ),
( 'stops', POINTER( StopInfo ) ),
( 'number_stops', c_ulong ),
( 'spread', SpreadMethod ),
( 'debug', MagickBooleanType ),
( 'type', ReferenceType ),
( 'gradient', GradientInfo ),
( 'signature', c_ulong ),
( 'previous', POINTER( _ElementReference ) ),
( 'next', POINTER( _ElementReference ) )
]
#------------------------------------------------------------------------------
( 'stroke', PixelPacket ),
( 'stroke_width', c_double ),
( 'gradient', GradientInfo ),
( 'fill_pattern', POINTER( Image ) ),
( 'tile', POINTER( Image ) ),
( 'stroke_pattern', POINTER( Image ) ),
( 'stroke_antialias', MagickBooleanType ),
( 'undercolor', PixelPacket ),
( 'border_color', PixelPacket ),
( 'server_name', STRING ),
( 'dash_pattern', POINTER( c_double ) ),
( 'clip_mask', STRING ),
( 'bounds', SegmentInfo ),
( 'clip_units', ClipPathUnits ),
( 'origin', PointInfo ),
]
#------------------------------------------------------------------------------
DrawContext = POINTER( _DrawingWand )
MonitorHandler = CFUNCTYPE( MagickBooleanType, STRING, MagickOffsetType, MagickSizeType, POINTER( ExceptionInfo ) )
ErrorHandler = CFUNCTYPE( None, ExceptionType, STRING, STRING )
FatalErrorHandler = CFUNCTYPE( None, ExceptionType, STRING, STRING )
WarningHandler = CFUNCTYPE( None, ExceptionType, STRING, STRING )
DecodeImageHandler = CFUNCTYPE( POINTER( Image ), POINTER( ImageInfo ), POINTER( ExceptionInfo ) )
EncodeImageHandler = CFUNCTYPE( MagickBooleanType, POINTER( ImageInfo ), POINTER( Image ) )
IsImageFormatHandler = CFUNCTYPE( MagickBooleanType, POINTER( c_ubyte ), size_t )
ImageFilterHandler = CFUNCTYPE( c_ulong, POINTER( POINTER( Image ) ), c_int, POINTER( STRING ), POINTER( ExceptionInfo ) )
( 'version', STRING ),
( 'note', STRING ),
( 'module', STRING ),
( 'image_info', POINTER( ImageInfo ) ),
( 'decoder', POINTER( DecodeImageHandler ) ),
( 'encoder', POINTER( EncodeImageHandler ) ),
( 'magick', POINTER( IsImageFormatHandler ) ),
( 'seekable_stream', MagickBooleanType ),
( 'thread_support', MagickStatusType ),
( 'stealth', MagickBooleanType ),
( 'previous', POINTER( _MagickInfo ) ),
( 'next', POINTER( _MagickInfo ) ),
( 'signature', c_ulong ),
]
src/p/y/py-tcdb-0.3/tcdb/tc.py py-tcdb(Download)
# -*- coding: utf-8 -*- # Tokyo Cabinet Python ctypes binding. from ctypes import CDLL, CFUNCTYPE, POINTER from ctypes import c_int, c_int8, c_int32, c_int64 from ctypes import c_uint, c_uint8, c_uint32, c_uint64 from ctypes import c_bool, c_size_t from ctypes import c_double from ctypes import c_char_p, c_void_p from ctypes import cast from ctypes.util import find_library c_int_p = POINTER(c_int)
c_int_p = POINTER(c_int) c_uint64_p = POINTER(c_uint64) c_double_p = POINTER(c_double) c_time = c_uint64 # FIX: This is valid in 64 bit architecture.
type_ -- a Python data type.
"""
ptr = cast(data, POINTER(type_))
values = [ptr[i] for i in range(size.value)]
return values
""" TCCMP_P = POINTER(TCCMP) TCCODEC = CFUNCTYPE(c_void_p, c_void_p, c_int, c_int_p, c_void_p) TCCODEC.__doc__ =\
""" TCCODEC_P = POINTER(TCCODEC) TCPDPROC = CFUNCTYPE(c_void_p, c_void_p, c_int, c_int_p, c_void_p) TCPDPROC.__doc__ =\
""" TCPDPROC_P = POINTER(TCPDPROC) TCITER = CFUNCTYPE(c_bool, c_void_p, c_int, c_void_p, c_int, c_void_p) TCITER.__doc__ =\
""" TCITER_P = POINTER(TCITER) # extensible string
('kbuf', c_void_p, 1),
('ksiz', c_int, 1),
('sp', c_int_p, 2),
('vbp', POINTER(tc_char_p), 2),
('vsp', c_int_p, 2))
hdb_getnext3.errcheck = lambda result, func, arguments :\
(result, arguments[3], arguments[4], arguments[5])
src/p/y/pylibconfig-HEAD/pylibconfig/pylibconfig.py pylibconfig(Download)
# -*- coding: utf-8 -*-
# Author: Riccardo Gori <goriccardo@gmail.com>
# License: GPL-3 http://www.gnu.org/licenses/gpl.txt
from ctypes import c_long, c_longlong, c_double, c_short, c_int, POINTER, \
byref, CDLL, c_void_p, c_char_p, Structure, Union, \
CFUNCTYPE, c_uint
class config_value_t(Union):
_fields_ = [('ival', c_long),
('llval',c_longlong),
('fval', c_double),
('sval', c_char_p),
('list', POINTER(config_list_t))]
config_setting_t._fields_ = [('name', c_char_p),
('type', c_short),
('format', c_short),
('value', config_value_t),
('parent', POINTER(config_setting_t)),
('config', POINTER(config_t)),
config_list_t._fields_ = [('length', c_uint),
('capacity', c_uint),
('elements', POINTER(POINTER(config_setting_t)))]
config_t._fields_ = [('root', POINTER(config_setting_t)),
('destructor', POINTER(CFUNCTYPE(None, c_void_p))),
self._config_write_file = libconfig.config_write_file
#Get array element
self._config_setting_get_elem = libconfig.config_setting_get_elem
self._config_setting_get_elem.restype = POINTER(config_setting_t)
self._config_setting_length = libconfig.config_setting_length
#Generic
self._config_lookup = libconfig.config_lookup
self._config_lookup.restype = POINTER(config_setting_t)
#From settings
self._config_setting_get_member = libconfig.config_setting_get_member
self._config_setting_get_member.restype = POINTER(config_setting_t)
self._config_setting_remove_elem = libconfig.config_setting_remove_elem
#Add
self._config_setting_add = libconfig.config_setting_add
self._config_setting_add.restype = POINTER(config_setting_t)
self._config_setting_add.argtypes = [POINTER(config_setting_t),
c_char_p, c_int]
src/c/0/c.seungjin.net-HEAD/lib/python2.5/site-packages/django/contrib/gis/geos/prototypes/io.py c.seungjin.net(Download)
import threading from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
def wkb_write_func(func):
func.argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)]
func.restype = c_uchar_p
func.errcheck = check_sized_string
return func
wkb_writer_write = wkb_write_func(GEOSFunc('GEOSWKBWriter_write'))
src/r/e/reporter-lib-HEAD/packages/Django/django/contrib/gis/geos/prototypes/io.py reporter-lib(Download)
import threading from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
def wkb_write_func(func):
func.argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)]
func.restype = c_uchar_p
func.errcheck = check_sized_string
return func
wkb_writer_write = wkb_write_func(GEOSFunc('GEOSWKBWriter_write'))
src/m/d/mdn-lib-HEAD/packages/Django/django/contrib/gis/geos/prototypes/io.py mdn-lib(Download)
import threading from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
def wkb_write_func(func):
func.argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)]
func.restype = c_uchar_p
func.errcheck = check_sized_string
return func
wkb_writer_write = wkb_write_func(GEOSFunc('GEOSWKBWriter_write'))
src/s/e/secret-squirrel-lib-HEAD/packages/Django/django/contrib/gis/geos/prototypes/io.py secret-squirrel-lib(Download)
import threading from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
def wkb_write_func(func):
func.argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)]
func.restype = c_uchar_p
func.errcheck = check_sized_string
return func
wkb_writer_write = wkb_write_func(GEOSFunc('GEOSWKBWriter_write'))
src/b/a/badger-lib-HEAD/packages/Django/django/contrib/gis/geos/prototypes/io.py badger-lib(Download)
import threading from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
class WKBReader_st(Structure): pass class WKBWriter_st(Structure): pass WKT_READ_PTR = POINTER(WKTReader_st) WKT_WRITE_PTR = POINTER(WKTWriter_st) WKB_READ_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
def wkb_write_func(func):
func.argtypes = [WKB_WRITE_PTR, GEOM_PTR, POINTER(c_size_t)]
func.restype = c_uchar_p
func.errcheck = check_sized_string
return func
wkb_writer_write = wkb_write_func(GEOSFunc('GEOSWKBWriter_write'))
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next