cv_64FC2.c

Dajiang Zhang, 2012-10-19 04:47 pm

Download (1.1 kB)

 
1
2
#include <stdio.h>
3
#include <string.h>
4
#include <math.h>
5
6
#include "opencv2/core/core_c.h"
7
#include "opencv2/highgui/highgui_c.h"
8
#include "opencv2/imgproc/imgproc_c.h"
9
#include "opencv2/calib3d/calib3d.hpp"
10
11
int main()
12
{
13
    int point_count = 8;
14
    
15
    CvMat* points1;
16
    CvMat* points2;
17
    CvMat* status;
18
    CvMat* fundamental_matrix;
19
    
20
    points1 = cvCreateMat(1, point_count, CV_64FC2);
21
    points2 = cvCreateMat(1, point_count, CV_64FC2);
22
    status = cvCreateMat(1, point_count, CV_8UC1);
23
    
24
    for (int i = 0; i < point_count; i++) {
25
        points1->data.db[i*2] = 1 + i;
26
        points1->data.db[i*2+1] = 2 + 3 * i;
27
        points2->data.db[i*2] = 2 + 1.5 * i;
28
        points2->data.db[i*2+1] = 3 + 2.2 * i;
29
    }
30
    
31
    fundamental_matrix = cvCreateMat(3,3,CV_32FC1);
32
33
    int result = cvFindFundamentalMat(points1, points2, fundamental_matrix, CV_FM_8POINT);
34
    
35
    for (int j = 0; j < 9; j++) {
36
        if (j % 3 == 0) {
37
            printf("\n");
38
        }
39
        printf("%f ", fundamental_matrix->data.fl[j]);
40
    }
41
        
42
    return 0;
43
    
44
}
45