opencv_contrib
opencv_contrib copied to clipboard
cv2.cudacodec.createVideoReader(x2_rma.mp4)
Traceback (most recent call last):
File "/home/ubuntu/apurva.thakkar/video_analysis/debug.py", line 39, in
This is my code import cv2 import time import subprocess
Function to check GPU usage
def check_gpu_usage(): # Run nvidia-smi and capture output result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE) print(result.stdout.decode())
def process_video_with_gpu(video_path): # Use the GPU decoder cap = cv2.cudacodec.createVideoReader(video_path) fps = cap.get(cv2.CAP_PROP_FPS)
frame_count = 0
total_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
while True:
ret, frame = cap.read()
if not ret:
break
# Process the frame (for now, just print frame count)
frame_count += 1
print(f"Processing frame {frame_count}/{total_frames}")
# Check GPU usage after processing each frame
if frame_count % 10 == 0: # Check every 10 frames
check_gpu_usage()
time.sleep(0.1)
cap.release()
Run the test
if name == "main":
video_path = 'x2_rma.mp4'
process_video_with_gpu(video_path)