//  [python]
def inference(det_net, cap):

    # 1. preprocess img
    img_plac = tf.placeholder(dtype=tf.uint8, shape=[None, None, 3])
    img_batch = tf.cast(img_plac, tf.float32)
    img_batch = img_batch - tf.constant(cfgs.PIXEL_MEAN)
    img_batch = short_side_resize_for_inference_data(img_tensor=img_batch,
                                                     target_shortside_len=cfgs.IMG_SHORT_SIDE_LEN,
                                                     is_resize=False)

    det_boxes_h, det_scores_h, det_category_h, \
    det_boxes_r, det_scores_r, det_category_r = det_net.build_whole_detection_network(input_img_batch=img_batch,
                                                                                      gtboxes_h_batch=None,
                                                                                      gtboxes_r_batch=None)

    init_op = tf.group(
        tf.global_variables_initializer(),
        tf.local_variables_initializer()
    )

    restorer, restore_ckpt = det_net.get_restorer()

    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True

    with tf.Session(config=config) as sess:
        sess.run(init_op)
        if not restorer is None:
            restorer.restore(sess, restore_ckpt)
            print('restore model')
        fourcc = cv2.VideoWriter_fourcc(*'xvid')
        out = cv2.VideoWriter('./camera_demo.avi', fourcc, 10, (640, 480))
        ret, frame = cap.read()
        while ret:
            ret, frame = cap.read()
            start = time.time()
            resized_img, det_boxes_h_, det_scores_h_, det_category_h_, \
            det_boxes_r_, det_scores_r_, det_category_r_ = \
                sess.run(
                    [img_batch, det_boxes_h, det_scores_h, det_category_h, det_boxes_r, det_scores_r, det_category_r],
                    feed_dict={img_plac: frame}
                )
            end = time.time()
            # det_detections_h = draw_box_in_img.draw_box_cv(np.squeeze(resized_img, 0),
            #                                                boxes=det_boxes_h_,
            #                                                labels=det_category_h_,
            #                                                scores=det_scores_h_)
            det_detections_r = draw_box_in_img.draw_rotate_box_cv(np.squeeze(resized_img, 0),
                                                                  boxes=det_boxes_r_,
                                                                  labels=det_category_r_,
                                                                  scores=det_scores_r_)
            # det_detections_h = cv2.resize(det_detections_h,
            #                               (det_detections_h.shape[0] // 2, det_detections_h.shape[1] // 2))
            # cv2.putText(det_detections_h,
            #             text="horizon bbox",
            #             org=(0, 0),
            #             fontFace=3,
            #             fontScale=1,
            #             color=(255, 0, 0))
            # det_detections_r = cv2.resize(det_detections_r,
            #                               (det_detections_r.shape[0] // 2, det_detections_r.shape[1] // 2))
            cv2.putText(det_detections_r,
                        text="rotated bbox--%3.2f"%(1/(end-start)),
                        org=(0, 10),
                        fontFace=1,
                        fontScale=1,
                        color=(0, 255, 0))
            out.write(det_detections_r)
            # hmerge = np.hstack((det_detections_h, det_detections_r))  # 水平拼接
            cv2.imshow("faceDetection", det_detections_r)
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
        cap.release()
        out.release()
        cv2.destroyAllWindows()