Ask Your Question

Revision history [back]

Sizes of input arguments do not match () in cvCalcOpticalFlowBM

hello

i am trying to Implement the opticalflow algorithm with block matching cv.CalcOpticalFlowBM(), but when i run i have error

OpenCV Error: Sizes of input arguments do not match () in cvCalcOpticalFlowBM, file /home/travis/miniconda/conda-bld/work/opencv-2.4.11/modules/legacy/src/optflowbm.cpp, line 88 Traceback (most recent call last): File "/home/kaos/PycharmProjects/untitled/1616.py", line 56, in <module> optix = calcOpticalFlow(image,image2 ,'BlockMatching') File "/home/kaos/PycharmProjects/untitled/1616.py", line 44, in calcOpticalFlow 0, cv.fromarray( opticalFlowArrayX ), cv.fromarray( opticalFlowArrayY ) ) cv2.error

here is the code i try all day, but didn't find where is the problem thank's

` def calcOpticalFlow( image1, image2, method="BlockMatching" ):

    storageWidth = image1.shape[0]
    storageHeight = image1.shape[1]

    if method == "BlockMatching":
        opticalFlowArrayX = np.ndarray( ( storageHeight, storageWidth ), dtype=np.float32 )
        opticalFlowArrayY = np.ndarray( ( storageHeight, storageWidth ), dtype=np.float32 )
        cv.CalcOpticalFlowBM(cv.fromarray(image1),cv.fromarray(image2),
            (16,16),
              (5,5),
              (1,1),
            0, cv.fromarray( opticalFlowArrayX ), cv.fromarray( opticalFlowArrayY ) )

    return ( opticalFlowArrayX, opticalFlowArrayY )

image = cv2.imread('2.jpg',cv2.CV_LOAD_IMAGE_GRAYSCALE)

image2 = cv2.imread('3.jpg',cv2.CV_LOAD_IMAGE_GRAYSCALE)

optix,optiy = calcOpticalFlow(image,image2 ,'BlockMatching')`