a few minor fixes in Python samples

This commit is contained in:
Vadim Pisarevsky 2011-07-13 06:19:21 +00:00
parent f098d98908
commit 386f147597
5 changed files with 17 additions and 9 deletions

View File

@ -37,10 +37,17 @@ def draw_match(img1, img2, p1, p2, status = None, H = None):
red = (0, 0, 255)
for (x1, y1), (x2, y2), inlier in zip(np.int32(p1), np.int32(p2), status):
col = [red, green][inlier]
if not inlier:
if inlier:
cv2.line(vis, (x1, y1), (x2+w1, y2), col)
cv2.circle(vis, (x1, y1), 2, col, -1)
cv2.circle(vis, (x2+w1, y2), 2, col, -1)
cv2.circle(vis, (x1, y1), 2, col, -1)
cv2.circle(vis, (x2+w1, y2), 2, col, -1)
else:
r = 2
thickness = 3
cv2.line(vis, (x1-r, y1-r), (x1+r, y1+r), col, thickness)
cv2.line(vis, (x1-r, y1+r), (x1+r, y1-r), col, thickness)
cv2.line(vis, (x2+w1-r, y2-r), (x2+w1+r, y2+r), col, thickness)
cv2.line(vis, (x2+w1-r, y2+r), (x2+w1+r, y2-r), col, thickness)
return vis
if __name__ == '__main__':

View File

@ -1,8 +1,8 @@
import numpy as np
import math
from numpy import random
import cv2
def make_gaussians(cluster_n, img_size):
points = []
ref_distrs = []
@ -20,7 +20,7 @@ def make_gaussians(cluster_n, img_size):
def draw_gaussain(img, mean, cov, color):
x, y = np.int32(mean)
w, u, vt = cv2.SVDecomp(cov)
ang = np.rad2deg( np.arctan2(u[1, 0], u[0, 0]) )
ang = np.arctan2(u[1, 0], u[0, 0])*(180/math.pi)
s1, s2 = np.sqrt(w)*3.0
cv2.ellipse(img, (x, y), (s1, s2), ang, 0, 360, color, 1, cv2.CV_AA)

View File

@ -5,8 +5,8 @@ from common import Sketcher
help_message = '''USAGE: inpaint.py [<image>]
Keys:
SPACE - update inpaint
r - restore image
SPACE - inpaint
r - reset the inpainting mask
ESC - exit
'''

View File

@ -1,4 +1,5 @@
import numpy as np
import math
import cv2, cv
import video
@ -29,7 +30,7 @@ def draw_hsv(flow):
ang = np.arctan2(fy, fx) + np.pi
v = np.sqrt(fx*fx+fy*fy)
hsv = np.zeros((h, w, 3), np.uint8)
hsv[...,0] = np.rad2deg(ang)/2
hsv[...,0] = ang*(180/math.pi/2)
hsv[...,1] = 255
hsv[...,2] = np.minimum(v*4, 255)
bgr = cv2.cvtColor(hsv, cv.CV_HSV2BGR)

View File

@ -51,7 +51,7 @@ class App:
print 'auto_update if', ['off', 'on'][self.auto_update]
if ch in [ord('r'), ord('R')]:
self.markers[:] = 0
self.markers_vis[:] = self.img
self.markers_vis[:] = self.img.copy()
self.sketch.show()