class_docstr: Video dataset from a capture device (e.g., webcam).
  
  This class requires that OpenCV be installed.
  
  Args:
      video_source: index of capture device.
          `get_num_devices` can be used to determine possible devices.
      transform: transform to be applied to each frame.
      max_num_frames: Max number of frames to iterate across. If `None` is passed,
          then the dataset will iterate infinitely.
  
  Raises:
      RuntimeError: OpenCV not installed.
class_docstr_tok: ["Video","dataset","from","a","capture","device","(","e.g.",",","webcam",")",".","This","class","requires","that","OpenCV","be","installed",".","Args",":","video_source",":","index","of","capture","device",".","`","get_num_devices","`","can","be","used","to","determine","possible","devices",".","transform",":","transform","to","be","applied","to","each","frame",".","max_num_frames",":","Max","number","of","frames","to","iterate","across",".","If","`","None","`","is","passed",",","then","the","dataset","will","iterate","infinitely",".","Raises",":","RuntimeError",":","OpenCV","not","installed","."]
docstr: Get number of possible devices detected by OpenCV that can be used for capture.
docstr_tok: ["Get","number","of","possible","devices","detected","by","OpenCV","that","can","be","used","for","capture","."]
code: def get_num_devices() -> int:
      """Get number of possible devices detected by OpenCV that can be used for capture."""
      if not has_cv2:
          return 0
      num_devices = 0
      while True:
          cap = cv2.VideoCapture(num_devices)
          if not cap.read()[0]:
              break
          num_devices += 1
          cap.release()
      return num_devices
  
imports: from __future__ import annotations
  import os
  import sys
  import tempfile
  from collections.abc import Callable
  from typing import TYPE_CHECKING, Any
  import numpy
  from torch.utils.data import Dataset, IterableDataset
  from monai.utils.enums import ColorOrder
  from monai.utils.module import optional_import
label_desc: Use image node_id 1 for calling the CameraDataset obj's underlying member method code with example usage: obj.get_num_devices() and returns: num_devices, int