To use functions in OpenCV like cvSmooth or cvAdaptiveThreshold you must have the data of your VideoCapture in an IplImage object.

VideoCapture capture;
Mat grayImage;
IplImage *imgSrc, *imgResult;

imgSrc = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 1);
imgResult = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 1);

capture.open(CV_CAP_OPENNI);
if (!capture.isOpened()) {
	cout << "Can not open a capture object." << endl;
	return -1;
}
capture.set(CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ);

for(;;) {
	if (!capture.grab()) {
		cout << "Can not grab images." << endl;
		return -1;
	}
	else {
		if (capture.retrieve(grayImage, CV_CAP_OPENNI_GRAY_IMAGE)) {
			imgSrc->imageData = (char *) grayImage.data;
			cvShowImage("Source", imgSrc);

			cvSmooth(imgSrc, imgResult, CV_BLUR, 100, 100);
			cvShowImage("Result", imgResult);
		}
	}
	if (waitKey(30) >= 0)
		break;
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert