|
368 | 368 | "\n",
|
369 | 369 | "def _residuals(cal):\n",
|
370 | 370 | " err = 0\n",
|
371 |
| - " for i_frame in range(n_frames):\n", |
372 |
| - " # fig, ax = plt.subplots()\n", |
| 371 | + " for i_frame in range(n_frames): \n", |
373 | 372 | " for i_point in range(len(points[i_frame])):\n",
|
374 | 373 | " if ids[i_frame][i_point][i_cam] != -1:\n",
|
375 | 374 | " tmp = convert_arr_metric_to_pixel(\n",
|
|
406 | 405 | },
|
407 | 406 | {
|
408 | 407 | "cell_type": "code",
|
409 |
| - "execution_count": null, |
| 408 | + "execution_count": 54, |
410 | 409 | "metadata": {},
|
411 | 410 | "outputs": [
|
412 | 411 | {
|
|
454 | 453 | "sol = minimize(error_function, x0, args=(cal), method='Nelder-Mead', tol=1e-4)\n"
|
455 | 454 | ]
|
456 | 455 | },
|
| 456 | + { |
| 457 | + "cell_type": "code", |
| 458 | + "execution_count": 55, |
| 459 | + "metadata": {}, |
| 460 | + "outputs": [ |
| 461 | + { |
| 462 | + "name": "stdout", |
| 463 | + "output_type": "stream", |
| 464 | + "text": [ |
| 465 | + "[ 1.29864389e+02 7.09995178e+01 6.06405459e+02 -1.18822423e-01\n", |
| 466 | + " 2.34215634e-01 9.15198506e-03 -1.76412191e-01 -9.97652573e-02\n", |
| 467 | + " 7.41781981e+01 3.41659939e-02 1.36738065e-01 3.02279045e-02\n", |
| 468 | + " 2.17198498e-03 -1.57233580e-02 1.88667731e+01 2.95341468e-02]\n" |
| 469 | + ] |
| 470 | + } |
| 471 | + ], |
| 472 | + "source": [ |
| 473 | + "print(sol.x)" |
| 474 | + ] |
| 475 | + }, |
| 476 | + { |
| 477 | + "cell_type": "code", |
| 478 | + "execution_count": 58, |
| 479 | + "metadata": {}, |
| 480 | + "outputs": [ |
| 481 | + { |
| 482 | + "data": { |
| 483 | + "text/plain": [ |
| 484 | + "80032.63451606502" |
| 485 | + ] |
| 486 | + }, |
| 487 | + "execution_count": 58, |
| 488 | + "metadata": {}, |
| 489 | + "output_type": "execute_result" |
| 490 | + } |
| 491 | + ], |
| 492 | + "source": [ |
| 493 | + "error_function(sol.x, cal)" |
| 494 | + ] |
| 495 | + }, |
| 496 | + { |
| 497 | + "cell_type": "code", |
| 498 | + "execution_count": null, |
| 499 | + "metadata": {}, |
| 500 | + "outputs": [ |
| 501 | + { |
| 502 | + "ename": "NameError", |
| 503 | + "evalue": "name 'cals' is not defined", |
| 504 | + "output_type": "error", |
| 505 | + "traceback": [ |
| 506 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 507 | + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
| 508 | + "Cell \u001b[0;32mIn[1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m i_frame \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m \n\u001b[1;32m 2\u001b[0m i_cam \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[0;32m----> 3\u001b[0m cal \u001b[38;5;241m=\u001b[39m \u001b[43mcals\u001b[49m[i_cam] \n\u001b[1;32m 4\u001b[0m array_to_calibration(sol\u001b[38;5;241m.\u001b[39mx, cal)\n\u001b[1;32m 6\u001b[0m fig, ax \u001b[38;5;241m=\u001b[39m plt\u001b[38;5;241m.\u001b[39msubplots()\n", |
| 509 | + "\u001b[0;31mNameError\u001b[0m: name 'cals' is not defined" |
| 510 | + ] |
| 511 | + } |
| 512 | + ], |
| 513 | + "source": [ |
| 514 | + "i_frame = 0 \n", |
| 515 | + "i_cam = 0\n", |
| 516 | + "cal = cals[i_cam] \n", |
| 517 | + "# array_to_calibration(sol.x, cal)\n", |
| 518 | + "\n", |
| 519 | + "fig, ax = plt.subplots()\n", |
| 520 | + "for i_point in range(len(points[i_frame])):\n", |
| 521 | + " if ids[i_frame][i_point][i_cam] != -1:\n", |
| 522 | + " tmp = convert_arr_metric_to_pixel(\n", |
| 523 | + " image_coordinates(np.atleast_2d(points[i_frame][i_point]), cal, cpar.get_multimedia_params()),\n", |
| 524 | + " cpar\n", |
| 525 | + " )\n", |
| 526 | + " x, y = targets[i_frame][i_cam][ids[i_frame][i_point][i_cam]].pos()\n", |
| 527 | + "\n", |
| 528 | + "\n", |
| 529 | + " ax.scatter(x, y, marker='+', color = 'blue')\n", |
| 530 | + " ax.scatter(tmp[0,0], tmp[0,1], marker='x', color = 'red')\n", |
| 531 | + "\n", |
| 532 | + "fig.show() \n" |
| 533 | + ] |
| 534 | + }, |
457 | 535 | {
|
458 | 536 | "cell_type": "code",
|
459 | 537 | "execution_count": null,
|
|
0 commit comments