ECE4960-TS3-Archive/cv_code/cv_code.cpp
/* Compare bewteen each frame. Determine which target is moving.
 */
Compare bewteen each frame. Determine which target is moving.
Compare bewteen each frame . Determine which target is moving .
void track_mode() {
	int moving = 0;
	Position cur_pos;
	if(vec_target_pos.empty()==true && vec_tmp_target_pos.empty()==false){
		vec_target_pos = vec_tmp_target_pos;
    }
	else {
		for (int i = 0;i < vec_target_pos.size();i++) vec_target_pos[i].still = 1;
		for (int i = 0; i < vec_tmp_target_pos.size();i++) {
			for (int j = 0;j < vec_target_pos.size();j++) {
				if ( 
					( (SQR(vec_tmp_target_pos.at(i).x - vec_target_pos.at(j).x) +
					   SQR(vec_tmp_target_pos.at(i).y - vec_target_pos.at(j).y) ) <= PIXEL_DISTENCE) &&
						(SQR(vec_tmp_target_pos.at(i).x - vec_target_pos.at(j).x) +
						   SQR(vec_tmp_target_pos.at(i).y - vec_target_pos.at(j).y)) >=30
					){
					vec_target_pos[j] = vec_tmp_target_pos.at(i);	
					vec_moving_tg1.push_back(vec_target_pos[j]);
					cur_x = vec_tmp_target_pos.at(i).x;
					cur_y = vec_tmp_target_pos.at(i).y;
					moving++;
					printf("--%i--pushed %f,%f\n", moving,vec_target_pos[j].x, vec_target_pos[j].y);					
					break;
				}
			}
		}
	}
}
void track_mode ( ) { int moving = 0 ; Position cur_pos ; if ( vec_target_pos . empty ( ) == true && vec_tmp_target_pos . empty ( ) == false ) { vec_target_pos = vec_tmp_target_pos ; } else { for ( int i = 0 ; i < vec_target_pos . size ( ) ; i ++ ) vec_target_pos [ i ] . still = 1 ; for ( int i = 0 ; i < vec_tmp_target_pos . size ( ) ; i ++ ) { for ( int j = 0 ; j < vec_target_pos . size ( ) ; j ++ ) { if ( ( ( SQR ( vec_tmp_target_pos . at ( i ) . x - vec_target_pos . at ( j ) . x ) + SQR ( vec_tmp_target_pos . at ( i ) . y - vec_target_pos . at ( j ) . y ) ) <= PIXEL_DISTENCE ) && ( SQR ( vec_tmp_target_pos . at ( i ) . x - vec_target_pos . at ( j ) . x ) + SQR ( vec_tmp_target_pos . at ( i ) . y - vec_target_pos . at ( j ) . y ) ) >= 30 ) { vec_target_pos [ j ] = vec_tmp_target_pos . at ( i ) ; vec_moving_tg1 . push_back ( vec_target_pos [ j ] ) ; cur_x = vec_tmp_target_pos . at ( i ) . x ; cur_y = vec_tmp_target_pos . at ( i ) . y ; moving ++ ; printf ( " \n " , moving , vec_target_pos [ j ] . x , vec_target_pos [ j ] . y ) ; break ; } } } } }
Compare bewteen each frame.
Compare bewteen each frame .
//int k = 0; //int target = 0; //if empty //if not. //ASSUME that # of target will NOT changed. //Check px distence bw each target  /*
		for (int i = 0; i < vec_tmp_target_pos.size();i++) {
			for (int j = 0;j < vec_target_pos.size();j++) {
				printf("---%f--\n", SQR(vec_tmp_target_pos.at(i).x - vec_target_pos.at(j).x) + SQR(vec_tmp_target_pos.at(i).y - vec_target_pos.at(j).y));
				if ((SQR(vec_tmp_target_pos.at(i).x - vec_target_pos.at(j).x) +
					SQR(vec_tmp_target_pos.at(i).y - vec_target_pos.at(j).y) ) >=20    ) {
				}
				vec_target_pos[j].still = 0;
				cout << "tg:" << j << " moving-----" << endl;
				continue;

			}
		}
		*/