Bonjour,
J'essaie d'utiliser la fonction cvCalcOpticalFlowLK
oui je sais elle est "deprecated" mais elle a l'air plus simple d'utilisation que cvCalcOpticalFlowPyrLK donc je commence avec elle pour le flot optique
(grâce à # include <opencv2\legacy\legacy.hpp>)
voici sa définition :
void*cvCalcOpticalFlowLK(const CvArr**prev, const CvArr**curr, CvSize*win_size, CvArr**velx, CvArr**vely)
Calculates the optical flow for two images using Lucas-Kanade algorithm.
prev*– First image, 8-bit, single-channel
curr*– Second image, 8-bit, single-channel
win_size*– Size of the averaging window used for grouping pixels
velx*– Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
vely*– Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
Voici mon code :
Dans lequel frames est un vector<Mat> qui contient les images d'une video
Il n'y a pas d'erreur lors de la compilation mais lorsque j’exécute mon cod eil y a un bug qui s'affiche et dans la console est écrit "unsupported array type" in cvGetMat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 CvSize winSize = cvSize(20,20); Mat velX = Mat(frames[0].rows,frames[0].cols,CV_32FC1); Mat *velx = &velX; Mat velY = Mat(frames[0].rows,frames[0].cols,CV_32FC1); Mat *vely=&velY; cvCalcOpticalFlowLK(&frames[0],&frames[10],winSize,velx,vely); imshow("Flot selon x:",*velx);
Quand j’exécute en mode debug
* on voit bien que le bug est obtenu lors de l'appel de cvCalcOpticalFlowLK
* j'obtiens : "Exception de première chance à 0x7c812fd3 (kernel32.dll) dans Open_cv.exe*: Exception Microsoft C++*: cv::Exception à l'emplacement mémoire 0x0011eaa8.."
* les valeurs de velx : Symbole "velx" introuvable
J'imagine que j'instancie mal mes variables velx et vely, peut être ne correspondent-elles pas à des CvArr* 32-bit floating-point, single-channel ??
Merci d'avance pour vos idées,
Cordialement,
Ronan
Partager