def runPeak(self, grid, size, expected_location, expected_value): (width, height) = size problem = peak.PeakProblem(grid, (0, 0, width, height)) peek_location = algorithms.algorithm1(problem) is_peak = problem.isPeak(peek_location) self.assertEqual(True, is_peak) self.assertEqual(expected_location, peek_location) self.assertEqual(expected_value, problem.get(peek_location))
def test_Algorithm1(self): for testNumber in range(10000): testArray = generate.randomProblem(10, 10, 1000) testProblem = peak.createProblem(testArray) testPeak = algorithms.algorithm1(testProblem) self.assertTrue(testProblem.isPeak(testPeak))
fps_list = [] prev_frame = [] # Read until video is completed while(cap.isOpened()): # Capture frame-by-frame ret, frame = cap.read() if ret == True: original_frame = np.copy(frame) # Add noise frame = saltAndPepperNoise(frame, 0.01) frame = gaussianNoise(frame, 400) # Apply 1st algorithm to noisy frame roi_mask, masked_frame = algorithm1(frame) # Display the resulting frame cv2.imshow('Original Video', original_frame) cv2.imshow('Noisy Video', frame) cv2.imshow('ROI Mask', roi_mask*255) cv2.imshow('ROI Video', masked_frame) # Keep previous frame prev_frame = frame # Calculate fps metric current_frame_time = time.time() seconds = current_frame_time - prev_frame_time prev_frame_time = current_frame_time fps = round(1/seconds, 2)
# Capture frame-by-frame ret, frame = cap.read() if ret == True: original_frame = np.copy(frame) # Add noise frame = saltAndPepperNoise(frame, 0.01) frame = gaussianNoise(frame, 400) # Remove noise: first remove salt-and-pepper noise # and then remove gaussian noise clean_frame = cv2.medianBlur(frame, 5) clean_frame = blurring(frame) # Apply 1st algorithm to noisy frame roi_mask, masked_frame = algorithm1(clean_frame) # Display the resulting frame cv2.imshow('Original Video', original_frame) cv2.imshow('Noisy Video', frame) cv2.imshow('ROI Mask', roi_mask*255) cv2.imshow('ROI Video', masked_frame) # Keep previous frame prev_frame = frame # Calculate fps metric current_frame_time = time.time() seconds = current_frame_time - prev_frame_time prev_frame_time = current_frame_time fps = round(1/seconds, 2)