如何计算智能手机相机和artoolkit标记之间的距离。 我试图从标记的变换矩阵得到它,但矢量值都是零。
float [] pMatrix = ARToolKit.getInstance().getProjectionMatrix(); float x = pMatrix[3]; float y = pMatrix[7]; float z = pMatrix[11];x,y,z都为零。
how to calculate distance betweeen smartphone camera and artoolkit marker. i tried to get it from transformation matrix of marker but the vector value are all zero.
float [] pMatrix = ARToolKit.getInstance().getProjectionMatrix(); float x = pMatrix[3]; float y = pMatrix[7]; float z = pMatrix[11];x, y , z are all zero.
最满意答案
我认为你正在看矩阵中的错误位置。 摄像机x,y,z位于变换矩阵的最后一列内:
queryMarkerTransformation(int markerId); Returns float array with 16 values. The values represent an OpenGL style transformation matrix. The first 4 values represent the first column of the matrix. i.e: float[16] = [0.24218401, 0.9598883, 0.14125957, 0.0, -0.8614648, 0.2801126, -0.42357886, 0.0, -0.44614935, -0.019116696, 0.8947546, 0.0, 23.678268, -6.4265084, -298.65326, 1.0] The matrix looks like: 0.24218401 -0.8614648 -0.44614935 23.678268 0.9598883 0.2801126 -0.019116696 -6.4265084 0.14125957 -0.42357886 0.8947546 -298.65326 0.0 0.0 0.0 1.0 The last column represents x,y,z in the camera coordinate system.其来源是: https : //www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm我相信。 (但不知怎的,我现在无法到达网址)
现在您也在阅读投影矩阵,而不是变换矩阵。 ( https://github.com/artoolkit/artoolkit5/blob/master/AndroidStudioProjects/ARSimpleProj/aRSimple/src/main/java/org/artoolkit/ar/samples/ARSimple/SimpleRenderer.java#L98 )
如果我正确地跟踪了这个值[14]应该给你到标记的距离。
更新:我刚刚在这里写下了更详细的解释: http : //augmentmy.world/artoolkit-distance-between-camera-and-marker
I think you are looking at the wrong positions in the matrix. The camera x,y,z is inside the last column of the transformation matrix:
queryMarkerTransformation(int markerId); Returns float array with 16 values. The values represent an OpenGL style transformation matrix. The first 4 values represent the first column of the matrix. i.e: float[16] = [0.24218401, 0.9598883, 0.14125957, 0.0, -0.8614648, 0.2801126, -0.42357886, 0.0, -0.44614935, -0.019116696, 0.8947546, 0.0, 23.678268, -6.4265084, -298.65326, 1.0] The matrix looks like: 0.24218401 -0.8614648 -0.44614935 23.678268 0.9598883 0.2801126 -0.019116696 -6.4265084 0.14125957 -0.42357886 0.8947546 -298.65326 0.0 0.0 0.0 1.0 The last column represents x,y,z in the camera coordinate system.The source for that is here: https://www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm I believe. (But somehow I cannot reach the url right now)
Now you are also reading the projection matrix, not the transformation matrix. (https://github.com/artoolkit/artoolkit5/blob/master/AndroidStudioProjects/ARSimpleProj/aRSimple/src/main/java/org/artoolkit/ar/samples/ARSimple/SimpleRenderer.java#L98)
If I tracked that down correctly value [14] should give you the distance to the marker.
Update: I just wrote down a more detailed explanation here: http://augmentmy.world/artoolkit-distance-between-camera-and-marker
在ArToolkit的android java SDK中找到ArMarker和相机之间的距离(Find distance between ArMarker and camera in ArToolkit's android java SDK)如何计算智能手机相机和artoolkit标记之间的距离。 我试图从标记的变换矩阵得到它,但矢量值都是零。
float [] pMatrix = ARToolKit.getInstance().getProjectionMatrix(); float x = pMatrix[3]; float y = pMatrix[7]; float z = pMatrix[11];x,y,z都为零。
how to calculate distance betweeen smartphone camera and artoolkit marker. i tried to get it from transformation matrix of marker but the vector value are all zero.
float [] pMatrix = ARToolKit.getInstance().getProjectionMatrix(); float x = pMatrix[3]; float y = pMatrix[7]; float z = pMatrix[11];x, y , z are all zero.
最满意答案
我认为你正在看矩阵中的错误位置。 摄像机x,y,z位于变换矩阵的最后一列内:
queryMarkerTransformation(int markerId); Returns float array with 16 values. The values represent an OpenGL style transformation matrix. The first 4 values represent the first column of the matrix. i.e: float[16] = [0.24218401, 0.9598883, 0.14125957, 0.0, -0.8614648, 0.2801126, -0.42357886, 0.0, -0.44614935, -0.019116696, 0.8947546, 0.0, 23.678268, -6.4265084, -298.65326, 1.0] The matrix looks like: 0.24218401 -0.8614648 -0.44614935 23.678268 0.9598883 0.2801126 -0.019116696 -6.4265084 0.14125957 -0.42357886 0.8947546 -298.65326 0.0 0.0 0.0 1.0 The last column represents x,y,z in the camera coordinate system.其来源是: https : //www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm我相信。 (但不知怎的,我现在无法到达网址)
现在您也在阅读投影矩阵,而不是变换矩阵。 ( https://github.com/artoolkit/artoolkit5/blob/master/AndroidStudioProjects/ARSimpleProj/aRSimple/src/main/java/org/artoolkit/ar/samples/ARSimple/SimpleRenderer.java#L98 )
如果我正确地跟踪了这个值[14]应该给你到标记的距离。
更新:我刚刚在这里写下了更详细的解释: http : //augmentmy.world/artoolkit-distance-between-camera-and-marker
I think you are looking at the wrong positions in the matrix. The camera x,y,z is inside the last column of the transformation matrix:
queryMarkerTransformation(int markerId); Returns float array with 16 values. The values represent an OpenGL style transformation matrix. The first 4 values represent the first column of the matrix. i.e: float[16] = [0.24218401, 0.9598883, 0.14125957, 0.0, -0.8614648, 0.2801126, -0.42357886, 0.0, -0.44614935, -0.019116696, 0.8947546, 0.0, 23.678268, -6.4265084, -298.65326, 1.0] The matrix looks like: 0.24218401 -0.8614648 -0.44614935 23.678268 0.9598883 0.2801126 -0.019116696 -6.4265084 0.14125957 -0.42357886 0.8947546 -298.65326 0.0 0.0 0.0 1.0 The last column represents x,y,z in the camera coordinate system.The source for that is here: https://www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm I believe. (But somehow I cannot reach the url right now)
Now you are also reading the projection matrix, not the transformation matrix. (https://github.com/artoolkit/artoolkit5/blob/master/AndroidStudioProjects/ARSimpleProj/aRSimple/src/main/java/org/artoolkit/ar/samples/ARSimple/SimpleRenderer.java#L98)
If I tracked that down correctly value [14] should give you the distance to the marker.
Update: I just wrote down a more detailed explanation here: http://augmentmy.world/artoolkit-distance-between-camera-and-marker
发布评论