简体   繁体   English

C ++中的Kinect缩放

[英]Kinect Scaling in C++

I am experimenting with the kinect, however I am having some problems with scaling. 我正在尝试kinect,但是缩放时遇到了一些问题。 The below is code from the kinect-kcb and although the face tracking works for the 'mesh' I am having problems returning the scaling value for my own classes. 下面是kinect-kcb的代码,尽管人脸跟踪适用于“网格”,但我在返回自己类的缩放值时遇到问题。 The below code returns a correct rotation and translation which function perfectly, but the scale only ever returns 1 for a long period (despite the mesh clearly changing size) and then slowly gets smaller 0.98... etc but clearly not correct scaling values. 下面的代码返回正确的旋转和平移,该旋转和平移功能完美,但是缩放比例仅在很长一段时间内返回1(尽管网格明显改变了尺寸),然后慢慢变小0.98 ...等,但显然不正确的缩放比例值。

float scale;
float rotation[ 3 ];
float translation[ 3 ];
hr = mResult->Get3DPose( &scale, rotation, translation );
if ( SUCCEEDED( hr ) ) {
    Vec3f r( rotation[ 0 ], rotation[ 1 ], rotation[ 2 ] );
    Vec3f t( translation[ 0 ], translation[ 1 ], translation[ 2 ] );

    face.mPoseMatrix.translate( t );
    face.mPoseMatrix.rotate( r );
    face.mPoseMatrix.translate( -t );
    face.mPoseMatrix.translate( t );
    face.mPoseMatrix.scale( Vec3f::one() * scale );
}

This scale value is used repeatedly thoughout the code, but does not seem to change often enough (example functions - not in order): 整个代码中都反复使用此小数位值,但似乎变化不够频繁(示例函数-顺序不正确):

hr = mModel->Get3DShape( shapeUnits, numShapeUnits, animationUnits, numAnimationUnits, scale, rotation, translation, pts, numVertices );

hr = mModel->GetProjectedShape( &mConfigColor, mSensorData.ZoomFactor, viewOffset, shapeUnits, numShapeUnits, animationUnits, 
                            numAnimationUnits, scale, rotation, translation, pts, numVertices );

The kinect has a function FaceModel.Scale(), however this only returns a constant value which I assume is the initial scaling value for the 3D model, and then I assumed the above scaling value would change as the user moved closer and further away from the camera. kinect有一个函数FaceModel.Scale(),但是它只返回一个常数值,我认为这是3D模型的初始缩放值,然后我假设上面的缩放值会随着用户移近和移远而改变。相机。

The method IFTResult::Get3DPose among other things, gives you the face scale value. IFTResult :: Get3DPose方法除其他外,为您提供面部比例值。 If it is equal to 1.0 then the face scale is equal to the loaded 3D model (so nothing to do?). 如果等于1.0,则脸部比例等于加载的3D模型(因此无事可做?)。

If when reloading the 3d model, the face value is not equal to 1.0 then you need to do work on the model. 如果在重新加载3d模型时面值不等于1.0,则需要对模型进行处理。

have you tried outputting some debug info of what IFTResult::Get3DPose assigns to pScale? 您是否尝试输出IFTResult :: Get3DPose分配给pScale的调试信息?

its also possible that the system is failing to track, you can check this with IFTResult::GetStatus . 也有可能系统无法跟踪,您可以使用IFTResult :: GetStatus进行检查。

It may be that what you are after is the magnitude of the face rectangle . 您所追求的可能是面部矩形的大小。 This would scale with the proximity of the image subject. 这将与图像对象的接近程度成比例。

Heres a relevant code project link. 这里是相关的代码项目链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM