Exemple #1
0
    def setCompoundEncoder(self, compFilename):
        """
        compFilename: csv path for a file containing smiles
        calc descriptors and save those info as self.CompDat
        
        """
        #calc FPs
        FP = Fingerprint(CF.FINGERPRINT_DIM, 4)
        FP.processCompFile(compFilename)
        self.FP = FP

        #set comp encoder
        CompDat = CompDatabase()
        CompDat.initialize(compFilename, FP.descDf, dimensionNum=CF.VALUE_DIM)

        self.CompDat = CompDat
    def getTrainSample(self):
        """
        :param attributes: List of attributes we want to obtain. Use constants defined in the class Fingerprint
        :return: trainSet, a list of Fingerprint objects
        """
        attributes = set(self.attributes).intersection(
            Fingerprint.MYSQL_ATTRIBUTES)
        attributes = ",".join(attributes)

        if len(self.train) == 0:
            self.splitData()

        counterString = "("
        for counter in self.train:
            counterString += str(counter) + ","

        counterString = counterString[0:len(counterString) - 1]
        counterString += ")"
        self.cur.execute('SELECT ' + attributes +
                         ' FROM fpData WHERE counter in ' + counterString)
        res = self.cur.fetchall()

        trainSet = list()
        for v in res:
            trainSet.append(Fingerprint(self.attributes, v))

        return trainSet
Exemple #3
0
 def _parse_key(self, dom):
     """Create NotaryResponseKey from dom instance"""
     if dom.tagName != "key":
         raise NotaryResponseException("Unrecognized key element: %s" % (dom.tagName))
     type = ServiceType.from_string(dom.getAttribute("type"))
     key = Fingerprint.from_string(dom.getAttribute("fp"))
     timespans = [self._parse_timespan(e)
                  for e in dom.getElementsByTagName("timestamp")]
     return NotaryResponseKey(type, key, timespans)
Exemple #4
0
    def get(self, service):
        """Return Fingerprint instance and last time seen for given host

        Returns None if there is no certificate in the cache."""
        key = self._key(service)
        if not self.store.has_key(key):
            raise KeyError("Host %s port %s not in cache" % (hostname,
                                                                 port))
        values = self.store[key]
        return (Fingerprint.from_string(values[0]), values[1])
Exemple #5
0
class Audio:
    def __init__(self, audio_file=None, fingerprint=None):
        if fingerprint is not None:
            self.fingerprint = fingerprint
        if audio_file is not None:
            self.fingerprint = Fingerprint(audio_file, amp_min=-90, plot=True)

    def get_fingerprint(self):
        return self.fingerprint

    def get_length(self):
        return self.fingerprint.get_length()

    def to_seconds(self, time):
        return self.fingerprint.to_seconds(time)

    def cut(self, start_time=0, stop_time=None):
        if stop_time is None:
            stop_time = self.length
        cut_fingerprint = self.fingerprint.cut(start_time, stop_time)
        return Audio(fingerprint=cut_fingerprint)
    def getDataTest(self):
        attributes = set(self.attributes).intersection(
            Fingerprint.MYSQL_ATTRIBUTES)
        attributes = ",".join(attributes)

        if len(self.train) == 0:
            self.splitData()

        counterString = "("
        for counter in self.train:
            counterString += str(counter) + ","

        counterString = counterString[0:len(counterString) - 1]
        counterString += ")"

        self.cur.execute('SELECT ' + attributes +
                         ' FROM fpData WHERE counter in (8242,8239)')
        res = self.cur.fetchall()
        fps = list()
        for v in res:
            fps.append(Fingerprint(self.attributes, v))

        return fps
Exemple #7
0
 def from_string(cls, type, str):
     """Create a ServiceKey instance from a string such as:
     93:cc:ed:bb:b9:84:42:fc:da:13:49:6a:89:95:50:28"""
     fingerprint = Fingerprint.from_string(str)
     return cls(type, fingerprint)
Exemple #8
0
 def __init__(self, audio_file=None, fingerprint=None):
     if fingerprint is not None:
         self.fingerprint = fingerprint
     if audio_file is not None:
         self.fingerprint = Fingerprint(audio_file, amp_min=-90, plot=True)
Exemple #9
0
 def from_string(cls, type, str):
     """Create a ServiceKey instance from a string such as:
     93:cc:ed:bb:b9:84:42:fc:da:13:49:6a:89:95:50:28"""
     fingerprint = Fingerprint.from_string(str)
     return cls(type, fingerprint)
 def test_get_movements(self):
     fingerprint = Fingerprint([0xb53f208a, 0x2f95a90a, 0xfb9bd053, 0x6ff99733], 'RSA 2048', 'MD5')
     me = open('natmchugh.txt', 'r').read()
     print str(fingerprint)
     self.assertEqual(str(fingerprint), me)
 def test_hash_to_moves(self):
     fingerprint = Fingerprint([0xfc94b0c1], 'RSA 2048', 'MD5')
     expected = [0,3,3,3,  0,1,1,2, 0,0,3,2, 1,0,0,3]
     actual = fingerprint.hash_to_moves([0xfc94b0c1])
     self.assertEqual(actual, expected)
Exemple #12
0
import numpy as np
from Holt import Holt
from CrossingNumber import CrossingNumber
from Fingerprint import Fingerprint

###################

images = []
target = None
# 1. Aquisição da imagem
for file in glob.glob("../dataset_test/*.png"
                      ):  # ALTERAR AQUI O CAMINNO DA PASTA COM AS IMAGENS
    filename = os.path.basename(file)

    if filename == 'target.png':
        target = Fingerprint(cv2.imread(file, 0))
        images.append(target)
    else:
        img = Fingerprint(cv2.imread(file, 0))
        images.append(img)

print(len(images))
control_index = 0

for image in images:
    # 2. Filtro da mediana
    mediana = cv2.medianBlur(image.img, 5)

    # 3. Filtro de aguçamento
    filtro = np.array([[-1, -1, -1, -1, -1], [-1, 2, 2, 2, -1],
                       [-1, 2, 3, 2, -1], [-1, 2, 2, 2, -1],
Exemple #13
0
 def get_fingerprint(self):
     """Return the Service's certificate fingerprint"""
     cert_pem = ssl.get_server_certificate((self.hostname, self.port))
     # Fix missing newline before END line
     cert_pem = self.bad_cert_end_re.sub(r"\1\n\2", cert_pem)
     return Fingerprint.from_certificate_PEM(cert_pem)