Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Binary thresholding works in static setting.

  • Loading branch information...
commit 9b59bf96faae31601cb2cb7337f453c097752617 1 parent b6b6e31
Brandt Westing authored
Showing with 72 additions and 17 deletions.
  1. +19 −17 main.cpp
  2. +53 −0 main_r01.cpp
36 main.cpp
View
@@ -17,35 +17,37 @@ const unsigned int YRES = 480;
int main(int argc, char** argv)
{
- // initialize the kinect
- sensor = new SkeletonSensor();
- sensor->initialize();
+ // initialize the kinect
+ sensor = new SkeletonSensor();
+ sensor->initialize();
- Mat depthRaw(YRES, XRES, CV_16UC1);
+ Mat depthRaw(YRES, XRES, CV_16UC1);
Mat depthShow(YRES, XRES, CV_8UC1);
- namedWindow("debugFrame", CV_WINDOW_AUTOSIZE);
+ namedWindow("debugFrame", CV_WINDOW_AUTOSIZE);
- int key = 0;
- while(key != 27 && key != 'q')
- {
+ int key = 0;
+ while(key != 27 && key != 'q')
+ {
- sensor->waitForDeviceUpdateOnUser();
+ sensor->waitForDeviceUpdateOnUser();
- // update 16 bit depth matrix
+ // update 16 bit depth matrix
memcpy(depthRaw.data, sensor->getDepthData(), XRES*YRES*2);
- depthRaw.convertTo(depthShow, CV_8U, 255/4096.0);
+ depthRaw.convertTo(depthShow, CV_8U, 255.0/4096.0);
- printf("center depth value: %d\n",depthRaw.at<short>(XRES/2,YRES/2));
+ //static binary threshold
+ depthShow = (depthShow > 20) & (depthShow < 150);
- imshow("debugFrame", depthShow);
- //imshow("colorFrame", rgb);
+ printf("center depth value: %d\n",depthRaw.at<short>(XRES/2,YRES/2));
- key = waitKey(10);
+ imshow("debugFrame", depthShow);
- }
+ key = waitKey(10);
- delete sensor;
+ }
+
+ delete sensor;
return 0;
}
53 main_r01.cpp
View
@@ -0,0 +1,53 @@
+#include "SkeletonSensor.h"
+
+// openCV
+#include <opencv/highgui.h>
+#include <opencv/cv.h>
+using namespace cv;
+
+#include <iostream>
+using namespace std;
+
+// globals
+SkeletonSensor* sensor;
+
+const unsigned int XRES = 640;
+const unsigned int YRES = 480;
+
+int main(int argc, char** argv)
+{
+
+ // initialize the kinect
+ sensor = new SkeletonSensor();
+ sensor->initialize();
+
+ Mat depthRaw(YRES, XRES, CV_16UC1);
+ Mat depthShow(YRES, XRES, CV_8UC1);
+
+ namedWindow("debugFrame", CV_WINDOW_AUTOSIZE);
+
+ int key = 0;
+ while(key != 27 && key != 'q')
+ {
+
+ sensor->waitForDeviceUpdateOnUser();
+
+ // update 16 bit depth matrix
+ memcpy(depthRaw.data, sensor->getDepthData(), XRES*YRES*2);
+ depthRaw.convertTo(depthShow, CV_8U, 255.0/4096.0);
+
+ //static binary threshold
+ depthShow = (depthShow > 20) & (depthShow < 150);
+
+ printf("center depth value: %d\n",depthRaw.at<short>(XRES/2,YRES/2));
+
+ imshow("debugFrame", depthShow);
+
+ key = waitKey(10);
+
+ }
+
+ delete sensor;
+
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.