Commit e6754bf4 authored by Pierre Bürki's avatar Pierre Bürki
Browse files

Add bounding box to detection area

parent 38f1d30c
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ void SkeletonFinder::initGUI(ofxGui& gui) {
	sensorBoxBottom.addListener(this, &SkeletonFinder::updateSensorBox);

	sensorBoxGuiGroup = panel->addGroup("SensorBox");
	sensorBoxGuiGroup->add(filtering.set("Filtering", true));
	sensorBoxGuiGroup->add<ofxGuiIntInputField>(sensorBoxLeft.set("left", 1000));
	sensorBoxGuiGroup->add<ofxGuiIntInputField>(sensorBoxRight.set("right", -1000));
	sensorBoxGuiGroup->add<ofxGuiIntInputField>(sensorBoxFront.set("front", 1000));
@@ -50,7 +51,11 @@ void SkeletonFinder::update(nuitrack::SkeletonData::Ptr data) {
			joints.push_back(Joint(joint.type, joint.confidence, pos));
		}

		skeletons.push_back(Skeleton(skel.id, joints));
		Skeleton skeleton(skel.id, joints);
		if (!filtering.get() || isSkeletonInBounds(skeleton)) {
			skeletons.push_back(skeleton);
		}

	}
}

@@ -168,3 +173,13 @@ void SkeletonFinder::updateSensorBox(int& value) {
	//captureCam.setPosition(5, 5, 0);
	//captureCam.
}

bool SkeletonFinder::isSkeletonInBounds(const Skeleton& skel) {
	glm::vec3 headPos = skel.joints[nuitrack::JOINT_HEAD].pos;
	return headPos.x < sensorBoxLeft.get() * SCALE
		&& headPos.x > sensorBoxRight.get() * SCALE
		&& headPos.y < sensorBoxFront.get()* SCALE
		&& headPos.y > sensorBoxBack.get() * SCALE
		&& headPos.z < sensorBoxTop.get()* SCALE
		&& headPos.z > sensorBoxBottom.get() * SCALE;
}
+3 −2
Original line number Diff line number Diff line
@@ -62,8 +62,6 @@ public:
    void setTransformMatrix(ofMatrix4x4* mat);
    void update(nuitrack::SkeletonData::Ptr data);
    
    void updateSensorBox(int & value);
    
    void drawSensorBox();
    void drawSkeletons2d(ofRectangle _rect);
    void drawSkeletons();
@@ -73,6 +71,8 @@ public:
    vector<Skeleton> getSkeletons();
    
private:
    void updateSensorBox(int & value);
    bool isSkeletonInBounds(const Skeleton& skel);

    ofxnui::TrackerRef tracker;
    vector<Skeleton> skeletons;
@@ -83,6 +83,7 @@ public:
    ofxGuiPanel *panel;
	ofxGuiGroup *sensorBoxGuiGroup;

    ofParameter<bool> filtering;
    ofParameter<int> sensorBoxLeft;
    ofParameter<int> sensorBoxRight;
    ofParameter<int> sensorBoxTop;