def main(): """ The main function """ ''' database = input("Enter the name of database: ") user = input("Enter your Username: "******"Enter the password: "******"Enter the host name where PostgreSQL database is install: ") port = input("Enter the port: ") Data = date_import(database, user, password, host, port) ''' Data = pd.read_csv("Data.csv") # create anomalies percent = 10 # percentage of anomalies in the data Data, true_data, anom_patients = generator(Data, percent) # calculate distances Mahaldist, Eucliddist, Cosinedist = calculate_dist(Data) # detection of anomalies (euclid, mahal, cosin, macos, maeuc, eucos, maeuccos, outliers) = detector(Mahaldist, Eucliddist, Cosinedist) # quality control #true_data = np.zeros(len(euclid)) max_acc, accuracy, frame_dict = quality_of_classification( euclid, mahal, cosin, macos, maeuc, eucos, maeuccos, true_data) return Data, max_acc, accuracy, frame_dict, outliers, anom_patients
def xml2json(file_name): # total_member, ref, nvd, non_nvd = 0, 0, 0, 0 with open('/home/wenbing/Desktop/Don_NTU/CNVD_dataset/'+file_name, 'r', encoding='UTF-8') as f: xmlString = f.read() jsonString = json.dumps(xmltodict.parse(xmlString),ensure_ascii=False, indent=4) output = json.loads(jsonString) member = output['vulnerabilitys']['vulnerability'] for _ in member: # total_member = total_member +1 if 'referenceLink' in _: url = _['referenceLink'] print("链接:", url) print(detector(url))
#reading the current frame ret, captured_frame = capture.read() #break the loop if no input is received if captured_frame is None: break #resizing the frame received captured_frame = cv2.resize(captured_frame, (imageSize)) #applying background subtraction method to get foreground mask fg_mask = bg_sub.apply(captured_frame) #creating an instance of detector object DetectorObject = detector(fg_mask, minimumDetectionArea, image_no, captured_frame) # Obtain measurements centers, coordinates = DetectorObject.detect() # Draws boxes where object detected, if no measurements, do nothing try: DetectorObject.draw_rectangles(coordinates, (0, 0, 0)) except: pass cv2.imshow('Detection on the Original Image', captured_frame) cv2.imshow('Detected Background After Filtering', fg_mask) # Write images into desired folder # cv2.imwrite(f'pics\org_box\{image_no}.jpg', captured_frame)