Setting Kinect's ElevationAngle randomly throws COM based InvalidOperationException

隐身守侯 提交于 2019-12-13 21:09:42

问题


I'm working on the Kinect tilt control (similar to those in the Kinect Explorer toolkit sample but composed just of a Scrollbar). This works well but setting the tilt angle:

CurrentKinectSensor.ElevationAngle = value;

causes randomly the System.InvalidOperationException caused by underlying COM:

This API has returned an exception from an HRESULT: 0x800704D5

System.InvalidOperationException was unhandled
HResult=-2146233079
Message=This API has returned an exception from an HRESULT: 0x800704D5
Source=Microsoft.Kinect
InnerException: System.Runtime.InteropServices.COMException
HResult=-2147023659
Message=The operation could not be completed. A retry should be performed. (Exception 
from HRESULT: 0x800704D5)
ErrorCode=-2147023659
InnerException: 

I can deal with it only by handling the exception but I do not exactly understand what is the reason.

So far I found that it is somehow related to the fact of setting the new value of the ElevationAngle property before the Kinect finishes physical tilt of the previous change of the Kinect controller.

It increases the probability of the exception to be thrown - in other words if you set the ElevationAngle property too frequently, the exception occurs.

The minimum acceptable delay between setting the ElevationAngle was tested to be about 750ms but I guess it depends on the angle to be changed as it may last longer.

How do I know that the Kinect sensor has finished its physical tilting operation and is ready for the next one?


回答1:


There is no way you can tell when the Kinect is finished tilting but you are overseeing one time. MSDN says the following

To reduce wear, your application should change the elevation angle no more than once per second. In addition, you must allow at least 20 seconds of rest after 15 consecutive changes.

So the error can be throw in two situations, either by changing the values to fast after one another or not letting the camera rest after 15 ways.

Just ALWAYS put a try-catch around the getter/setter of the Kinect Angle.



来源:https://stackoverflow.com/questions/23603394/setting-kinects-elevationangle-randomly-throws-com-based-invalidoperationexcept

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!