Update to 2.0.0 tree from current Fremantle build
[opencv] / utils / cvarr_operators.py
index 963a537..26b7085 100644 (file)
@@ -15,6 +15,10 @@ SCALAR_OPERATORS={
     '|':'cvOrS',
     '^':'cvXorS',
 }
+SCALE_OPERATORS={
+    '*':'val',
+    '/':'1.0/val'
+}
 CMP_OPERATORS={
     '==':'CV_CMP_EQ',
     '!=':'CV_CMP_NE',
@@ -27,6 +31,10 @@ ARR={
     '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)
@@ -69,23 +77,27 @@ for arr in ARR:
     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