# cv::error: (-215:Assertion failed) src1.type() == CV_8UC1 in function 'calcOpticalFlowFarneback'

- **ID:** `opencv/opticalflow-calcopticalflowfarneback-input-type-mismatch`
- **Domain:** opencv
- **Category:** type_error
- **Error Code:** `-215`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

calcOpticalFlowFarneback requires the input image to be single-channel 8-bit (grayscale), but a multi-channel or different depth image was provided.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **Convert the input image to grayscale before calling calcOpticalFlowFarneback: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY); ensure gray is a single-channel 8-bit image.** (95% success)
   ```
   Convert the input image to grayscale before calling calcOpticalFlowFarneback: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY); ensure gray is a single-channel 8-bit image.
   ```
2. **If the input is already grayscale but has a different depth (e.g., 16-bit), use cv2.convertScaleAbs to convert to CV_8U: gray = cv2.convertScaleAbs(gray, alpha=(255.0/65535.0)).** (85% success)
   ```
   If the input is already grayscale but has a different depth (e.g., 16-bit), use cv2.convertScaleAbs to convert to CV_8U: gray = cv2.convertScaleAbs(gray, alpha=(255.0/65535.0)).
   ```

## Dead Ends

- **** — The function signature expects a single channel; a 3-channel input will still trigger the assertion. (90% fail)
- **** — The original multi-channel image remains unchanged, causing the assertion to fail again. (80% fail)
