Example #1
0
    def test_imagevector_integrity(self):
        print(
            "Testing imagevector integrity over storing in model and storing in file..."
        )
        cap = utils.camopen()
        ret, campic = cap.read()

        R = Retina()
        R.info()
        R.loadLoc(os.path.join(datadir, "retinas", "ret50k_loc.pkl"))
        R.loadCoeff(os.path.join(datadir, "retinas", "ret50k_coeff.pkl"))

        x = campic.shape[1] / 2
        y = campic.shape[0] / 2
        fixation = (y, x)
        R.prepare(campic.shape, fixation)

        ret, img = cap.read()
        if ret:
            V = R.sample(img, fixation)

        originalvector = ImageVector(V,
                                     framenum=1,
                                     timestamp="HH:MM:SS.SS",
                                     label="dummy",
                                     fixationy=y,
                                     fixationx=x,
                                     retinatype="50k")
        self.assertTrue(np.array_equal(V, originalvector._vector),
                        'Vector has been modified by storage in model')

        vectors = [originalvector]
        ip.saveHDF5(os.path.join("testdata", "integritytest.h5"), vectors)
        newvectors = ip.loadhdf5(os.path.join("testdata", "integritytest.h5"),
                                 None)
        newvector = newvectors[0]
        self.assertTrue(np.array_equal(V, originalvector._vector),
                        'Vector has been modified by storage in HDF5')

        ip.saveCSV(os.path.join("testdata", "integritytest.csv"), vectors)
        newvectors = ip.loadCsv(os.path.join("testdata", "integritytest.csv"),
                                None)
        newvector = newvectors[0]
        self.assertTrue(np.array_equal(V, originalvector._vector),
                        'Vector has been modified by storage in CSV')

        print("Vector has not been modified by the system")
Example #2
0
from retinavision.cortex import Cortex
from retinavision import datadir, utils
from retinavision.pyramid import Pyramid
from os.path import join


def visualize(BI, title, pyr, dog=False):
    for i in range(len(BI[:-1])):
        if dog: im = np.true_divide(BI[i], pyr.norm_maps[i])
        else: im = BI[i]
        cv2.namedWindow(title + str(i), cv2.WINDOW_AUTOSIZE)
        cv2.imshow(title + str(i), im)


#Open webcam
cap = utils.camopen()  #cap is the capture object (global)
ret, campic = cap.read()

#Create and load retina
R = Retina()
R.info()
R.loadLoc(join(datadir, "retinas", "ret50k_loc.pkl"))
R.loadCoeff(join(datadir, "retinas", "ret50k_coeff.pkl"))

#Prepare retina
x = campic.shape[1] / 2
y = campic.shape[0] / 2
fixation = (y, x)
R.prepare(campic.shape, fixation)

#Prepare pyramid
@author: Piotr Ozimek
"""
import cv2
import numpy as np
from retinavision.retina import Retina
from retinavision.cortex import Cortex
from retinavision import datadir, utils
from os.path import join

#TODO: github changes line endings inside the .pkl files, making them incompatible
#1. F**k github 2. find a workaround

#Open webcam
#cap is the capture object (global)
cap = utils.camopen()
ret, campic = cap.read()

#Create and load retina
R = Retina()
R.info()
R.loadLoc(join(datadir, "retinas", "ret50k_loc.pkl"))
R.loadCoeff(join(datadir, "retinas", "ret50k_coeff.pkl"))

#Prepare retina
x = campic.shape[1] / 2
y = campic.shape[0] / 2
fixation = (y, x)
R.prepare(campic.shape, fixation)

#Create and prepare cortex