def detect_image_in_container(blob_name, should_upload, container_service): bytes = container_service.download_blob(blob_name) image = get_image_from_bytes_string(bytes) for color in COLORS: image_binary_where_color = np.zeros(image.shape[0:2], dtype=np.uint8) for bound in color.bounds: image_binary_where_color_bound = find_color_in_image( image, np.array(bound.lower), np.array(bound.upper)) image_binary_where_color = np.bitwise_or( image_binary_where_color, image_binary_where_color_bound) biggest_contour = get_biggest_contour_in_range( image_binary_where_color) if len(biggest_contour) > 0: bounding_box_xywh = cv2.boundingRect(biggest_contour) draw_bounding_box( image, bounding_box_xywh, f"{color.name} ziptie", color.default_color, ) if should_upload: image_file_extension = f".{blob_name.split('.')[-1]}" image_file_name = blob_name.split("/")[-1] bytes_string = get_bytes_string_from_image(image, image_file_extension) blob_client = container_service.get_blob_client( f"processed_images/{image_file_name}") blob_client.upload_blob(bytes_string, overwrite=True) else: show_image(image)
def draw_all(image, boxes, score=None, class_num=None): show_image( draw_boxes((image - 127.5) / 127.5, boxes[:, 0:4], class_num=class_num, score=score, blue=255, green=0, red=0))
def main(): images_dir = input("Please enter the directory containing the shredded images to be reassembled: ") filenames = files_in_directory(images_dir) print("files to be reassembled: {0}".format(filenames)) slices = [] for filename in filenames: slices.append(load_image(filename)) #show_all_images(slices[0], tuple(slices[1:])) while len(slices) > 1: left_index, right_index = findBestMatch(slices) print((left_index, right_index)) merge(slices, left_index, right_index) show_image(slices[0])
def main(): images_dir = input( "Please enter the directory containing the shredded images to be reassembled: " ) filenames = files_in_directory(images_dir) print("files to be reassembled: {0}".format(filenames)) slices = [] for filename in filenames: slices.append(load_image(filename)) #show_all_images(slices[0], tuple(slices[1:])) while len(slices) > 1: left_index, right_index = findBestMatch(slices) print((left_index, right_index)) merge(slices, left_index, right_index) show_image(slices[0])
def run_demo(): """ Run demo on images in folder "images" """ path = os.path.abspath("../images") image_list = os.listdir(path) for image_name in image_list: image_path = os.path.join(path, image_name) print("-----------------------------------------------") print("Path:", image_path) image = image_load(image_path) detect_data = detection(image_path) if len(detect_data) > 0: draw_boxes(image, detect_data[:, 0:4], detect_data[:, 4], detect_data[:, 5], red=255) show_image(image, False) print(detect_data)
return image def profile_measurement(self, frame): points3d, profile = self.points_profile(frame) frame = self.draw_points(frame, profile, color=(0, 0, 255), thickness=2) if len(points3d) > 0: print points3d point3d = points3d[len(points3d)/5] cv2.putText(frame, '%s' % point3d, (11, 22), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 255, 255), thickness=1, lineType=cv2.CV_AA) return frame if __name__ == '__main__': import image img = image.read_image('../data/utest9.png') profile0 = Profile(axis=1, thr=180, method='pcog') image.show_image(profile0.profile_measurement(img)) #cv2.imwrite('peak.png', profile0.profile_measurement(img)) #profile0.load_configuration('triangulation0.yml') # Camera test #from webcam import Webcam #camera = Webcam(device=1) #camera.set_size((800, 600)) #camera.set_parameters(0.30, 0.20, 0.10) #camera.run(callback=lambda img: profile0.profile_measurement(img))
train_data[-1].append(float(info[i])) with open("binMNIST_data/targetdigit_trn.csv") as f: lines = f.readlines() for line in lines: train_label.append(int(line)) return train_data, train_label def get_test_data(): test_data = [] test_label = [] index = 0 with open("binMNIST_data/bindigit_tst.csv") as f: lines = f.readlines() for line in lines: test_data.append([]) info = line.split(",") for i in range(784): test_data[-1].append(float(info[i])) with open("binMNIST_data/targetdigit_tst.csv") as f: lines = f.readlines() for line in lines: test_label.append(int(line)) return test_data, test_label if __name__ == "__main__": x, y = get_train_data() x1, y1 = get_test_data() image.show_image(x[0]) print y[0]