Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 204 | chris | 1 | /******************************************************* |
| 2 | * |
||
| 3 | * Author: Hirokazu Kato |
||
| 4 | * |
||
| 5 | * kato@sys.im.hiroshima-cu.ac.jp |
||
| 6 | * |
||
| 7 | * Date: 01/09/10 |
||
| 8 | * |
||
| 9 | *******************************************************/ |
||
| 10 | |||
| 11 | #include <AR/ar.h> |
||
| 12 | |||
| 13 | static double arGetTransMatContSub( ARMarkerInfo *marker_info, double prev_conv[3][4], |
||
| 14 | double center[2], double width, double conv[3][4] ); |
||
| 15 | |||
| 16 | double arGetTransMatCont( ARMarkerInfo *marker_info, double prev_conv[3][4], |
||
| 17 | double center[2], double width, double conv[3][4] ) |
||
| 18 | { |
||
| 19 | double err1, err2; |
||
| 20 | double wtrans[3][4]; |
||
| 21 | int i, j; |
||
| 22 | |||
| 23 | err1 = arGetTransMatContSub(marker_info, prev_conv, center, width, conv); |
||
| 24 | if( err1 > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR ) { |
||
| 25 | err2 = arGetTransMat(marker_info, center, width, wtrans); |
||
| 26 | if( err2 < err1 ) { |
||
| 27 | for( j = 0; j < 3; j++ ) { |
||
| 28 | for( i = 0; i < 4; i++ ) conv[j][i] = wtrans[j][i]; |
||
| 29 | } |
||
| 30 | err1 = err2; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return err1; |
||
| 35 | } |
||
| 36 | |||
| 37 | |||
| 38 | static double arGetTransMatContSub( ARMarkerInfo *marker_info, double prev_conv[3][4], |
||
| 39 | double center[2], double width, double conv[3][4] ) |
||
| 40 | { |
||
| 41 | double rot[3][3]; |
||
| 42 | double ppos2d[4][2]; |
||
| 43 | double ppos3d[4][2]; |
||
| 44 | int dir; |
||
| 45 | double err; |
||
| 46 | int i, j; |
||
| 47 | |||
| 48 | for( i = 0; i < 3; i++ ) { |
||
| 49 | for( j = 0; j < 3; j++ ) { |
||
| 50 | rot[i][j] = prev_conv[i][j]; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | dir = marker_info->dir; |
||
| 55 | ppos2d[0][0] = marker_info->vertex[(4-dir)%4][0]; |
||
| 56 | ppos2d[0][1] = marker_info->vertex[(4-dir)%4][1]; |
||
| 57 | ppos2d[1][0] = marker_info->vertex[(5-dir)%4][0]; |
||
| 58 | ppos2d[1][1] = marker_info->vertex[(5-dir)%4][1]; |
||
| 59 | ppos2d[2][0] = marker_info->vertex[(6-dir)%4][0]; |
||
| 60 | ppos2d[2][1] = marker_info->vertex[(6-dir)%4][1]; |
||
| 61 | ppos2d[3][0] = marker_info->vertex[(7-dir)%4][0]; |
||
| 62 | ppos2d[3][1] = marker_info->vertex[(7-dir)%4][1]; |
||
| 63 | ppos3d[0][0] = center[0] - width/2.0; |
||
| 64 | ppos3d[0][1] = center[1] + width/2.0; |
||
| 65 | ppos3d[1][0] = center[0] + width/2.0; |
||
| 66 | ppos3d[1][1] = center[1] + width/2.0; |
||
| 67 | ppos3d[2][0] = center[0] + width/2.0; |
||
| 68 | ppos3d[2][1] = center[1] - width/2.0; |
||
| 69 | ppos3d[3][0] = center[0] - width/2.0; |
||
| 70 | ppos3d[3][1] = center[1] - width/2.0; |
||
| 71 | |||
| 72 | for( i = 0; i < AR_GET_TRANS_MAT_MAX_LOOP_COUNT; i++ ) { |
||
| 73 | err = arGetTransMat3( rot, ppos2d, ppos3d, 4, conv, |
||
| 74 | arParam.dist_factor, arParam.mat ); |
||
| 75 | if( err < AR_GET_TRANS_MAT_MAX_FIT_ERROR ) break; |
||
| 76 | } |
||
| 77 | return err; |
||
| 78 | } |