31 'CvMat':'cvCreateMat(self->rows, self->cols, self->type)',
32 'IplImage':'cvCreateImage(cvGetSize(self), self->depth, self->nChannels)'
35 'CvMat':'cvCreateMat(self->rows, self->cols, CV_8U)',
36 'IplImage':'cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1)'
39 def scalar_scale_operator(arr, op, arg):
40 print '\t%s * operator %s (double val){' % (arr, op)
41 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
42 print '\t\tcvScale(self, res, %s);' % arg
43 print '\t\treturn res;'
45 print '\t%s * operator %s (double val){' % (arr, op)
46 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
47 print '\t\tcvScale(self, res, %s);' % arg
48 print '\t\treturn res;'
51 print "/** This file was automatically generated using util/cvarr_operators.py script */"
54 print '%%extend %s {' % arr
55 for op in BINARY_OPERATORS:
56 print '\t%%newobject operator %s;' % (op)
57 print '\t%s * operator %s (CvArr * src){' % ( arr, op )
58 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
59 print '\t\t%s(self, src, res);' % ( BINARY_OPERATORS[op] )
60 print '\t\treturn res;'
62 print '\t%s * operator %s= (CvArr * src){' % ( arr, op )
63 print '\t\t%s(self, src, self);' % ( BINARY_OPERATORS[op] )
64 print '\t\treturn self;'
66 for op in SCALAR_OPERATORS:
67 print '\t%%newobject operator %s;' % (op)
68 print '\t%s * operator %s (CvScalar val){' % ( arr, op )
69 print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
70 print '\t\t%s(self, val, res);' % ( SCALAR_OPERATORS[op] )
71 print '\t\treturn res;'
73 print '\t%s * operator %s= (CvScalar val){' % ( arr, op )
74 print '\t\t%s(self, val, self);' % ( SCALAR_OPERATORS[op] )
75 print '\t\treturn self;'
77 for op in CMP_OPERATORS:
78 print '\t%%newobject operator %s;' % (op)
79 print '\t%s * operator %s (CvArr * src){' % ( arr, op )
80 print '\t\t%s * res = %s;' % ( arr, CMP_ARR[arr] )
81 print '\t\tcvCmp(self, src, res, %s);' % ( CMP_OPERATORS[op] )
82 print '\t\treturn res;'
84 print '\t%s * operator %s (double val){' % ( arr, op )
85 print '\t\t%s * res = %s;' % ( arr, CMP_ARR[arr] )
86 print '\t\tcvCmpS(self, val, res, %s);' % ( CMP_OPERATORS[op] )
87 print '\t\treturn res;'
90 for op in SCALE_OPERATORS:
91 print '\t%%newobject operator %s;' % (op)
92 print '\t%s * operator %s (double val){' % (arr, op)
93 print '\t\t%s * res = %s;' % (arr, ARR[arr] )
94 print '\t\tcvScale(self, res, %s);' % SCALE_OPERATORS[op]
95 print '\t\treturn res;'
97 print '\t%s * operator %s= (double val){' % (arr, op)
98 print '\t\tcvScale(self, self, %s);' % SCALE_OPERATORS[op]
99 print '\t\treturn self;'
103 print '} /* extend %s */\n' % arr