#from camera import camera from ultrasonic import ultrasonic from infrared import infrared from line_tracker import line_tracker #import cv2 import time address='192.168.0.101' #cam = camera(address) #cam.start() inf = infrared(address) inf.start() ult = ultrasonic(address) ult.start() lt = line_tracker(address) lt.start() inf_t = time.time() while True: try: t = time.time() # if cam.image!=[]: # cv2.imshow("image",cam.image) # cv2.waitKey(1) if t-inf_t>1: print("infrared left,right: ",inf.left,inf.right) print("ultrasonic: ",ult.measurement) print("line_tracker: ",lt.data) inf_t = t
def __init__(self): self.sonic = ultrasonic() print("Hello~Are you OK????")
GPIO.setwarnings(False) GPIO.setmode( GPIO.BCM ) #referring to pins by Boardcom SOC channel (i.e. not physical pin numbers) # setup LCD lcd = CharLCD(numbering_mode=GPIO.BCM, pin_rs=26, pin_e=19, pins_data=[21, 20, 16, 12], cols=16, rows=2) lcd.clear() # setup ultrasonics uL = US.ultrasonic(trig=8, echo=7) uR = US.ultrasonic(trig=6, echo=5) uB = US.ultrasonic(trig=27, echo=22) # setup motors mL = MC.motor(23, 18, 14) # enable, pin1, pin2 mR = MC.motor(4, 17, 3) # enable, pin1, pin2 # setup encoders eL = EC.encoder(24, 25) #outA, out B eR = EC.encoder(9, 11) radius = 5 #in cm distanceL = 0 # initialize distance travelled by left wheel distanceR = 0 # initialize distance travelled by right wheel #setup pulsecounts
from subprocess import call # initialize all face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') # initialize the camera and grab a reference to the raw camera capture camera = PiCamera() camera.resolution = (640, 480) camera.framerate = 32 rawCapture = PiRGBArray(camera, size=(640, 480)) lastTime = 0 faceState = -1 # allow the camera to warmup time.sleep(0.1) ultrasonicInstance = ultrasonic(18, 16) # capture frames from the camera for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): # grab the raw NumPy array representing the image, then initialize the timestamp # and occupied/unoccupied text image = frame.array gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, 1.3, 5) for (x, y, w, h) in faces: cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2) roi_gray = gray[y:y + h, x:x + w]
import RPi.GPIO as GPIO from time import sleep import ultrasonic as US import numpy as np # setup ultrasonics uL = US.ultrasonic(8,7) uR = US.ultrasonic(6,5) uB = US.ultrasonic(27,22) # initialize variables max_dist=0 min_dist=100 tot_dist=0 for i in range(20): dist = uL.measure() max_dist = max(max_dist,dist) min_dist = min(min_dist,dist) tot_dist += dist mean_dist = tot_dist/20 print("mean: "+str(mean_dist)) print("range: "+str((max_dist-min_dist)/2))
import ultrasonic import accelerometer import icamera import time import gsm print '\n\n...................VEHICLE TRACKER..............\n\n\n' ##velocity,speed = ultrasonic.ultrasonic() speed = ultrasonic.ultrasonic() if (speed > 40): print '\n\nRule Break : Out of speed\n\n' ##x,y,z=accelerometer. accelerometer() stri = str(time.time()) + '.jpg' no_plate = icamera.mycamera(stri) #no_plate=' ' p = no_plate gsm.gsm(p) opt = raw_input('Do you want to search a particular vehicle? : (y/n)') if opt == 'y': no_plate_check = input('Enter vehicle no : ') if no_plate == no_plate_check: print 'Found' else: print 'Not found' else: print 'ok' print '\n\nODD...EVEN\n\n' if ((int)(no_plate)) % 2 == 0: