'|':'cvOrS',
'^':'cvXorS',
}
+SCALE_OPERATORS={
+ '*':'val',
+ '/':'1.0/val'
+}
CMP_OPERATORS={
'==':'CV_CMP_EQ',
'!=':'CV_CMP_NE',
'CvMat':'cvCreateMat(self->rows, self->cols, self->type)',
'IplImage':'cvCreateImage(cvGetSize(self), self->depth, self->nChannels)'
}
+CMP_ARR={
+ 'CvMat':'cvCreateMat(self->rows, self->cols, CV_8U)',
+ 'IplImage':'cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1)'
+}
def scalar_scale_operator(arr, op, arg):
print '\t%s * operator %s (double val){' % (arr, op)
for op in CMP_OPERATORS:
print '\t%%newobject operator %s;' % (op)
print '\t%s * operator %s (CvArr * src){' % ( arr, op )
- print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
+ print '\t\t%s * res = %s;' % ( arr, CMP_ARR[arr] )
print '\t\tcvCmp(self, src, res, %s);' % ( CMP_OPERATORS[op] )
print '\t\treturn res;'
print '\t}'
print '\t%s * operator %s (double val){' % ( arr, op )
- print '\t\t%s * res = %s;' % ( arr, ARR[arr] )
+ print '\t\t%s * res = %s;' % ( arr, CMP_ARR[arr] )
print '\t\tcvCmpS(self, val, res, %s);' % ( CMP_OPERATORS[op] )
print '\t\treturn res;'
print '\t}'
- # *,/ scalar operators
- print '\t%newobject operator /;'
- print '\t%s * operator / (double val){' % arr
- print '\t\t%s * res = %s;' % (arr, ARR[arr] )
- print '\t\tcvScale(self, res, val);'
- print '\t\treturn res;'
- print '\t}'
+ for op in SCALE_OPERATORS:
+ print '\t%%newobject operator %s;' % (op)
+ print '\t%s * operator %s (double val){' % (arr, op)
+ print '\t\t%s * res = %s;' % (arr, ARR[arr] )
+ print '\t\tcvScale(self, res, %s);' % SCALE_OPERATORS[op]
+ print '\t\treturn res;'
+ print '\t}'
+ print '\t%s * operator %s= (double val){' % (arr, op)
+ print '\t\tcvScale(self, self, %s);' % SCALE_OPERATORS[op]
+ print '\t\treturn self;'
+ print '\t}'
print '} /* extend %s */\n' % arr