0

I'm running a pose estimation script on an NVIDIA Jetson Nano. It works fine on a short video I tried, but when I run it on a longer video I get the following error:

(python3.6:24822): GStreamer-CRITICAL **: 23:27:53.556: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed

(python3.6:24822): GStreamer-CRITICAL **: 23:27:53.570: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed


[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: no source element for URI "/home/fvpt/Desktop/tech"

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

[ERROR:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap.cpp (392) open VIDEOIO(GSTREAMER): raised OpenCV exception:

OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp:1392: error: (-215:Assertion failed) fps > 0 in function 'open'
Process finished with exit code 0

The only place i can find "open" in my script is where i load in the json file for the pose estimation.

with open(*'path to json'*, 'r') as f:
human_pose = json.load(f)

I'm not sure what details are relevant to give - I'm running this on Ubuntu 18.04, using PyCharm but the same error happens even when I run the script from terminal. OpenCV version 4.1.1 Python version 3.6.9. It works when I run it on a video from an iphone. I created a video in davinci resolve with multiple videos from multiple sources, but it's a normal mp4, 720x576, 24 fps, nothing weird.

Example code:

import cv2
import PIL.Image, PIL.ImageFont
import numpy as np
import argparse
import os.path


parser = argparse.ArgumentParser(description='TensorRT pose estimation run')
parser.add_argument('--model', type=str, default='resnet', help='resnet or densenet')
parser.add_argument('--video', type=str, default='/home/fvpt/Desktop/tech project/videos/final.mp4', help='video file name')
args = parser.parse_args()


cap = cv2.VideoCapture(args.video)
ret_val, img = cap.read()
H = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

W = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))

fpsvid = cap.get(cv2.CAP_PROP_FPS)

fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
dir, filename = os.path.split(args.video)
name, ext = os.path.splitext(filename)
out_video = cv2.VideoWriter('/home/fvpt/Desktop/tech project/outputs/mrf%s_%s.mp4' % (args.model, name), fourcc, fpsvid,
                            (W, H))
count = 0

count = 1
while cap.isOpened():
    ret_val, dst = cap.read()
    if ret_val == False:
        print("Frame Read End")
        break
    img = cv2.resize(dst, dsize=(640, 480), interpolation=cv2.INTER_AREA)
    pilimg = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)
    pilimg = PIL.Image.fromarray(pilimg)
    array = np.asarray(pilimg, dtype="uint8")
    out_video.write(array)
    count += 1

cv2.destroyAllWindows()
out_video.release()
cap.release()

This code works fine with this video, and this is the video it gives the error on.

Community
  • 1
  • 1
kar
  • 13
  • 4
  • "open" is coming from the file written in that line, it's called in the library code, not yours. Please include a [mcve] in your question. – alkasm Dec 04 '20 at 20:23
  • Hi @alkasm thanks for your reply, I've added the code, but unfortunately it's not going to be reproducible as I'm using Pose_TRT and you'd have to have that installed. I've also added links to the videos I'm talking about. – kar Dec 04 '20 at 21:35
  • The suggestion for a "minimal" reproducible example is to get the fewest lines of code where you can still repro your problem. Probably you can delete almost all your code except for the video capture objects and still reproduce the error? – alkasm Dec 05 '20 at 01:38
  • Hi! Yes, you were right, it was just the video cap part that still gives the error. I updated the post with the minimal reproducible example. It must be some problem with the video I'm using, I just don't know what it could be – kar Dec 06 '20 at 15:51
  • Probably you aren't giving the correct filename, spaces or other characters may need to be escaped properly. How are you specifying the filenames? If you notice your path has a space in it, and OpenCV is trying to open the path which stops at the space. For your future self, never put spaces in path names/directories. They can be easily dealt with anyways, but still, escaping spaces sucks and leads to errors like this for scripting. – alkasm Dec 07 '20 at 05:52

0 Answers0