def detect_light_vncl4040(self): try: import board import busio import adafruit_vcnl4040 self.sensor_vcnl4040 = adafruit_vcnl4040.VCNL4040( busio.I2C(board.SCL, board.SDA)) self.sensor_vcnl4040.proximity_shutdown = True #device test return True except: return False
def __init__(self): # parameters that change self.random = 1 self.changingVariable = 1 i2c = busio.I2C(board.SCL, board.SDA) self.sensor = adafruit_vcnl4040.VCNL4040(i2c) self.cap = cv2.VideoCapture( 0) # Connect to camera 0 (or the only camera) self.cap.set(3, 320) # Set the width to 320 self.cap.set(4, 240) # Set the height to 240 self.Center = np.array([]) self.f = 3.04 / (1.12 * 10**-3) #img=cv2.imread("20200830_152410.jpg") self.sample_parameters = { "hue": [0, 6], "sat": [100, 255], "value": [100, 255], "Height": 40, "OR_MASK": True, "Kernel": True, "Circle": True } self.lander_parameters = { "hue": [15, 30], "sat": [100, 255], "value": [100, 255], "Height": 65, "OR_MASK": False, "Kernel": False, "Circle": False } self.obstacle_parameters = { "hue": [40, 70], "sat": [50, 255], "value": [40, 255], "Height": 150, "OR_MASK": False, "Kernel": False, "Circle": False } self.cover_parameters = { "hue": [95, 107], "sat": [60, 255], "value": [0, 255], "Height": 70, "OR_MASK": False, "Kernel": False, "Circle": False }
def __init__(self): # Camera capture integration with command centre self.imgCounter = 0 # parameters that change self.random = 1 self.changingVariable = 1 i2c = busio.I2C(board.SCL, board.SDA) self.sensor = adafruit_vcnl4040.VCNL4040(i2c) self.cap = cv2.VideoCapture(0) # Connect to camera 0 (or the only camera) self.cap.set(3, 320) # Set the width to 320 self.cap.set(4, 240) # Set the height to 240 self.Center=np.array([]) self.f=3.04/(1.12*10**-3) #img=cv2.imread("MultipleCovers.jpg") self.sample_parameters={"hue":[0,5],"sat":[100,255],"value":[100,255],"Height":40,"OR_MASK":True, "Kernel":True,"Circle":True,"BBoxColour":[204,0,204]} self.lander_parameters={"hue":[15,30],"sat":[100,255],"value":[100,255],"Height":570,"OR_MASK":False, "Kernel":False,"Circle":False,"BBoxColour":[0,0,255]} self.obstacle_parameters={"hue":[40,70],"sat":[40,255],"value":[40,255],"Height":150,"OR_MASK":False, "Kernel":False,"Circle":False,"BBoxColour":[204,204,0]} self.cover_parameters={"hue":[95,107],"sat":[0,255],"value":[0,255],"Height":70,"OR_MASK":False, "Kernel":False,"Circle":False,"BBoxColour":[255,255,255]}
import time import board import busio import adafruit_vcnl4040 i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_vcnl4040.VCNL4040(i2c) while True: print("Proximity:", sensor.proximity) print("Light:", sensor.light) print("White:", sensor.white) time.sleep(0.3)
log.info("Starting in TEST Mode") if (_USE_BLOB_STORAGE): log.info("Blob Storage Enabled.") connect_storage_account() if (_DELETE_IMAGES): log.info("Deleting images after classification.") if args.sensor == 'vcnl4010': log.info("Calibrating VCNL4010 motion sensor") i2c = busio.I2C(board.SCL, board.SDA) vcnl = adafruit_vcnl4010.VCNL4010(i2c) percent = calibratePSensor(vcnl) flash_led = LED(23) #LED connected on GPIO pin 23 if args.sensor == 'vcnl4040': log.info("Calibrating VCNL4040 motion sensor") i2c = busio.I2C(board.SCL, board.SDA) vcnl = adafruit_vcnl4040.VCNL4040(i2c) percent = calibratePSensor(vcnl) flash_led = LED(23) #LED connected on GPIO pin 23 if args.sensor == 'motion': log.info("Using Motion Sensor") move_sensor = MotionSensor( 17) #Motion Sensor control connected to GPIO pin 17 red_led = LED(18) #LED connected to GPIO pin 18 try: startup() except SystemExit: pass finally: GPIO.cleanup() sys.exit(0)
def __init__(self): # parameters that change self.state = 1 self.random = 1 self.changingVariable = 1 # https://stackoverflow.com/questions/11420748/setting-camera-parameters-in-opencv-python i2c = busio.I2C(board.SCL, board.SDA) self.sensor = adafruit_vcnl4040.VCNL4040(i2c) self.cap = cv2.VideoCapture( 0) # Connect to camera 0 (or the only camera) self.cap.set(3, 320) # Set the width to 320 self.cap.set(4, 240) # Set the height to 240 self.cap.set(12, 0.6) # Exposure # self.cap.set(17,6005.56) # White Balance self.Center = np.array([]) self.f = 3.04 / (1.12 * 10**-3) self.landerArea = 0 #img=cv2.imread("MultipleCovers.jpg") self.sample_parameters = { "hue": [0, 5], "sat": [125, 255], "value": [125, 255], "Height": 40, "OR_MASK": True, "Kernel": True, "Circle": True, "BBoxColour": [204, 0, 204], "type": 0 } self.lander_parameters = { "hue": [15, 30], "sat": [70, 255], "value": [100, 255], "Height": 80, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [0, 0, 255], "type": 1 } self.obstacle_parameters = { "hue": [40, 70], "sat": [30, 255], "value": [20, 255], "Height": 80, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [204, 204, 0], "type": 2 } self.cover_parameters = { "hue": [95, 107], "sat": [130, 255], "value": [30, 200], "Height": 70, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [255, 255, 255], "type": 3 } self.hole_parameters = { "hue": [0, 255], "sat": [50, 255], "value": [20, 100], "Height": 50, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [180, 0, 180], "type": 4 } self.wall_parameters = { "hue": [0, 255], "sat": [0, 255], "value": [0, 30], "Height": 80, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [255, 0, 0], "type": 6 } self.coverhole_parameters = { "hue": [0, 255], "sat": [0, 255], "value": [0, 50], "Height": 10, "OR_MASK": False, "Kernel": False, "Circle": False, "BBoxColour": [255, 0, 0], "type": 5 }
def __init__(self, channel_config): self.i2c = busio.I2C(board.SCL, board.SDA) self.sensor = adafruit_vcnl4040.VCNL4040(self.i2c) self.config = channel_config['SENSOR_DETAILS']