zhreshold commented on a change in pull request #9808: [MXNET-267] Ssd camera demo URL: https://github.com/apache/incubator-mxnet/pull/9808#discussion_r179674488
########## File path: example/ssd/demo.py ########## @@ -131,13 +138,59 @@ def parse_data_shape(data_shape_str): raise ValueError("Unexpected data_shape: %s", data_shape_str) return data_shape -if __name__ == '__main__': - args = parse_args() - if args.cpu: - ctx = mx.cpu() - else: - ctx = mx.gpu(args.gpu_id) +def draw_detection(frame, det, class_names): + (klass, score, x0, y0, x1, y1) = det + klass_name = class_names[int(klass)] + h = frame.shape[0] + w = frame.shape[1] + # denormalize detections from [0,1] to the frame size + p0 = tuple(map(int, (x0*w,y0*h))) + p1 = tuple(map(int, (x1*w,y1*h))) + logging.info("detection: %s %s", klass_name, score) + cv2.rectangle(frame, p0, p1, (0,0,255), 2) + # Where to draw the text, a few pixels above the top y coordinate + tp0 = (p0[0], p0[1]-5) + draw_text = "{} {}".format(klass_name, score) + cv2.putText(frame, draw_text, tp0, cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.5, (0,0,255)) + +def network_path(prefix, network, data_shape): + return "{}{}_{}".format(prefix, network, data_shape) + +def run_camera(args,ctx): + assert args.batch_size == 1, "only batch size of 1 is supported" + logging.info("Detection threshold is {}".format(args.thresh)) + iter = CameraIterator() Review comment: iter is reserved keyword ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services