Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

NameError: name 'cap' is not defined

import cv2 import os

dir_path = '/home/ji/YouTubeClips'

for name in os.listdir(dir_path): #count=count+1 video_id = name.split('.')[0] single_frame = '/home/frame_single/image/'+video_id+'.jpg' if not (os.path.isfile(single_frame) ):

    video_file_path=os.path.join(dir_path, name)
    print(video_file_path)
    if (cap.isOpened()== False): 
          print("Error opening video stream or file")
    total = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))


    if success:
        cv2.imwrite(video_id+'.jpg',image) 
        vidcap.set(cv2.CAP_PROP_POS_MSEC,(count*65000))    # added this line 
    # save frame as JPEG file

help me to solve this issue

click to hide/show revision 2
None

updated 2019-03-15 04:14:27 -0500

berak gravatar image

NameError: name 'cap' is not defined

.

import cv2
import os

os dir_path = '/home/ji/YouTubeClips'

'/home/ji/YouTubeClips'

for name in os.listdir(dir_path): #count=count+1 video_id = name.split('.')[0] single_frame = '/home/frame_single/image/'+video_id+'.jpg' if not (os.path.isfile(single_frame) ):

):
     video_file_path=os.path.join(dir_path, name)
     print(video_file_path)
     if (cap.isOpened()== False): 
           print("Error opening video stream or file")
     total = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))


     if success:
         cv2.imwrite(video_id+'.jpg',image) 
         vidcap.set(cv2.CAP_PROP_POS_MSEC,(count*65000))    # added this line 
     # save frame as JPEG file

help me to solve this issue

NameError: name 'cap' is not defined

.

import cv2
import os
dir_path = '/home/ji/YouTubeClips'

for name in os.listdir(dir_path):
  #count=count+1
 video_id = name.split('.')[0]
 cap = cv2.VideoCapture(0)
success,image = vidcap.read()
count = 0
success = True

total_frames = vidcap.get(1)
single_frame = '/home/frame_single/image/'+video_id+'.jpg'
    '/home/jeevitha/2017611005/frame_single/image/'+video_id+'.jpg'
if not (os.path.isfile(single_frame) ):
):        video_file_path=os.path.join(dir_path, name)
     print(video_file_path)
     if (cap.isOpened()== False): 
           print("Error opening video stream or file")
     total = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))


     if success:
         cv2.imwrite(video_id+'.jpg',image) 
         vidcap.set(cv2.CAP_PROP_POS_MSEC,(count*65000))    # added this line 
     # save frame as JPEG file

help me to solve this issue