Esempio n. 1
0
                        EW.drawPixel(x, y)

            EW.setPenColor((0, 0, 0))
            text = '{}  OK:{} TODO:{}'.format(100 * right / (right + wrong),
                                              right, wrong)
            EW.drawText((10, 10), text)
            EW.show()
            #print('%i OK, %i bad pixels',right,wrong)

            k = cv2.waitKey(33)
            if k == 27 or k == ord('m'):
                break

    if k == ord('f'):
        print('showing frame')
        frame = W.getFrame()
        cv2.imshow('webcam', frame)

    if k == ord('d'):
        print('showing merge of 10 frames')
        frame = W.getFrame(10)
        cv2.imshow('webcam', frame)

    if k == ord('s'):  # 'save'
        points = W.getWebcamZoom()
        print('Here are the coordinates of 4 corners of webcam zoom')
        for i in range(4):
            print('Corner %i = (%f,%f)', i, points[2 * i], points[2 * i + 1])

    if k == ord('l'):  # 'load'
        delx = 0.1
Esempio n. 2
0
from skimage.measure import compare_ssim as ssim


def mse(imageA, imageB):
    # the 'Mean Squared Error' between the two images is the
    # sum of the squared difference between the two images;
    # NOTE: the two images must have the same dimension
    err = np.sum((imageA.astype("float") - imageB.astype("float"))**2)
    err /= float(imageA.shape[0] * imageA.shape[1])
    return err


if __name__ == "__main__":
    camera = Webcam()
    if camera.isConnected():
        try:
            print("copying output")
            camera.start()
            while (True):
                image1 = camera.getFrame()
                image2 = camera.getFrame()
                cor = ssim(image1, image2)
                if cor < 0.78:
                    print("gettingframe:   ", cor)
                #camera.show(image1)
        except (KeyboardInterrupt, SystemExit):
            print("exiting")
            camera.stop()
    else:
        print("problems")