Esempio n. 1
0
    def alphacv(self, img):
        # This is an alternative computer vision algorithm proposed by Matthew
        master = self.master
        BLUR_FACTOR = master.values['BLUR']
        TRACK_PT_NUM = master.values['PTS']
        RADIUS = master.values['RADI']
        ALPHA = master.values['A']
        BETA = master.values['B']
        GAMMA = 1 - ALPHA - BETA
        THRESHOLD = master.values['THRS']
        SAMPLESIZE = master.values['SIZE']
        CERTAINTY = master.values['CERT']
        # Do the image processing
        # Generate grayscale image
        grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        # Blur image
        blurred = findBlurred(grayimg, BLUR_FACTOR)

        # The dynamic threshold calculation is embedded in algorithm
        # TODO: Experiment to be done to determine the realibility of statistic

        # Display necessary information on HUD

        # Find tracking segments
        interval = 15
        pt_count = 10 #min(TRACK_PT_NUM, interval)
        grayimg, pts = processing.get_good_pts(blurred, grayimg,
            interval = interval, pt_count = pt_count)

        master.cntframe = grayimg
        master.trackingpts = pts
Esempio n. 2
0
def captureAndSaveImage():
    # Boot option: -c, captures image with recognition
    stream = io.BytesIO()
    CAMERA.resolution = (V_WIDTH, V_HEIGHT)
    CAMERA.framerate = FRAMERATE
    CAMERA.start_preview()
    time.sleep(0.5)
    CAMERA.capture(stream, format='jpeg')
    data = np.fromstring(stream.getvalue(), dtype=np.uint8)
    raw_img = cv2.imdecode(data, 0) # Returns a grayscale image
    blurred = findBlurred(raw_img, CV_BLUR_FACTOR)
    display, pointlst = processing.get_good_pts(blurred, raw_img,
        interval=ALPHACV_INTERVAL, pt_count=ALPHACV_PT_COUNT,
        skip=ALPHA_CV_ROW_SKIP, choose_thin=ALPHA_CV_CHOOSE_THIN)
    # assert(len(pointlst) == 0): this is postcondition of alphacv
    filename = 'captured/' + time.ctime().replace(' ', '_').replace(':', '_') \
        + '.jpg'
    cv2.imwrite(filename, display)