17 for(
int i=0; i < M.cols; i++) {
18 bool detected =
false;
19 for(
int j=0; j < M.rows; j++) {
25 for(
int j=0; j < M.rows; j++) {
26 printf(
" %i",(
int)
cvmGet(&M,j,i) );
43 for(
int i=0; i < M.rows; i++) {
44 for(
int j=0; j < M.cols; j++) {
45 printf(
" %12.6f ",
cvmGet(&M,i,j) );
49 if (M.rows >=3 && M.cols >=3 && (M.rows == M.cols)) {
51 cvGetSubRect(&M, &sub, cvRect(0,0, 3, 3));
52 printf(
"Det: %f\n", cvDet(&sub));
65 cout << header <<
"\n";
89 for(
int i=0; i < M.rows; i++) {
90 for(
int j=0; j < M.cols; j++) {
91 length = sprintf(buffer,
" %12.6f ",
cvmGet(&M,i,j));
92 fwrite( buffer,
sizeof(
char), length, stream );
94 length = sprintf(buffer,
"\n");
95 fwrite( buffer,
sizeof(
char), length, stream );
97 length = sprintf(buffer,
"\n");
98 fwrite( buffer,
sizeof(
char), length, stream );
106 double R_matrix[3][3],
111 double S_matrix[3][3],
298 t1 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 1-1 + (1-1)*3);
300 t2 = S_matrix[1-1][1-1];
302 t4 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 2-1 + (1-1)*3);
304 t5 = S_matrix[2-1][1-1];
306 t7 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 3-1 + (1-1)*3);
308 t8 = S_matrix[3-1][1-1];
312 t13 = S_matrix[1-1][2-1];
314 t15 = S_matrix[2-1][2-1];
316 t17 = S_matrix[3-1][2-1];
320 t22 = S_matrix[1-1][3-1];
322 t24 = S_matrix[2-1][3-1];
324 t26 = S_matrix[3-1][3-1];
328 t36 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 1-1 + (3-1)*3);
330 t38 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 2-1 + (3-1)*3);
332 t40 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 3-1 + (3-1)*3);
334 t57 = (t36 * t2 + t38 * t5 + t40 * t8) * t11 + (t36 * t13 + t38 * t15 + t40 * t17) * t20 + (t36 * t22 + t38 * t24 + t40 * t26) * t29 + t36 * Sx + t38 * Sy + t40 * Sz;
336 t60 = R_matrix[3-1][1-1];
338 t62 = R_matrix[3-1][2-1];
340 t64 = R_matrix[3-1][3-1];
342 t81 = (t60 * t2 + t62 * t5 + t64 * t8) * t11 + (t60 * t13 + t62 * t15 + t64 * t17) * t20 + (t60 * t22 + t62 * t24 + t64 * t26) * t29 + t60 * Sx + t62 * Sy + t64 * Sz + Rz;
346 t84 = R_matrix[1-1][1-1];
348 t86 = R_matrix[1-1][2-1];
350 t88 = R_matrix[1-1][3-1];
351 t108 = fx * ((t84 * t2 + t86 * t5 + t88 * t8) * t11 + (t84 * t13 + t86 * t15 + t88 * t17) * t20 + (t84 * t22 + t86 * t24 + t88 * t26) * t29 + t84 * Sx + t86 * Sy + t88 * Sz + Rx) + cx * t81;
356 t111 = (fx * ((t84 * t2 + t86 * t5 + t88 * t8) * t11 + (t84 * t13 + t86 * t15 + t88 * t17) * t20 + (t84 * t22 + t86 * t24 + t88 * t26) * t29 + t84 * Sx + t86 * Sy + t88 * Sz + Rx) + cx * t81) * t110;
358 t114 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 1-1 + (1-1)*3);
360 t116 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 2-1 + (1-1)*3);
362 t118 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 3-1 + (1-1)*3);
364 t137 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 1-1 + (3-1)*3);
366 t139 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 2-1 + (3-1)*3);
368 t141 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 3-1 + (3-1)*3);
370 t158 = (t137 * t2 + t139 * t5 + t141 * t8) * t11 + (t137 * t13 + t139 * t15 + t141 * t17) * t20 + (t137 * t22 + t139 * t24 + t141 * t26) * t29 + t137 * Sx + t139 * Sy + t141 * Sz;
372 t164 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 1-1 + (1-1)*3);
374 t166 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 2-1 + (1-1)*3);
376 t168 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 3-1 + (1-1)*3);
378 t187 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 1-1 + (3-1)*3);
380 t189 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 2-1 + (3-1)*3);
382 t191 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 3-1 + (3-1)*3);
384 t208 = (t187 * t2 + t189 * t5 + t191 * t8) * t11 + (t187 * t13 + t189 * t15 + t191 * t17) * t20 + (t187 * t22 + t189 * t24 + t191 * t26) * t29 + t187 * Sx + t189 * Sy + t191 * Sz;
386 t217 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 1-1 + (1-1)*3);
388 t219 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 1-1 + (2-1)*3);
390 t221 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 1-1 + (3-1)*3);
392 t225 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 2-1 + (1-1)*3);
394 t227 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 2-1 + (2-1)*3);
396 t229 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 2-1 + (3-1)*3);
398 t233 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 3-1 + (1-1)*3);
400 t235 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 3-1 + (2-1)*3);
402 t237 = CV_MAT_ELEM(*S_jacobian,
double, 1-1, 3-1 + (3-1)*3);
404 t258 = (t60 * t217 + t62 * t219 + t64 * t221) * t11 + (t60 * t225 + t62 * t227 + t64 * t229) * t20 + (t60 * t233 + t62 * t235 + t64 * t237) * t29;
406 t264 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 1-1 + (1-1)*3);
408 t266 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 1-1 + (2-1)*3);
410 t268 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 1-1 + (3-1)*3);
412 t272 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 2-1 + (1-1)*3);
414 t274 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 2-1 + (2-1)*3);
416 t276 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 2-1 + (3-1)*3);
418 t280 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 3-1 + (1-1)*3);
420 t282 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 3-1 + (2-1)*3);
422 t284 = CV_MAT_ELEM(*S_jacobian,
double, 2-1, 3-1 + (3-1)*3);
424 t305 = (t60 * t264 + t62 * t266 + t64 * t268) * t11 + (t60 * t272 + t62 * t274 + t64 * t276) * t20 + (t60 * t280 + t62 * t282 + t64 * t284) * t29;
426 t311 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 1-1 + (1-1)*3);
428 t313 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 1-1 + (2-1)*3);
430 t315 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 1-1 + (3-1)*3);
432 t319 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 2-1 + (1-1)*3);
434 t321 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 2-1 + (2-1)*3);
436 t323 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 2-1 + (3-1)*3);
438 t327 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 3-1 + (1-1)*3);
440 t329 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 3-1 + (2-1)*3);
442 t331 = CV_MAT_ELEM(*S_jacobian,
double, 3-1, 3-1 + (3-1)*3);
444 t352 = (t60 * t311 + t62 * t313 + t64 * t315) * t11 + (t60 * t319 + t62 * t321 + t64 * t323) * t20 + (t60 * t327 + t62 * t329 + t64 * t331) * t29;
446 t376 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 1-1 + (2-1)*3);
448 t378 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 2-1 + (2-1)*3);
450 t380 = CV_MAT_ELEM(*R_jacobian,
double, 1-1, 3-1 + (2-1)*3);
452 t402 = R_matrix[2-1][1-1];
454 t404 = R_matrix[2-1][2-1];
456 t406 = R_matrix[2-1][3-1];
458 t426 = fy * ((t402 * t2 + t404 * t5 + t406 * t8) * t11 + (t402 * t13 + t404 * t15 + t406 * t17) * t20 + (t402 * t22 + t404 * t24 + t406 * t26) * t29 + t402 * Sx + t404 * Sy + t406 * Sz + Ry) + cy * t81;
460 t427 = (fy * ((t402 * t2 + t404 * t5 + t406 * t8) * t11 + (t402 * t13 + t404 * t15 + t406 * t17) * t20 + (t402 * t22 + t404 * t24 + t406 * t26) * t29 + t402 * Sx + t404 * Sy + t406 * Sz + Ry) + cy * t81) * t110;
462 t430 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 1-1 + (2-1)*3);
464 t432 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 2-1 + (2-1)*3);
466 t434 = CV_MAT_ELEM(*R_jacobian,
double, 2-1, 3-1 + (2-1)*3);
468 t458 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 1-1 + (2-1)*3);
470 t460 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 2-1 + (2-1)*3);
472 t462 = CV_MAT_ELEM(*R_jacobian,
double, 3-1, 3-1 + (2-1)*3);
474 cgret[0] = (fx * ((t1 * t2 + t4 * t5 + t7 * t8) * t11 + (t1 * t13 + t4 * t15 + t7 * t17) * t20 + (t1 * t22 + t4 * t24 + t7 * t26) * t29 + t1 * Sx + t4 * Sy + t7 * Sz) + cx * t57) * t82 - t111 * t57;
476 cgret[1] = (fx * ((t114 * t2 + t116 * t5 + t118 * t8) * t11 + (t114 * t13 + t116 * t15 + t118 * t17) * t20 + (t114 * t22 + t116 * t24 + t118 * t26) * t29 + t114 * Sx + t116 * Sy + t118 * Sz) + cx * t158) * t82 - t111 * t158;
478 cgret[2] = (fx * ((t164 * t2 + t166 * t5 + t168 * t8) * t11 + (t164 * t13 + t166 * t15 + t168 * t17) * t20 + (t164 * t22 + t166 * t24 + t168 * t26) * t29 + t164 * Sx + t166 * Sy + t168 * Sz) + cx * t208) * t82 - t111 * t208;
484 cgret[5] = cx * t82 - t111;
486 cgret[6] = (fx * ((t84 * t217 + t86 * t219 + t88 * t221) * t11 + (t84 * t225 + t86 * t227 + t88 * t229) * t20 + (t84 * t233 + t86 * t235 + t88 * t237) * t29) + cx * t258) * t82 - t111 * t258;
488 cgret[7] = (fx * ((t84 * t264 + t86 * t266 + t88 * t268) * t11 + (t84 * t272 + t86 * t274 + t88 * t276) * t20 + (t84 * t280 + t86 * t282 + t88 * t284) * t29) + cx * t305) * t82 - t111 * t305;
490 cgret[8] = (fx * ((t84 * t311 + t86 * t313 + t88 * t315) * t11 + (t84 * t319 + t86 * t321 + t88 * t323) * t20 + (t84 * t327 + t86 * t329 + t88 * t331) * t29) + cx * t352) * t82 - t111 * t352;
492 cgret[9] = (fx * t84 + cx * t60) * t82 - t111 * t60;
494 cgret[10] = (fx * t86 + cx * t62) * t82 - t111 * t62;
496 cgret[11] = (fx * t88 + cx * t64) * t82 - t111 * t64;
498 cgret[12] = (fy * ((t376 * t2 + t378 * t5 + t380 * t8) * t11 + (t376 * t13 + t378 * t15 + t380 * t17) * t20 + (t376 * t22 + t378 * t24 + t380 * t26) * t29 + t376 * Sx + t378 * Sy + t380 * Sz) + cy * t57) * t82 - t427 * t57;
500 cgret[13] = (fy * ((t430 * t2 + t432 * t5 + t434 * t8) * t11 + (t430 * t13 + t432 * t15 + t434 * t17) * t20 + (t430 * t22 + t432 * t24 + t434 * t26) * t29 + t430 * Sx + t432 * Sy + t434 * Sz) + cy * t158) * t82 - t427 * t158;
502 cgret[14] = (fy * ((t458 * t2 + t460 * t5 + t462 * t8) * t11 + (t458 * t13 + t460 * t15 + t462 * t17) * t20 + (t458 * t22 + t460 * t24 + t462 * t26) * t29 + t458 * Sx + t460 * Sy + t462 * Sz) + cy * t208) * t82 - t427 * t208;
506 cgret[16] = fy * t82;
508 cgret[17] = cy * t82 - t427;
510 cgret[18] = (fy * ((t402 * t217 + t404 * t219 + t406 * t221) * t11 + (t402 * t225 + t404 * t227 + t406 * t229) * t20 + (t402 * t233 + t404 * t235 + t406 * t237) * t29) + cy * t258) * t82 - t427 * t258;
512 cgret[19] = (fy * ((t402 * t264 + t404 * t266 + t406 * t268) * t11 + (t402 * t272 + t404 * t274 + t406 * t276) * t20 + (t402 * t280 + t404 * t282 + t406 * t284) * t29) + cy * t305) * t82 - t427 * t305;
514 cgret[20] = (fy * ((t402 * t311 + t404 * t313 + t406 * t315) * t11 + (t402 * t319 + t404 * t321 + t406 * t323) * t20 + (t402 * t327 + t404 * t329 + t406 * t331) * t29) + cy * t352) * t82 - t427 * t352;
515 cgret[21] = (fy * t402 + cy * t60) * t82 - t427 * t60;
516 cgret[22] = (fy * t404 + cy * t62) * t82 - t427 * t62;
517 cgret[23] = (fy * t406 + cy * t64) * t82 - t427 * t64;