Ejemplo n.º 1
0
    def query(self, imname):
        """Find a list of matching images for imname
        """
        h = self.candidates_from_histogram()

        matchscores = []
        for imid in candidates:
            # get name
            cand_name = self.con.execute("""
                                        SELECT filename
                                        FROM imlist
                                        WHERE rowid = '%d'""" %
                                         imid).fetchone()

            cand_h = self.get_imhistogram(cand_name)
            cand_dist = np.sqrt(np.sum((h - cand_h)**2))
            matchscores.append((cand_dist, imid))

            return matchscores.sort()
Ejemplo n.º 2
0
def gauss(m, v, x):
    """Evaluate gaussian in d-dimensions with independent

       mean m and variance v at the points in (the rows of) x.
    """

    if len(x.shape) == 1:
        n, d = 1, x.shape[0]
    else:
        n, d = x.shape

    # covariance matrix, subtract mean
    S = np.diag(1 / v)
    x = x - m

    # product of probabilities
    y = np.exp(-.05 * np.diag(np.dot(x, np.dot(S, x.T))))

    # normalize and return
    return y * (2 * np.pi) ** (-d / 2.0) / (np.sqrt(np.prod(v)) + 1e-6)
Ejemplo n.º 3
0
 def L2dist(p1, p2):
     return np.sqrt(np.sum((p1 - p2)**2))
Ejemplo n.º 4
0
				(0, 255, 255), 2)
			cv2.circle(frame, center, 5, (0, 0, 255), -1)
 
	# update the points queue
	pts.appendleft(center)

        # loop over the set of tracked points
	for i in range(1, len(pts)):
		# if either of the tracked points are None, ignore
		# them
		if pts[i - 1] is None or pts[i] is None:
			continue
 
		# otherwise, compute the thickness of the line and
		# draw the connecting lines
		thickness = int(np.sqrt(args["buffer"] / float(i + 1)) * 2.5)
		cv2.line(frame, pts[i - 1], pts[i], (0, 0, 255), thickness)
 
	# show the frame to our screen
	cv2.imshow("Frame", frame)
	key = cv2.waitKey(1) & 0xFF
 
	# if the 'q' key is pressed, stop the loop
	if key == ord("q"):
		break
 
# if we are not using a video file, stop the camera video stream
if not args.get("video", False):
	vs.stop()
 
# otherwise, release the camera