protected void Awake() { if (instance == null) { instance = this; } if (!cam) { cam = Camera.main; } }
public void UpdateInfo(BoundingBox bounding_box) { if (!mano_utils) { mano_utils = ManoUtils.Instance; } if (!bound_line_renderer) { Debug.Log("bound_line_renderer: null"); return; } switch (myBoundingBoxType) { case BoundingBoxType.Outer: normalizedTopLeftX = bounding_box.top_left.x; normalizedTopLeftY = bounding_box.top_left.y; normalizedBBWidth = bounding_box.width; normalizedHeight = bounding_box.height; normalizedTopLeft = new Vector3(normalizedTopLeftX, normalizedTopLeftY); normalizedTopRight = new Vector3(normalizedTopLeftX + normalizedBBWidth, normalizedTopLeftY); normalizedBotRight = new Vector3(normalizedTopLeftX + normalizedBBWidth, normalizedTopLeftY - normalizedHeight); normalizedBotLeft = new Vector3(normalizedTopLeftX, normalizedTopLeftY - normalizedHeight); bound_line_renderer.SetPosition(0, ManoUtils.Instance.CalculateNewPosition(normalizedTopLeft, backgroundDepth)); bound_line_renderer.SetPosition(1, ManoUtils.Instance.CalculateNewPosition(normalizedTopRight, backgroundDepth)); bound_line_renderer.SetPosition(2, ManoUtils.Instance.CalculateNewPosition(normalizedBotRight, backgroundDepth)); bound_line_renderer.SetPosition(3, ManoUtils.Instance.CalculateNewPosition(normalizedBotLeft, backgroundDepth)); normalizedTopLeft.y += textAdjustment * 3; top_left.gameObject.transform.position = ManoUtils.Instance.CalculateNewPosition(normalizedTopLeft, backgroundDepth / textDepthModifier); top_left.text = "Top Left: " + "X: " + normalizedTopLeftX.ToString("F2") + " Y: " + normalizedTopLeftY.ToString("F2"); normalizedTextHeightPosition = new Vector3(normalizedTopLeftX + normalizedBBWidth + textAdjustment, (normalizedTopLeftY - normalizedHeight / 2f)); height.transform.position = ManoUtils.Instance.CalculateNewPosition(normalizedTextHeightPosition, backgroundDepth / textDepthModifier); height.GetComponent <TextMesh>().text = "Height: " + normalizedHeight.ToString("F2"); normalizedTextWidth = new Vector3(normalizedTopLeftX + normalizedBBWidth / 2f, (normalizedTopLeftY - normalizedHeight) - textAdjustment); width.transform.position = ManoUtils.Instance.CalculateNewPosition(normalizedTextWidth, backgroundDepth / textDepthModifier); width.GetComponent <TextMesh>().text = "Width: " + normalizedBBWidth.ToString("F2"); break; default: break; } }
// Update is called once per frame public void UpdateInfo(BoundingBox bounding_box) { topLeftX = Mathf.Lerp(topLeftX, bounding_box.top_left.x, smoothingFactor); topLeftY = Mathf.Lerp(topLeftY, bounding_box.top_left.y, smoothingFactor); bbWidth = Mathf.Lerp(bbWidth, bounding_box.width, smoothingFactor); bbHeight = Mathf.Lerp(bbHeight, bounding_box.height, smoothingFactor); if (!mano_utils) { mano_utils = ManoUtils.Instance; } if (!bound_line_renderer) { Debug.Log("bound_line_renderer: null"); } bound_line_renderer.SetPosition(0, mano_utils.CalculateNewPosition(new Vector3(topLeftX, 1 - topLeftY, 1), 1)); bound_line_renderer.SetPosition(1, mano_utils.CalculateNewPosition(new Vector3(topLeftX + bbWidth, 1 - topLeftY, 1), 1)); bound_line_renderer.SetPosition(2, mano_utils.CalculateNewPosition(new Vector3(topLeftX + bbWidth, (1 - topLeftY - bbHeight), 1), 1)); bound_line_renderer.SetPosition(3, mano_utils.CalculateNewPosition(new Vector3(topLeftX, (1 - topLeftY - bbHeight), 1), 1)); top_left.gameObject.transform.position = mano_utils.CalculateNewPosition(new Vector3(topLeftX, 1.05f - topLeftY, 1), 1); top_left.text = "Top Left: " + "X: " + topLeftX.ToString("F2") + " Y: " + topLeftY.ToString("F2"); height.transform.position = mano_utils.CalculateNewPosition(new Vector3(topLeftX + bbWidth + 0.025f, (1 - topLeftY - bbHeight / 2f), 1), 1); height.GetComponent <TextMesh>().text = "Height: " + bbHeight.ToString("F2"); width.transform.position = mano_utils.CalculateNewPosition(new Vector3(topLeftX + bbWidth / 2f, (1 - topLeftY - bbHeight) - 0.025f, 1), 1); width.GetComponent <TextMesh>().text = "Width: " + bbWidth.ToString("F2"); //pure data //bound_line_renderer.SetPosition(0, mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x, 1 - bounding_box.top_left.y, 1), 1)); //bound_line_renderer.SetPosition(1, mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x + bounding_box.width, 1 - bounding_box.top_left.y, 1), 1)); //bound_line_renderer.SetPosition(2, mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x + bounding_box.width, (1 - bounding_box.top_left.y - bounding_box.height), 1), 1)); //bound_line_renderer.SetPosition(3, mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x, (1 - bounding_box.top_left.y - bounding_box.height), 1), 1)); //top_left.gameObject.transform.position = mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x, 1.05f - bounding_box.top_left.y, 1), 1); //top_left.text = "Top Left: " + "X: " + bounding_box.top_left.x.ToString("F2") + " Y: " + bounding_box.top_left.y.ToString("F2"); //height.transform.position = mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x + bounding_box.width + 0.025f, (1 - bounding_box.top_left.y - bounding_box.height / 2f), 1), 1); //height.GetComponent<TextMesh>().text = "Height: " + bounding_box.height.ToString("F2"); //width.transform.position = mano_utils.CalculateNewPosition(new Vector3(bounding_box.top_left.x + bounding_box.width / 2f, (1 - bounding_box.top_left.y - bounding_box.height) - 0.025f, 1), 1); //width.GetComponent<TextMesh>().text = "Width: " + bounding_box.width.ToString("F2"); }
void Start() { if (!cam) { cam = Camera.main; } mano_utils = ManoUtils.Instance; SetHandsSupportedByLicence(); SetPointsBasedOnHandNumber(); CreatePalmCenterParticle(); CreateFingerTipLabelParticles(); CreateFingerTipParticles(); CreateContourParticles(); CreateInnerParticles(); InstantiateManomotionMeshes(); CreateBoundingBoxes(); }
private void Start() { mano_utils = ManoUtils.Instance; bound_line_renderer.positionCount = 4; }