用kinect实现深度裁剪,获取一定返回内的图像,主要代码如下:
kinect.update();
if(kinect.isOpened()){
image.setFromPixels(kinect.getPixelsRef());
colorImage.setFromPixels(kinect.getPixelsRef());
depthImage.setFromPixels(kinect.getDepthPixels());
tempGrayImage.setFromPixels(kinect.getDepthPixels());
monoPixels.setFromPixels(tempGrayImage.getPixels(), 320,240, 1);
if (bLearnBakground == true){
monoPixels_diff.setFromPixels(tempGrayImage.getPixels(),320,240, 1);
bLearnBakground = false;
}
for (int i = 0; i <320*240; i++){
int valtemp = monoPixels[i] - monoPixels_diff[i];
if (valtemp < thresholdLow || valtemp > thresholdHigh){
valtemp = 0;
} else {
valtemp = 1000;
}
grayPixels[i] = (unsigned char)valtemp;
}
// paso_openCV.absDiff(grayImage,depthImage);
paso_openCV.setFromPixels(grayPixels);
if(bLearnBakground2==true)
{
absdiffimage=paso_openCV;
bLearnBakground2=false;
}
paso_openCV.absDiff(absdiffimage);
// paso_openCV.setFromPixels(grayPixels);
grayImage.warpIntoMe(paso_openCV, entrada, destino_camera_warp);
image.warpPerspective(entrada2[0], entrada2[1], entrada2[2], entrada2[3]);
//colorImage.warpPerspective(entrada[0], entrada[1], entrada[2], entrada[3]);
grayImage.threshold(threshold);
grayImage.blur(5);
/*paso_openCV.absDiff(absdiffimage);
grayImage.warpIntoMe(paso_openCV, entrada, destino_camera_warp);
paso_openCV.threshold(threshold);
paso_openCV.blur(5); */
contourFinderDepth.findContours(grayImage, 20, (320 * 240)/3, 10, true);
作者QQ:715705486