Skip to content

Commit

Permalink
Added to the Eye Calbiration Wizard.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdfeist committed Jun 3, 2013
1 parent fdc3264 commit 82817ea
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 42 deletions.
1 change: 0 additions & 1 deletion BlinkAnalysis/AppData.h
Expand Up @@ -57,7 +57,6 @@ public class AppData
char fileName[1024];
char filePath[1024];
char error[1024];

};


6 changes: 6 additions & 0 deletions BlinkAnalysis/BlinkAnalysis.vcxproj
Expand Up @@ -96,6 +96,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="*Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="*System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="*System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="*System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Microsoft.VisualBasic.PowerPacks.Vs" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand Down
14 changes: 14 additions & 0 deletions BlinkAnalysis/ClientHandler.cpp
Expand Up @@ -7,6 +7,12 @@

#include <string.h>

// Dikablis
int ClientHandler::DikablisViewingWidth = 768;
int ClientHandler::DikablisViewingHeight = 576;

int ClientHandler::DikablisViewingMargin = 100;

// Constructor: Sets the default values for the ClientHandler
ClientHandler::ClientHandler(void)
{
Expand All @@ -28,13 +34,21 @@ ClientHandler::ClientHandler(void)
NULL);

this->rigidBodyTool = -1;

this->dikablisEyeVectorArray = (float*) malloc(
sizeof(float) *
((DikablisViewingWidth + 2*DikablisViewingMargin) *
(DikablisViewingHeight + 2*DikablisViewingMargin)));
}

// Cleans up the ClientHandler
ClientHandler::~ClientHandler(void)
{
// Free the mutex
CloseHandle(this->g_hMutex);

if (this->dikablisEyeVectorArray != NULL)
free(this->dikablisEyeVectorArray);
}

// Add a Rigid Body to the ClientHandler
Expand Down
16 changes: 16 additions & 0 deletions BlinkAnalysis/ClientHandler.h
Expand Up @@ -50,6 +50,15 @@ class ClientHandler

int iOptiTrackConnectionType; // The Connection Type of the OptiTrack server

// Dikablis
// Width and Height of the Field of View for the Dikablis
static int DikablisViewingWidth;
static int DikablisViewingHeight;
static int DikablisViewingMargin;

// Used to store the calibrated eye vectors
float *dikablisEyeVectorArray;

public:
ClientHandler(void); // Constructor
~ClientHandler(void); // Destructor
Expand Down Expand Up @@ -125,13 +134,20 @@ class ClientHandler
// Updates the RigidBody's transformation based on it's id
void transformRigidBody(int id, osg::Vec3 pos, osg::Vec4 rot);

// Labeled Markers
bool addLabeledMarker(int id, Marker* marker);
Marker* getLabeledMarker(int id);
std::map<int, Marker*>* getLabeledMarkerMap();
void clearLabeledMarkers();
void clearStaleMarkers();

// Rigid Body Tool for defining objects
void setRigidBodyTool(int id) { rigidBodyTool = id; }
int getRigidBodyTool() { return rigidBodyTool; }

// Dikablis
static int getDikablisViewingWidth() { return DikablisViewingWidth; }
static int getDikablisViewingHeight() { return DikablisViewingHeight; }
static int getDikablisViewingMargin() { return DikablisViewingMargin; }
};

27 changes: 26 additions & 1 deletion BlinkAnalysis/EyeCalibration.cpp
@@ -1,2 +1,27 @@
#include "StdAfx.h"
#include "EyeCalibration.h"
#include "EyeCalibration.h"

#include <osg/Matrix>

EyeCalibration::EyeCalibration(void) {
this->rbHeadId = -1;
this->rbViewingObjectId = -1;
}

char* EyeCalibration::getNameById(int id) {
if (id < 0)
return 0;

ClientHandler* client = AppData::getInstance()->getClient();

if (client)
{
RigidBody* body = client->getRigidBody(id);
if (body)
{
return body->getName();
}
}

return 0;
}
44 changes: 5 additions & 39 deletions BlinkAnalysis/EyeCalibration.h
Expand Up @@ -37,52 +37,18 @@ class EyeCalibration {
int rbViewingObjectId;
osg::Vec3 eyeVector;

static int fieldOfViewWidth;
static int fieldOfViewHeight;

char* getNameById(int id) {
ClientHandler* client = AppData::getInstance()->getClient();

if (client)
{
RigidBody* body = client->getRigidBody(id);
if (body)
{
return body->getName();
}
}

return 0;
}
char* getNameById(int id);

std::vector<CalibrationPoint> calibrationPoints;
public:
EyeCalibration(void) { this->rbHeadId = -1; };
EyeCalibration(void);
~EyeCalibration(void) {};

static void setFieldOfViewWidth(int width) { EyeCalibration::fieldOfViewWidth = width; }
static int getFieldOfViewWidth() { return EyeCalibration::fieldOfViewWidth; }

static void setFieldOfViewHeight(int height) { EyeCalibration::fieldOfViewHeight = height; }
static int getFieldOfViewHeight() { return EyeCalibration::fieldOfViewHeight; }


void setHeadId(int id) { this->rbHeadId = id; }
int getHeadId() { return this->rbHeadId; }
char* getHeadName()
{
if (this->rbHeadId < 0)
return 0;

return getNameById(this->rbHeadId);
}
char* getHeadName() { return getNameById(this->rbHeadId); }

void setViewingObjectId(int id) { this->rbViewingObjectId = id; }
int getViewingObjectId() { return this->rbViewingObjectId; }
char* getViewingObjectName()
{
if (this->rbViewingObjectId < 0)
return 0;

return getNameById(this->rbViewingObjectId);
}
char* getViewingObjectName() { return getNameById(this->rbViewingObjectId); }
};
156 changes: 156 additions & 0 deletions BlinkAnalysis/EyeCalibrationWizardForm.h
Expand Up @@ -63,6 +63,23 @@ namespace BlinkAnalysis {

private: System::Windows::Forms::ListView^ objectRigidBodyListView;
private: System::Windows::Forms::TabPage^ calibrationPage;
private: System::Windows::Forms::Button^ addCalibrationPointBtn;

private: System::Windows::Forms::Label^ calibrationPointInstructionsLabel;
private: System::Windows::Forms::Label^ calibrationExampleLabel;
private: Microsoft::VisualBasic::PowerPacks::ShapeContainer^ shapeContainer1;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint7;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint8;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint9;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint6;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint5;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint4;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint2;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint3;
private: Microsoft::VisualBasic::PowerPacks::OvalShape^ demoCalibrationPoint1;
private: Microsoft::VisualBasic::PowerPacks::RectangleShape^ screenShape;
private: System::Windows::Forms::TabPage^ calculatingPage;


private:
/// <summary>
Expand Down Expand Up @@ -96,10 +113,26 @@ namespace BlinkAnalysis {
this->objectSelectionInstructionsLabel = (gcnew System::Windows::Forms::Label());
this->objectRigidBodyListView = (gcnew System::Windows::Forms::ListView());
this->calibrationPage = (gcnew System::Windows::Forms::TabPage());
this->calibrationExampleLabel = (gcnew System::Windows::Forms::Label());
this->addCalibrationPointBtn = (gcnew System::Windows::Forms::Button());
this->calibrationPointInstructionsLabel = (gcnew System::Windows::Forms::Label());
this->shapeContainer1 = (gcnew Microsoft::VisualBasic::PowerPacks::ShapeContainer());
this->demoCalibrationPoint7 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint8 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint9 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint6 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint5 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint4 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint2 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint3 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->demoCalibrationPoint1 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());
this->screenShape = (gcnew Microsoft::VisualBasic::PowerPacks::RectangleShape());
this->calculatingPage = (gcnew System::Windows::Forms::TabPage());
this->wizardPages->SuspendLayout();
this->introPage->SuspendLayout();
this->headSelectPage->SuspendLayout();
this->objectSelectPage->SuspendLayout();
this->calibrationPage->SuspendLayout();
this->SuspendLayout();
//
// backBtn
Expand Down Expand Up @@ -145,6 +178,7 @@ namespace BlinkAnalysis {
this->wizardPages->Controls->Add(this->headSelectPage);
this->wizardPages->Controls->Add(this->objectSelectPage);
this->wizardPages->Controls->Add(this->calibrationPage);
this->wizardPages->Controls->Add(this->calculatingPage);
this->wizardPages->Font = (gcnew System::Drawing::Font(L"Segoe UI", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->wizardPages->Location = System::Drawing::Point(0, 0);
Expand Down Expand Up @@ -315,6 +349,10 @@ namespace BlinkAnalysis {
//
// calibrationPage
//
this->calibrationPage->Controls->Add(this->calibrationExampleLabel);
this->calibrationPage->Controls->Add(this->addCalibrationPointBtn);
this->calibrationPage->Controls->Add(this->calibrationPointInstructionsLabel);
this->calibrationPage->Controls->Add(this->shapeContainer1);
this->calibrationPage->Location = System::Drawing::Point(4, 22);
this->calibrationPage->Name = L"calibrationPage";
this->calibrationPage->Padding = System::Windows::Forms::Padding(3);
Expand All @@ -323,6 +361,120 @@ namespace BlinkAnalysis {
this->calibrationPage->Text = L"Calibration";
this->calibrationPage->UseVisualStyleBackColor = true;
//
// calibrationExampleLabel
//
this->calibrationExampleLabel->Font = (gcnew System::Drawing::Font(L"Segoe UI", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->calibrationExampleLabel->Location = System::Drawing::Point(14, 190);
this->calibrationExampleLabel->Name = L"calibrationExampleLabel";
this->calibrationExampleLabel->Size = System::Drawing::Size(143, 102);
this->calibrationExampleLabel->TabIndex = 12;
this->calibrationExampleLabel->Text = L"For best calibration results try to follow the pattern to the left.";
//
// addCalibrationPointBtn
//
this->addCalibrationPointBtn->Anchor = System::Windows::Forms::AnchorStyles::Top;
this->addCalibrationPointBtn->Location = System::Drawing::Point(379, 231);
this->addCalibrationPointBtn->Name = L"addCalibrationPointBtn";
this->addCalibrationPointBtn->Size = System::Drawing::Size(109, 23);
this->addCalibrationPointBtn->TabIndex = 10;
this->addCalibrationPointBtn->Text = L"Add Point";
this->addCalibrationPointBtn->UseVisualStyleBackColor = true;
this->addCalibrationPointBtn->Click += gcnew System::EventHandler(this, &EyeCalibrationWizardForm::addCalibrationPointBtn_Click);
//
// calibrationPointInstructionsLabel
//
this->calibrationPointInstructionsLabel->AutoSize = true;
this->calibrationPointInstructionsLabel->Font = (gcnew System::Drawing::Font(L"Segoe UI", 10));
this->calibrationPointInstructionsLabel->Location = System::Drawing::Point(13, 7);
this->calibrationPointInstructionsLabel->MaximumSize = System::Drawing::Size(500, 300);
this->calibrationPointInstructionsLabel->Name = L"calibrationPointInstructionsLabel";
this->calibrationPointInstructionsLabel->Size = System::Drawing::Size(491, 171);
this->calibrationPointInstructionsLabel->TabIndex = 9;
this->calibrationPointInstructionsLabel->Text = resources->GetString(L"calibrationPointInstructionsLabel.Text");
//
// shapeContainer1
//
this->shapeContainer1->Location = System::Drawing::Point(3, 3);
this->shapeContainer1->Margin = System::Windows::Forms::Padding(0);
this->shapeContainer1->Name = L"shapeContainer1";
this->shapeContainer1->Shapes->AddRange(gcnew cli::array< Microsoft::VisualBasic::PowerPacks::Shape^ >(10) {this->demoCalibrationPoint7,
this->demoCalibrationPoint8, this->demoCalibrationPoint9, this->demoCalibrationPoint6, this->demoCalibrationPoint5, this->demoCalibrationPoint4,
this->demoCalibrationPoint2, this->demoCalibrationPoint3, this->demoCalibrationPoint1, this->screenShape});
this->shapeContainer1->Size = System::Drawing::Size(523, 289);
this->shapeContainer1->TabIndex = 11;
this->shapeContainer1->TabStop = false;
//
// demoCalibrationPoint7
//
this->demoCalibrationPoint7->Location = System::Drawing::Point(167, 262);
this->demoCalibrationPoint7->Name = L"demoCalibrationPoint7";
this->demoCalibrationPoint7->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint8
//
this->demoCalibrationPoint8->Location = System::Drawing::Point(238, 262);
this->demoCalibrationPoint8->Name = L"demoCalibrationPoint8";
this->demoCalibrationPoint8->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint9
//
this->demoCalibrationPoint9->Location = System::Drawing::Point(310, 262);
this->demoCalibrationPoint9->Name = L"demoCalibrationPoint9";
this->demoCalibrationPoint9->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint6
//
this->demoCalibrationPoint6->Location = System::Drawing::Point(310, 228);
this->demoCalibrationPoint6->Name = L"demoCalibrationPoint6";
this->demoCalibrationPoint6->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint5
//
this->demoCalibrationPoint5->Location = System::Drawing::Point(238, 228);
this->demoCalibrationPoint5->Name = L"demoCalibrationPoint5";
this->demoCalibrationPoint5->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint4
//
this->demoCalibrationPoint4->Location = System::Drawing::Point(167, 228);
this->demoCalibrationPoint4->Name = L"demoCalibrationPoint4";
this->demoCalibrationPoint4->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint2
//
this->demoCalibrationPoint2->Location = System::Drawing::Point(238, 191);
this->demoCalibrationPoint2->Name = L"demoCalibrationPoint2";
this->demoCalibrationPoint2->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint3
//
this->demoCalibrationPoint3->Location = System::Drawing::Point(310, 191);
this->demoCalibrationPoint3->Name = L"demoCalibrationPoint3";
this->demoCalibrationPoint3->Size = System::Drawing::Size(20, 20);
//
// demoCalibrationPoint1
//
this->demoCalibrationPoint1->Location = System::Drawing::Point(167, 191);
this->demoCalibrationPoint1->Name = L"demoCalibrationPoint1";
this->demoCalibrationPoint1->Size = System::Drawing::Size(20, 20);
//
// screenShape
//
this->screenShape->Location = System::Drawing::Point(156, 187);
this->screenShape->Name = L"screenShape";
this->screenShape->Size = System::Drawing::Size(183, 100);
//
// calculatingPage
//
this->calculatingPage->Location = System::Drawing::Point(4, 22);
this->calculatingPage->Name = L"calculatingPage";
this->calculatingPage->Padding = System::Windows::Forms::Padding(3);
this->calculatingPage->Size = System::Drawing::Size(529, 295);
this->calculatingPage->TabIndex = 4;
this->calculatingPage->Text = L"Calculating";
this->calculatingPage->UseVisualStyleBackColor = true;
//
// EyeCalibrationWizardForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
Expand All @@ -347,6 +499,8 @@ namespace BlinkAnalysis {
this->headSelectPage->PerformLayout();
this->objectSelectPage->ResumeLayout(false);
this->objectSelectPage->PerformLayout();
this->calibrationPage->ResumeLayout(false);
this->calibrationPage->PerformLayout();
this->ResumeLayout(false);

}
Expand Down Expand Up @@ -517,5 +671,7 @@ private: System::Void selectAsObjectBtn_Click(System::Object^ sender, System::E
this->selectedObjectLabel->Text = "No Rigid Body is selected to be the viewing object.";
}
}
private: System::Void addCalibrationPointBtn_Click(System::Object^ sender, System::EventArgs^ e) {
}
};
}

0 comments on commit 82817ea

Please sign in to comment.