def __init__(self, graph_obj: Graph): # some_query_img_objects = (query_video_distinct_frames.get_objects(0, 2)) # img_objects_list contains 3 elements # nodes_matched = self.match_node_with_frames(some_query_img_objects, graph_obj) print("atleast started") # nodes_matched = [] # self.nodes_matched.append(graph_obj.get_node(2)) self.nodes_matched.append(graph_obj.get_node(0)) # self.find_edge_with_nodes(0) return
def match_node_with_frames(some_query_img_objects: list, graph_obj: Graph): search_list = graph_obj.Nodes node_confidence = [] # node_confidence is list of (node.identity:int , confidence:int , total_fraction_matched:float) for node in search_list: for img_obj in some_query_img_objects: node_images: vo2.DistinctFrames = node.node_images if node_images is not None: for data_obj in node_images.get_objects(): image_fraction_matched, min_good_matches = mt.SURF_returns( img_obj.get_elements(), data_obj.get_elements(), 2500, 0.7) if min_good_matches > 100 and image_fraction_matched != -1: if image_fraction_matched > 0.05 or min_good_matches > 225: print("Match found btw" + str(img_obj.get_time()) + " of query video and " + str(data_obj.get_time()) + " of node data") if len(node_confidence ) > 0 and node_confidence[-1][ 0] == node.identity: entry = node_confidence[-1] node_confidence[-1] = ( node.identity, entry[1] + 1, entry[2] + image_fraction_matched) # print(str(node.identity) + " matched by " + str(image_fraction_matched)) else: node_confidence.append( (node.identity, 1, image_fraction_matched)) node_confidence = sorted(node_confidence, key=lambda x: (x[1], x[2]), reverse=True) print(node_confidence) final_node_list = [] for entry in node_confidence: final_node_list.append(graph_obj.get_node(entry[0])) return final_node_list