def captureImages(self, image):
     if self.picturesPerSecond != 0:
         while functions.getTime() - self.lastTime < 1.0/self.picturesPerSecond:
             time.sleep(0.1)
         self.lastTime = functions.getTime()
     cv2.imwrite(self.captureLocation + self.name + ' (' + str(self.pictureNumber) + ').jpg', image)
     self.pictureNumber += 1
     return image
Esempio n. 2
0
def main():
    while cv2.waitKey(1) != 27:
        previousTime = functions.getTime()
        if constants.CAPTUREMODE:
            cv2.imshow("Image", constants.recorder.captureImages(towerCamera.read()))
        elif constants.DEBUGLEVEL >= 5:
            cv2.imshow("Image", constants.SU.getImage())
        elif constants.DEBUGLEVEL >= 3 and not constants.RUNNINGONPI:
            cv2.imshow("Image", processing.processTower(towerCamera.read()))
        else:
            processing.processTower(towerCamera.read())
        deltaTime = (1 / constants.FPSLIMIT) - (functions.getTime() - previousTime)
        if deltaTime > 0:
            sleep(deltaTime)
        functions.calculateFPS()
    deInit()
Esempio n. 3
0
def init():
    if constants.RUNNINGONPI:
        constants.DEBUGLEVEL = 2
        constants.MANUALIMAGEMODE = False
    constants.visionTable = networkTableManager.networkTable(constants.roboRioHostname, "vision")
    if constants.MANUALIMAGEMODE:
        constants.towerCamera = pollCamera.camera(1, "Dummy_Tower")
    else:
        constants.towerCamera = pollCamera.camera(1, "Tower")
    if constants.CAPTUREMODE:
        constants.recorder = cameraRecording.recorder(2, "Tower")
    functions.lastTime = functions.getTime()
    if constants.DEBUGLEVEL >= 3 and not constants.RUNNINGONPI:
        cv2.namedWindow("Image", cv2.WINDOW_AUTOSIZE)
    global towerCamera, visionTable
    towerCamera = constants.towerCamera
    visionTable = constants.visionTable
    timeSpentWaiting = 0
    while not towerCamera.isFrameRead():
        sleep(0.1)
        if timeSpentWaiting > 5:
            visionTable.sendError(
                "Could not open " + towerCamera.getCameraType() + " Camera within 5 seconds, restarting"
            )
            restart()
        timeSpentWaiting += 0.1
    if constants.DEBUGLEVEL >= 5:
        constants.SU = superUser.SUDO(constants.towerCamera)
Esempio n. 4
0
def scrape_recipie(url, cuisine):

    data_row = []

    res = requests.get(url, headers=headers)
    res.raise_for_status()
    soup = bs4.BeautifulSoup(res.text, 'html.parser')

    title = soup.find(
        'h1', attrs={'class:', 'gel-trafalgar content-title__text'}).text

    prep_time = soup.find('p', attrs={'class:', 'recipe-metadata__prep-time'}).text
    cook_time = soup.find('p', attrs={'class:', 'recipe-metadata__cook-time'}).text
    is_veg = soup.find('p', attrs={'class:', 'recipe-metadata__dietary-vegetarian-text'}) != None

    ingredients = soup.find_all('li', attrs={'recipe-ingredients__list-item'})

    ingredient_list = []
    steps_list = []

   

    for ingredient in ingredients:
        
        amount = ingredient.text
        if(ingredient.find('a') != None):
            #name = ingredient.find('a').text
            ingredient_list.append(amount)
        else:
            ingredient_list.append(amount)


    ingredients_string = ""
    for gred in ingredient_list:
        ingredients_string += gred +" "
    
    steps = soup.find_all(
        'p', attrs={'class:', 'recipe-method__list-item-text'})

    for step in steps:
        steps_list.append(step.text)

    img = soup.find('img', attrs={'class:', 'recipe-media__image'})

    if(img != None):
        img_src = img['src']
    else:
        img_src = None

    data_row = [title, cuisine, f.getTime(prep_time, cook_time), int(is_veg), f.getMeats(ingredients_string),
        f.isSpicy(ingredients_string), f.getVegetables(ingredients_string), img_src, json.dumps(ingredient_list), json.dumps(steps_list)]

    return data_row
 def __init__(self, picturesPerSecond, name):
     '''
     @param picturesPerSecond: The number of pictures to capture each second. Set to 0 to remove limit to number of pictures per second.
     @param name: The name of the captured images.
     '''
     self.picturesPerSecond = picturesPerSecond
     self.pictureNumber = 1;
     self.name = name
     dateTime = str(time.strftime("%m-%d_%H-%M", time.gmtime()))
     self.captureLocation = 'capturedImages/'+ self.name + " " + dateTime + '/'
     constants.visionTable.sendInfo("Capturing " + self.name + " Images to: " + self.captureLocation)
     self.lastTime = functions.getTime()
     if not os.path.exists(self.captureLocation):
         os.makedirs(self.captureLocation)
Esempio n. 6
0
        new_suf = ''.join(phon_suf)
        for seq in functions.to_revert.keys():
            if seq in new_suf:
                new_suf = new_suf.replace(seq, functions.to_revert[seq])
        new_suf = new_suf.replace('-', '')

        form.output_change[0] = new_suf

# For each generation to conduct
while generation <= constants.total_generations:
    # Conduct the generation
    expected_outputs = conductGeneration(generation, corpus, expected_outputs)
    # Increment the generation counter
    generation += 1
    # Print time it took for generation to finish
    print 'Time so far: %s' % functions.getTime(time.time() - start)

# Write output to stats
with open(constants.out_file, mode='wb') as f:
    stats = csv.writer(f, delimiter='\t')
    stats.writerow([
        'Word', 'Declension', 'Gender', 'CaseNum', 'Case', 'Num', 'TotFreq',
        'LatSuf', 'Declined'
    ] + range(0, constants.total_generations + 1))

    for lemma in corpus:
        for case, form in lemma.cases.iteritems():
            to_write = [
                form.lemmacase, form.parent.declension,
                form.parent.orig_gender, form.casenum, form.case, form.num,
                form.parent.totfreq, form.suffix
Esempio n. 7
0
                new_suf = ''.join(phon_suf)
                for seq in functions.to_revert.keys():
                        if seq in new_suf:
                            new_suf = new_suf.replace(seq, functions.to_revert[seq])
                new_suf = new_suf.replace('-', '')

                form.output_change[0] = new_suf

# For each generation to conduct
while generation <= constants.total_generations:
        # Conduct the generation
        expected_outputs = conductGeneration(generation, corpus, expected_outputs)
        # Increment the generation counter
        generation += 1
        # Print time it took for generation to finish
        print 'Time so far: %s' % functions.getTime(time.time() - start) 

# Write output to stats
with open(constants.out_file, mode = 'wb') as f:
        stats = csv.writer(f, delimiter = '\t')
        stats.writerow(['Word', 'Declension', 'Gender', 'Case', 'TotFreq', 'Declined'] + range(0, constants.total_generations+1))

        for lemma in corpus:
                for case, form in lemma.cases.iteritems():
                        to_write = [form.lemmacase, form.parent.declension, form.parent.orig_gender, form.casenum, form.parent.totfreq]
                        if form.suffix == 'NULL':
                                to_write.append(form.root)
                        else:
                                to_write.append(form.root + form.suffix)
                        for generation in sorted(form.output_change.keys()):
                                to_write.append(form.output_change[generation])
Esempio n. 8
0
 def o_time():
     print("T_OUTPUT: time")
     self.animtts.say("^mode(contextual) " + functions.getTime())
 def sendInfo(self, message):
     if True:
         print ("INFO[" + str(round(functions.getTime(),3)) + "]: " + message)
     self.visionNetworkTable.putString("Debug", message)