예제 #1
0
def thread():
    #p1 = Process(target=camera.record)

    print('\nBuckle up, butter cup. You just flipped my bitch switch\n')
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(10, GPIO.LOW)
    print('Set-up Pin 10\n')
    GPIO.setup(21, GPIO.LOW)
    GPIO.output(21, GPIO.HIGH)
    print('Set-up Pin 21\n')

    adxl = ADXL345()
    print('Set-up ADXL345\n')

    GPIO.output(10, GPIO.HIGH)

    while True:
        axes = adxl.getAxes(True)
        xyforce = math.sqrt(axes['x']**2 + axes['y']**2)
        netforce = math.sqrt(xyforce**2 + axes['z']**2)

        if (netforce >= 7):
            time.sleep(0.25)
            if (netforce >= 7):
                GPIO.output(10, GPIO.LOW)
                print('LAUNCH LAUNCH LAUNCH LAUNCH LAUNCH')
                break
    camera.record()
예제 #2
0
	GPIO.output(21, GPIO.HIGH)
	
    adxl = ADXL345()

    GPIO.output(10, GPIO.HIGH)
        
    while True:
        axes = adxl.getAxes(True)
        xyforce = math.sqrt(axes['x'] ** 2 + axes['y'] ** 2)
        netforce = math.sqrt(xyforce ** 2 + axes['z'] ** 2)

        if(netforce >= 3):
            GPIO.output(10, GPIO.LOW)
            print('LAUNCH LAUNCH LAUNCH LAUNCH LAUNCH')
            break
    camera.record()
    #p1.start()

    # commented out to experiment with several threads writing images to the sd card at once

    #    p1.start()
    #    adxl = ADXL345()
    #
    #    while True:
    #        axes = adxl.getAxes(True)
    #        xyforce = math.sqrt(axes['x'] ** 2 + axes['y'] ** 2)
    #        netforce = math.sqrt(xyforce ** 2 + axes['z'] ** 2)
    #
    #        if(netforce >= 2):
    #            print('LAUNCH LAUNCH LAUNCH LAUNCH LAUNCH')
    #            break
예제 #3
0
        # 基準画像を撮影
        image = mc.shot(camera)
        origin_hash = average_hash.get_average_hash(image)

        while True:
            # 比較画像を撮影
            image = mc.shot(camera)
            validation_hash = average_hash.get_average_hash(image)
            hamming_distance = average_hash.get_hamming_distance(
                origin_hash, validation_hash)
            print('hamming distance: ' + str(hamming_distance))

            # 録画判定
            if hamming_distance >= RECORDING_THRESHOLD:
                filename = make_filename()
                image.save(tmpdir + '/' + filename + '.jpg')
                ret, validation_hash = mc.record(camera, tmpdir, filename,
                                                 validation_hash,
                                                 make_filename)
                # ディスク容量不足で書き込みに失敗した場合は転送処理が終わるまで待つ
                while ret == False and photo_stocker.processing():
                    pass
                origin_hash = validation_hash
            time.sleep(0.1)

        # 転送の終了待ち
        photo_stocker.shutdown()
        while photo_stocker.processing():
            pass
예제 #4
0
def control():
    global num_seed
    num_seed = 0
    model = load_model(MODEL_NAME)
    #-----------
    imagede = '/home/pi/Desktop/photos/default.jpg'
    img_default = load_image(imagede)
    classify(model, img_default)

    ##初始化
    pygame.init()
    ##变量存放处

    size = width, height = 300, 200
    bgColor = (0, 0, 0)

    ##設置界面寬高

    screen = pygame.display.set_mode(size)

    ##設置標題

    pygame.display.set_caption("Team 1 Monitor")

    ##要在Pygame中使用文本,必须创建Font对象

    ##第一个参数指定字体 ,第二个参数指定字体大小

    font = pygame.font.Font(None, 20)

    ##调用get_linesize()方法获得每行文本的高度

    line_height = font.get_linesize()
    position = 0
    screen.fill(bgColor)

    ##创建一个存放的文本TXT

    # f = open("record.txt",'w')

    while True:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                # 關閉文件
                # f.close()
                sys.exit()
            # print('GG\n')
            if event.type == pygame.KEYDOWN:
                # f.write(str(event) + '\n')
                if event.key == K_w:
                    # print('w\n')
                    cm.send('#W')
                elif event.key == K_s:
                    cm.send('#S')
                if event.key == K_j:
                    # print('w\n')
                    cm.send('#w')
                elif event.key == K_k:
                    cm.send('#s')

                elif event.key == K_d:
                    cm.send('#D')
                elif event.key == K_a:
                    cm.send('#A')

                elif event.key == K_x:
                    cm.send('#x')
                elif event.key == K_b:
                    cm.send('#b')
                # --------------------------------------------

                elif event.key == K_p:
                    camera.stop()
                    imagepath = '/home/pi/Desktop/photos/' + str(
                        num_seed) + '.jpg'
                    img = load_image(imagepath)
                    label, prob, _ = classify(model, img)
                    print(
                        'we think image name:{} with certainty {} that it is {}'
                        .format(imagepath, prob, label))

                # ------------------------------
                # 目标跟随,返回
                #  hd5文件请放在执行文件目录下,输入输出在photos文件夹
                elif event.key == K_g:
                    camera.stop()
                    imagepath = '/home/pi/Desktop/photos/' + str(
                        num_seed) + '.jpg'
                    outputpath = '/home/pi/Desktop/photos/' + str(
                        num_seed) + 'new.jpg'
                    execution_path = os.getcwd()
                    detector = ObjectDetection()
                    detector.setModelTypeAsRetinaNet()
                    detector.setModelPath(
                        os.path.join(execution_path,
                                     'resnet50_coco_best_v2.0.1.h5'))
                    detector.loadModel()
                    a = time.time()

                    custom_objects = detector.CustomObjects(bottle=True)

                    detections = detector.detectCustomObjectsFromImage(
                        custom_objects=custom_objects,
                        input_image=imagepath,
                        output_image_path=outputpath,
                        minimum_percentage_probability=50,
                        box_show=True)
                    b = time.time()
                    print('the time is {}'.format(b - a))
                    print('the direction is {}'.format(
                        detections[0]['direction']))
                    for eachObject in detections:
                        print(eachObject['name'] + ':' +
                              eachObject['percentage_probability'])

                elif event.key == K_t:
                    num_seed = camera.capture(num_seed)

                elif event.key == K_q:
                    camera.stop()
                    print("==End of Photograph==")
                elif event.key == K_o:
                    camera.start()
                    print("==Begin of Photograph==")
                elif event.key == K_r:
                    camera.record()
                    # render()将文本渲染成Surface对象
                # 第一个参数是带渲染的文本
                # 第二个参数指定是否消除锯齿
                # 第三个参数指定文本的颜色
                screen.blit(font.render(str(event), True, (0, 255, 0)),
                            (0, position))
                position += line_height
                if position >= height:
                    position = 0
                    screen.fill(bgColor)
                pygame.display.flip()
예제 #5
0
def signal_handler(signal, frame):
    GPIO.output(10, GPIO.LOW)
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

for i in range(0, 30):
    GPIO.output(10, GPIO.HIGH)
    time.sleep(0.1)
    GPIO.output(10, GPIO.LOW)
    time.sleep(0.1)

while GPIO.input(4) == 1:
    pass

while True:
    status = GPIO.input(4)
    if status == 1:
        GPIO.output(10, GPIO.HIGH)

        print('f**k wiht me you know i got it -Dan with love')
        c.record()
        GPIO.output(10, GPIO.LOW)
        #except:
        #	GPIO.output(10,GPIO.LOW)
        #	exit(0)
    else:
        GPIO.output(10, GPIO.LOW)
예제 #6
0
import zlab
import camera
import time

camera.start()
camera.setMetaData("myvar1=22&yourvar=hello")
print "Recording"
camera.record("c:/zlab/camera_test.pma")
print "Sleeping"
time.sleep(4)
print "Stopping"
camera.stop()
print "Done"
예제 #7
0
        for char in i:
            if char == "1":
                temp.append(True)
            else:
                temp.append(False)
        bool_list.append(temp)
    return bool_list


num_list = read_file_return_ints("input.txt")
bin_list = []

for i in num_list:
    i = i % (2**6)
    binary = binary_convert(i)
    if len(binary) != 6:
        diff = abs(6 - len(binary))
        binary = (diff * "0") + binary
    bin_list.append(binary)

times = boolean_convert(bin_list)
print("Converted input numbers to binary!")
print(times)
print("Now generating C++ for Arduino!")
print("Sending C++ code to Arduino!")
toCPP(times)
print("Starting Recording!")
record()
time.sleep(2)
print("Uploading recording to GitHub as output!")
os.system("./uploader.sh")
예제 #8
0
def control():
    global num_seed
    num_seed = 0
    model = load_model(MODEL_NAME)

    ##初始化
    pygame.init()
    ##变量存放处

    size = width, height = 300, 200
    bgColor = (0, 0, 0)

    ##設置界面寬高

    screen = pygame.display.set_mode(size)

    ##設置標題

    pygame.display.set_caption("Team 1 Monitor")

    ##要在Pygame中使用文本,必须创建Font对象

    ##第一个参数指定字体 ,第二个参数指定字体大小

    font = pygame.font.Font(None, 20)

    ##调用get_linesize()方法获得每行文本的高度

    line_height = font.get_linesize()
    position = 0
    screen.fill(bgColor)

    ##创建一个存放的文本TXT

    # f = open("record.txt",'w')

    while True:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                # 關閉文件
                # f.close()
                sys.exit()
            # print('GG\n')
            if event.type == pygame.KEYDOWN:
                # f.write(str(event) + '\n')
                if event.key == K_w:
                    # print('w\n')
                    cm.send('#W')
                elif event.key == K_s:
                    cm.send('#S')
                if event.key == K_j:
                    # print('w\n')
                    cm.send('#w')
                elif event.key == K_k:
                    cm.send('#s')

                elif event.key == K_d:
                    cm.send('#D')
                elif event.key == K_a:
                    cm.send('#A')

                elif event.key == K_x:
                    cm.send('#x')
                elif event.key == K_b:
                    cm.send('#b')
                # --------------------------------------------
                #  这下面的代码是云加的,想法是按下p键开始预测,与之对应的向拍照传入种子来编号
                elif event.key == K_p:
                    imagepath = '/home/pi/Desktop/photos/' + str(num_seed) + '.jpg'

                    img = load_image(imagepath)
                    label, prob, _ = classify(model, img)
                    print('we think image name:{} with certainty {} that it is {}'.format(imagepath, prob, label))

                # ---------------------------------------------
                # ---------------------------------------------
                elif event.key == K_t:
                    num_seed = camera.capture(num_seed)


                elif event.key == K_q:
                    camera.stop()
                    print("==End of Photograph==")
                elif event.key == K_o:
                    camera.start()
                    print("==Begin of Photograph==")
                elif event.key == K_r:
                    camera.record()
                    # render()将文本渲染成Surface对象
                # 第一个参数是带渲染的文本
                # 第二个参数指定是否消除锯齿
                # 第三个参数指定文本的颜色
                screen.blit(font.render(str(event), True, (0, 255, 0)), (0, position))
                position += line_height
                if position >= height:
                    position = 0
                    screen.fill(bgColor)
                pygame.display.flip()