1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| CvMatrix3 matrix;
CvMatrix3* matrixF;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
{
matrix.m[i][j]=(float)cvmGet(Fmatrix,0,1);
}
matrixF=&matrix;
RightImage=cvCloneImage(RectifD);
LeftImage=cvCloneImage(RectifG);
CvSize ImgSize;
ImgSize.width=RightImage->width*3;
ImgSize.height=RightImage->height*3;
int line_count;
cvMakeScanlines(0,ImgSize,0,0,0,0,&line_count);
line_count=2400;
int* scanlines1;
int* scanlines2;
int* scanlinesA;
scanlines1=(int*)(calloc( line_count * 2, sizeof(int) * 4));
scanlines2=(int*)(calloc( line_count * 2, sizeof(int) * 4));
scanlinesA=(int*)(calloc( line_count * 2, sizeof(int) * 4));
int* lenghts1;
int* lenghts2;
int* lenghts;
lenghts1=(int*)(calloc( line_count * 2, sizeof(int)*4));
lenghts2=(int*)(calloc( line_count * 2, sizeof(int)*4));
lenghts=(int*)(calloc( line_count * 2, sizeof(int)*4));
uchar* dst1;
dst1=(uchar*)(malloc(ImgSize.width * (ImgSize.height+1) * 3 *
sizeof(uchar)));
uchar* dst2;
dst2=(uchar*)(malloc(ImgSize.width * (ImgSize.height+1) * 3 *
sizeof(uchar)));
uchar* dst_pix;
dst_pix=(uchar*)(calloc(ImgSize.width * (ImgSize.height+1), 3 *
sizeof(uchar)));
int* runs1;
int* runs2;
runs1=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof (int)));
runs2=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof (int)));
int* first_corr;
int* second_corr;
first_corr=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof(int)));
second_corr=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof(int)));
int* num_runs1;
int* num_runs2;
num_runs1=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof(int)));
num_runs2=(int*)(calloc(ImgSize.width * ImgSize.height * 2, 2 * sizeof(int)));
ImgSize.width=RightImage->width;
ImgSize.height=RightImage->height;
cvMakeScanlines(matrixF,ImgSize,0,0,0,0,&line_count);
cvMakeScanlines(matrixF,ImgSize,scanlines1,scanlines2,lenghts1,lenghts2,&line_count) ;
IplImage* image1=cvCreateImage(cvGetSize(RightImage),8,3);
image1=cvCloneImage(RightImage);
cvPreWarpImage(line_count,image1,dst1,lenghts1,scanlines1);
IplImage* image2=cvCreateImage(cvGetSize(LeftImage),8,3);
image2=cvCloneImage(LeftImage);
cvPreWarpImage(line_count,image2,dst2,lenghts2,scanlines2);
RectifG=cvCloneImage(image2);
RectifD=cvCloneImage(image1);
DisplayImage("Image gauche Rectifiée",RectifG,0);
DisplayImage("Image droite Rectifiée",RectifD,1);
if (scanlines1 != 0) free (scanlines1);
if (scanlines2 != 0) free (scanlines2);
if (scanlinesA != 0) free (scanlinesA);
if (lenghts1 != 0) free (lenghts1);
if (lenghts2 != 0) free (lenghts2);
if (lenghts != 0) free (lenghts);
if (dst1 != 0) free (dst1);
if (dst2 != 0) free (dst2);
if (dst_pix != 0) free (dst_pix);
if (runs1 != 0) free (runs1);
if (runs2 != 0) free (runs2);
if (first_corr != 0) free (first_corr);
if (second_corr != 0) free (second_corr);
if (num_runs1 != 0) free (num_runs1);
if (num_runs2 != 0) free (num_runs2);
scanlines1 = 0;
scanlines2 = 0;
scanlinesA = 0;
lenghts1 = 0;
lenghts2 = 0;
lenghts = 0;
runs1 = 0;
runs2 = 0;
dst1 = 0;
dst2 = 0;
dst_pix = 0;
num_runs1 = 0;
num_runs2 = 0;
first_corr = 0;
second_corr = 0; |