Ask Your Question

Revision history [back]

Convert opencv videocapture to opengl videostream

Hi I have following code and only one Asus Xtion. openni::Device device; openni::VideoStream color; openni::VideoFrameRef colorFrame;

Status rc=STATUS_OK;
rc = openni::OpenNI::initialize();
rc = device.open(openni::ANY_DEVICE);
rc = color.create(device, openni::SENSOR_COLOR);
rc = color.start();

Mat frame; namedWindow("Original Image @ Istanbul Technical University");

nite::Status niStatus = nite::STATUS_OK;
//printf("Initializing NiTE ...\r\n");
niStatus = nite::NiTE::initialize();
printf("Creating a user tracker object ...\r\n");

niStatus = uTracker.create();
if (!HandleStatus(niStatus)) return 1;
printf("Done.\r\n");

//printf("Initializing OpenGL ...\r\n");
gl_texture = (OniRGB888Pixel*)malloc(window_w * window_h * sizeof(OniRGB888Pixel));


glutInit(&argc, (char**)argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(window_w, window_h);
glutCreateWindow ("AISENSE-MarieCurie @ Istanbul Technical University");
glutKeyboardFunc(gl_KeyboardCallback);
glutDisplayFunc(gl_DisplayCallback);
glutIdleFunc(gl_IdleCallback);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
//printf("Starting OpenGL rendering process ...\r\n");
glPointSize(10.0);

..... cv::VideoCapture capture( CV_CAP_OPENNI); if (!capture.isOpened()) { printf("Could not open OpenNI-capable sensor\n"); system("pause"); return -1; } capture.set(CV_CAP_PROP_OPENNI_REGISTRATION, 1); double focal_length = capture.get(CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH); //printf("Focal length = %f\n", focal_length);

I want to use both cv::videocapture and openni::videostream. How can I combine it?