Exemplo n.º 1
0
def contact_camera():
    nrf_bridge = Bridge('/dev/ttyACM0')  # '/dev/ttyACM0'
    a = nrf_bridge.assign_addresses()
    for i in list(a.keys()):
        nrf_bridge.set_TX_address(i)
        if nrf_bridge.get_ID_type()[6] == 1:  # find first camera in neighbours
            camera_address = i
            break
    else:
        raise RuntimeError('No cameras found')
    return nrf_bridge
Exemplo n.º 2
0
import math
import time
from sklearn.neighbors import NearestNeighbors
import scipy.sparse.csgraph

import circle as CL
import clustering as CLTR

SHOW_NEIGHBORS = True
LED_DETECTION_THRESHOLD = 6
ix, iy = -1, -1

nrf = Bridge('/dev/ttyACM0')  # '/dev/ttyACM1'
a = nrf.assign_addresses()
for i in list(a.keys()):
    nrf.set_TX_address(i)
    if nrf.get_ID_type()[6] == 1:  # find first camera in neighbours
        camera_address = i
        break
else:
    raise RuntimeError('No cameras found')


def draw_circle(event, x, y, flags, param):
    global ix, iy
    if event == cv2.EVENT_LBUTTONDBLCLK:
        destination = [x, y]
        print(destination)


# nrf.send_packet('\x94'+chr(64)) #overclock PSoC and camera (default is 48MHz, which gives 15fps SXGA, 30fps VGA, 60fps CIF and 120fps QCIF)
Exemplo n.º 3
0
    if sys.argv[1] == '-c':
        camera_calibration = True
        print 'Entered camera calibration mode.'
    else:
        # -c: for turning on the calibration LED patterns
        print 'Usage:', sys.argv[0], '[-c]'
        sys.exit(1)
else:
    camera_calibration = False

nrf = Bridge()
cameras, ebugs, unknowns = nrf.assign_static_addresses('../libs/ebug_tab.json')

for addr, info in ebugs.items():
    print 'Initializing eBug: ', addr
    nrf.set_TX_address(addr)
    nrf.enable_LEDs(0, 1, 0, 0)
    nrf.LED_brightness(8)
    nrf.LCD_backlight(0)
    if camera_calibration == True:
        # Calibration LED pattern (upward looking set):
        # D2 is illuminated red - front (0 degrees) - GGRGG
        # D18 is illuminated blue - (180 degrees) - GGBGG
        red = 0x0800 + 0x4000 + 0x8000 + 0x0001 + 0x0040 + 0x0080 + 0x0100
        green = 0x1000 + 0x2000 + 0x0002 + 0x0020 + 0x0200 + 0x0400
        blue = 0x0010 + 0x0008 + 0x0004
        nrf.set_LEDs(red, green, blue)
    else:
        red = info['led_sequence'][0]
        green = info['led_sequence'][1]
        blue = info['led_sequence'][2]
Exemplo n.º 4
0
from nrf import Bridge

nrf = Bridge()

while True:
    camera, eBugs, unknown = nrf.assign_static_addresses(path = \
                                                     u'../libs/ebug_tab.json')
    if camera:
        break
    else:
        print u" -------- Waiting for camera --------"
        time.sleep(0.03)

#set communication with the first camera detected
#to be changed when multiple cameras
nrf.set_TX_address(iter(camera).next())

#settings camera
# Do not play with the settings, we will fix them with camera.py
# So commenting them out.
# nrf.camera_write_reg(0x10, 20)
# values = [0x79, 0x9a, 0xb1, 0x5a, 0xc6, 0x70, 0xa3, 0x82]
# nrf.set_camera_thresholds(values)


def stat(maxINT):
    u'''
    @param int maxINT : the number of get_blobs() calls
    @return : displays various stats on the function get_blobs()
    '''
    array = list()