diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/Computer Vision Toolkit.csproj b/Computer Vision Toolkit/Computer Vision Toolkit/Computer Vision Toolkit.csproj index 7e3aff9..7006da5 100644 --- a/Computer Vision Toolkit/Computer Vision Toolkit/Computer Vision Toolkit.csproj +++ b/Computer Vision Toolkit/Computer Vision Toolkit/Computer Vision Toolkit.csproj @@ -1,218 +1,224 @@ - - - - - Debug - AnyCPU - {58D1E99E-3294-47A4-BE32-ECDBECDEA4BC} - WinExe - Computer_Vision_Toolkit - CVER Toolkit - v4.6.1 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - lib\Assets\icon.ico - - - - - - - - - - - - - - - - - Form - - - AboutBox.cs - - - Form - - - AlgorithmsForm.cs - - - Form - - - batchName.cs - - - Form - - - MainForm.cs - - - Form - - - ParametersForm.cs - - - Form - - - ProcessForm.cs - - - - - Form - - - PythonCheckForm.cs - - - Form - - - resultDialog.cs - - - - AboutBox.cs - - - AlgorithmsForm.cs - - - batchName.cs - - - MainForm.cs - - - ParametersForm.cs - - - ProcessForm.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - PythonCheckForm.cs - - - resultDialog.cs - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - Always - - - - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - + + + + + Debug + AnyCPU + {58D1E99E-3294-47A4-BE32-ECDBECDEA4BC} + WinExe + Computer_Vision_Toolkit + CVER Toolkit + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + lib\Assets\icon.ico + + + + + + + + + + + + + + + + + Form + + + AboutBox.cs + + + Form + + + AlgorithmsForm.cs + + + Form + + + batchName.cs + + + Form + + + MainForm.cs + + + Form + + + ParametersForm.cs + + + Form + + + ProcessForm.cs + + + + + Form + + + PythonCheckForm.cs + + + Form + + + resultDialog.cs + + + + AboutBox.cs + + + AlgorithmsForm.cs + + + batchName.cs + + + MainForm.cs + + + ParametersForm.cs + + + ProcessForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + PythonCheckForm.cs + + + resultDialog.cs + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + Always + + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + \ No newline at end of file diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/lib/Algorithms/RoboticVisionLabDetector.py b/Computer Vision Toolkit/Computer Vision Toolkit/lib/Algorithms/RoboticVisionLabDetector.py new file mode 100644 index 0000000..a1d546d --- /dev/null +++ b/Computer Vision Toolkit/Computer Vision Toolkit/lib/Algorithms/RoboticVisionLabDetector.py @@ -0,0 +1,488 @@ +import struct +import numpy as np +from keras.layers import Conv2D +from keras.layers import Input +from keras.layers import BatchNormalization +from keras.layers import LeakyReLU +from keras.layers import ZeroPadding2D +from keras.layers import UpSampling2D +from keras.layers.merge import add, concatenate +from keras.models import Model +from keras.models import load_model +from keras.preprocessing.image import load_img +from keras.preprocessing.image import img_to_array +from numpy import expand_dims +import cv2 as cv +import timer + + + +def _conv_block(inp, convs, skip=True): + x = inp + count = 0 + for conv in convs: + if count == (len(convs) - 2) and skip: + skip_connection = x + count += 1 + if conv['stride'] > 1: x = ZeroPadding2D(((1,0),(1,0)))(x) # peculiar padding as darknet prefer left and top + x = Conv2D(conv['filter'], + conv['kernel'], + strides=conv['stride'], + padding='valid' if conv['stride'] > 1 else 'same', # peculiar padding as darknet prefer left and top + name='conv_' + str(conv['layer_idx']), + use_bias=False if conv['bnorm'] else True)(x) + if conv['bnorm']: x = BatchNormalization(epsilon=0.001, name='bnorm_' + str(conv['layer_idx']))(x) + if conv['leaky']: x = LeakyReLU(alpha=0.1, name='leaky_' + str(conv['layer_idx']))(x) + return add([skip_connection, x]) if skip else x + + +def make_yolov3_model(): + input_image = Input(shape=(None, None, 3)) + + # Layer 0 => 4 + x = _conv_block(input_image, + [{'filter': 32, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 0}, + {'filter': 64, 'kernel': 3, 'stride': 2, 'bnorm': True, 'leaky': True, 'layer_idx': 1}, + {'filter': 32, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 2}, + {'filter': 64, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 3}]) + + # Layer 5 => 8 + x = _conv_block(x, [{'filter': 128, 'kernel': 3, 'stride': 2, 'bnorm': True, 'leaky': True, 'layer_idx': 5}, + {'filter': 64, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 6}, + {'filter': 128, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 7}]) + + # Layer 9 => 11 + x = _conv_block(x, [{'filter': 64, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 9}, + {'filter': 128, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 10}]) + + # Layer 12 => 15 + x = _conv_block(x, [{'filter': 256, 'kernel': 3, 'stride': 2, 'bnorm': True, 'leaky': True, 'layer_idx': 12}, + {'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 13}, + {'filter': 256, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 14}]) + + # Layer 16 => 36 + for i in range(7): + x = _conv_block(x, [ + {'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 16 + i * 3}, + {'filter': 256, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 17 + i * 3}]) + + skip_36 = x + + # Layer 37 => 40 + x = _conv_block(x, [{'filter': 512, 'kernel': 3, 'stride': 2, 'bnorm': True, 'leaky': True, 'layer_idx': 37}, + {'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 38}, + {'filter': 512, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 39}]) + + # Layer 41 => 61 + for i in range(7): + x = _conv_block(x, [ + {'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 41 + i * 3}, + {'filter': 512, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 42 + i * 3}]) + + skip_61 = x + + # Layer 62 => 65 + x = _conv_block(x, [{'filter': 1024, 'kernel': 3, 'stride': 2, 'bnorm': True, 'leaky': True, 'layer_idx': 62}, + {'filter': 512, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 63}, + {'filter': 1024, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 64}]) + + # Layer 66 => 74 + for i in range(3): + x = _conv_block(x, [ + {'filter': 512, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 66 + i * 3}, + {'filter': 1024, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 67 + i * 3}]) + + # Layer 75 => 79 + x = _conv_block(x, [{'filter': 512, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 75}, + {'filter': 1024, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 76}, + {'filter': 512, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 77}, + {'filter': 1024, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 78}, + {'filter': 512, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 79}], + skip=False) + + # Layer 80 => 82 + yolo_82 = _conv_block(x, [{'filter': 1024, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 80}, + {'filter': 255, 'kernel': 1, 'stride': 1, 'bnorm': False, 'leaky': False, + 'layer_idx': 81}], skip=False) + + # Layer 83 => 86 + x = _conv_block(x, [{'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 84}], + skip=False) + x = UpSampling2D(2)(x) + x = concatenate([x, skip_61]) + + # Layer 87 => 91 + x = _conv_block(x, [{'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 87}, + {'filter': 512, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 88}, + {'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 89}, + {'filter': 512, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 90}, + {'filter': 256, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 91}], + skip=False) + + # Layer 92 => 94 + yolo_94 = _conv_block(x, [{'filter': 512, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 92}, + {'filter': 255, 'kernel': 1, 'stride': 1, 'bnorm': False, 'leaky': False, + 'layer_idx': 93}], skip=False) + + # Layer 95 => 98 + x = _conv_block(x, [{'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 96}], + skip=False) + x = UpSampling2D(2)(x) + x = concatenate([x, skip_36]) + + # Layer 99 => 106 + yolo_106 = _conv_block(x, [{'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, 'layer_idx': 99}, + {'filter': 256, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, + 'layer_idx': 100}, + {'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, + 'layer_idx': 101}, + {'filter': 256, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, + 'layer_idx': 102}, + {'filter': 128, 'kernel': 1, 'stride': 1, 'bnorm': True, 'leaky': True, + 'layer_idx': 103}, + {'filter': 256, 'kernel': 3, 'stride': 1, 'bnorm': True, 'leaky': True, + 'layer_idx': 104}, + {'filter': 255, 'kernel': 1, 'stride': 1, 'bnorm': False, 'leaky': False, + 'layer_idx': 105}], skip=False) + + model = Model(input_image, [yolo_82, yolo_94, yolo_106]) + return model + + +class WeightReader: + def __init__(self, weight_file): + with open(weight_file, 'rb') as w_f: + major, = struct.unpack('i', w_f.read(4)) + minor, = struct.unpack('i', w_f.read(4)) + revision, = struct.unpack('i', w_f.read(4)) + + if (major * 10 + minor) >= 2 and major < 1000 and minor < 1000: + w_f.read(8) + else: + w_f.read(4) + + transpose = (major > 1000) or (minor > 1000) + + binary = w_f.read() + + self.offset = 0 + self.all_weights = np.frombuffer(binary, dtype='float32') + + def read_bytes(self, size): + self.offset = self.offset + size + return self.all_weights[self.offset - size:self.offset] + + def load_weights(self, model): + for i in range(106): + try: + conv_layer = model.get_layer('conv_' + str(i)) + #print("loading weights of convolution #" + str(i)) + + if i not in [81, 93, 105]: + norm_layer = model.get_layer('bnorm_' + str(i)) + + size = np.prod(norm_layer.get_weights()[0].shape) + + beta = self.read_bytes(size) # bias + gamma = self.read_bytes(size) # scale + mean = self.read_bytes(size) # mean + var = self.read_bytes(size) # variance + + weights = norm_layer.set_weights([gamma, beta, mean, var]) + + if len(conv_layer.get_weights()) > 1: + bias = self.read_bytes(np.prod(conv_layer.get_weights()[1].shape)) + kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape)) + + kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape))) + kernel = kernel.transpose([2, 3, 1, 0]) + conv_layer.set_weights([kernel, bias]) + else: + kernel = self.read_bytes(np.prod(conv_layer.get_weights()[0].shape)) + kernel = kernel.reshape(list(reversed(conv_layer.get_weights()[0].shape))) + kernel = kernel.transpose([2, 3, 1, 0]) + conv_layer.set_weights([kernel]) + except ValueError: + k=0 + #print("no convolution #" + str(i)) + + def reset(self): + self.offset = 0 + +class BoundBox: + def __init__(self, xmin, ymin, xmax, ymax, objness=None, classes=None): + self.xmin = xmin + self.ymin = ymin + self.xmax = xmax + self.ymax = ymax + + self.objness = objness + self.classes = classes + + self.label = -1 + self.score = -1 + + def get_label(self): + if self.label == -1: + self.label = np.argmax(self.classes) + + return self.label + + def get_score(self): + if self.score == -1: + self.score = self.classes[self.get_label()] + + return self.score +def _sigmoid(x): + return 1. / (1. + np.exp(-x)) + + +def decode_netout(netout, anchors, obj_thresh, nms_thresh, net_h, net_w): + grid_h, grid_w = netout.shape[:2] + nb_box = 3 + netout = netout.reshape((grid_h, grid_w, nb_box, -1)) + nb_class = netout.shape[-1] - 5 + + boxes = [] + + netout[..., :2] = _sigmoid(netout[..., :2]) + netout[..., 4:] = _sigmoid(netout[..., 4:]) + netout[..., 5:] = netout[..., 4][..., np.newaxis] * netout[..., 5:] + netout[..., 5:] *= netout[..., 5:] > obj_thresh + + for i in range(grid_h * grid_w): + row = i / grid_w + col = i % grid_w + + for b in range(nb_box): + # 4th element is objectness score + objectness = netout[int(row)][int(col)][b][4] + # objectness = netout[..., :4] + + if (objectness.all() <= obj_thresh): continue + + # first 4 elements are x, y, w, and h + x, y, w, h = netout[int(row)][int(col)][b][:4] + + x = (col + x) / grid_w # center position, unit: image width + y = (row + y) / grid_h # center position, unit: image height + w = anchors[2 * b + 0] * np.exp(w) / net_w # unit: image width + h = anchors[2 * b + 1] * np.exp(h) / net_h # unit: image height + + # last elements are class probabilities + classes = netout[int(row)][col][b][5:] + + box = BoundBox(x - w / 2, y - h / 2, x + w / 2, y + h / 2, objectness, classes) + # box = BoundBox(x-w/2, y-h/2, x+w/2, y+h/2, None, classes) + + boxes.append(box) + + return boxes + + +def correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w): + if (float(net_w) / image_w) < (float(net_h) / image_h): + new_w = net_w + new_h = (image_h * net_w) / image_w + else: + new_h = net_w + new_w = (image_w * net_h) / image_h + + for i in range(len(boxes)): + x_offset, x_scale = (net_w - new_w) / 2. / net_w, float(new_w) / net_w + y_offset, y_scale = (net_h - new_h) / 2. / net_h, float(new_h) / net_h + + boxes[i].xmin = int((boxes[i].xmin - x_offset) / x_scale * image_w) + boxes[i].xmax = int((boxes[i].xmax - x_offset) / x_scale * image_w) + boxes[i].ymin = int((boxes[i].ymin - y_offset) / y_scale * image_h) + boxes[i].ymax = int((boxes[i].ymax - y_offset) / y_scale * image_h) + +def preprocess_input(image, net_h, net_w): + new_h, new_w, _ = image.shape + + # determine the new size of the image + if (float(net_w)/new_w) < (float(net_h)/new_h): + new_h = (new_h * net_w)//new_w + new_w = net_w + else: + new_w = (new_w * net_h)//new_h + new_h = net_h + + # resize the image to the new size + resized = cv.resize(image[:,:,::-1]/255., (new_w, new_h)) + + # embed the image into the standard letter box + new_image = np.ones((net_h, net_w, 3)) * 0.5 + new_image[(net_h-new_h)//2:(net_h+new_h)//2, (net_w-new_w)//2:(net_w+new_w)//2, :] = resized + new_image = np.expand_dims(new_image, 0) + + return new_image + + +def _interval_overlap(interval_a, interval_b): + x1, x2 = interval_a + x3, x4 = interval_b + + if x3 < x1: + if x4 < x1: + return 0 + else: + return min(x2,x4) - x1 + else: + if x2 < x3: + return 0 + else: + return min(x2,x4) - x3 + + +def bbox_iou(box1, box2): + intersect_w = _interval_overlap([box1.xmin, box1.xmax], [box2.xmin, box2.xmax]) + intersect_h = _interval_overlap([box1.ymin, box1.ymax], [box2.ymin, box2.ymax]) + + intersect = intersect_w * intersect_h + + w1, h1 = box1.xmax - box1.xmin, box1.ymax - box1.ymin + w2, h2 = box2.xmax - box2.xmin, box2.ymax - box2.ymin + + union = w1 * h1 + w2 * h2 - intersect + + return float(intersect) / union + + +def do_nms(boxes, nms_thresh): + if len(boxes) > 0: + nb_class = len(boxes[0].classes) + else: + return + + for c in range(nb_class): + sorted_indices = np.argsort([-box.classes[c] for box in boxes]) + + for i in range(len(sorted_indices)): + index_i = sorted_indices[i] + + if boxes[index_i].classes[c] == 0: continue + + for j in range(i + 1, len(sorted_indices)): + index_j = sorted_indices[j] + + if bbox_iou(boxes[index_i], boxes[index_j]) >= nms_thresh: + boxes[index_j].classes[c] = 0 + +# get all of the results above a threshold +def get_boxes(boxes, labels, thresh): + v_boxes, v_labels, v_scores = list(), list(), list() + # enumerate all boxes + for box in boxes: + # enumerate all possible labels + for i in range(len(labels)): + if i == 0: + # check if the threshold for this label is high enough + if box.classes[i] > thresh: + v_boxes.append(box) + v_labels.append(labels[i]) + v_scores.append(box.classes[i]*100) + # don't break, many labels may trigger for one box + return v_boxes, v_labels, v_scores + +net_h, net_w = 416, 416 +nms_thresh = 0.45 +anchors = [[116,90, 156,198, 373,326], [30,61, 62,45, 59,119], [10,13, 16,30, 33,23]] +labels = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", \ + "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", \ + "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", \ + "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", \ + "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", \ + "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", \ + "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", \ + "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse", \ + "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", \ + "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"] + +def CreateMask(image,boxes,labels, obj_thresh): + new_h, new_w, color_c = image.shape + mask = image * 0 + + + for box in boxes: + label_str = '' + label = -1 + + for i in range(len(labels)): + if box.classes[i] > obj_thresh: + label = i + if label == 0: + #print('hello') + #print(box.xmin,box.xmax , box.ymin, box.ymax) + mask[box.ymin: box.ymax,box.xmin:box.xmax ] = box.classes[i] * 100 *2 + mask = cv.cvtColor(mask, cv.COLOR_BGR2GRAY) + mask = np.interp(mask, [np.min(mask), np.max(mask)], [0, 255]) + + return mask + +def draw_boxes(image, boxes, labels, obj_thresh): + for box in boxes: + label_str = '' + label = -1 + + for i in range(len(labels)): + if box.classes[i] > obj_thresh: + label_str += labels[i] + label = i + #print(labels[i] + ': ' + str(box.classes[i]*100) + '%') + + if label == 0: + cv.rectangle(image, (box.xmin,box.ymin), (box.xmax,box.ymax), (0,255,0), 3) + #cv.putText(image, + #label_str + ' ' + str(box.get_score()), + #(box.xmin, box.ymin - 13), + #cv2.FONT_HERSHEY_SIMPLEX, + #1e-3 * image.shape[0], + #(0,255,0), 2) + + return image + +def Robotic_Vision_Lab(image_file, Params): + scale_value = 1.0 + # Statistics Variables + t = timer.Timer() + + # Attempt to Analyze + t.start() + obj_thresh = Params["PersonThreshold"] + # Read the input image + if isinstance(image_file, str): + src_img = cv.imread(image_file, cv.IMREAD_COLOR) + else: + src_img = image_file + # define the model + model = make_yolov3_model() + # load the model weights + weight_reader = WeightReader('lib/Algorithms/yolov3.weights') + # set the model weights into the model + weight_reader.load_weights(model) + + + image_h, image_w, _ = src_img.shape + new_image = preprocess_input(src_img, net_h, net_w) + yolos = model.predict(new_image) + + boxes = [] + + for i in range(len(yolos)): + # decode the output of the network + boxes += decode_netout(yolos[i][0], anchors[i], obj_thresh, nms_thresh, net_h, net_w) + + # correct the sizes of the bounding boxes + correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w) + + # suppress non-maximal boxes + do_nms(boxes, nms_thresh) + v_boxes, v_labels, v_scores = get_boxes(boxes, labels, obj_thresh) + + mask = CreateMask(src_img, boxes, labels, obj_thresh) + #mask = draw_boxes(src_img, boxes, labels, obj_thresh) + + t.stop() + + return mask, t.get_time(), 0 \ No newline at end of file diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/lib/Setup/installPythonPackages.bat b/Computer Vision Toolkit/Computer Vision Toolkit/lib/Setup/installPythonPackages.bat index 476b69c..d478edc 100644 --- a/Computer Vision Toolkit/Computer Vision Toolkit/lib/Setup/installPythonPackages.bat +++ b/Computer Vision Toolkit/Computer Vision Toolkit/lib/Setup/installPythonPackages.bat @@ -1,23 +1,29 @@ -:: Install the python libraries with pip -:: openCV -pip3 install -v opencv-python opencv-contrib-python -:: NumPy -pip3 install -v numpy -:: SciPy -pip3 install -v scipy -:: Scikit-Learn -pip3 install -v scikit-learn -:: Spectral Python -pip3 install -v spectral -:: Matplotlib -pip3 install -v matplotlib - -::==================================================================================== -::--------------------For new algorithms add the new packages here-------------------- -::==================================================================================== -::Use: 'pip3 install -v ' - - - - - +:: Install the python libraries with pip +:: openCV +pip3 install -v opencv-python opencv-contrib-python +:: NumPy +pip3 install -v numpy +:: SciPy +pip3 install -v scipy +:: Scikit-Learn +pip3 install -v scikit-learn +:: Spectral Python +pip3 install -v spectral +:: Matplotlib +pip3 install -v matplotlib + + +::==================================================================================== +::--------------------For new algorithms add the new packages here-------------------- +::==================================================================================== +::Use: 'pip3 install -v ' + +::Tensorflow +pip3 install -v tensorflow +::keras +pip3 install -v keras + + + + + diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.ini b/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.ini index a8937fe..7743440 100644 --- a/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.ini +++ b/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.ini @@ -1,3 +1,4 @@ -RXD=0=1=2 -DebrisDetect=0=1=3 -Dehaze=0=0=1 \ No newline at end of file +RXD=0=1=2 +DebrisDetect=0=1=3 +Dehaze=0=0=1 +Robotic_Vision_Lab=0=0=4 \ No newline at end of file diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.py b/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.py index 42d645e..0748e02 100644 --- a/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.py +++ b/Computer Vision Toolkit/Computer Vision Toolkit/lib/algorithms.py @@ -1,336 +1,340 @@ -# Import the required libraries -import sys -import os -import cv2 as cv -import numpy as np -import json - -from operator import itemgetter - -#Timer class -import timer -from status import status, log - - -#======================================================================================================== -#---------------------------------------------Setup Algorithms------------------------------------------- -#======================================================================================================== - -# Import algorithm libraries -from Algorithms.RXDetector import RXD -from Algorithms.DXDetector import DebrisDetect -from Algorithms.AODNet import Dehaze - - - -#Default parameters for each algorithm -Params = { - "RxThreshold":90.0, - "RxChiThreshold":0.999, - "LineGaussianIter":0, - "LineDilationIter":1, - "LineBilatBlurColor":75, - "LineBilatBlurSpace":75, - "LineCannyEdgeLowerBound":100, - "LineCannyEdgeThreshold":140, - "CornerGaussianIter":0, - "CornerErosionIter":1, - "CornerBilateralColor":200, - "CornerBilateralSpace":500, - "CornerMaxDistance":75, - "CornerNumPoints":3 - - } - - - -#List of aglorithm functions -Alg_List = { - 'RXD':RXD, - 'DebrisDetect':DebrisDetect, - 'Dehaze':Dehaze - - } - -Alg_Order = { - 'RXD':2, - 'DebrisDetect':3, - 'Dehaze':1 - - } - -Alg_Pipe = { - 'RXD':0, - 'DebrisDetect':0, - 'Dehaze':0 - - } - - - - -#======================================================================================================== -#------------------------------------------Read Parameters File------------------------------------------ -#======================================================================================================== - -#Get parameters.ini file -paramFile = open(os.path.join( os.path.dirname(sys.argv[0]), "parameters.ini"), "r") - -#Add code to read in the parameters from the file Here to overwrite the defaults -for line in paramFile: - if line[0] == '#': - pass - else: - #split the line into a list - splitLine=line.strip().split("=") - - #see if parameter is in our dictionary - #splitline[1] is 1 for default, 0 for User value - if splitLine[0] in Params and int(splitLine[1]) is 0: - Params[splitLine[0]] = float(splitLine[3]) - - -#======================================================================================================== -#------------------------------------------Read Algortihms File------------------------------------------ -#======================================================================================================== - -#Get algorithms.ini file -algFile = open(os.path.join( os.path.dirname(sys.argv[0]), "algorithms.ini"), "r") -#Add code to read in the parameters from the file Here to overwrite the defaults -for line in algFile: - if line[0] == '#': - pass - else: - #split the line into a list - splitLine=line.strip().split("=") - - #see if the algorithm is in our dictionary - #splitline[2] determines if th algorithm will be used during analysis. 1 for use, 0 for not use - if splitLine[0] in Alg_Order: - if int(splitLine[2]) is 1: - Alg_Order[splitLine[0]] = int(splitLine[3]) - Alg_Pipe[splitLine[0]] = int(splitLine[1]) - else: - Alg_Order[splitLine[0]] = -1 #Set the order to -1. This means that the algorithm will not be used in the analysis. - - -#======================================================================================================== -#-------------------------------------------Run the Algorithms------------------------------------------- -#======================================================================================================== - -def algorithms(image_path, apply_heatmap=True, range_min=0, range_max=255, scale_value = 1.0): - - #Read image from an object or file path - if isinstance(image_path, str): - image = cv.imread( image_path, cv.IMREAD_COLOR ) - else: - image = image_path - - #Scale the image - if scale_value != 1.0: - height, width = image.shape[:2] - image = cv.resize( image, (int( width * scale_value ), int( height * scale_value)), interpolation=cv.INTER_LINEAR) - - #Setup the scores matrix - scores = np.zeros(image.shape[:2]) - time = float(0) - stats = float(0) - - #Create the unused image list - unused_images = [] - - #-------------------------------------------------------------------------------------------------------- - #-------------------------------------------------------------------------------------------------------- - - #Sort the algorithms to use by the order saved by the user. This is stored in the 'algorithms.ini' file - alg_sorted = sorted(Alg_Order.items(), key=lambda kv: kv[1], reverse=False) - - #Run the algorithms - #for alg in Alg_List.items(): - for alg in alg_sorted: - if alg[0] in Alg_List and alg[1] != -1: #Check if this algorithm will be run - - if alg[0] is 'Dehaze': #The Dehaze algorithm always requires it to be piped into another algorithm - Alg_Pipe[alg[0]] = 1 - - if alg[0] in Alg_Pipe and Alg_Pipe[alg[0]] == 1: #Check if this algorithm's results need to be piped into other algorithms - rtn = Alg_List[alg[0]](image, Params) - - #Convert a 2D matrix of scores into a grayscale 3 channel image - if len(rtn[0].shape) < 3: - image = cv.applyColorMap( rtn[0].astype(np.uint8), cv.COLORMAP_BONE ) - else: - image = rtn[0] - - else: - #Get the function from Alg_List and run it - rtn = Alg_List[alg[0]](image, Params) - - #Add the current algorithm's results to the overall results - if len(rtn[0].shape) < 3: - scores += rtn[0] - else: - unused_images.append(rtn[0]) - - - #Add the current algorithm's completion time and statistics - time += rtn[1] - stats += rtn[2] - - #-------------------------------------------------------------------------------------------------------- - #-------------------------------------------------------------------------------------------------------- - - #Map final scores to the range [0,255] - if np.max(scores) > 0: - scores = np.interp(scores, [np.min(scores), np.max(scores)], [range_min, range_max]) - else: - scores = unused_images[0] - - #Return the results - return scores, time, stats, unused_images - - - -#======================================================================================================== -#----------------------------------------------Run an Analysis------------------------------------------- -#======================================================================================================== - -#Analyze the given image (img) -def run_analysis(args): - img = args[0] #Image to be analyzed - batch_path = args[1] #Used for save location - - batch_log = open(os.path.join(batch_path, 'batch_log.txt'), 'a+') - detected_log = open(os.path.join(batch_path, 'detected_log.txt'), 'a+') - other_log = open(os.path.join(batch_path, 'other_log.txt'), 'a+') - - #Accepted extensions - ext = os.path.splitext(img)[-1] - - #Image name to save the heatmap under - img_name = ".".join(os.path.split(img)[1].split(".")[:-1]) - - #Handles video input - if ext.lower() == ".mp4": - #Create and start the timer - t = timer.Timer() - t.start() - - #Analyze the video - rtn_name = analyzeVideo( (img, batch_path, 30) ) - - #Stop the timer - t.stop() - - #Log the results - rtn_str = rtn_name, t.get_time(), 0.0 - status('-v-', rtn_str ) - log(detected_log, '-v-', rtn_str ) - - else: - - #Call the algorithms - final_scores, final_time, final_stats, unused_images = algorithms(img) - - #-------------------------------------------------------------------------------------------------------- - #-------------------------------------------------------------------------------------------------------- - - #Apply colormap to the combined heatmap if it is not already a color image - if len(final_scores.shape) < 3: - final_image = cv.applyColorMap( final_scores.astype(np.uint8), cv.COLORMAP_JET ) #TODO: Compare with COLORMAP_RAINBOW (First Responders stated that they tend to use it instead of Jet) - else: - final_image = final_scores - - - #-------------------------------------------------------------------------------------------------------- - #-------------------------------------------------------------------------------------------------------- - - #Save heatmap in the correct folder - if np.max(final_scores) >= 50: #TODO: Re-Evaluate whether this is still a valid requirement - results_str = [ img_name, final_time, final_stats ] - status('-d-', results_str) - log(batch_log, '-d-', results_str) - log(detected_log, '-d-', results_str) - #cv.imwrite(os.path.join( detected_folder, img_name + ".jpg"), final_image) - cv.imwrite(os.path.join( batch_path, "Analyzed", img_name + ".jpg"), final_image) - - else: - results_str = [ img_name, final_time, final_stats ] - status( '-o-', results_str) - log(batch_log, '-o-', results_str) - log(other_log, '-o-', results_str) - #cv.imwrite(os.path.join( other_folder, img_name + ".jpg"), final_image) - cv.imwrite(os.path.join( batch_path, "Other Analyzed", img_name + ".jpg"), final_image) - - #Save any resulting images from the algorithms that couldn't be used to produce the heatmap -# ct = 1 -# for u_img in unused_images: -# results_str = [ img_name, final_time, "Modified Original" ] -# status( '-i-', "An unused image was detected. Image saved to 'Modified Original' folder.") -# status( '-m-', results_str) -# log(batch_log, '-m-', results_str) -# cv.imwrite(os.path.join( batch_path, "Modified Original", img_name + ".jpg"), u_img) -# ct += 1 - - batch_log.close() - detected_log.close() - other_log.close() - return - - - -#======================================================================================================== -#--------------------------------------------Run a Video Analysis---------------------------------------- -#======================================================================================================== - -def analyzeVideo(args): - video_path = args[0] - batch_path = args[1] - fps = args[2] - - vid_name = ".".join(os.path.split(video_path)[1].split(".")[:-1]) - vid_capture = cv.VideoCapture(video_path) - success, frame = vid_capture.read() - size = (frame.shape[1],frame.shape[0]) - - count = 0 - success = True - - save_path = os.path.join(batch_path, "Videos") - if not os.path.exists(save_path): - os.makedirs(save_path) - - fourcc = cv.VideoWriter_fourcc('D', 'I', 'V', 'X') - out = cv.VideoWriter(os.path.join(save_path, vid_name + '_heatmap.mp4'), fourcc, int(fps), size) - - #TODO: Add ability to toggle video output during analysis - show_progress = True - key_pressed = 0 - - #Extract frames - while success: - frame_str = "frame{0}.jpg".format(count) - - #cv.imwrite(os.path.join(save_path, frame_str), frame) # save frame as JPEG file - #heatmap_frame = cv.applyColorMap( algs.algorithms(os.path.join(save_path, frame_str))[0].astype(np.uint8), cv.COLORMAP_JET ) - - heatmap_frame = cv.applyColorMap( algorithms(frame)[0].astype(np.uint8), cv.COLORMAP_JET ) - out.write(heatmap_frame) - - success, frame = vid_capture.read() - count += 1 - - #Display progress - if show_progress: - cv.namedWindow('Generating Video Heatmap - Press ESCAPE to close', cv.WINDOW_KEEPRATIO) - cv.resizeWindow('Generating Video Heatmap - Press ESCAPE to close', (500, 375)) - cv.imshow('Generating Video Heatmap - Press ESCAPE to close', heatmap_frame) - key_pressed = cv.waitKey(1) - - if key_pressed == 27: - show_progress = False - cv.destroyAllWindows() - - cv.destroyAllWindows() - out.release() - return os.path.join( vid_name + '_heatmap.mp4') +# Import the required libraries +import sys +import os +import cv2 as cv +import numpy as np +import json + +from operator import itemgetter + +#Timer class +import timer +from status import status, log + + +#======================================================================================================== +#---------------------------------------------Setup Algorithms------------------------------------------- +#======================================================================================================== + +# Import algorithm libraries +from Algorithms.RXDetector import RXD +from Algorithms.DXDetector import DebrisDetect +from Algorithms.AODNet import Dehaze +from Algorithms.AODNet import Dehaze +from Algorithms.RoboticVisionLabDetector import Robotic_Vision_Lab + + + +#Default parameters for each algorithm +Params = { + "RxThreshold":90.0, + "RxChiThreshold":0.999, + "LineGaussianIter":0, + "LineDilationIter":1, + "LineBilatBlurColor":75, + "LineBilatBlurSpace":75, + "LineCannyEdgeLowerBound":100, + "LineCannyEdgeThreshold":140, + "CornerGaussianIter":0, + "CornerErosionIter":1, + "CornerBilateralColor":200, + "CornerBilateralSpace":500, + "CornerMaxDistance":75, + "CornerNumPoints":3, + "PersonThreshold":0.5 + + } + + + +#List of aglorithm functions +Alg_List = { + 'RXD':RXD, + 'DebrisDetect':DebrisDetect, + 'Dehaze':Dehaze, + 'Robotic_Vision_Lab':Robotic_Vision_Lab + + } + +Alg_Order = { + 'RXD':2, + 'DebrisDetect':3, + 'Dehaze':1, + 'Robotic_Vision_Lab':4 + } + +Alg_Pipe = { + 'RXD':0, + 'DebrisDetect':0, + 'Dehaze':0, + 'Robotic_Vision_Lab':0 + } + + + + +#======================================================================================================== +#------------------------------------------Read Parameters File------------------------------------------ +#======================================================================================================== + +#Get parameters.ini file +paramFile = open(os.path.join( os.path.dirname(sys.argv[0]), "parameters.ini"), "r") + +#Add code to read in the parameters from the file Here to overwrite the defaults +for line in paramFile: + if line[0] == '#': + pass + else: + #split the line into a list + splitLine=line.strip().split("=") + + #see if parameter is in our dictionary + #splitline[1] is 1 for default, 0 for User value + if splitLine[0] in Params and int(splitLine[1]) is 0: + Params[splitLine[0]] = float(splitLine[3]) + + +#======================================================================================================== +#------------------------------------------Read Algortihms File------------------------------------------ +#======================================================================================================== + +#Get algorithms.ini file +algFile = open(os.path.join( os.path.dirname(sys.argv[0]), "algorithms.ini"), "r") +#Add code to read in the parameters from the file Here to overwrite the defaults +for line in algFile: + if line[0] == '#': + pass + else: + #split the line into a list + splitLine=line.strip().split("=") + + #see if the algorithm is in our dictionary + #splitline[2] determines if th algorithm will be used during analysis. 1 for use, 0 for not use + if splitLine[0] in Alg_Order: + if int(splitLine[2]) is 1: + Alg_Order[splitLine[0]] = int(splitLine[3]) + Alg_Pipe[splitLine[0]] = int(splitLine[1]) + else: + Alg_Order[splitLine[0]] = -1 #Set the order to -1. This means that the algorithm will not be used in the analysis. + + +#======================================================================================================== +#-------------------------------------------Run the Algorithms------------------------------------------- +#======================================================================================================== + +def algorithms(image_path, apply_heatmap=True, range_min=0, range_max=255, scale_value = 1.0): + + #Read image from an object or file path + if isinstance(image_path, str): + image = cv.imread( image_path, cv.IMREAD_COLOR ) + else: + image = image_path + + #Scale the image + if scale_value != 1.0: + height, width = image.shape[:2] + image = cv.resize( image, (int( width * scale_value ), int( height * scale_value)), interpolation=cv.INTER_LINEAR) + + #Setup the scores matrix + scores = np.zeros(image.shape[:2]) + time = float(0) + stats = float(0) + + #Create the unused image list + unused_images = [] + + #-------------------------------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------------------------------- + + #Sort the algorithms to use by the order saved by the user. This is stored in the 'algorithms.ini' file + alg_sorted = sorted(Alg_Order.items(), key=lambda kv: kv[1], reverse=False) + + #Run the algorithms + #for alg in Alg_List.items(): + for alg in alg_sorted: + if alg[0] in Alg_List and alg[1] != -1: #Check if this algorithm will be run + + if alg[0] is 'Dehaze': #The Dehaze algorithm always requires it to be piped into another algorithm + Alg_Pipe[alg[0]] = 1 + + if alg[0] in Alg_Pipe and Alg_Pipe[alg[0]] == 1: #Check if this algorithm's results need to be piped into other algorithms + rtn = Alg_List[alg[0]](image, Params) + + #Convert a 2D matrix of scores into a grayscale 3 channel image + if len(rtn[0].shape) < 3: + image = cv.applyColorMap( rtn[0].astype(np.uint8), cv.COLORMAP_BONE ) + else: + image = rtn[0] + + else: + #Get the function from Alg_List and run it + rtn = Alg_List[alg[0]](image, Params) + + #Add the current algorithm's results to the overall results + if len(rtn[0].shape) < 3: + scores += rtn[0] + else: + unused_images.append(rtn[0]) + + + #Add the current algorithm's completion time and statistics + time += rtn[1] + stats += rtn[2] + + #-------------------------------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------------------------------- + + #Map final scores to the range [0,255] + if np.max(scores) > 0: + scores = np.interp(scores, [np.min(scores), np.max(scores)], [range_min, range_max]) + else: + scores = unused_images[0] + + #Return the results + return scores, time, stats, unused_images + + + +#======================================================================================================== +#----------------------------------------------Run an Analysis------------------------------------------- +#======================================================================================================== + +#Analyze the given image (img) +def run_analysis(args): + img = args[0] #Image to be analyzed + batch_path = args[1] #Used for save location + + batch_log = open(os.path.join(batch_path, 'batch_log.txt'), 'a+') + detected_log = open(os.path.join(batch_path, 'detected_log.txt'), 'a+') + other_log = open(os.path.join(batch_path, 'other_log.txt'), 'a+') + + #Accepted extensions + ext = os.path.splitext(img)[-1] + + #Image name to save the heatmap under + img_name = ".".join(os.path.split(img)[1].split(".")[:-1]) + + #Handles video input + if ext.lower() == ".mp4": + #Create and start the timer + t = timer.Timer() + t.start() + + #Analyze the video + rtn_name = analyzeVideo( (img, batch_path, 30) ) + + #Stop the timer + t.stop() + + #Log the results + rtn_str = rtn_name, t.get_time(), 0.0 + status('-v-', rtn_str ) + log(detected_log, '-v-', rtn_str ) + + else: + + #Call the algorithms + final_scores, final_time, final_stats, unused_images = algorithms(img) + + #-------------------------------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------------------------------- + + #Apply colormap to the combined heatmap if it is not already a color image + if len(final_scores.shape) < 3: + final_image = cv.applyColorMap( final_scores.astype(np.uint8), cv.COLORMAP_JET ) #TODO: Compare with COLORMAP_RAINBOW (First Responders stated that they tend to use it instead of Jet) + else: + final_image = final_scores + + + #-------------------------------------------------------------------------------------------------------- + #-------------------------------------------------------------------------------------------------------- + + #Save heatmap in the correct folder + if np.max(final_scores) >= 50: #TODO: Re-Evaluate whether this is still a valid requirement + results_str = [ img_name, final_time, final_stats ] + status('-d-', results_str) + log(batch_log, '-d-', results_str) + log(detected_log, '-d-', results_str) + #cv.imwrite(os.path.join( detected_folder, img_name + ".jpg"), final_image) + cv.imwrite(os.path.join( batch_path, "Analyzed", img_name + ".jpg"), final_image) + + else: + results_str = [ img_name, final_time, final_stats ] + status( '-o-', results_str) + log(batch_log, '-o-', results_str) + log(other_log, '-o-', results_str) + #cv.imwrite(os.path.join( other_folder, img_name + ".jpg"), final_image) + cv.imwrite(os.path.join( batch_path, "Other Analyzed", img_name + ".jpg"), final_image) + + #Save any resulting images from the algorithms that couldn't be used to produce the heatmap +# ct = 1 +# for u_img in unused_images: +# results_str = [ img_name, final_time, "Modified Original" ] +# status( '-i-', "An unused image was detected. Image saved to 'Modified Original' folder.") +# status( '-m-', results_str) +# log(batch_log, '-m-', results_str) +# cv.imwrite(os.path.join( batch_path, "Modified Original", img_name + ".jpg"), u_img) +# ct += 1 + + batch_log.close() + detected_log.close() + other_log.close() + return + + + +#======================================================================================================== +#--------------------------------------------Run a Video Analysis---------------------------------------- +#======================================================================================================== + +def analyzeVideo(args): + video_path = args[0] + batch_path = args[1] + fps = args[2] + + vid_name = ".".join(os.path.split(video_path)[1].split(".")[:-1]) + vid_capture = cv.VideoCapture(video_path) + success, frame = vid_capture.read() + size = (frame.shape[1],frame.shape[0]) + + count = 0 + success = True + + save_path = os.path.join(batch_path, "Videos") + if not os.path.exists(save_path): + os.makedirs(save_path) + + fourcc = cv.VideoWriter_fourcc('D', 'I', 'V', 'X') + out = cv.VideoWriter(os.path.join(save_path, vid_name + '_heatmap.mp4'), fourcc, int(fps), size) + + #TODO: Add ability to toggle video output during analysis + show_progress = True + key_pressed = 0 + + #Extract frames + while success: + frame_str = "frame{0}.jpg".format(count) + + #cv.imwrite(os.path.join(save_path, frame_str), frame) # save frame as JPEG file + #heatmap_frame = cv.applyColorMap( algs.algorithms(os.path.join(save_path, frame_str))[0].astype(np.uint8), cv.COLORMAP_JET ) + + heatmap_frame = cv.applyColorMap( algorithms(frame)[0].astype(np.uint8), cv.COLORMAP_JET ) + out.write(heatmap_frame) + + success, frame = vid_capture.read() + count += 1 + + #Display progress + if show_progress: + cv.namedWindow('Generating Video Heatmap - Press ESCAPE to close', cv.WINDOW_KEEPRATIO) + cv.resizeWindow('Generating Video Heatmap - Press ESCAPE to close', (500, 375)) + cv.imshow('Generating Video Heatmap - Press ESCAPE to close', heatmap_frame) + key_pressed = cv.waitKey(1) + + if key_pressed == 27: + show_progress = False + cv.destroyAllWindows() + + cv.destroyAllWindows() + out.release() + return os.path.join( vid_name + '_heatmap.mp4') diff --git a/Computer Vision Toolkit/Computer Vision Toolkit/lib/parameters.ini b/Computer Vision Toolkit/Computer Vision Toolkit/lib/parameters.ini index d6bb1d3..2f0d993 100644 --- a/Computer Vision Toolkit/Computer Vision Toolkit/lib/parameters.ini +++ b/Computer Vision Toolkit/Computer Vision Toolkit/lib/parameters.ini @@ -1,14 +1,15 @@ -RxThreshold=1=90=90 -RxChiThreshold=1=0.999=0.999 -LineGaussianIter=1=0=0 -LineDilationIter=1=1=1 -LineBilatBlurColor=1=75=75 -LineBilatBlurSpace=1=75=75 -LineCannyEdgeLowerBound=1=100=100 -LineCannyEdgeThreshold=1=140=140 -CornerGaussianIter=1=0=0 -CornerErosionIter=1=1=1 -CornerBilateralColor=1=200=200 -CornerBilateralSpace=1=500=500 -CornerMaxDistance=1=75=75 -CornerNumPoints=1=3=3 +RxThreshold=1=90=90 +RxChiThreshold=1=0.999=0.999 +LineGaussianIter=1=0=0 +LineDilationIter=1=1=1 +LineBilatBlurColor=1=75=75 +LineBilatBlurSpace=1=75=75 +LineCannyEdgeLowerBound=1=100=100 +LineCannyEdgeThreshold=1=140=140 +CornerGaussianIter=1=0=0 +CornerErosionIter=1=1=1 +CornerBilateralColor=1=200=200 +CornerBilateralSpace=1=500=500 +CornerMaxDistance=1=75=75 +CornerNumPoints=1=3=3 +PersonThreshold=1=0.5=0.5 \ No newline at end of file diff --git a/Documentation/RoboticVisionLab_PersonDetector.pdf b/Documentation/RoboticVisionLab_PersonDetector.pdf new file mode 100644 index 0000000..19190de Binary files /dev/null and b/Documentation/RoboticVisionLab_PersonDetector.pdf differ diff --git a/README.md b/README.md index e4aa694..57f7fa7 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,61 @@ -# Computer-Vision-Emergency-Response-Toolkit - -Release version can be found at: http://cver.hrail.crasar.org - -## CVERT Competition -* Create a Fork of the "CVERT-Competition-Master" branch. This is a copy of the current release version. -* You can now freely work on your Forked version of the project. - -### Submissions -* There are 3 submission branches, one for each category in the competition. -* To submit your project create a "New Pull Request" to the approriate "CVERT-Competition-Category-#" your project falls under. -* You may include a "Competition-README.txt" file with anything important you might want to tell us about your project. This should at least include things such as, software and/or hardware requirements to run the project, any known issues, or anything that you wanted to highlight about your project. - - -# Setup - -## Visual Studio -* Microsoft .NET Framework 4.6.1 -* Microsoft Visual Studio 2017 Installer Projects Extension - * This can be installed by clicking ```Tools -> Extensions and Updates... -> Online``` then entering the name of the extension in the search box - - -## Python Setup -* Python 3.6.4 - * https://www.python.org - -* OpenCV - * pip install opencv-python - * pip install opencv-contrib-python - * https://opencv.org - * Tutorial - * http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html -* Numpy - * pip install numpy - * http://www.numpy.org -* SciPy - * pip install scipy - * https://www.scipy.org -* Scikit-Learn - * pip install scikit-learn - * http://scikit-learn.org/stable/ -* Spectral (SPy) - * pip install spectral - * http://www.spectralpython.net -* Argparse - * pip install argparse -* Matplotlib - * pip install matplotlib - * https://matplotlib.org - +# Computer-Vision-Emergency-Response-Toolkit + +Release version can be found at: http://cver.hrail.crasar.org + +## CVERT Competition +* Create a Fork of the "CVERT-Competition-Master" branch. This is a copy of the current release version. +* You can now freely work on your Forked version of the project. + +### Submissions +* There are 3 submission branches, one for each category in the competition. +* To submit your project create a "New Pull Request" to the approriate "CVERT-Competition-Category-#" your project falls under. +* You may include a "Competition-README.txt" file with anything important you might want to tell us about your project. This should at least include things such as, software and/or hardware requirements to run the project, any known issues, or anything that you wanted to highlight about your project. + + +# Setup + +## Visual Studio +* Microsoft .NET Framework 4.6.1 +* Microsoft Visual Studio 2017 Installer Projects Extension + * This can be installed by clicking ```Tools -> Extensions and Updates... -> Online``` then entering the name of the extension in the search box + +## Developer Note +* Note: Before building the project in Visual Studio, please verify that the ‘yolov3.weights’ file is present in the ‘Computer-Vision-Emergency-Response-Toolkit-CVERT-Competition-Master\Computer Vision Toolkit\Computer Vision Toolkit\lib\Algorithms’ folder . If it is not present, it can be downloaded from https://pjreddie.com/media/files/yolov3.weights. + +* Currently I am not able to commit large LFS file and issue regarding this already open in github community. +* https://github.com/git-lfs/git-lfs/issues/1449 +* https://github.com/Fergex/Platformer445/issues/2 + + +## Python Setup +* Python 3.6.4 + * https://www.python.org + +* OpenCV + * pip install opencv-python + * pip install opencv-contrib-python + * https://opencv.org + * Tutorial + * http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html +* Numpy + * pip install numpy + * http://www.numpy.org +* SciPy + * pip install scipy + * https://www.scipy.org +* Scikit-Learn + * pip install scikit-learn + * http://scikit-learn.org/stable/ +* Spectral (SPy) + * pip install spectral + * http://www.spectralpython.net +* Argparse + * pip install argparse +* Matplotlib + * pip install matplotlib + * https://matplotlib.org +* Tensorflow + * pip install -v tensorflow +* keras + * pip install -v keras +