Unified handling of InputOutputArrays in Python wrapper generator
This makes arguments of type InputOutputArray required in python unless they have a default value in C++. As result following python functions changes signatures in non-trivial way: * calcOpticalFlowFarneback * calcOpticalFlowPyrLK * calibrateCamera * findContours * findTransformECC * floodFill * kmeans * PCACompute * stereoCalibrate And the following functions become return their modified inputs as a return value: * accumulate * accumulateProduct * accumulateSquare * accumulateWeighted * circle * completeSymm * cornerSubPix * drawChessboardCorners * drawContours * drawDataMatrixCodes * ellipse * fillConvexPoly * fillPoly * filterSpeckles * grabCut * insertChannel * line * patchNaNs * polylines * randn * randShuffle * randu * rectangle * setIdentity * updateMotionHistory * validateDisparity * watershed
This commit is contained in:
@@ -27,7 +27,7 @@ if __name__ == '__main__':
|
||||
img_mask = img_mask[0]
|
||||
except:
|
||||
img_mask = '../cpp/left*.jpg'
|
||||
|
||||
|
||||
img_names = glob(img_mask)
|
||||
debug_dir = args.get('--debug')
|
||||
square_size = float(args.get('--square_size', 1.0))
|
||||
@@ -46,7 +46,7 @@ if __name__ == '__main__':
|
||||
if img is None:
|
||||
print "Failed to load", fn
|
||||
continue
|
||||
|
||||
|
||||
h, w = img.shape[:2]
|
||||
found, corners = cv2.findChessboardCorners(img, pattern_size)
|
||||
if found:
|
||||
@@ -65,7 +65,7 @@ if __name__ == '__main__':
|
||||
|
||||
print 'ok'
|
||||
|
||||
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h))
|
||||
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h), None, None)
|
||||
print "RMS:", rms
|
||||
print "camera matrix:\n", camera_matrix
|
||||
print "distortion coefficients: ", dist_coefs.ravel()
|
||||
|
@@ -46,7 +46,7 @@ if __name__ == '__main__':
|
||||
img = make_image()
|
||||
h, w = img.shape[:2]
|
||||
|
||||
contours0, hierarchy = cv2.findContours( img.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||||
_, contours0, hierarchy = cv2.findContours( img.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||||
contours = [cv2.approxPolyDP(cnt, 3, True) for cnt in contours0]
|
||||
|
||||
def update(levels):
|
||||
|
@@ -14,9 +14,9 @@ from common import mosaic
|
||||
from digits import *
|
||||
|
||||
def main():
|
||||
try:
|
||||
try:
|
||||
src = sys.argv[1]
|
||||
except:
|
||||
except:
|
||||
src = 0
|
||||
cap = video.create_capture(src)
|
||||
|
||||
@@ -35,7 +35,7 @@ def main():
|
||||
|
||||
bin = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 31, 10)
|
||||
bin = cv2.medianBlur(bin, 3)
|
||||
contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
|
||||
_, contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
|
||||
try:
|
||||
heirs = heirs[0]
|
||||
except:
|
||||
|
@@ -29,7 +29,7 @@ if __name__ == '__main__':
|
||||
if img is None:
|
||||
print 'Failed to load image file:', fn
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
h, w = img.shape[:2]
|
||||
mask = np.zeros((h+2, w+2), np.uint8)
|
||||
seed_pt = None
|
||||
|
@@ -32,7 +32,7 @@ if __name__ == '__main__':
|
||||
points, _ = make_gaussians(cluster_n, img_size)
|
||||
|
||||
term_crit = (cv2.TERM_CRITERIA_EPS, 30, 0.1)
|
||||
ret, labels, centers = cv2.kmeans(points, cluster_n, term_crit, 10, 0)
|
||||
ret, labels, centers = cv2.kmeans(points, cluster_n, None, term_crit, 10, 0)
|
||||
|
||||
img = np.zeros((img_size, img_size, 3), np.uint8)
|
||||
for (x, y), label in zip(np.int32(points), labels.ravel()):
|
||||
|
@@ -63,7 +63,7 @@ if __name__ == '__main__':
|
||||
while True:
|
||||
ret, img = cam.read()
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0)
|
||||
flow = cv2.calcOpticalFlowFarneback(prevgray, gray, None, 0.5, 3, 15, 3, 5, 1.2, 0)
|
||||
prevgray = gray
|
||||
|
||||
cv2.imshow('flow', draw_flow(gray, flow))
|
||||
|
@@ -24,7 +24,7 @@ def find_squares(img):
|
||||
bin = cv2.dilate(bin, None)
|
||||
else:
|
||||
retval, bin = cv2.threshold(gray, thrs, 255, cv2.THRESH_BINARY)
|
||||
contours, hierarchy = cv2.findContours(bin, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
|
||||
bin, contours, hierarchy = cv2.findContours(bin, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
|
||||
for cnt in contours:
|
||||
cnt_len = cv2.arcLength(cnt, True)
|
||||
cnt = cv2.approxPolyDP(cnt, 0.02*cnt_len, True)
|
||||
|
Reference in New Issue
Block a user