Skip to content

Commit 98f22e5

Browse files
Fix randint error in video tutorial by casting frame count diff to int
In frames_from_video_file, cv2.VideoCapture().get(cv2.CAP_PROP_FRAME_COUNT) returns a float. This causes random.randint to fail with: TypeError: 'float' object cannot be interpreted as an integer Fix: cast (video_length - need_length) to int before passing to randint.
1 parent e21d085 commit 98f22e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

site/en/tutorials/load_data/video.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
" if need_length > video_length:\n",
631631
" start = 0\n",
632632
" else:\n",
633-
" max_start = video_length - need_length\n",
633+
" max_start = int(video_length - need_length)\n",
634634
" start = random.randint(0, max_start + 1)\n",
635635
"\n",
636636
" src.set(cv2.CAP_PROP_POS_FRAMES, start)\n",

0 commit comments

Comments
 (0)