{"id":1065,"date":"2018-11-01T10:18:15","date_gmt":"2018-11-01T09:18:15","guid":{"rendered":"http:\/\/www.calvert.ch\/maurice\/?p=1065"},"modified":"2018-11-02T19:46:37","modified_gmt":"2018-11-02T18:46:37","slug":"realsense-cameras-calculating-3d-coordinates-from-depth-row-and-column","status":"publish","type":"post","link":"https:\/\/www.calvert.ch\/maurice\/2018\/11\/01\/realsense-cameras-calculating-3d-coordinates-from-depth-row-and-column\/","title":{"rendered":"RealSense cameras &#8211; Calculating 3D coordinates from depth, row and column"},"content":{"rendered":"<p>A depth camera measures the distance from the camera to a point in 3D space. For a given point, the camera supplies the row and column on its \u2018screen\u2019 and the depth towards the point. It is worth pointing out here that classic depth cameras like the Kinect supply the length of the ray; RealSense cameras supply the range, or Z component.<\/p>\n<p>Calculating the coordinates of the point is fairly straightforward trigonometry. Suppose a D435 camera is mounted 500mm off the ground, pointing at the horizon. 1000mm away there is an object 101.5mm high:<\/p>\n<p><a href=\"http:\/\/www.calvert.ch\/maurice\/files\/2018\/10\/Improving.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1066 size-large\" src=\"http:\/\/www.calvert.ch\/maurice\/files\/2018\/10\/Improving-1024x700.png\" alt=\"\" width=\"695\" height=\"475\" srcset=\"https:\/\/www.calvert.ch\/maurice\/files\/2018\/10\/Improving-1024x700.png 1024w, https:\/\/www.calvert.ch\/maurice\/files\/2018\/10\/Improving-300x205.png 300w, https:\/\/www.calvert.ch\/maurice\/files\/2018\/10\/Improving-768x525.png 768w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n<p>To warm up, the camera\u2019s vertical field of view is 56\u00b0, so at 1\u2019000mm half of the height is<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-ef77efcfe19702eb7e6c64b199c4dd6e_l3.png\" height=\"19\" width=\"223\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#49;&#48;&#48;&#48;&#42;&#116;&#97;&#110;&#40;&#53;&#54;&#47;&#50;&#41;&#61;&#53;&#51;&#49;&#46;&#55;&#109;&#109;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>The camera has 480 rows, so it will see the 101.5mm-high object at row<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-e3df723ae96bbcf7abaf5ddb2605087a_l3.png\" height=\"19\" width=\"437\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#40;&#40;&#52;&#56;&#48;&#45;&#49;&#41;&#47;&#50;&#41;&#43;&#40;&#45;&#51;&#57;&#56;&#46;&#53;&#41;&#47;&#53;&#51;&#49;&#46;&#55;&#42;&#40;&#40;&#52;&#56;&#48;&#45;&#49;&#41;&#47;&#50;&#41;&#61;&#114;&#111;&#119;&#92;&#32;&#54;&#48;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>Bonus: It sees the object at an angle of<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-114ed79cd069c6d25838d630a076f402_l3.png\" height=\"19\" width=\"215\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#65;&#116;&#97;&#110;&#8289;&#40;&#51;&#57;&#56;&#46;&#53;&#47;&#49;&#48;&#48;&#48;&#41;&#61;&#45;&#50;&#49;&#46;&#55;&#94;&#92;&#99;&#105;&#114;&#99;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>Now we define constants for the Fx intrinsics, the centre row and the height of a pixel:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-be0fff1d91820dda496838fbd33eda6f_l3.png\" height=\"18\" width=\"141\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#70;&#111;&#118;&#50;&#61;&#86;&#70;&#111;&#118;&#47;&#50;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-eb42f116c7fec982c4a1ef95ba5e8d1a_l3.png\" height=\"18\" width=\"199\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#83;&#105;&#122;&#101;&#61;&#84;&#97;&#110;&#40;&#86;&#70;&#111;&#118;&#50;&#41;&#42;&#50;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-95f0da83bf6eb62ad3ecae78db032f98_l3.png\" height=\"19\" width=\"199\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#67;&#101;&#110;&#116;&#114;&#101;&#61;&#40;&#82;&#111;&#119;&#115;&#45;&#49;&#41;&#47;&#50;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-09ae8167b05622d7f07ef162aee1b4ad_l3.png\" height=\"19\" width=\"227\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#80;&#105;&#120;&#101;&#108;&#61;&#86;&#83;&#105;&#122;&#101;&#47;&#40;&#82;&#111;&#119;&#115;&#45;&#49;&#41;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-29c4a3f95bf599ee89a18d86f05e7c72_l3.png\" height=\"18\" width=\"292\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#82;&#97;&#116;&#105;&#111;&#61;&#40;&#86;&#67;&#101;&#110;&#116;&#114;&#101;&#45;&#114;&#111;&#119;&#41;&#42;&#86;&#80;&#105;&#120;&#101;&#108;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 16px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-bafa5fbfeb7018f3b346040d36f3c4eb_l3.png\" height=\"16\" width=\"177\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#89;&#61;&#82;&#97;&#110;&#103;&#101;&#42;&#45;&#86;&#82;&#97;&#116;&#105;&#111;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>Notice the &#8216;Rows-1&#8217; because there are 479 intervals between 480 pixels: row 239 points just under the horizon and row 240 points just above the horizon.<\/p>\n<p>Then, for the example above we define our constants:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-df5af8854955795a66e97d92340c1ac9_l3.png\" height=\"18\" width=\"156\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#70;&#111;&#118;&#50;&#61;&#53;&#54;&#47;&#50;&#61;&#50;&#56;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-10d5441912c0fc84ce0907d0c001c39c_l3.png\" height=\"18\" width=\"237\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#83;&#105;&#122;&#101;&#61;&#84;&#97;&#110;&#40;&#50;&#56;&#41;&#42;&#50;&#61;&#49;&#46;&#48;&#54;&#51;&#52;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-ade6ec1c12a1adbdb10cd6a19aca58a6_l3.png\" height=\"19\" width=\"246\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#67;&#101;&#110;&#116;&#114;&#101;&#61;&#40;&#52;&#56;&#48;&#45;&#49;&#41;&#47;&#50;&#61;&#50;&#51;&#57;&#46;&#53;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-e509fd7c99ac59d20affb6128ef363b7_l3.png\" height=\"19\" width=\"292\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#80;&#105;&#120;&#101;&#108;&#61;&#49;&#46;&#48;&#54;&#51;&#52;&#47;&#40;&#52;&#56;&#48;&#45;&#49;&#41;&#61;&#48;&#46;&#48;&#48;&#50;&#50;&#50;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>and calculate the Y coordinate:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-7ed2ca98b44d07afbfad90728073e301_l3.png\" height=\"18\" width=\"323\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#86;&#82;&#97;&#116;&#105;&#111;&#61;&#40;&#50;&#51;&#57;&#46;&#53;&#45;&#54;&#48;&#41;&#42;&#48;&#46;&#48;&#48;&#50;&#50;&#50;&#61;&#48;&#46;&#51;&#57;&#56;&#53;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 14px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.calvert.ch\/maurice\/wp-content\/ql-cache\/quicklatex.com-dc173670b9f1a02d2a42e9742654b9fd_l3.png\" height=\"14\" width=\"272\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91;&#89;&#61;&#49;&#48;&#48;&#48;&#42;&#45;&#86;&#82;&#97;&#116;&#105;&#111;&#61;&#45;&#51;&#57;&#56;&#46;&#53;&#32;&#109;&#109;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>The calculations for the X-coordinate are identical, replacing \u2018Vertical\u2019 with \u2018Horizontal\u2019 and Z is simply the supplied range.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A depth camera measures the distance from the camera to a point in 3D space. For a given point, the camera supplies the row and column on its \u2018screen\u2019 and the depth towards the point. It is worth pointing out <a href='https:\/\/www.calvert.ch\/maurice\/2018\/11\/01\/realsense-cameras-calculating-3d-coordinates-from-depth-row-and-column\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67,47,11],"tags":[],"class_list":["post-1065","post","type-post","status-publish","format-standard","hentry","category-3d","category-programming","category-technology","category-67-id","category-47-id","category-11-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/posts\/1065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/comments?post=1065"}],"version-history":[{"count":22,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/posts\/1065\/revisions"}],"predecessor-version":[{"id":1102,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/posts\/1065\/revisions\/1102"}],"wp:attachment":[{"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/media?parent=1065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/categories?post=1065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.calvert.ch\/maurice\/wp-json\/wp\/v2\/tags?post=1065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}