public void finish() { //一致率の最も高いアイテムを得る。 VertexSortTable.Item top_item = this._tracking_list.getTopItem(); //アイテムを検出できなくなるまで、一致率が高い順にアイテムを得る。 while (top_item != null) { //検出したアイテムのARmarkerIndexのデータをセット TMarkerData target = top_item.marker; //検出カウンタが1以上(未検出の場合のみ検出) if (target.lost_count > 0) { target.lost_count = 0; target.life++; target.sq = top_item.ref_sq; target.sq.rotateVertexL(4 - top_item.shift); NyARIntPoint2d.shiftCopy(top_item.ref_sq.ob_vertex, target.tl_vertex, 4 - top_item.shift); target.tl_center.setValue(top_item.ref_sq.center2d); target.tl_rect_area = top_item.ref_sq.rect_area; } //基準アイテムと重複するアイテムを削除する。 this._tracking_list.disableMatchItem(top_item); top_item = this._tracking_list.getTopItem(); } }
public bool update(SquareStack.Item i_new_sq) { int[] ret = this.__ret; int new_area = i_new_sq.rect_area; //頂点の対角距離 int new_sq_dist = i_new_sq.vertex_area.getDiagonalSqDist(); bool is_dispatched = false; for (int i = this.Count - 1; i >= 0; i--) { TMarkerData target = this[i]; if (target.lost_count > 1) { continue; } //面積比が急激0.8-1.2倍以外の変動なら無視 int a_rate = new_area * 100 / target.tl_rect_area; if (a_rate < 50 || 150 < a_rate) { continue; } //移動距離^2の二乗が対角線距離^2の4倍以上なら無視 long sq_move = target.tl_center.sqDist(i_new_sq.center2d); if (sq_move * 4 / new_sq_dist > 0) { continue; } compareVertexSet(i_new_sq.ob_vertex, target.tl_vertex, ret); int sqdist = ret[1]; int shift = ret[0]; //頂点移動距離の合計が、(中心点移動距離+8)の10倍を超えてたらNG <- if (sqdist > (sq_move + 8) * 10) { continue; } //登録可能か確認 VertexSortTable.Item item = this._tracking_list.getInsertPoint(sqdist); if (item == null) { continue; } //登録 item = this._tracking_list.insertFromTailBefore(item); item.marker = target; item.shift = shift; item.sq_dist = sqdist; item.ref_sq = i_new_sq; is_dispatched = true; } return(is_dispatched); }