我正在使用C++中的windows Kinect。 我試圖檢查右手是否從右側走到左肩,就像擦拭動作一樣。 我試圖與std :: async一起工作,因爲我需要方法的返回值。 我已經使用了我得到的錯誤,不知道最新的事情。std :: async返回值。未知錯誤
我2點的方法,我用:
bool NuiSkeletonStream::timeNext(clock_t start)
{
clock_t end, diff;
end = clock();
diff = end - start;
while(diff <= 1500)
{
if(diff >= 1500)
{
if(i_rhx == i_lsx && i_rhy == i_lsy)
{
return true;
}
else
{
return false;
}
}
else
{
diff = end - start;
end = clock();
}
}
}
bool NuiSkeletonStream::runNext()
{
clock_t start;
// std::thread compare(timeNext(start),std::move(xNext));
for (int i = 0; i < NUI_SKELETON_COUNT; i++)
{
if (m_skeletonFrame.SkeletonData[i].eTrackingState == NUI_SKELETON_TRACKED)
{
i_rhx = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HAND_RIGHT].x*5+5;
i_rhy = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HAND_RIGHT].y*5+5;
//i_rhz = (m_skeletonFrame.SkeletonData[i].SkeletonPositions[11].z*10)-10;
i_rsx = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_SHOULDER_RIGHT].x*5+5;
i_rsy = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_SHOULDER_RIGHT].y*5+5;
i_lsx = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_SHOULDER_LEFT].x*5+5;
i_lsy = m_skeletonFrame.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_SHOULDER_LEFT].y*5+5;
if(i_rhx == i_rsx && i_rhy == i_rsy)
{
start = clock();
auto f1 = std::async(timeNext(start));
}
}
}
我有以下錯誤:
Error 24 error C2440: 'return' : cannot convert from 'std::_Do_call_ret<_Forced,_Ret,_Funx,_Btuple,_Ftuple>::type' to '_Ret'
獎勵:你的std ::使用異步是不是真的異步。基本上你需要抓住迴歸的未來並保持活力。看看http://en.cppreference.com/w/cpp/thread/async上的例子 – sbabbi