Esempio n. 1
0
UINT64 ofApp::updateMostLegitimateBody() {
	
	UINT64 legitimate = getMostCenteredBodyId();
	if (legitimate == 0) {
		return 0;
	}

	if (legitimate != currLegitimateTrackingId) {
		if (legitimate != newcomerId) {
			ofLog() << "New Comer " << legitimate;
			newcomerId = legitimate;
			newcomerNumPresence = 0;
		}
		if (newcomerNumPresence++ > newcomerNumFrameForElection) {
			ofLog() << "New legitimate " << legitimate;
			currLegitimateTrackingId = legitimate;
			newcomerId = 0;
			newcomerNumPresence = 0;
			//vgb.setBodyId(currLegitimateTrackingId);
		}
	}
	else {
		if (newcomerNumPresence > 0) {
			ofLog() << "Reset new comer presence " << legitimate;
			newcomerNumPresence = 0;
		}
	}

	if (currLegitimateTrackingId != 0) {
		return currLegitimateTrackingId;
	}
	return 0;
}
int OSCSender::getMostLegitimateBody() {
	if (bodies.size() == 1) {
		return 0;
	}
	UINT64 legitimate = getMostCenteredBodyId();
	if (legitimate != currLegitimateTrackingId) {
		if (legitimate != newcomerId) {
			WinLog(L"New Comer", legitimate);
			newcomerId = legitimate;
			newcomerNumPresence = 0;
		}
		if (newcomerNumPresence++ > 60) {
			WinLog(L"New legitimate", legitimate);
			currLegitimateTrackingId = legitimate;
			newcomerId = -1;
			newcomerNumPresence = 0;
		}
	}
	else {
		if (newcomerNumPresence > 0) {
			WinLog(L"Reset new comer presence", legitimate);
			newcomerNumPresence = 0;
		}
	}

	if (currLegitimateTrackingId != -1) {
		return getBodyIdFromTrackingId(currLegitimateTrackingId);
	}
	return -1;
}