def hough(img,theta=None): """ Apply a linear hough transform to the input image Input: - img <ndarray> : Thresholded input image (ndim=2,dtype=float) - theta <ndarray> : Angle range to search in trsnform space. (ndim=1,dtype=float) If None, defaults to (-pi/2,pi/2) Output: - hough <ndarray> : The hough transform coefficients (ndim=2,dtype=float) - dists <ndarray> : Distance values (ndim=1,dtype=float) - theta <ndarray> : Angle values (ndim=1,dtype=float) --- """ if img.ndim != 2: raise ValueError('Input image must be a 2D array'); if not theta: theta = np.linspace(-np.pi/2,np.pi/2,180); # Compute the vertical bins (distances) dist = np.ceil(np.hypot(*img.shape)); nbins = 2*dist; bins = np.linspace(-dist,dist,nbins); map = np.zeros((nbins,len(theta)),dtype=np.uint64); cos_theta = np.cos(theta); sen_theta = np.sen(theta); y,x = np.nonzero(img); for i,(cT,sT) in enumerate(izip(cos_theta,sen_theta)): dists = x*cT + y*sT; shift = np.round(dists) - bins[0]; indxs = shift.astype(np.int); bincount = np.bincount(indxs); map[:len(bincount),i] = bincount return map,theta,bins;
def center_callback(self, data): try: while True: rospy.sleep(0.1) self.servo_head = data.current_pos #relacao engrenagens = 12 pra 20 ang_kinect = 12 * servo_head / 20 #relacao entre servo e kinect ang_kinect_correto = 1.56 + ang_kinect #angulo do kinect em radianos, tarado para 0 radianos na posicao horizontal para frente xk = np.round(self.R * np.cos(ang_servo), 2) zk = np.round(self.R * np.sen(ang_servo), 2) if ang_servo >= (math.pi / 2): x = xk - self.xb x = math.fabs(x) else: x = xk + self.xb z = zk + self.zb rotx = (math.pi / 2) - ang_servo br = tf.TransformBroadcaster() br.sendTransform((x, 0, z), (rotx, 0, 0), rospy.Time.now(), "/base_link", "/kinect_center") except KeyboardInterrupt: print("Shutting down")
def proyectily(t): return v_0*np.sen(a)*t - ((g*(t**2))/2)
def derivproyectil(): return v_0*np.sen(a) - (g*t)
def exata(x): c2=1./70.*(8-12*np.sen(np.log(2))-4*np.cos(np.log(2))) c1=11./10.-c2 y=c1*x+c2/(x**2)-3./10.*np.sen(np.log(x))-1./10.*np.cos(np.log(x)) return y
def f(i,h): ai=1 bi=2/(i*h) ci=-2/((i*h)**2) di=np.sen(np.log(i*h))/((i*h)**2) return ai,bi,ci,di
import numpy as np import time t_amostragem = int(conflista[i+1])/0.1 V_inic = int(instrument.read_register(1,0)) amp = int(conflista[i+2])/2 instrument.write_register(100, 1) instrument.write_register(101, 1) for i in range (1, t_amostragem): V_ripple = V_inic + amp*np.sen((np.pi*i/10)+(3*np.pi/2)) + amp instrument.write_register(683, V_ripple) print (seno) time.sleep(0.1)
def F6(x): return np.array([3*x[0]-np.cos(x[1]*x[2])-1/2, x[0]**2-81*(x[1]+0.1)**2+np.sen(x[2]+1.06), np.exp(-x[0]*x[1])+20*x[2]+(10*np.pi-3)/3])
def rotacion(puntox,puntoy): angulo = input("angulo de rotacion") rotacion = np.matrix([[np.cos(angulo),-np.sen(angulo),0],[np.sen(angulo),np.cos(angulo),0],[0,0,0]]) puntos = np.matrix([puntox],[puntoy],[1]) return rotacion.dot(puntos)