opencv runtime_error ai_generated true

cv::calcOpticalFlowPyrLK: input images must be grayscale

ID: opencv/optical-flow-error

Also available as: JSON · Markdown
82%Fix Rate
86%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4 active

Root Cause

Optical flow function received wrong input format.

generic

Workarounds

  1. 92% success Convert to grayscale before optical flow: cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  2. 88% success Ensure previous and current frames have same size and type

Dead Ends

Common approaches that don't work:

  1. Use dense flow for everything 68% fail

    Slow for sparse tracking

  2. Skip optical flow 78% fail

    No motion estimation