opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.67k stars 55.65k forks source link

AttributeError: module 'cv2.optflow' has no attribute 'writeOpticalFlow' #25545

Closed lulu1315 closed 1 month ago

lulu1315 commented 1 month ago

System Information

OpenCV python version: 4.9.0.80 Operating System / Platform: Ubuntu 20.04 Python version: 3.8.5

Detailed description

trying to write .flow files. i have opencv-contrib-python installed (pip3 install opencv-contrib-python) but it gives me this message (see title)

Steps to reproduce

using this code . flow is calculated with

deepF = cv2.optflow.createOptFlow_DeepFlow() flowDeep = deepF.calc(grayA, grayB, None) # cv2.optflow.writeOpticalFlow(flow_name,flowDeep)

Issue submission checklist

LaurentBerger commented 1 month ago

cv2.optflow.writeOpticalFlow(flow_name,flowDeep)

May be you should read doc carefully

cv.writeOpticalFlow("toto",flowDeep) MRE :

import numpy as np
import cv2 as cv

imgA = np.zeros((480,640))
imgB = np.zeros((480,640))

deepF = cv.optflow.createOptFlow_DeepFlow()
flowDeep = deepF.calc(imgA, imgB, None)

cv.writeOpticalFlow("toto",flowDeep)
lulu1315 commented 1 month ago

ooops. ok it works. sorry for the noise