input videos in tensorflow. TypeError: Required argument 'mat' (pos 2) not found

14 views
Skip to first unread message

Goli

unread,
Dec 8, 2018, 8:29:15 PM12/8/18
to OpenCV with Python Blueprints

Hi. I have a question and I would be very thankful if anyone can help. I have the code below with cv2. This code is downloaded from https://github.com/dipakkr/3d-cnn-action-recognition (videoto3d.py). I want to use cv2.imshow to visualize the frames of the video it get. But I get the following error. What is the problem? The mostimportant problem is that I want to visualize the input to make sure that it can read the input. I am doubtful of whether this code is really able to read the videos as what is returns is an array of zeros.



       cap = cv2.VideoCapture(filename)
        #ret, frame=cap.read()
        #cv2.imshow('frame', frame)
        nframe = cap.get(cv2.CAP_PROP_FRAME_COUNT) #Returns the specified VideoCapture property  ,,Number of frames in the video file

        print (nframe, "nframe")

        if skip:
            frames = [x * nframe / self.depth for x in range(self.depth)]
            print (frames, "frameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees")

        else:
            frames = [x for x in range(self.depth)]
            print (frames, "frameseeeeeeeeeeeeeeeeeeeeeeeeeeeeeee2")

        framearray = []

        for i in range(self.depth):
            cap.set(cv2.CAP_PROP_POS_FRAMES, frames[i])  #Sets a property in the VideoCapture. ,,0-based index of the frame to be decoded/captured next.
            ret, frame = cap.read()
            cv2.imshow(frame)
            print(ret, "reeeeeeeeeeeeeeeeettttttttt")
            print(frame ,"frame issssssssssss:")
            frame = cv2.resize(frame, (self.height, self.width))
            print(frame, "frame222 isssssssssssssss")
            #cv2.imshow(frame)
            if color:
                framearray.append(frame)
            else:
                framearray.append(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))

        cap.release()
        return np.array(framearray)


X.append(vid3d.video3d(v_file_path, color=color, skip=skip))
Error:

   main()
  File "3dcnn.py", line 151, in main
    args.output, args.color, args.skip)
  File "3dcnn.py", line 103, in loaddata
    X.append(vid3d.video3d(v_file_path, color=color, skip=skip))
  File "/home/gxa131/Documents/final_project_computationalintelligence/3d-cnn-action-recognition/videoto3d.py", line 34, in video3d
    cv2.imshow(frame)
TypeError: Required argument 'mat' (pos 2) not found

Michael Beyeler

unread,
Dec 11, 2018, 12:26:09 PM12/11/18
to OpenCV with Python Blueprints
The problem seems to be that video3d wants a second argument mat, which you did not provide (last line). I don't know their code. You should ask them. ;-)

Best,
Michael
Reply all
Reply to author
Forward
0 new messages