Commit 5668225e by wester

neue kinect Halterungen/Thumbs.db

parent 68a04f88
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Camera::Camera() : Camera(vec3(10.0f, 5.0f, 0.0f)) Camera::Camera() : Camera(vec3(7.0f, 3.0f, 0.0f))
{ {
} }
......
#include "main.h" #include "main.h"
#include "glut.h"
#include "SteamTracking.h"
#include <ctime>
#include <cmath>
#include <cstdio>
#include <Windows.h>
#include <Ole2.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <glm/vec3.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "glm/gtc/matrix_transform.hpp"
#include <Kinect.h>
#include "Camera.h"
#include "objloader.hpp"
// We'll be using buffer objects to store the kinect point cloud // We'll be using buffer objects to store the kinect point cloud
...@@ -61,12 +40,15 @@ IKinectSensor* sensor; // Kinect sensor ...@@ -61,12 +40,15 @@ IKinectSensor* sensor; // Kinect sensor
IMultiSourceFrameReader* reader; // Kinect data source IMultiSourceFrameReader* reader; // Kinect data source
ICoordinateMapper* mapper; // Converts between depth, color, and 3d coordinates ICoordinateMapper* mapper; // Converts between depth, color, and 3d coordinates
TIMESPAN colorFrameTime = -1; TIMESPAN colorFrameTime = -1;
float KinectOriginOffsetX = ((92 + 73) / 2.0f) / 1000.0f;
float KinectOriginOffsetY = 21 / 1000.0f;
float KinectSizeX = 0.249; float KinectSizeX = 0.249;
float KinectSizeY = 0.042; // 42 mm, 66mm ist die gesammthhe float KinectSizeY = 0.042; // 42 mm, 66mm ist die gesammthhe
float KinectSizeZ = 0.067; float KinectSizeZ = 0.067;
float KinectOriginOffsetX = ((92 + 73) / 2.0f) / 1000.0f;
float KinectOriginOffsetY = KinectSizeY/2.0f;
float minTrackingKinect = 0.8f; float minTrackingKinect = 0.8f;
float maxTrackingKinect = 2.5f; float maxTrackingKinect = 2.5f;
...@@ -279,14 +261,32 @@ void processCurrentFrameForExport() { ...@@ -279,14 +261,32 @@ 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);
float minx, miny, minz;
minx = miny = minz = std::numeric_limits<float>::max();
float maxx, maxy, maxz;
maxx = maxy = maxz = -std::numeric_limits<float>::max();
for (unsigned int i = 0; i < width*height; i++) { for (unsigned int i = 0; i < width*height; i++) {
if (frameValidPoints[i]) { if (frameValidPoints[i]) {
points.push_back(glm::vec3( *currentControlerPos * controlerToKinect * glm::vec4(framePositions[i], 1.0f))); glm::vec3 positionLocal = framePositions[i];
glm::vec3 positionGlobal = glm::vec3(*currentControlerPos * controlerToKinect * glm::vec4(positionLocal, 1.0f));
glm::vec3 position = positionLocal;
if (position.x < minx) minx = position.x;
if (position.x > maxx) maxx = position.x;
if (position.y < miny) miny = position.y;
if (position.y > maxy) maxy = position.y;
if (position.z < minz) minz = position.z;
if (position.z > maxz) maxz = position.z;
points.push_back(positionGlobal);
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]);
} }
} }
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;
...@@ -458,6 +458,7 @@ void mainRenderLoop() { ...@@ -458,6 +458,7 @@ void mainRenderLoop() {
glMultMatrixf(glm::value_ptr(controlerToKinect)); glMultMatrixf(glm::value_ptr(controlerToKinect));
DrawCoordinateSystem(); DrawCoordinateSystem();
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
DrawKinect(); DrawKinect();
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
...@@ -527,6 +528,13 @@ float degreeToRadioan(float degree) { ...@@ -527,6 +528,13 @@ float degreeToRadioan(float degree) {
return degree*M_PI / 180.0; return degree*M_PI / 180.0;
} }
void printVector(glm::vec3 vector)
{
std::cout << "[" << vector.x << "/" << vector.y << "/" << vector.z << "]";
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::cout << "Starting Kinect VR Point Cloud creator\n"; std::cout << "Starting Kinect VR Point Cloud creator\n";
if (!init(argc, argv)) return 1; if (!init(argc, argv)) return 1;
...@@ -576,25 +584,45 @@ int main(int argc, char* argv[]) { ...@@ -576,25 +584,45 @@ int main(int argc, char* argv[]) {
//controlerToKinect = glm::translate(glm::mat4x4(), (glm::vec3(-4.0f, -7.5f, 13.0f)*0.01f)); //controlerToKinect = glm::translate(glm::mat4x4(), (glm::vec3(-4.0f, -7.5f, 13.0f)*0.01f));
float dx = KinectOriginOffsetX - KinectSizeX/ 2;
float dy = KinectSizeY / 2.0f + 0.008; // dicke Halterung;
float dz = 0.045f +(KinectSizeZ-(0.066 /*halterung z*/-0.012 /*halterung ende*/)); //TODO - offset nach hinten;
controlerToKinect = glm::translate(glm::mat4x4(), (glm::vec3(0.0f, 0.0f,0.173 /*controller*/+0.03 /*Halterung*/ ))); //controlerToKinect = glm::translate(glm::mat4x4(), (glm::vec3(0.0f, 0.0f,0.173 /*controller*/+0.03 /*Halterung*/ )));
controlerToKinect = glm::mat4x4();
controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(-58+180 /*63,9...*/), glm::vec3(1.0f, 0.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-64 /*63,9...*/), glm::vec3(1.0f, 0.0f, 0.0f)); float dx = 0.0;// KinectOriginOffsetX - KinectSizeX / 2;
controlerToKinect = glm::rotate(controlerToKinect, degreeToRadioan(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)); float dy = KinectSizeY / 2.0f + 0.004 /*HAlterung Platte*/ + 0.011 /* Conroller*/;
float dz = 0.0; //-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)));
glm::vec3 tempPos = glm::vec3(controlerToKinect*glm::vec4(0, 0, 0, 1)); glm::vec3 tempPos = glm::vec3(controlerToKinect*glm::vec4(0, 0, 0, 1));
std::cout << "Controller Kinect Transformation [" << tempPos.x << "/" << tempPos.y << "/" << tempPos.z << "]" << std::endl; std::cout << "Controller Kinect Transformation ";
printVector(tempPos);
std::cout << std::endl;
std::cout << "Kinect to center: " << dx <<" "<< dy << " " << dz <<std::endl;
// Error Testing
std::cout << "Kinect to center: " << dx <<" "<< dy << " " << dz<<std::endl; glm::mat4 kinectToController = glm::inverse(controlerToKinect);
// x kinect mitte =
float angleInDegrees = 30;
glm::vec4 test = controlerToKinect * glm::rotate(glm::mat4(), degreeToRadioan(angleInDegrees), glm::vec3(1.0f, 0.0f, 0.0f)) * kinectToController * glm::vec4(0.0, 0.0, 1.0, 1.0);
std::cout << "Angle Error x ";
printVector(test);
std::cout << std::endl;
test = controlerToKinect * glm::rotate(glm::mat4(), degreeToRadioan(angleInDegrees), glm::vec3(0.0f, 1.0f, 0.0f)) * kinectToController * glm::vec4(0.0, 0.0, 1.0, 1.0);
std::cout << "Angle Error y ";
printVector(test);
std::cout << std::endl;
test = controlerToKinect * glm::rotate(glm::mat4(), degreeToRadioan(angleInDegrees), glm::vec3(0.0f, 0.0f, 1.0f)) * kinectToController * glm::vec4(0.0, 0.0, 1.0, 1.0);
std::cout << "Angle Error z ";
printVector(test);
std::cout << std::endl;
// //
......
#pragma once #pragma once
#include <openvr.h> #include <openvr.h>
#include "glut.h"
#include "SteamTracking.h"
#include <ctime>
#include <cmath>
#include <cstdio>
#include <Windows.h>
#include <Ole2.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <glm/vec3.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "glm/gtc/matrix_transform.hpp"
#include <Kinect.h>
#include "Camera.h"
#include "objloader.hpp"
const int width = 512; const int width = 512;
const int height = 424; const int height = 424;
const int colorwidth = 1920; const int colorwidth = 1920;
...@@ -21,6 +44,8 @@ void setupFrameBuffer(); ...@@ -21,6 +44,8 @@ void setupFrameBuffer();
void reshapeFunction(int width, int height); void reshapeFunction(int width, int height);
void printVector(glm::vec3 vector);
struct pntsHeader { struct pntsHeader {
unsigned char magic[4] = { 'p','n','t','s' }; unsigned char magic[4] = { 'p','n','t','s' };
......
...@@ -2,8 +2,8 @@ module base(){ ...@@ -2,8 +2,8 @@ module base(){
difference() { difference() {
cube([70,4,66]); cube([70,4,66]);
cube([10,4,10]); translate([60,0,0])cube([10,4,10]);
translate([60,0,56]) cube([10,4,10]); translate([0,0,56]) cube([10,4,10]);
} }
} }
...@@ -15,5 +15,10 @@ module HohlZylinder(size=20, thickness = 5){ ...@@ -15,5 +15,10 @@ module HohlZylinder(size=20, thickness = 5){
} }
} }
base(); module main(){
translate([35,4,33]) rotate([-90,0,0]) HohlZylinder(37,5); base();
\ No newline at end of file translate([35,4,33]) rotate([-90,0,0]) HohlZylinder(37,5);
}
rotate([90,0,0]) main();
\ No newline at end of file
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