def update_any_entry():
    # print("X", selected_row_data[0], name.get(), blood_group.get(), city.get(), contact.get())
    database.update_table(selected_row_data[0], name.get(), blood_group.get(),
                          city.get(), contact.get())
    database_list.delete(0, tk.END)
    for row in database.show():
        database_list.insert(tk.END, row)
Ejemplo n.º 2
0
def parse(url):
    """ Parses the data fetched from fetch_url
        If its not empty, frequency, POS, sentiment of the text are
        returned back to front-end.
    """
    soup = fetch_url(url)
    result = {}
    if soup:
        text = text_from_html(soup)
        text = re.sub(' +', ' ', text)
        result_list = pos_text(text)
        #print "result_list", result_list
        word_tuple = []
        for x in result_list:
            res = hash_word(x)
            word_tuple.append(res)
        print "word_tuple", word_tuple
        url_hashed = hash_word(quote(url))
        sent = get_intent(url)
        update_table((url_hashed, sent), "string")
        for y in word_tuple:
            update_table(y, "tuple")
        for (x, y) in result_list:
            result[x] = y
        return result
    else:
        print "Alert the url could not be found"
        return ""
Ejemplo n.º 3
0
def submit():
    if request.method == 'POST':
        data = request.form.to_dict()
        # write_to_csv(data)
        update_table(data)
        return redirect('/thankyou.html')
    else:
        return 'Something Went Wrong!!!'
Ejemplo n.º 4
0
 def differenceoftimes(self, data, suffix=''):
     self.sum_time = (time.time() - self.time_dict["start_time"])
     database.update_table(self.xmodule_runtime.user_id,
                           self.xmodule_runtime.xqueue['default_queuename'],
                           "web_count", self.sum_time)
Ejemplo n.º 5
0
# table = PrettyTable(['ID', 'name', 'club', 'wins', 'defeats', 'hits_got', 'hits_given'])
# for fencer in index:
#    table.add_row([fencer.ID,fencer.name,fencer.club,fencer.wins,fencer.defeats,fencer.hits_got,fencer.hits_given])
# print(table)

#создаём базу
create_db()

#вбрасываем первых ребят
first_update(index)

#вызов функции должен быть перенесен в main.py
matching(index)

#прописываем подравшихся драчунов
update_table(update)

#дёргаем текущую версию базы
for x in ask_table():
    print(x)

#делаем рейтинг
dwarfing(index)

#смотрим табличку
table = PrettyTable(
    ['ID', 'name', 'club', 'wins', 'defeats', 'hits_got - hits_given'])
for fencer in index:
    table.add_row([
        fencer.ID, fencer.name, fencer.club, fencer.wins, fencer.defeats,
        int(fencer.hits_got) - int(fencer.hits_given)
Ejemplo n.º 6
0
    def detect(self, path, student_name, course_name, block_id):
        image_string = self.decode_json(path, course_name, block_id,
                                        student_name)
        frame = self.decode_image(image_string)
        log.info("Line 2")
        # Load the Haar-Cascade and
        # retrieve Cascade to detect eyes from the same
        eye_cascade_path = "/edx/app/edxapp/venvs/proctor/lib/python2.7/site-packages/suspicious_images/haarcascade_eye.xml"
        eye_cascade = cv2.CascadeClassifier(eye_cascade_path)

        # A boolean variable which stores if the person was cheating in the frame
        cheat_bool = 0

        # reduce the noise in image by blurring and the blurred image to
        # original image so as to subtract local mean color image.
        blurred = cv2.GaussianBlur(frame, (21, 21), 0)
        weight_frame = cv2.addWeighted(frame, 1.75, blurred, -0.5, 0)

        # Equalise histogram to improve the contrast (Removing glare)
        # - Need to convert it to YUV image
        yuv = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV)
        yuv[:, :, 0] = cv2.equalizeHist(yuv[:, :, 0])
        # reconvert the image to grayscale to be feeded to Clahe
        bgr_frame = cv2.cvtColor(yuv, cv2.COLOR_YUV2BGR)
        gray = cv2.cvtColor(bgr_frame, cv2.COLOR_BGR2GRAY)

        # again apply Contrast Limited Adaptive Histogram Equalisation
        # can only work on grayscale images
        clahe = cv2.createCLAHE(clipLimit=40.0, tileGridSize=(8, 8))
        gray = clahe.apply(gray)

        # load the haar-cascade to get the region of interest - eye_region
        eyes = eye_cascade.detectMultiScale(gray,
                                            scaleFactor=1.1,
                                            minNeighbors=3)

        # How many times to load the haar-cascade to increase effectiveness
        sample_tries = 2
        while sample_tries:
            for (x, y, width, height) in eyes:
                cv2.rectangle(frame, (x, y), (x + width, y + height),
                              (0, 255, 0), 2)
                break

            sample_tries -= 1

            # if already eyes are recongnized - break out of loop
            if len(eyes):
                break
    # If no eye_region is found, that would mean that either the person's face is not
    # straightly oriented in front of webcam or he is cheating - In any case mark as suspicious
        if len(eyes) == 0:
            cheat_bool = 1

        else:
            # crop the right portion of the eyes to enable accurate detection of pupil,
            # blur that region again to reduce noise.
            gray_cropped_right = gray[eyes[0][1]:eyes[0][1] + eyes[0][3],
                                      eyes[0][0] + eyes[0][2] / 2:eyes[0][0] +
                                      eyes[0][2]]
            cv2.GaussianBlur(gray_cropped_right, (3, 3), 16)

            # use HoughCircles method to detect the circular shape in right part of eye (cropped earlier)
            circles_right = cv2.HoughCircles(gray_cropped_right,
                                             cv2.cv.CV_HOUGH_GRADIENT,
                                             dp=5,
                                             minDist=60,
                                             param1=30,
                                             param2=10,
                                             minRadius=5,
                                             maxRadius=20)
            try:
                # find the pupil-positions corresponding to the circle region
                pupil_position = np.uint16(np.around(circles_right))

                # form a small circle around the pupil-position
                for (a, b, radius) in pupil_position[0]:
                    cv2.circle(frame, (a + x + width / 2, b + y), 2,
                               (255, 0, 0), 2)

            except:
                pass

    # If the user is found to be cheating, the corresponding images can be saved in the directory
        if cheat_bool == 1:
            # TODO Increament this variable in database using some course_name/student_name
            student_id = database.get_id(student_name)
            database.update_table(student_id, course_name, "img_count", 1)

            path_img = self.get_path(path, course_name, block_id,
                                     student_name) + "/susp_img"

            if not os.path.exists(path_img):
                os.makedirs(path_img)

            path_img += "/"

            cv2.imwrite(path_img + str(len(os.listdir(path_img))) + ".jpg",
                        frame)