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(frame_resize=parse_frame_resize(args.frame_resize)) class_names = parse_class_names(args.class_names) mean_pixels = (args.mean_r, args.mean_g, args.mean_b) data_shape = int(args.data_shape) batch_size = int(args.batch_size) detector = Detector( get_symbol(args.network, data_shape, num_classes=len(class_names)), network_path(args.prefix, args.network, data_shape), args.epoch, data_shape, mean_pixels, batch_size, ctx) for frame in iter: logging.info("Frame info: shape %s type %s", frame.shape, frame.dtype) logging.info("Generating batch") data_batch = detector.create_batch(frame) logging.info("Detecting objects") detections_batch = detector.detect_batch(data_batch) #detections = [mx.nd.array((1,1,0.2,0.2,0.4,0.4))] detections = detections_batch[0] logging.info("%d detections", len(detections)) for det in detections: obj = det.asnumpy() (klass, score, x0, y0, x1, y1) = obj if score > args.thresh: draw_detection(frame, obj, class_names) cv2.imshow('frame', frame)
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() class_names = parse_class_names(args.class_names) mean_pixels = (args.mean_r, args.mean_g, args.mean_b) data_shape = int(args.data_shape) batch_size = int(args.batch_size) detector = Detector( get_symbol(args.network, data_shape, num_classes=len(class_names)), network_path(args.prefix, args.network, data_shape), args.epoch, data_shape, mean_pixels, batch_size, ctx ) for frame in iter: logging.info("Frame info: shape %s type %s", frame.shape, frame.dtype) logging.info("Generating batch") data_batch = detector.create_batch(frame) logging.info("Detecting objects") detections_batch = detector.detect_batch(data_batch) #detections = [mx.nd.array((1,1,0.2,0.2,0.4,0.4))] detections = detections_batch[0] logging.info("%d detections", len(detections)) for det in detections: obj = det.asnumpy() (klass, score, x0, y0, x1, y1) = obj if score > args.thresh: draw_detection(frame, obj, class_names) cv2.imshow('frame', frame)