本文整理汇总了C++中Kinect::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Kinect::init方法的具体用法?C++ Kinect::init怎么用?C++ Kinect::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kinect
的用法示例。
在下文中一共展示了Kinect::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main(void) {
unsigned char menu =0;
unsigned total_n_pose = 12;
unsigned pose_n_frames = 100;
unsigned feature_dimension = 60; // 특징 차원 수
double *features = new double[feature_dimension]; // 특징벡터
float gamma[12] = {0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1};
Kinect kinect;
if(!kinect.init()) {
cout << "Kinect is not working";
return;
}
long angle = kinect.getCameraElevationAngle();
IplImage *frame = cvCreateImage(cvSize(640,480),8,3);
IplImage *frame_masked = cvCreateImage(cvSize(640,480),8,3);
IplImage *depth8 = cvCreateImage(cvSize(320,240),8,1);
IplImage *depth8_masked = cvCreateImage(cvSize(320,240),8,1);
IplImage *depthPlayer = cvCreateImage(cvSize(320,240),8,3);
char text[256],text2[256];;
while(1) {
cvDestroyAllWindows();
cout << " 1 : 키넥트 연결 확인 " << endl;
cout << " 2 : 포즈 저장하기 " << endl;
cout << " 3 : 포즈 확인하기 " << endl;
cout << " 4 : SVM 학습 및 검증 집합 만들기 " << endl;
cout << " 5 : SVM 학습하기 " << endl;
cout << " 6 : SVM 검증집합 인식결과 " << endl;
cout << " 7 : 실시간 포즈 인식 " << endl;
cout << " u : 카메라 각도 올리기" << endl;
cout << " d : 카메라 각도 내리기" << endl;
cout << " 종료 : ctrl+c"<<endl;
cout << " > ";
cin >> menu;
getchar();
/*
키넥트 영상 보기
*/
if(menu == '1') {
cout << "메뉴복귀 : esc 키 누르기 (opencv 윈도우 활성화된 상태에서) " << endl;
int key = 0;
while(1) {
kinect.videoImage(frame);
kinect.depth8BitImage(depth8);
kinect.depthPlayerImage(depthPlayer);
//cout << "Number of Players : " << kinect.numOfPlayers() << endl;
for(int i=0; i<NUI_SKELETON_COUNT; i++)
if(kinect.getPlayer(i).isInitialized())
kinect.getPlayer(i).drawSkeletonInDepthCoordinates(depthPlayer);
cvShowImage("depth",depth8);
cvShowImage("depthPlayer",depthPlayer);
cvShowImage("color",frame);
key = cvWaitKey(10);
if(key==27 || key=='q' || key=='Q')
break;
}
}
/*
포즈 저장하기
*/
else if(menu == '2') {
int key = 0;
cout << " 몇개의 포즈를 찍으시겠습니까 ? > " ;
cin >> total_n_pose;
cout << " 포즈당 몇 프레임을 찍으시겠습니까 ? > " ;
cin >> pose_n_frames;
DBforKinect db;
for(int i=0; i<total_n_pose; i++) {
key =0;
while(key != 1) {
cout << i << "번째 포즈 저장 시작 [1 엔터] " << endl;
cin >> key;
}
Sleep(5000);
sprintf(text,"%d_pose",i);
db.createFolder(text);
db.locateFolder(text);
db.initCnt();
//.........这里部分代码省略.........
示例2: main
int main() {
sf::ContextSettings Settings;
Settings.depthBits = 24; // Request a 24 bits depth buffer
Settings.stencilBits = 8; // Request a 8 bits stencil buffer
Settings.antialiasingLevel = 2; // Request 2 levels of antialiasing
sf::Window window(sf::VideoMode(WNDW_WIDTH, WNDW_HEIGHT, 32), APP_NAME, sf::Style::Close, Settings);
window.setKeyRepeatEnabled(false); // not count key holding press
if (!init()) exit(EXIT_FAILURE);
if (!K.init()) KinectOn = false;
M.init();
std::cout << "LOADING OK" << std::endl;
sf::Clock clock;
sf::Time elapsed;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
switch (event.key.code) {
case sf::Keyboard::Num1: M.increaseRotation(1, 0.0f, 0.0f); break;
case sf::Keyboard::Num2: M.increaseRotation(-1, 0.0f, 0.0f); break;
case sf::Keyboard::Num3: M.increaseRotation(0.0f, 1.0f, 0.0f); break;
case sf::Keyboard::Num4: M.increaseRotation(0.0f, -1.0f, 0.0f); break;
case sf::Keyboard::Num5: M.increaseRotation(0.0f, 0.0f, 1.0f); break;
case sf::Keyboard::Num6: M.increaseRotation(0.0f, 0.0f, -1.0f); break;
case sf::Keyboard::P: K.playRecord(); break;
case sf::Keyboard::R: K.record(); break;
case sf::Keyboard::S: K.stopRecord(); break;
case sf::Keyboard::Z: M.setShocked(); break;
case sf::Keyboard::X: M.undoShocked(); break;
case sf::Keyboard::Escape: window.close(); break;
default: break;
}
break;
default:
break;
}
}
elapsed = clock.getElapsedTime();
if (elapsed.asSeconds() > 1.0 / 30) { // 30 fps = 1.0/60
window.setActive();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (KinectOn) {
K.update();
if (K.IsTracked()) {
FLOAT* sc = K.GetScale();
FLOAT* rot = K.GetRotation();
FLOAT* trans = K.GetTranslation();
FLOAT* AU = K.GetAnimationUnits();
UINT* numAU = K.GetNumAU();
FLOAT* SU = K.GetShapeUnits();
UINT* numSU = K.GetNumSU();
M.registerResult(sc, rot, trans, AU, numAU, SU, numSU);
}
else M.stopAnimation();
}
M.update();
K.render();
M.render();
window.display();
}
}
return 0;
}