Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Utilities
  • PyFlink DataStream
  • PyFlink Common

pyflink.multimodal.operators.image_face_detect#

image_face_detect(*columns, cv_classifier='haarcascade_frontalface_alt.xml', min_neighbors=3, scale_factor=1.1, min_size=None, max_size=None, concurrency=None)[source]#

Create a face detection UDF (OpenCV Haar Cascade-based).

Requires pip install opencv-python-headless. This is a scalar UDF.

Parameters
  • *columns – Optional image column(s). When provided, the UDF is applied directly instead of returning a factory.

  • cv_classifier – OpenCV Haar cascade XML filename. Must be a bare filename without path separators. Default "haarcascade_frontalface_alt.xml".

  • min_neighbors – OpenCV detectMultiScale minNeighbors value. Higher values reduce false positives but may miss faces. Default 3.

  • scale_factor – Image pyramid scale factor for multi-scale detection. Default 1.1.

  • min_size – Minimum face size as (width, height) tuple in pixels. Detections smaller than this are ignored. None (default) uses OpenCV’s built-in minimum.

  • max_size – Maximum face size as (width, height) tuple in pixels. Detections larger than this are ignored. None (default) imposes no upper limit.

  • concurrency – UDF concurrency. None uses the framework default.

Returns

A UDF that returns a list of face bounding boxes as (x, y, w, h, confidence) structs, or None for null input. The confidence field is always None for Haar Cascade detection because OpenCV does not expose per-detection probability.

Raises

ValueError – If detection parameters are invalid.

Usage:

>>> # As a reusable variable
>>> detect = image_face_detect(min_neighbors=3)
>>> df = df.with_column("faces", detect(col("img")))
>>>
>>> # Inline
>>> df = df.with_column("faces", image_face_detect(col("img")))

previous

pyflink.multimodal.operators.image_detect_subplot

next

pyflink.multimodal.operators.image_face_count

Show Source

Created using Sphinx 4.5.0.