本文整理汇总了C++中xn::HandsGenerator::RegisterHandCallbacks方法的典型用法代码示例。如果您正苦于以下问题:C++ HandsGenerator::RegisterHandCallbacks方法的具体用法?C++ HandsGenerator::RegisterHandCallbacks怎么用?C++ HandsGenerator::RegisterHandCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xn::HandsGenerator
的用法示例。
在下文中一共展示了HandsGenerator::RegisterHandCallbacks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandsGenerator_RegisterHandCallbacks_wrapped
XnCallbackHandle HandsGenerator_RegisterHandCallbacks_wrapped(xn::HandsGenerator& self, BP::object create, BP::object update, BP::object destroy) {
checkValid(self);
XnCallbackHandle handle;
BP::object* cookie = new BP::object [3]; //FIXME: fix cookie
cookie[0] = create;
cookie[1] = update;
cookie[2] = destroy;
check( self.RegisterHandCallbacks(&Create_callback, &Update_callback, &Destroy_callback, cookie, handle) );
return handle;
}
示例2: main
int main(int argc, char* argv[])
{
// Start
VideoCapture capture (CV_CAP_OPENNI);
if(!capture.isOpened())
{
int error = -1;
return 1;
}
namedWindow( "Color Image", 1 );
//namedWindow( "Depth Map", 1);
Mat view;
bool blink = false;
// NITE + openni
XnStatus rc = XN_STATUS_OK;
Context context;
rc = context.Init();
rc = g_GestureGenerator.Create(context);
rc = g_HandsGenerator.Create(context);
XnCallbackHandle hcb1,hcb2;
g_GestureGenerator.RegisterGestureCallbacks(Gesture_Recognized, Gesture_Process, NULL, hcb1);
g_HandsGenerator.RegisterHandCallbacks(handCreate, handUpdate, handDestroy, NULL, hcb2);
rc = context.StartGeneratingAll();
rc = g_GestureGenerator.AddGesture(GESTURE_TO_USE, NULL);
double d = 1.0;
double angle = 0.0;
double angleZ = 0.0;
Mat result;
Mat orig = imread("crocus.jpg");
result.create(750, 750, CV_8UC3);
double centerX = orig.cols/2;
double centerY = orig.rows/2;
warpPerspective(orig, orig, getScaleMatrix(1.0), orig.size(), INTER_CUBIC, BORDER_TRANSPARENT);
while( capture.isOpened() )
{
rc = context.WaitAndUpdateAll();
d = getZoom();
angle = getAngle();
angleZ = getAngle3D();
if (abs(d - oldZoom) > 0.009) {
//printf("angle = %f \n",angle);
oldAngle += angle;
//create the transformation to be passed to warp
Mat openCVTransform = getRotationMatrix2D(Point2f(centerX, centerY), oldAngle, d);
//warp image to apply transformation
result.setTo(Scalar(0));
warpAffine(orig, result, openCVTransform, result.size(), INTER_CUBIC, BORDER_TRANSPARENT);
oldZoom = d;
}
imshow("Result", result);
Mat bgrImage;
capture.grab();
capture.retrieve( bgrImage, CV_CAP_OPENNI_BGR_IMAGE );
if (hand1ID != -1) {
circle(bgrImage,Point(hand1.back().X + bgrImage.rows/2, bgrImage.cols/2 - hand1.back().Y),2,CV_RGB(0,255,0),3);
}
if (hand2ID != -1) {
circle(bgrImage,Point(hand2.back().X + bgrImage.rows/2, bgrImage.cols/2 - hand2.back().Y),2,CV_RGB(0,255,0),3);
}
flip(bgrImage,bgrImage,1);
imshow("Color Image", bgrImage);
result.create(750, 750, CV_8UC3);
if(waitKey(33) == 'q')
{
break;
}
}
context.Shutdown();
return 0;
}