{"action":"created","comment":{"url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/comments/180139126","pull_request_review_id":110500935,"id":180139126,"diff_hunk":"@@ -0,0 +1,150 @@\n+#!/usr/bin/env python\n+import argparse\n+import kalibr_common as kc\n+import math\n+import matplotlib.pyplot as plt\n+import matplotlib.image as mpimg\n+import numpy as np\n+import sm\n+\n+\n+def parse_arguments():\n+    parser = argparse.ArgumentParser(\n+        description=\n+        'Visualizes a camchain-cam.yaml distortion.')\n+    parser.add_argument(\n+        '--cam',\n+        dest='chain_yaml',\n+        help=\n+        'Camera configuration as yaml file (can take multiple configurations).',\n+        nargs='+',\n+        required=True)\n+    parser.add_argument(\n+        '--number_of_rectangles',\n+        help=\"Number of rectangles to draw.\",\n+        default=5)\n+    parser.add_argument(\n+        '--line_thickness',\n+        help=\"Line thickness.\",\n+        default=3)\n+    parsed_args = parser.parse_args()\n+    return parsed_args\n+\n+def normalize((u,v), focal_lengths, principal_point):\n+    x = (u - principal_point[1]) / focal_lengths[1]\n+    y = (v - principal_point[0]) / focal_lengths[0]\n+    return (x,y)\n+\n+def denormalize((x,y), focal_lengths, principal_point):\n+    u = x * focal_lengths[1] + principal_point[1]\n+    v = y * focal_lengths[0] + principal_point[0]\n+    return (u,v)\n+\n+def distortPoint((x,y), distortion_model, distortion_coeffs):\n+    if distortion_model == \"radial-tangential\" or distortion_model == \"radtan\":\n+        x2 = x**2\n+        y2 = y**2\n+        xy = x * y\n+        rho2 = x2 + y2\n+        rad_dist = distortion_coeffs[0] * rho2 + distortion_coeffs[1] * rho2**2\n+        x += x * rad_dist + 2.0 * distortion_coeffs[2] * xy + \\\n+            distortion_coeffs[3] * (rho2 + 2.0 * x2)\n+        y += y * rad_dist + 2.0 * distortion_coeffs[2] * xy + \\\n+            distortion_coeffs[3] * (rho2 + 2.0 * y2)\n+        return (x, y) \n+    elif distortion_model == \"equidistant\" or distortion_model == \"equi\":\n+        r = math.sqrt(x**2 + y**2)\n+        if r < 1e-8:\n+          return (x,y)\n+        theta = math.atan(r)\n+        thetad = theta * (1 + distortion_coeffs[0] * theta**2  + \\\n+            distortion_coeffs[1] * theta**4 + distortion_coeffs[2] * \\\n+            theta**6 + distortion_coeffs[3] * theta**8)\n+        scaling = thetad / r\n+        return (scaling * x, scaling * y)\n+    elif distortion_model ==  \"fov\":\n+        w = distortion_coeffs[0]\n+        r_u = np.linalg.norm((x,y))\n+        tanwhalf = math.tan(w / 2)\n+        atan_wrd = math.atan(2. * tanwhalf * r_u)\n+        \n+        r_rd = 0.0\n+        if w * w < 1e-5:\n+          r_rd = 1.0\n+        else:\n+          if r_u * r_u < 1e-5:\n+            r_rd = 2. * tanwhalf / w\n+          else:\n+            r_rd = atan_wrd / (r_u * w)\n+        return (x * r_rd, y * r_rd)\n+    else:\n+      raise Exception('Distortion model ' + distortion_model + ' not found.')\n+\n+def distort(image, distortion_model, distortion_coeffs, focal_lengths, ","path":"aslam_offline_calibration/kalibr/python/kalibr_visualize_distortion","position":83,"original_position":83,"commit_id":"717af463b715d66041654f12f7badc45b856685b","original_commit_id":"717af463b715d66041654f12f7badc45b856685b","user":{"login":"fabianbl","id":14781925,"avatar_url":"https://avatars2.githubusercontent.com/u/14781925?v=4","gravatar_id":"","url":"https://api.github.com/users/fabianbl","html_url":"https://github.com/fabianbl","followers_url":"https://api.github.com/users/fabianbl/followers","following_url":"https://api.github.com/users/fabianbl/following{/other_user}","gists_url":"https://api.github.com/users/fabianbl/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianbl/subscriptions","organizations_url":"https://api.github.com/users/fabianbl/orgs","repos_url":"https://api.github.com/users/fabianbl/repos","events_url":"https://api.github.com/users/fabianbl/events{/privacy}","received_events_url":"https://api.github.com/users/fabianbl/received_events","type":"User","site_admin":false},"body":"probably it would be faster to use the aslam_cv_python implementation of the distort function, but on the other hand it doesn't matter so much here..","created_at":"2018-04-09T15:44:33Z","updated_at":"2018-04-09T15:49:43Z","html_url":"https://github.com/ethz-asl/kalibr/pull/175#discussion_r180139126","pull_request_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/comments/180139126"},"html":{"href":"https://github.com/ethz-asl/kalibr/pull/175#discussion_r180139126"},"pull_request":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175"}}},"pull_request":{"url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175","id":179920259,"html_url":"https://github.com/ethz-asl/kalibr/pull/175","diff_url":"https://github.com/ethz-asl/kalibr/pull/175.diff","patch_url":"https://github.com/ethz-asl/kalibr/pull/175.patch","issue_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/175","number":175,"state":"open","locked":false,"title":"added distortion viewer","user":{"login":"floriantschopp","id":17647950,"avatar_url":"https://avatars2.githubusercontent.com/u/17647950?v=4","gravatar_id":"","url":"https://api.github.com/users/floriantschopp","html_url":"https://github.com/floriantschopp","followers_url":"https://api.github.com/users/floriantschopp/followers","following_url":"https://api.github.com/users/floriantschopp/following{/other_user}","gists_url":"https://api.github.com/users/floriantschopp/gists{/gist_id}","starred_url":"https://api.github.com/users/floriantschopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floriantschopp/subscriptions","organizations_url":"https://api.github.com/users/floriantschopp/orgs","repos_url":"https://api.github.com/users/floriantschopp/repos","events_url":"https://api.github.com/users/floriantschopp/events{/privacy}","received_events_url":"https://api.github.com/users/floriantschopp/received_events","type":"User","site_admin":false},"body":"wdyt?","created_at":"2018-04-06T11:17:13Z","updated_at":"2018-04-09T15:49:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9b80c2c0a7b1986a6d66c888731367e7381c172","assignee":null,"assignees":[],"requested_reviewers":[{"login":"schneith","id":5337083,"avatar_url":"https://avatars3.githubusercontent.com/u/5337083?v=4","gravatar_id":"","url":"https://api.github.com/users/schneith","html_url":"https://github.com/schneith","followers_url":"https://api.github.com/users/schneith/followers","following_url":"https://api.github.com/users/schneith/following{/other_user}","gists_url":"https://api.github.com/users/schneith/gists{/gist_id}","starred_url":"https://api.github.com/users/schneith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schneith/subscriptions","organizations_url":"https://api.github.com/users/schneith/orgs","repos_url":"https://api.github.com/users/schneith/repos","events_url":"https://api.github.com/users/schneith/events{/privacy}","received_events_url":"https://api.github.com/users/schneith/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175/commits","review_comments_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175/comments","review_comment_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/175/comments","statuses_url":"https://api.github.com/repos/ethz-asl/kalibr/statuses/717af463b715d66041654f12f7badc45b856685b","head":{"label":"ethz-asl:feature/distortion_viewer","ref":"feature/distortion_viewer","sha":"717af463b715d66041654f12f7badc45b856685b","user":{"login":"ethz-asl","id":475362,"avatar_url":"https://avatars0.githubusercontent.com/u/475362?v=4","gravatar_id":"","url":"https://api.github.com/users/ethz-asl","html_url":"https://github.com/ethz-asl","followers_url":"https://api.github.com/users/ethz-asl/followers","following_url":"https://api.github.com/users/ethz-asl/following{/other_user}","gists_url":"https://api.github.com/users/ethz-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/ethz-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethz-asl/subscriptions","organizations_url":"https://api.github.com/users/ethz-asl/orgs","repos_url":"https://api.github.com/users/ethz-asl/repos","events_url":"https://api.github.com/users/ethz-asl/events{/privacy}","received_events_url":"https://api.github.com/users/ethz-asl/received_events","type":"Organization","site_admin":false},"repo":{"id":20293077,"name":"kalibr","full_name":"ethz-asl/kalibr","owner":{"login":"ethz-asl","id":475362,"avatar_url":"https://avatars0.githubusercontent.com/u/475362?v=4","gravatar_id":"","url":"https://api.github.com/users/ethz-asl","html_url":"https://github.com/ethz-asl","followers_url":"https://api.github.com/users/ethz-asl/followers","following_url":"https://api.github.com/users/ethz-asl/following{/other_user}","gists_url":"https://api.github.com/users/ethz-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/ethz-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethz-asl/subscriptions","organizations_url":"https://api.github.com/users/ethz-asl/orgs","repos_url":"https://api.github.com/users/ethz-asl/repos","events_url":"https://api.github.com/users/ethz-asl/events{/privacy}","received_events_url":"https://api.github.com/users/ethz-asl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethz-asl/kalibr","description":"The Kalibr calibration toolbox","fork":false,"url":"https://api.github.com/repos/ethz-asl/kalibr","forks_url":"https://api.github.com/repos/ethz-asl/kalibr/forks","keys_url":"https://api.github.com/repos/ethz-asl/kalibr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethz-asl/kalibr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethz-asl/kalibr/teams","hooks_url":"https://api.github.com/repos/ethz-asl/kalibr/hooks","issue_events_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/events{/number}","events_url":"https://api.github.com/repos/ethz-asl/kalibr/events","assignees_url":"https://api.github.com/repos/ethz-asl/kalibr/assignees{/user}","branches_url":"https://api.github.com/repos/ethz-asl/kalibr/branches{/branch}","tags_url":"https://api.github.com/repos/ethz-asl/kalibr/tags","blobs_url":"https://api.github.com/repos/ethz-asl/kalibr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethz-asl/kalibr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethz-asl/kalibr/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethz-asl/kalibr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethz-asl/kalibr/statuses/{sha}","languages_url":"https://api.github.com/repos/ethz-asl/kalibr/languages","stargazers_url":"https://api.github.com/repos/ethz-asl/kalibr/stargazers","contributors_url":"https://api.github.com/repos/ethz-asl/kalibr/contributors","subscribers_url":"https://api.github.com/repos/ethz-asl/kalibr/subscribers","subscription_url":"https://api.github.com/repos/ethz-asl/kalibr/subscription","commits_url":"https://api.github.com/repos/ethz-asl/kalibr/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethz-asl/kalibr/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethz-asl/kalibr/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethz-asl/kalibr/contents/{+path}","compare_url":"https://api.github.com/repos/ethz-asl/kalibr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethz-asl/kalibr/merges","archive_url":"https://api.github.com/repos/ethz-asl/kalibr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethz-asl/kalibr/downloads","issues_url":"https://api.github.com/repos/ethz-asl/kalibr/issues{/number}","pulls_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls{/number}","milestones_url":"https://api.github.com/repos/ethz-asl/kalibr/milestones{/number}","notifications_url":"https://api.github.com/repos/ethz-asl/kalibr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethz-asl/kalibr/labels{/name}","releases_url":"https://api.github.com/repos/ethz-asl/kalibr/releases{/id}","deployments_url":"https://api.github.com/repos/ethz-asl/kalibr/deployments","created_at":"2014-05-29T12:31:48Z","updated_at":"2018-04-09T13:09:32Z","pushed_at":"2018-04-06T14:34:07Z","git_url":"git://github.com/ethz-asl/kalibr.git","ssh_url":"git@github.com:ethz-asl/kalibr.git","clone_url":"https://github.com/ethz-asl/kalibr.git","svn_url":"https://github.com/ethz-asl/kalibr","homepage":null,"size":4092,"stargazers_count":523,"watchers_count":523,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":286,"mirror_url":null,"archived":false,"open_issues_count":74,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":286,"open_issues":74,"watchers":523,"default_branch":"master"}},"base":{"label":"ethz-asl:master","ref":"master","sha":"d8f1d30f19a377be94b8ba342094173432725433","user":{"login":"ethz-asl","id":475362,"avatar_url":"https://avatars0.githubusercontent.com/u/475362?v=4","gravatar_id":"","url":"https://api.github.com/users/ethz-asl","html_url":"https://github.com/ethz-asl","followers_url":"https://api.github.com/users/ethz-asl/followers","following_url":"https://api.github.com/users/ethz-asl/following{/other_user}","gists_url":"https://api.github.com/users/ethz-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/ethz-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethz-asl/subscriptions","organizations_url":"https://api.github.com/users/ethz-asl/orgs","repos_url":"https://api.github.com/users/ethz-asl/repos","events_url":"https://api.github.com/users/ethz-asl/events{/privacy}","received_events_url":"https://api.github.com/users/ethz-asl/received_events","type":"Organization","site_admin":false},"repo":{"id":20293077,"name":"kalibr","full_name":"ethz-asl/kalibr","owner":{"login":"ethz-asl","id":475362,"avatar_url":"https://avatars0.githubusercontent.com/u/475362?v=4","gravatar_id":"","url":"https://api.github.com/users/ethz-asl","html_url":"https://github.com/ethz-asl","followers_url":"https://api.github.com/users/ethz-asl/followers","following_url":"https://api.github.com/users/ethz-asl/following{/other_user}","gists_url":"https://api.github.com/users/ethz-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/ethz-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethz-asl/subscriptions","organizations_url":"https://api.github.com/users/ethz-asl/orgs","repos_url":"https://api.github.com/users/ethz-asl/repos","events_url":"https://api.github.com/users/ethz-asl/events{/privacy}","received_events_url":"https://api.github.com/users/ethz-asl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethz-asl/kalibr","description":"The Kalibr calibration toolbox","fork":false,"url":"https://api.github.com/repos/ethz-asl/kalibr","forks_url":"https://api.github.com/repos/ethz-asl/kalibr/forks","keys_url":"https://api.github.com/repos/ethz-asl/kalibr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethz-asl/kalibr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethz-asl/kalibr/teams","hooks_url":"https://api.github.com/repos/ethz-asl/kalibr/hooks","issue_events_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/events{/number}","events_url":"https://api.github.com/repos/ethz-asl/kalibr/events","assignees_url":"https://api.github.com/repos/ethz-asl/kalibr/assignees{/user}","branches_url":"https://api.github.com/repos/ethz-asl/kalibr/branches{/branch}","tags_url":"https://api.github.com/repos/ethz-asl/kalibr/tags","blobs_url":"https://api.github.com/repos/ethz-asl/kalibr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethz-asl/kalibr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethz-asl/kalibr/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethz-asl/kalibr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethz-asl/kalibr/statuses/{sha}","languages_url":"https://api.github.com/repos/ethz-asl/kalibr/languages","stargazers_url":"https://api.github.com/repos/ethz-asl/kalibr/stargazers","contributors_url":"https://api.github.com/repos/ethz-asl/kalibr/contributors","subscribers_url":"https://api.github.com/repos/ethz-asl/kalibr/subscribers","subscription_url":"https://api.github.com/repos/ethz-asl/kalibr/subscription","commits_url":"https://api.github.com/repos/ethz-asl/kalibr/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethz-asl/kalibr/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethz-asl/kalibr/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethz-asl/kalibr/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethz-asl/kalibr/contents/{+path}","compare_url":"https://api.github.com/repos/ethz-asl/kalibr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethz-asl/kalibr/merges","archive_url":"https://api.github.com/repos/ethz-asl/kalibr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethz-asl/kalibr/downloads","issues_url":"https://api.github.com/repos/ethz-asl/kalibr/issues{/number}","pulls_url":"https://api.github.com/repos/ethz-asl/kalibr/pulls{/number}","milestones_url":"https://api.github.com/repos/ethz-asl/kalibr/milestones{/number}","notifications_url":"https://api.github.com/repos/ethz-asl/kalibr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethz-asl/kalibr/labels{/name}","releases_url":"https://api.github.com/repos/ethz-asl/kalibr/releases{/id}","deployments_url":"https://api.github.com/repos/ethz-asl/kalibr/deployments","created_at":"2014-05-29T12:31:48Z","updated_at":"2018-04-09T13:09:32Z","pushed_at":"2018-04-06T14:34:07Z","git_url":"git://github.com/ethz-asl/kalibr.git","ssh_url":"git@github.com:ethz-asl/kalibr.git","clone_url":"https://github.com/ethz-asl/kalibr.git","svn_url":"https://github.com/ethz-asl/kalibr","homepage":null,"size":4092,"stargazers_count":523,"watchers_count":523,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":286,"mirror_url":null,"archived":false,"open_issues_count":74,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":286,"open_issues":74,"watchers":523,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175"},"html":{"href":"https://github.com/ethz-asl/kalibr/pull/175"},"issue":{"href":"https://api.github.com/repos/ethz-asl/kalibr/issues/175"},"comments":{"href":"https://api.github.com/repos/ethz-asl/kalibr/issues/175/comments"},"review_comments":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175/comments"},"review_comment":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethz-asl/kalibr/pulls/175/commits"},"statuses":{"href":"https://api.github.com/repos/ethz-asl/kalibr/statuses/717af463b715d66041654f12f7badc45b856685b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"fabianbl"}}