<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Ed K's Activities</title><link>https://communities.bentley.com/members/6898281e_2d00_b7f8_2d00_43c1_2d00_810f_2d00_381dfebd4b79</link><description>Ed K's recent activity</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Let me Help You</title><link>https://communities.bentley.com/achievements/687f4b6d-e18a-4e55-836c-49926ca2c9d9</link><pubDate>Thu, 23 Jul 2020 00:20:18 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:91102ac6-6b5f-4840-82af-065844c8112b</guid><dc:creator /><description>Answer a question that is verified as helpful or correct.</description></item><item><title>Calculating Rotation Matrix from Yaw/Pitch/Roll (CC SDK)</title><link>https://communities.bentley.com/products/3d_imaging_and_point_cloud_software/f/contextcapture-descartes-pointools-forum/200751/calculating-rotation-matrix-from-yaw-pitch-roll-cc-sdk</link><pubDate>Wed, 22 Jul 2020 18:57:42 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:2ed8768a-cc39-4624-822f-d90dc231dd3c</guid><dc:creator>Ed K</dc:creator><description>&lt;p&gt;I have a use case where I need to update the metadata for each photo from a data file that has more accurate position and yaw/pitch/roll data than what is contained in each photo&amp;#39;s exifdata.&lt;/p&gt;
&lt;p&gt;Through the SDK, I am able to modify each photo&amp;#39;s PoseMetadata Point3d `center` and Matrix3 `rotation` attributes. To change `rotation`, I must find the transformation from yaw/pitch/roll to ContextCapture rotation matrix.&lt;/p&gt;
&lt;p&gt;However, the rotation matrix formula provided in the CC user guide does not appear to be correct (&lt;a href="https://docs.bentley.com/LiveContent/web/ContextCapture%20Help-v10/en/GUID-2D452A8A-A4FE-450D-A0CA-9336DCF1238A.html"&gt;docs.bentley.com/.../GUID-2D452A8A-A4FE-450D-A0CA-9336DCF1238A.html&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;For instance, if I add a photo with 0 yaw/0 pitch/0 roll exifdata (confirmed through CC SDK photo.exifData.yawPitchRoll), the photo&amp;#39;s poseMetadata rotation matrix is [[0.9703417, -0.24173759, -0.00000276], [0.20574631, 0.8258776, -0.52497107], [0.12690751, 0.5094007, 0.85112005]], whereas the provided formula results in [[1, -0, 0], [0, 0, -1], [0, 1, 0]].&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have&amp;nbsp;created the following minimum reproduceable example using&amp;nbsp;any image named &amp;quot;example_image_0.jpg&amp;quot; with yaw/pitch/roll exifdata.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;import ccmasterkernel
import math
import numpy as np
np.set_printoptions(suppress=True)

def compare_rotation_matrices():
    print(&amp;quot;MasterKernel version %s&amp;quot; % ccmasterkernel.version())
    print()

    project = ccmasterkernel.Project()
    block = ccmasterkernel.Block(project)
    project.addBlock(block)
    photogroups = block.getPhotogroups()

    path = &amp;quot;example_image_0.jpg&amp;quot;
    print(&amp;quot;----------&amp;quot;, path, &amp;quot;----------&amp;quot;)
    photo = photogroups.addPhotoInAutoMode(path)

    yaw, pitch, roll = photo.exifData.yawPitchRoll
    print(&amp;quot;--- PHOTO EXIFDATA ---&amp;quot;)
    print(&amp;quot;Yaw:&amp;quot;, yaw, &amp;quot;\tPitch:&amp;quot;, pitch, &amp;quot;\tRoll:&amp;quot;, roll)
    print()

    rot_mat = np.asarray(photo.poseMetadata.rotation.getElements(), dtype=np.float32).reshape((3, 3))
    print(&amp;quot;--- CONTEXTCAPTURE ROTATION MATRIX ---&amp;quot;)
    print(rot_mat)
    print()

    calculated_rot_mat = yaw_pitch_roll_to_rotation_matrix(yaw=yaw, pitch=pitch, roll=roll)
    print(&amp;quot;--- CALCULATED ROTATION MATRIX ---&amp;quot;)
    print(calculated_rot_mat)
    print()


def yaw_pitch_roll_to_rotation_matrix(yaw, pitch, roll):
    &amp;quot;&amp;quot;&amp;quot;
    Formula from ContextCapture User Manual.
    https://docs.bentley.com/LiveContent/web/ContextCapture%20Help-v10/en/GUID-2D452A8A-A4FE-450D-A0CA-9336DCF1238A.html
    &amp;quot;&amp;quot;&amp;quot;
    P = np.deg2rad(pitch)
    R = np.deg2rad(roll)
    Y = np.deg2rad(yaw)
    M_00 =  math.cos(R) * math.cos(Y) - math.sin(R) * math.sin(P) * math.sin(Y)
    M_01 = -math.cos(R) * math.sin(Y) - math.cos(Y) * math.sin(R) * math.sin(P)
    M_02 =  math.cos(P) * math.sin(R)
    M_10 =  math.cos(Y) * math.sin(R) + math.cos(R) * math.sin(P) * math.sin(Y)
    M_11 =  math.cos(R) * math.cos(Y) * math.sin(P) - math.sin(R) * math.sin(Y)
    M_12 = -math.cos(R) * math.cos(P)
    M_20 = math.cos(P) * math.sin(Y)
    M_21 = math.cos(P) * math.cos(Y)
    M_22 = math.sin(P)
    return np.array([[M_00, M_01, M_02],
                     [M_10, M_11, M_12],
                     [M_20, M_21, M_22]])


if __name__ == &amp;quot;__main__&amp;quot;:
    compare_rotation_matrices()
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the&amp;nbsp;output using two example images I have:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/343228/pastedimage1595443907851v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;As can be seen, the matrices are not the same, so I cannot update the photo rotation with confidence.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please get back to me. Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Ask A Question I</title><link>https://communities.bentley.com/achievements/460ac7df-7ccc-4c42-a204-9e05eef3be09</link><pubDate>Wed, 22 Jul 2020 18:58:33 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0337c961-d464-4209-b230-37fc343a764d</guid><dc:creator /><description>Ask a question in a forum.</description></item></channel></rss>