def main():
    # Read two images. PLEASE provide complete path containing test_input folder
    img_1 = input_image.input_im('test_input/1/01_1.bmp')
    img_2 = input_image.input_im('test_input/1/01_10.bmp')

    # Enhancing the image, followed by morphological operations.
    img_skeleton_1 = image_enhancement.perform_enhancement_and_morphology(
        img_1)
    img_skeleton_2 = image_enhancement.perform_enhancement_and_morphology(
        img_2)

    # This step finds ridge bifurcations and endings. Descriptors are obtained for these minutiae points
    kp1, des1 = descriptors.get_descriptors(img_skeleton_1)
    kp2, des2 = descriptors.get_descriptors(img_skeleton_2)

    # Displaying key points(ridge bifurcations and endings) on image
    img4 = cv2.drawKeypoints(img_skeleton_1.astype('uint8') * 255,
                             kp1,
                             outImage=None)
    img5 = cv2.drawKeypoints(img_skeleton_2.astype('uint8') * 255,
                             kp2,
                             outImage=None)
    cv2.imshow("key points for img_1", img4)
    cv2.imshow("key points for img_2", img5)

    # Matching between descriptors
    bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=False)
    matches = sorted(bf.match(des1, des2), key=lambda match: match.distance)
    # Plot keypoints

    # Plot matches
    img3 = cv2.drawMatches(img_skeleton_1.astype('uint8') * 255,
                           kp1,
                           img_skeleton_2.astype('uint8') * 255,
                           kp2,
                           matches,
                           flags=2,
                           outImg=None)
    cv2.imshow("matched image ", img3)
    cv2.waitKey(0)

    # Calculate score and display matching result.
    score = 0
    for match in matches:
        score += match.distance
    score_threshold = 33
    print(score_threshold)
    if score / len(matches) < score_threshold:
        print("Fingerprint matches.")
    else:
        print("Fingerprint does not match.")
Example #2
0
 def parse(self, data, offset=0):
     """Parse the given data saving the service information
     
     Parses the given data starting at the given offset to save the service information.
     Once the parsing is complete the offset at which it was completed is returned. This
     allows a loop to process a block of SDT service description data.
     Arguments:
         data   -- array of data bytes to parse to build the elementary stream information
         offset -- the byte offset at which to start the parsing (default 0)
     Returns:
         The byte offset at which this elementary stream data ends
     """
     ln = len(data) - offset
     if ln < 5: #TODO - add exception here
         return None
     self.service_id = (data[0+offset] << 8) + data[1+offset]
     eit_flags = data[2+offset]
     if eit_flags & (int('00000010', 2)):
         self.eit_schedule_flag = True
     if eit_flags & (int('00000001', 2)):
         self.eit_present_following_flag = True      
     ca_rs_flags = data[3+offset]
     self.running_status = ca_rs_flags & (int('11100000', 2))
     self.running_status >>=  5
     if ca_rs_flags & (int('00010000', 2)):
         self.free_ca_mode = True
     self.descriptors_len  = ((data[3+offset] & int('00001111', 2)) << 8) + data[4+offset]
     
     if self.descriptors_len + 5 > ln: #TODO - add exception here
         return None
     
     desc_data = data[5+offset:self.descriptors_len + 5 + offset]
     self.descriptors = descriptors.get_descriptors(desc_data)
     self.length = self.descriptors_len + 5
     return self.descriptors_len + 5 + offset
Example #3
0
 def parse(self, data):
     """Parses the given data to generate all the Cat information
     
     Given an array of bytes that comprise a CAT section, this method will parse and record all the section information
     in object members. Inherits from Section.parse. Will call the Section.parse() method and once complete will parse
     the section table_data to get the CAT specific information.
     Arguments:
         data -- Array of data bytes that describe all or part of the CAT section (default None)
     """
     super(Cat, self).parse(data)
     if self.complete:
         self.payload = self.table_body[5:]
         desc_data = self.payload[0:-4]
         self.descriptors = descriptors.get_descriptors(desc_data)
         del(self.payload)
Example #4
0
 def parse(self, data=None):
     """Parses the given data to generate all the BAT/NIT information
     
     Given an array of bytes that comprise a BAT/NIT section, this method will parse and record all the section information
     in object members. Inherits from Section.parse. Will call the Section.parse() method and once complete will parse
     the section table_data to get the BAT/NIT specific information.
     Arguments:
         data -- Array of data bytes that describe all or part of the BAT/NIT section (default None)
     """
     super(BatNitBase, self).parse(data)
     if self.complete:
         self.payload = self.table_body[5:]
         self._get_descriptors_len()
         desc_data        = self.payload[2:2+self.descriptors_len]
         self.descriptors = descriptors.get_descriptors(desc_data)
         self._get_ts_loop_len()
         self._get_ts_loop()
         del(self.payload)
Example #5
0
 def parse(self, data):
     """Parses the given data to generate all the PMT information
     
     Given an array of bytes that comprise a PMT section, this method will parse and record all the section information
     in object members. Inherits from Section.parse. Will call the Section.parse() method and once complete will parse
     the section table_data to get the PMT specific information.
     Arguments:
         data -- Array of data bytes that describe all or part of the PAT section (default None)
     """
     super(Pmt, self).parse(data)
     self.program_number = self.table_id_extension
     if self.complete:
         self.payload = self.table_body[5:]
         self.pcr_pid = get_pcr_pid(self.payload)
         self.program_info_length = get_program_info_length(self.payload)
         self.program_info_data = get_program_info_data(self.payload)
         self.descriptors = descriptors.get_descriptors(
             self.program_info_data)
         self._get_es_loop(self.payload)
         del (self.payload)
Example #6
0
 def parse(self, data, offset):
     """Parse the given data saving the elementary stream information
     
     Parses the given data starting at the given offset to save the elementary stream
     information. Once the parsing is complete the offset at which it was completed is
     returned. This allows a loop to process a block of PMT elementary stream data.
     Arguments:
         data   -- array of data bytes to parse to build the elementary stream information
         offset -- the byte offset at which to start the parsing
     Returns:
         The byte offset at which this elementary stream data ends
     """
     self.stream_type = data[offset]
     self.pid = data[offset + 1] & int('00011111', 2)
     self.pid = self.pid << 8
     self.pid = self.pid + data[offset + 2]
     self.es_info_length = data[offset + 3] & int('00001111', 2)
     self.es_info_length = self.es_info_length << 8
     self.es_info_length = self.es_info_length + data[offset + 4]
     self.es_data = data[offset + 5:offset + 5 + self.es_info_length]
     self.descriptors = descriptors.get_descriptors(self.es_data)
     return 5 + self.es_info_length
Example #7
0
 def parse(self, data, offset=0):
     """Parse the given data saving the Transport Stream information
     
     Parses the given data starting at the given offset to save the TS information.
     Once the parsing is complete the offset at which it was completed is returned. This
     allows a loop to process a block of NIT/BAT TS loop data.
     Arguments:
         data   -- array of data bytes to parse to build the transport stream information
         offset -- the byte offset at which to start the parsing (default 0)
     Returns:
         The byte offset at which this transport stream data ends
     """
     ln = len(data) - offset
     if ln < 6:#TODO - exception here
         return None
     self.transport_stream_id = (data[0+offset] << 8) + data[1+offset]
     self.original_network_id = (data[2+offset] << 8) + data[3+offset]
     self.ts_descriptors_len  = ((data[4+offset] & int('00001111', 2)) << 8) + data[5+offset]
     if self.ts_descriptors_len + 6 > ln:#TODO - exception here
         return None
     desc_data = data[6+offset:self.ts_descriptors_len + 6 + offset]
     self.descriptors = descriptors.get_descriptors(desc_data)
     self.length = self.ts_descriptors_len + 6
     return self.ts_descriptors_len + 6 + offset