Commit 63e925bc by wester

pntsHeader

parent eee6612f
...@@ -16,7 +16,7 @@ private: ...@@ -16,7 +16,7 @@ private:
glm::vec3 position; glm::vec3 position;
glm::vec3 up; glm::vec3 up;
float speed = 0.1f; float speed = 0.05f;
float mouseSpeed = 0.005f; float mouseSpeed = 0.005f;
float horizontalAngle = (float) -M_PI/2; float horizontalAngle = (float) -M_PI/2;
......
pnts128
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -52,9 +52,9 @@ float KinectSizeZ = 0.067; ...@@ -52,9 +52,9 @@ float KinectSizeZ = 0.067;
float KinectOriginOffsetX = ((92 + 73) / 2.0f) / 1000.0f; float KinectOriginOffsetX = ((92 + 73) / 2.0f) / 1000.0f;
float KinectOriginOffsetY = KinectSizeY/2.0f; float KinectOriginOffsetY = KinectSizeY/2.0f;
glm::vec3 FrameTranslation(0.0,0.0,0.0);
float minTrackingKinect = 0.2f;//0.8f;
float maxTrackingKinect = 0.8f;// 2.5f;
//Vive Tracking //Vive Tracking
SteamTracking* steamTracking = nullptr; SteamTracking* steamTracking = nullptr;
...@@ -67,7 +67,7 @@ std::vector<glm::vec3> controllerPositions; ...@@ -67,7 +67,7 @@ std::vector<glm::vec3> controllerPositions;
bool toggleCam = true; bool toggleCam = false;
Camera mainCam; Camera mainCam;
static bool trackControllerPos = true; static bool trackControllerPos = true;
...@@ -77,20 +77,29 @@ static bool captureFrame = false; ...@@ -77,20 +77,29 @@ static bool captureFrame = false;
int lastX, lastY; int lastX, lastY;
float degreeToRadioan(float degree) {
return degree*M_PI / 180.0;
}
//Filter Settings //Filter Settings
float minTrackingKinect = 0.2f;//0.8f;
float maxTrackingKinect = 1.8f;// 2.5f;
//Custom //Custom
//float angleDegrees = 20.0f; //float angleDegrees = 20.0f;
float maxNormalAngle = degreeToRadioan(25.0f); float maxNormalAngle = degreeToRadioan(25.0f);
bool enableDepthFilter = false; bool enableDepthFilter = false;
bool enableNormalFilter = true;//true; bool enableNormalFilter = false;//true;
//Bilateral / FastDepthNoise //Bilateral / FastDepthNoise
bool enableFastDepthNoiseFilter = true;
float repairThreshold = 100.0f; float repairThreshold = 100.0f;
float degreeToRadioan(float degree) {
return degree*M_PI / 180.0;
}
void DrawCoordinateSystem() { void DrawCoordinateSystem() {
//TETAEDRON BY HAND //TETAEDRON BY HAND
glBegin(GL_LINES); glBegin(GL_LINES);
...@@ -191,28 +200,24 @@ void getDepthData(IMultiSourceFrame* frame) { ...@@ -191,28 +200,24 @@ void getDepthData(IMultiSourceFrame* frame) {
cv::Mat OriginalDepthFrame(height, width, CV_16UC1);// , &buf); cv::Mat OriginalDepthFrame(height, width, CV_16UC1);// , &buf);
const unsigned short* curr = (const unsigned short*)buf; const unsigned short* curr = (const unsigned short*)buf;
for (unsigned int y = 0; y < height; y++) if (enableFastDepthNoiseFilter) {
{ for (unsigned int y = 0; y < height; y++)
for (unsigned int x = 0; x < width; x++)
{ {
OriginalDepthFrame.ptr<unsigned short>(y)[x] = curr[x + y* width]; for (unsigned int x = 0; x < width; x++)
{
OriginalDepthFrame.ptr<unsigned short>(y)[x] = curr[x + y* width];
}
} }
}
cv::Mat FilerdDepth;
FilerdDepth.create(OriginalDepthFrame.size(), OriginalDepthFrame.type());
FastDepthNoiseRemoval filter(3,0.0f,3, repairThreshold);
filter.setKillBorder(true);
filter.setInput(OriginalDepthFrame);
filter.filter(OriginalDepthFrame);
// cv::imshow("Input", OriginalDepthFrame);
//cv::bilateralFilter(OriginalDepthFrame, FilerdDepth, 15, 80, 80);
//const unsigned short* curr = (const unsigned short*)buf; FastDepthNoiseRemoval filter(3, 0.0f, 3, repairThreshold);
curr = (const unsigned short*)OriginalDepthFrame.data; filter.setKillBorder(true);
filter.setInput(OriginalDepthFrame);
filter.filter(OriginalDepthFrame);
// cv::imshow("Input", OriginalDepthFrame);
//cv::bilateralFilter(OriginalDepthFrame, FilerdDepth, 15, 80, 80);
curr = (const unsigned short*)OriginalDepthFrame.data;
}
// Write vertex coordinates // Write vertex coordinates
mapper->MapDepthFrameToCameraSpace(width*height, curr, width*height, depth2xyz); mapper->MapDepthFrameToCameraSpace(width*height, curr, width*height, depth2xyz);
...@@ -369,6 +374,8 @@ void getKinectData() { ...@@ -369,6 +374,8 @@ void getKinectData() {
} }
int counter = 0;
void processCurrentFrameForExport() { void processCurrentFrameForExport() {
points.reserve(points.size() + width*height); points.reserve(points.size() + width*height);
colors.reserve(colors.size() + width*height * 3); colors.reserve(colors.size() + width*height * 3);
...@@ -378,10 +385,15 @@ void processCurrentFrameForExport() { ...@@ -378,10 +385,15 @@ void processCurrentFrameForExport() {
float maxx, maxy, maxz; float maxx, maxy, maxz;
maxx = maxy = maxz = -std::numeric_limits<float>::max(); maxx = maxy = maxz = -std::numeric_limits<float>::max();
std::ofstream myfile;
char buffer[64]; // make sure it's big enough
snprintf(buffer, sizeof(buffer), "frames/pnts_%d.txt", counter++);
myfile.open(buffer, std::ios::out | std::ios::binary);
for (unsigned int i = 0; i < width*height; i++) { for (unsigned int i = 0; i < width*height; i++) {
if (frameValidPoints[i]) { if (frameValidPoints[i]) {
glm::vec3 position = framePositions[i]; glm::vec3 position = framePositions[i];
glm::vec3 positionGlobal = glm::vec3(*currentControlerPos * controlerToKinect * glm::vec4(position, 1.0f)); glm::vec3 positionGlobal = glm::vec3(*currentControlerPos * glm::translate(glm::mat4(), FrameTranslation) * controlerToKinect * glm::vec4(position, 1.0f));
if (isinf(position.x) || isinf(position.y) || isinf(position.z)) if (isinf(position.x) || isinf(position.y) || isinf(position.z))
continue; continue;
...@@ -399,9 +411,17 @@ void processCurrentFrameForExport() { ...@@ -399,9 +411,17 @@ void processCurrentFrameForExport() {
colors.push_back(frameColors[i * 3]); colors.push_back(frameColors[i * 3]);
colors.push_back(frameColors[i * 3 + 1]); colors.push_back(frameColors[i * 3 + 1]);
colors.push_back(frameColors[i * 3 + 2]); colors.push_back(frameColors[i * 3 + 2]);
myfile << positionGlobal.x << " "<<positionGlobal.y << " " << positionGlobal.z << " "
<< (int)frameColors[i * 3] << " " << (int)frameColors[i * 3 + 1] << " " << (int)frameColors[i * 3 + 2] << std::endl;
} }
} }
myfile.close();
std::cout << "Frame Local Boundingbox Min: [" << minx << "|" << miny << "|" << minz << "] Max: [" << maxx << "|" << maxy << "|" << maxz << "]"<< std::endl; std::cout << "Frame Local Boundingbox Min: [" << minx << "|" << miny << "|" << minz << "] Max: [" << maxx << "|" << maxy << "|" << maxz << "]"<< std::endl;
//update Buffers //update Buffers
if (points.size() == 0) return; if (points.size() == 0) return;
...@@ -511,6 +531,8 @@ void mainRenderLoop() { ...@@ -511,6 +531,8 @@ void mainRenderLoop() {
glm::vec3 current = controllerPositions.back(); glm::vec3 current = controllerPositions.back();
std::cout << "Current Position [" << current.x << "/" << current.y << "/" << current.z << "] distance " << distance(lastClicketControlelrPos, current) << std::endl ; std::cout << "Current Position [" << current.x << "/" << current.y << "/" << current.z << "] distance " << distance(lastClicketControlelrPos, current) << std::endl ;
lastClicketControlelrPos = controllerPositions.back(); lastClicketControlelrPos = controllerPositions.back();
FrameTranslation = glm::vec3(0.0, 0.0, 0.0);
captureFrame = false; captureFrame = false;
} }
...@@ -583,7 +605,9 @@ void mainRenderLoop() { ...@@ -583,7 +605,9 @@ void mainRenderLoop() {
{//Kinect Space {//Kinect Space
glPushMatrix(); glPushMatrix();
glTranslatef(FrameTranslation.x, FrameTranslation.y, FrameTranslation.z);
glMultMatrixf(glm::value_ptr(controlerToKinect)); glMultMatrixf(glm::value_ptr(controlerToKinect));
DrawCoordinateSystem(); DrawCoordinateSystem();
glColor4f(0.2f, 0.2f, 0.2f, 1.0f); glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
...@@ -604,6 +628,15 @@ void mainRenderLoop() { ...@@ -604,6 +628,15 @@ void mainRenderLoop() {
} }
void moveCurrentFrame(glm::vec3 dir) {
float factor = 0.002;
FrameTranslation += factor*dir;
std::cout << "Frame Transformation ";
printVector(FrameTranslation);
std::cout << std::endl;
}
void keyPressed(unsigned char key, int x, int y) void keyPressed(unsigned char key, int x, int y)
{ {
mainCam.keyPressed(key, x, y); mainCam.keyPressed(key, x, y);
...@@ -624,6 +657,27 @@ void keyPressed(unsigned char key, int x, int y) ...@@ -624,6 +657,27 @@ void keyPressed(unsigned char key, int x, int y)
case 'q': case 'q':
toggleCam = !toggleCam; toggleCam = !toggleCam;
break; break;
case 'u':
moveCurrentFrame(glm::vec3(1.0, 0.0, 0.0));
break;
case 'j':
moveCurrentFrame(glm::vec3(-1.0, 0.0, 0.0));
break;
case 'i':
moveCurrentFrame(glm::vec3(0.0, 1.0, 0.0));
break;
case 'k':
moveCurrentFrame(glm::vec3(0.0, -1.0, 0.0));
break;
case 'o':
moveCurrentFrame(glm::vec3(0.0, 0.0, 1.0));
break;
case 'l':
moveCurrentFrame(glm::vec3(0.0, 0.0, -1.0));
break;
case 'p':
FrameTranslation = glm::vec3(0.0, 0.0, 0.0);
break;
case 27: // Escape key case 27: // Escape key
exit(0); exit(0);
break; break;
...@@ -721,9 +775,9 @@ int main(int argc, char* argv[]) { ...@@ -721,9 +775,9 @@ int main(int argc, char* argv[]) {
controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 1.0f, 0.0f)); controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 1.0f, 0.0f));
//controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)); //controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
float dx = 0.00;// KinectOriginOffsetX - KinectSizeX / 2; float dx = 0.010;// 0.00;
float dy = KinectSizeY / 2.0f + 0.004 /*HAlterung Platte*/ + 0.011 /* Conroller*/;// -0.01; float dy = KinectSizeY / 2.0f + 0.004 /*HAlterung Platte*/ + 0.011 /* Conroller*/;
float dz = 0.00; //-0.023 + 0.02; // 0.045f /*= versatz auf der Halterung; Distanz zur Halterung:*/ + (KinectSizeZ - (0.066 /*halterung z*/ - 0.012 /*halterung berstand*/)); float dz = -0.01; //-0.023 + 0.02; // 0.045f /*= versatz auf der Halterung; Distanz zur Halterung:*/ + (KinectSizeZ - (0.066 /*halterung z*/ - 0.012 /*halterung berstand*/));
controlerToKinect = glm::translate(controlerToKinect, (glm::vec3(dx, -dy, dz))); controlerToKinect = glm::translate(controlerToKinect, (glm::vec3(dx, -dy, dz)));
......
...@@ -45,6 +45,7 @@ void setupFrameBuffer(); ...@@ -45,6 +45,7 @@ void setupFrameBuffer();
void reshapeFunction(int width, int height); void reshapeFunction(int width, int height);
void printVector(glm::vec3 vector); void printVector(glm::vec3 vector);
float degreeToRadioan(float degree);
struct pntsHeader { struct pntsHeader {
......
{
"asset": {
"version": "0.0"
},
"geometricError": 0,
"root": {
"boundingVolume": {
"sphere": [
0,
0,
0,
5
]
},
"geometricError": 0,
"refine": "add",
"children": [
{
"transform": [
1.0, 0.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 1.0,
0.0, 0.0, 0.0, 1.0
],
"boundingVolume": {
"sphere": [
0,
0,
0,
5
]
},
"geometricError": 0,
"content": {
"url": "example2.pnts"
}
}
]
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment