Commit 63e925bc by wester

pntsHeader

parent eee6612f
......@@ -16,7 +16,7 @@ private:
glm::vec3 position;
glm::vec3 up;
float speed = 0.1f;
float speed = 0.05f;
float mouseSpeed = 0.005f;
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;
float KinectOriginOffsetX = ((92 + 73) / 2.0f) / 1000.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
SteamTracking* steamTracking = nullptr;
......@@ -67,7 +67,7 @@ std::vector<glm::vec3> controllerPositions;
bool toggleCam = true;
bool toggleCam = false;
Camera mainCam;
static bool trackControllerPos = true;
......@@ -77,20 +77,29 @@ static bool captureFrame = false;
int lastX, lastY;
float degreeToRadioan(float degree) {
return degree*M_PI / 180.0;
}
//Filter Settings
float minTrackingKinect = 0.2f;//0.8f;
float maxTrackingKinect = 1.8f;// 2.5f;
//Custom
//float angleDegrees = 20.0f;
float maxNormalAngle = degreeToRadioan(25.0f);
bool enableDepthFilter = false;
bool enableNormalFilter = true;//true;
bool enableNormalFilter = false;//true;
//Bilateral / FastDepthNoise
bool enableFastDepthNoiseFilter = true;
float repairThreshold = 100.0f;
float degreeToRadioan(float degree) {
return degree*M_PI / 180.0;
}
void DrawCoordinateSystem() {
//TETAEDRON BY HAND
glBegin(GL_LINES);
......@@ -191,6 +200,7 @@ void getDepthData(IMultiSourceFrame* frame) {
cv::Mat OriginalDepthFrame(height, width, CV_16UC1);// , &buf);
const unsigned short* curr = (const unsigned short*)buf;
if (enableFastDepthNoiseFilter) {
for (unsigned int y = 0; y < height; y++)
{
for (unsigned int x = 0; x < width; x++)
......@@ -199,20 +209,15 @@ void getDepthData(IMultiSourceFrame* frame) {
}
}
cv::Mat FilerdDepth;
FilerdDepth.create(OriginalDepthFrame.size(), OriginalDepthFrame.type());
FastDepthNoiseRemoval filter(3,0.0f,3, repairThreshold);
FastDepthNoiseRemoval filter(3, 0.0f, 3, repairThreshold);
filter.setKillBorder(true);
filter.setInput(OriginalDepthFrame);
filter.filter(OriginalDepthFrame);
// cv::imshow("Input", OriginalDepthFrame);
// cv::imshow("Input", OriginalDepthFrame);
//cv::bilateralFilter(OriginalDepthFrame, FilerdDepth, 15, 80, 80);
//const unsigned short* curr = (const unsigned short*)buf;
curr = (const unsigned short*)OriginalDepthFrame.data;
}
// Write vertex coordinates
mapper->MapDepthFrameToCameraSpace(width*height, curr, width*height, depth2xyz);
......@@ -369,6 +374,8 @@ void getKinectData() {
}
int counter = 0;
void processCurrentFrameForExport() {
points.reserve(points.size() + width*height);
colors.reserve(colors.size() + width*height * 3);
......@@ -378,10 +385,15 @@ void processCurrentFrameForExport() {
float maxx, maxy, maxz;
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++) {
if (frameValidPoints[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))
continue;
......@@ -399,9 +411,17 @@ void processCurrentFrameForExport() {
colors.push_back(frameColors[i * 3]);
colors.push_back(frameColors[i * 3 + 1]);
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;
//update Buffers
if (points.size() == 0) return;
......@@ -511,6 +531,8 @@ void mainRenderLoop() {
glm::vec3 current = controllerPositions.back();
std::cout << "Current Position [" << current.x << "/" << current.y << "/" << current.z << "] distance " << distance(lastClicketControlelrPos, current) << std::endl ;
lastClicketControlelrPos = controllerPositions.back();
FrameTranslation = glm::vec3(0.0, 0.0, 0.0);
captureFrame = false;
}
......@@ -583,7 +605,9 @@ void mainRenderLoop() {
{//Kinect Space
glPushMatrix();
glTranslatef(FrameTranslation.x, FrameTranslation.y, FrameTranslation.z);
glMultMatrixf(glm::value_ptr(controlerToKinect));
DrawCoordinateSystem();
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
......@@ -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)
{
mainCam.keyPressed(key, x, y);
......@@ -624,6 +657,27 @@ void keyPressed(unsigned char key, int x, int y)
case 'q':
toggleCam = !toggleCam;
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
exit(0);
break;
......@@ -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, 0.0f, 1.0f));
float dx = 0.00;// KinectOriginOffsetX - KinectSizeX / 2;
float dy = KinectSizeY / 2.0f + 0.004 /*HAlterung Platte*/ + 0.011 /* Conroller*/;// -0.01;
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 dx = 0.010;// 0.00;
float dy = KinectSizeY / 2.0f + 0.004 /*HAlterung Platte*/ + 0.011 /* Conroller*/;
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)));
......
......@@ -45,6 +45,7 @@ void setupFrameBuffer();
void reshapeFunction(int width, int height);
void printVector(glm::vec3 vector);
float degreeToRadioan(float degree);
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