video#

pydantic model perceptivo.types.video.Frame#

Bases: perceptivo.types.root.PerceptivoType

Single video frame container

Variables
  • frame (numpy.ndarray) – Frame!

  • timestamp (datetime.datetime) – Time of acquisition

  • color (bool) – If False , grayscale (frame should be 2 dimensional or 3rd axis should be len == 1 ). if True, RGB Color.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Show JSON schema
{
   "title": "Frame",
   "description": "Single video frame container\n\nAttributes:\n    frame (:class:`numpy.ndarray`): Frame!\n    timestamp (:class:`datetime.datetime`): Time of acquisition\n    color (bool): If ``False`` , grayscale (frame should be 2 dimensional or 3rd axis should be len  == 1 ).\n        if ``True``, RGB Color.",
   "type": "object",
   "properties": {
      "frame": {
         "title": "Frame"
      },
      "timestamp": {
         "title": "Timestamp",
         "type": "string",
         "format": "date-time"
      },
      "color": {
         "title": "Color",
         "type": "boolean"
      },
      "cropped": {
         "title": "Cropped"
      },
      "dtype": {
         "title": "Dtype"
      }
   }
}

Config
  • arbitrary_types_allowed: bool = True

Fields
field frame: numpy.ndarray [Required]#
field timestamp: datetime.datetime [Optional]#
field cropped: Optional[perceptivo.types.video.Frame] = None#
field dtype: Optional[numpy.dtype] = None#
field color: Optional[bool] = None#
set_color(color)#
norm()#

make frame 0-1

property gray: numpy.ndarray#

Grayscale version of the frame, if color

crop(bbox: List[int])#

Crop with a bounding box (top, bottom, left, right), assign to self.cropped

Parameters

bbox ()

Returns

new Frame image with cropped image as its frame

pydantic model perceptivo.types.video.Picamera_Params#

Bases: pydantic.main.BaseModel

Configuration for a perceptivo.video.cameras.PiCamera

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Show JSON schema
{
   "title": "Picamera_Params",
   "description": "Configuration for a :class:`perceptivo.video.cameras.PiCamera`",
   "type": "object",
   "properties": {
      "sensor_mode": {
         "title": "Sensor Mode",
         "default": 0,
         "type": "integer"
      },
      "resolution": {
         "title": "Resolution",
         "default": [
            1280,
            720
         ],
         "type": "array",
         "minItems": 2,
         "maxItems": 2,
         "items": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ]
      },
      "fps": {
         "title": "Fps",
         "default": 30,
         "type": "integer"
      },
      "format": {
         "title": "Format",
         "default": "grayscale",
         "enum": [
            "rgb",
            "grayscale"
         ],
         "type": "string"
      },
      "output_file": {
         "title": "Output File",
         "type": "string",
         "format": "path"
      }
   }
}

Fields
field sensor_mode: int = 0#
field resolution: Tuple[int, int] = (1280, 720)#
field fps: int = 30#
field format: Literal['rgb', 'grayscale'] = 'grayscale'#
field output_file: Optional[pathlib.Path] = None#
class perceptivo.types.video.Camera_Calibration(picam: perceptivo.types.video.Picamera_Params, distance: float, mm_per_px: float)#

Bases: object

Parameters that define the conditions of use for a camera

Parameters
  • picam (Picamera_Params) – Parameterization of the PiCamera

  • distance (float) – distance from camera to subject in mm

  • mm_per_px (float) – approximate number of mm per pixel at a given distance

picam: perceptivo.types.video.Picamera_Params#
distance: float#
mm_per_px: float#