opencv cvCalcOpticalFlowLK

sir i used cvCalcOpticalFlowLK function to get velocity values but the problem is while accessing velocity values i am getting all zeroes,please give me a suggetion

#include<stdio.h>
#include<malloc.h>
#include<math.h>
#include "cv.h"
#include "highgui.h"
int main (int argc, char *argv[])
{

IplImage *img1,*img2,*vel_x,*vel_y,*Gs1,*Gs2;
img1=cvLoadImage(argv[1],-1);



img2=cvLoadImage(argv[2],-1);

CvSize cvsize;
cvsize.width=img1->width;
cvsize.height=img1->height;

Gs1=cvCreateImage(cvsize,IPL_DEPTH_8U,1);
cvCvtColor(img1,Gs1,CV_RGB2GRAY);
Gs2=cvCreateImage(cvsize,IPL_DEPTH_8U,1);
cvCvtColor(img2,Gs2,CV_RGB2GRAY);


vel_x = cvCreateImage( cvSize(img1->width, img1->height),
IPL_DEPTH_32F, 1 );
vel_y = cvCreateImage( cvSize(img1->width, img1->height),
IPL_DEPTH_32F, 1 );




//cvsize.width=3;
//cvsize.height=3;
//printf("hello");

int i,j;
cvCalcOpticalFlowLK( Gs1, Gs2, cvSize (5,5), vel_x, vel_y );

//for(i=0;i<img1->height;i++)
//for(j=0;j<img1->width;j++)
//{printf("%d\n",vel_y);

//}
for(int x=0;x<vel_x->width;x++){
for(int y=0; y<vel_x->height;y++){
float dx = ((float*)(vel_x->imageData +
vel_x->widthStep*y))[x];
//printf("%d",dx);
float dy = ((float*)(vel_y->imageData +
vel_y->widthStep*y))[x];
printf("%f\n",dy);
}
}
Topic archived. No new replies allowed.