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_count#

image_face_count(*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 count UDF (OpenCV Haar Cascade-based).

Requires pip install opencv-python-headless. This is a scalar UDF that returns the number of detected faces as an integer.

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 the number of detected faces as an integer, or None for null input. None means the input itself is null; 0 means a valid image was processed and no faces were detected.

Raises

ValueError – If detection parameters are invalid.

Usage:

>>> # As a reusable variable
>>> count = image_face_count(min_neighbors=3)
>>> df = df.with_column("face_count", count(col("img")))
>>>
>>> # Inline
>>> df = df.with_column("face_count", image_face_count(col("img")))

previous

pyflink.multimodal.operators.image_face_detect

next

pyflink.multimodal.operators.image_face_blur

Show Source

Created using Sphinx 4.5.0.