27 'CvMat':'cvCreateMat(self->rows, self->cols, self->type)',
28 'IplImage':'cvCreateImage(cvGetSize(self), self->depth, self->nChannels)'
31 def scalar_scale_operator(arr, op, arg):
32 print '\t%s * operator %s (double val){' % (arr, op)
33 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
34 print '\t\tcvScale(self, res, %s);' % arg
35 print '\t\treturn res;'
37 print '\t%s * operator %s (double val){' % (arr, op)
38 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
39 print '\t\tcvScale(self, res, %s);' % arg
40 print '\t\treturn res;'
43 print "/** This file was automatically generated using util/cvarr_operators.py script */"
46 print '%%extend %s {' % arr
47 for op in BINARY_OPERATORS:
48 print '\t%%newobject operator %s;' % (op)
49 print '\t%s * operator %s (CvArr * src){' % ( arr, op )
50 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
51 print '\t\t%s(self, src, res);' % ( BINARY_OPERATORS[op] )
52 print '\t\treturn res;'
54 print '\t%s * operator %s= (CvArr * src){' % ( arr, op )
55 print '\t\t%s(self, src, self);' % ( BINARY_OPERATORS[op] )
56 print '\t\treturn self;'
58 for op in SCALAR_OPERATORS:
59 print '\t%%newobject operator %s;' % (op)
60 print '\t%s * operator %s (CvScalar val){' % ( arr, op )
61 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
62 print '\t\t%s(self, val, res);' % ( SCALAR_OPERATORS[op] )
63 print '\t\treturn res;'
65 print '\t%s * operator %s= (CvScalar val){' % ( arr, op )
66 print '\t\t%s(self, val, self);' % ( SCALAR_OPERATORS[op] )
67 print '\t\treturn self;'
69 for op in CMP_OPERATORS:
70 print '\t%%newobject operator %s;' % (op)
71 print '\t%s * operator %s (CvArr * src){' % ( arr, op )
72 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
73 print '\t\tcvCmp(self, src, res, %s);' % ( CMP_OPERATORS[op] )
74 print '\t\treturn res;'
76 print '\t%s * operator %s (double val){' % ( arr, op )
77 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
78 print '\t\tcvCmpS(self, val, res, %s);' % ( CMP_OPERATORS[op] )
79 print '\t\treturn res;'
82 # *,/ scalar operators
83 print '\t%newobject operator /;'
84 print '\t%s * operator / (double val){' % arr
85 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
86 print '\t\tcvScale(self, res, val);'
87 print '\t\treturn res;'
91 print '} /* extend %s */\n' % arr