def read_user_dots(path, number_points, x, y, w, h, shape): dco = DetectContours() points = [] for i in range(0, number_points): #if i < 10: # i = str(0) + str(i) print path + "/" + str(i + 1) + ".jpg" img = cv2.imread(path + "/" + str(i + 1) + ".jpg") # make image for userpt_locations blank = np.zeros(shape) f_x = 1.0 * w / img.shape[1] f_y = 1.0 * h / img.shape[0] print img.shape print f_y, f_x print w / img.shape[1], h / img.shape[0] sys.stdout.flush() dots = cv2.resize(img, (None), fx=f_x, fy=f_y, interpolation=cv2.INTER_LINEAR) blank[y:int(y + h), x:int(x + w)] = dots print blank.dtype sys.stdout.flush() a = dco.getContours(np.asarray(blank, np.uint8)) #dci.get_circles(img) points.append(dco.getCentroids(a)) #points.append(dci.get) return points
def read_cam_dots(path, number_points): dch = DetectChanges() dco = DetectContours() points = [] bg = cv2.imread(path + "/0.jpg") for i in range(0, number_points): img = cv2.imread(path + "/" + str(i + 1) + ".jpg") a = dch.getContours(bg, img) points.append(dco.getCentroids(a)) return points
def read_dots(path, number_points): dco = DetectContours() points = [] for i in range(0, number_points): #if i < 10: # i = str(0) + str(i) img = cv2.imread(path + "/" + str(i + 1) + ".jpg") a = dco.getContours(img) #dci.get_circles(img) points.append(dco.getCentroids(a)) #points.append(dci.get) return points
import cv2 import cv2.cv as cv import numpy as np import math import sys import os import imutils from util import * from getDots import * from detectPattern import DetectContours from detectPattern import DetectCircles from findHomography import FindHomography dco = DetectContours() dci = DetectCircles() fh = FindHomography() # TODO: automate getting the centroids of all the original calibration images orig12 = [(30, 30), (283, 30), (536, 30), (789, 30), (30, 310), (283, 310), (536, 310), (789, 310), (30, 589), (283, 589), (536, 589), (789, 589)] orig18 = [(30, 30), (182, 30), (334, 30), (486, 30), (638, 30), (789, 30), (30, 310), (182, 310), (334, 310), (486, 310), (638, 310), (789, 310), (30, 589), (182, 589), (334, 589), (486, 589), (638, 589), (789, 589)] #(1) translation from original to points -> get in between pixels from bilinear interpolation #(2) homography from 4 points (1245) (2356)
import numpy as np import math import sys import os import imutils from util import * from getDotsOld import * from detectPattern import DetectContours from detectPattern import DetectCircles from findHomography import FindHomography #from computeMapping import interpolate_colour, reverse_warp_helper, warp_image # 1) check that i warp rectangle to camera image number_points = 28 dco = DetectContours() fh = FindHomography() cam_points = [] cam_shape = [] x = 100 y = 50 w = 300 h = 200 #userpt_locations = read_user_dots(os.getcwd() + "/user/generated/" + sys.argv[3], number_points, x,y,w,h, # cv2.imread(os.getcwd() + "/user/camera/" + sys.argv[3] + "/0.jpg").shape) #origpoints = read_dots(os.getcwd() + "/user/generated/" + sys.argv[3], number_points) #camera points for i in range(0, number_points): #if i < 10: # i = str(0) + str(i) img = cv2.imread("images/" + sys.argv[1] + "/" + str(i) + ".jpg")