0

This is the code snippet I am currently working on.

cap = cv2.VideoCapture('/home/nvidia/TensorFlowTX2/Faster-RCNN_TF/data/demo/vid.mp4')

while (cap.isOpened()):
    frame = cap # get current frame
    frameId = cap.get(1)
    (grabbed, f) = cap.read()

    #if grabbed == True:
    if(0==0):
        demo(sess, net, f)
        plt.show()

The output displayed works framewise. I want to create a live video of the output.

I am interested in converting plt.show(matplotlib function) to imshow(OpenCV function) so that I can work on continous output video processing.

Thanks

Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
Pratosha
  • 29
  • 1
  • 4
  • `cv2.imshow("frame", f);cv2.waitKey(30)` – Kinght 金 Jan 22 '18 at 05:28
  • When doing tuple restructuring you shouldn't add parens. `grabbed, f = cap.read`. You also shouldn't add parens to ifs: `if 0 == 0:`. – Bailey Parker Jan 22 '18 at 05:38
  • The demo function returns object detected with bounding boxes which is in the form of plt.show() . When I use cv2.imshow("frame", f);cv2.waitKey(30) . The output obtained is just the live video without any detections or bounding boxes. Hence I want to convert plt.show to an openCV function so that the bounding boxes and objects detected are also displayed. – Pratosha Jan 23 '18 at 03:25
  • The demo(sess,net,f) function ends and returns with the part below. plt.axis('off'); plt.tight_layout(); plt.draw(); How to obtain cv2.imshow from this? – Pratosha Jan 23 '18 at 04:32

1 Answers1

0

I was able to convert matplotlib plt.show to openCV imshow function using the below links: http://www.icare.univ-lille1.fr/tutorials/convert_a_matplotlib_figure

Convert image from PIL to openCV format

Pratosha
  • 29
  • 1
  • 4