Exemplo n.º 1
0
int main(void)
{
	Initgraph();
	Waiting();
	runkernel();
	Closegraph();
	return 0;
}
void CueContrastKernel::execute() {

	if(debug) std::cout << getName() << "::execute()\n";

	if(!m_setParam) { std::cerr << getName() << "::execute()::ERROR::Call setParam() first!\n"; return; }

	if(!m_init) { initialize(); return; }

	obtainInput();

	TrackData* track = trackIn.getBuffer();
	if(!track) { 
		//if(debug) std::cerr<< getName() << "::ERROR::execute()::trackIn is NULL!...\n"; 
		track = &m_track; 
	}

	m_y0.x = (float)(track->winnerPos.x);
	m_y0.y = (float)(track->winnerPos.y);
	if(debug) std::cout << getName() << "::execute()::m_y0 = [" << m_y0.x << " " << m_y0.y << "]\n";


	for(int i=0;i<3;++i) mp_rel[i] = 0.0;
	runkernel(&(mp_y1[0]), &(mp_target_candidate[0]), &(mp_rel[0]), h);
	//runkernel(&(mp_y1[1]), &(mp_target_candidate[1]), &(mp_rel[1]), h*1.1);
	//runkernel(&(mp_y1[2]), &(mp_target_candidate[2]), &(mp_rel[2]), h*0.9);
	unsigned int maxindex = 0;
	//maxindex = findmax(mp_rel, 3);


	m_track.reliability = mp_rel[maxindex];

	if(mp_rel[maxindex] > m_threshold){
		//m_y0.x = mp_y1[maxindex].x;
		//m_y0.y = mp_y1[maxindex].y;

		//if(maxindex == 1){
		//	h = h * 1.1;
		//	m_objsize.width = cvRound((float)m_objsize.width * h);
		//	m_objsize.height = cvRound((float)m_objsize.height * h);
		//}
		//else if(maxindex == 2){
		//	h = h * 0.9;
		//	m_objsize.width = cvRound((float)m_objsize.width * h);
		//	m_objsize.height = cvRound((float)m_objsize.height * h);
		//}
		this->drawGrayBall(&(mp_y1[maxindex]), &m_objsize);

		m_track.winnerPos.x = cvRound(mp_y1[maxindex].x);
		m_track.winnerPos.y = cvRound(mp_y1[maxindex].y);
		m_track.winnerSize.width = m_objsize.width;
		m_track.winnerSize.height = m_objsize.height;

		m_track.winnerRect.x = cvRound(mp_y1[maxindex].x - (float)(m_track.winnerSize.width/2.0));
		m_track.winnerRect.y = cvRound(mp_y1[maxindex].y - (float)(m_track.winnerSize.height/2.0));
		m_track.winnerRect.width = m_objsize.width;
		m_track.winnerRect.height = m_objsize.height;
		
		if(debug) std::cout << getName() << "::execute()::maxindex = " << maxindex << ", mp_y1[" << maxindex << "] = [" << mp_y1[maxindex].x << " " << mp_y1[maxindex].y << "] size = [" << m_track.winnerSize.width << " " << m_track.winnerSize.height << "]\n";
	}
	else{
		cvSetZero(mp_cvoutputimg->ipl);

		if(debug) std::cout << getName() << "::execute()::rel = " << mp_rel[maxindex] << " below threshold [" << m_threshold << "]. Tracking lost\n";

		m_track.reliability = 0.0;
		
		m_init = false;
	}

	trackOut.setBuffer(&m_track);
	trackOut.out();
	
	cvSalImageOut.out();

	if(debug) std::cout << getName() << "::execute() complete\n";

}