/// <summary> /// Returns a random viewpoint in search space /// </summary> /// <returns>The viewpoint, expressed as an array of float parameters</returns> /// <param name="dimension">viewpoint dimension (3 for just position, 6 for position + lookAt, etc)</param> /// <param name="smart">whether to use smart random generation or not</param> /// <param name="t">target to use in case of smart initialization</param> public override float[] ComputeRandomViewpoint(int dimension, bool smart = false, CLTarget t = null) { float[] candidatePos = cameraDomain.ComputeRandomViewpoint(dimension); return(candidatePos); }
/// <summary> /// Returns a random viewpoint in search space, expressed as parameters (the value depends on the specific CLCameraMan subclass). /// If smart = true, the viewpoint is randomly computed according to the current properties (i.e. with more probability where /// the properties are more likely to be satisfied) /// </summary> /// <param name="dimension">dimension of the viewpoint to be generated</param> /// <param name="smart">whether to use smart initialization or not</param> /// <param name="t">Target provided for smart initialization or not. If it is provided, we initialize according to /// that target properties. If it is null, we instead initialize according to all targets </param> /// <returns>The candidate.</returns> public abstract float[] ComputeRandomViewpoint(int dimension, bool smart = false, CLTarget t = null);
/// <summary> /// Returns a random viewpoint in search space /// </summary> /// <returns>The viewpoint, expressed as an array of float parameters</returns> /// <param name="dimension">viewpoint dimension (3 for just position, 6 for position + lookAt, etc)</param> /// <param name="smart">whether to use smart random generation or not</param> /// <param name="t">target to use in case of smart initialization</param> public override float[] ComputeRandomViewpoint(int dimension, bool smart = false, CLTarget t = null) { float[] candidatePos = cameraDomain.ComputeRandomViewpoint(dimension); if (smart) { // in this case we use some of the provided target properties to control randomness, i.e. size and orientation, if present. // Look-at point is set randomly inside target AABB. If a target is not provided, we use all targets as a target // XXX Warning: we are not handling cases where e.g. the search space is only one or two-dimensional ... bool useOrientation = true; if (t == null) { t = allTargets; useOrientation = false; } // this will give up after n tries, so we default to random initialization if there are problems Vector3 pos = t.GenerateRandomSatisfyingPosition(this, useOrientation); candidatePos [0] = pos.x; candidatePos [1] = pos.y; candidatePos [2] = pos.z; candidatePos [3] = UnityEngine.Random.Range(t.boundingBox.min.x, t.boundingBox.max.x); candidatePos [4] = UnityEngine.Random.Range(t.boundingBox.min.y, t.boundingBox.max.y); candidatePos [5] = UnityEngine.Random.Range(t.boundingBox.min.z, t.boundingBox.max.z); } return(candidatePos); }
// this builds a VC problem from a list of targets. For each target, we request size, visibility, vertical // and horizontal orientation void buildVCProblem(List <GameObject> targetObjects, float desiredSize, bool addChildren) { // define list of properties List <CLVisualProperty> properties = new List <CLVisualProperty> (); List <CLVisualProperty> allProperties = new List <CLVisualProperty> (); List <CLTarget> targets = new List <CLTarget> (); List <float> weights = new List <float> (); int layerMask = (1 << 2); float preferredSize = desiredSize / (targetObjects.Count); // for each game object in the list foreach (GameObject targetobj in targetObjects) { List <GameObject> renderables = getChildrenWithRenderers(targetobj); List <GameObject> colliders = getChildrenWithColliders(targetobj); if ((renderables.Count > 0) && (colliders.Count > 0)) { CLTarget target = new CLTarget(targetobj, renderables, colliders, layerMask, CLTarget.VisibilityPointGenerationMethod.UNIFORM_IN_BB, 6); targets.Add(target); List <CLTarget> properties_targets = new List <CLTarget> (); properties_targets.Add(target); //area property with 2.5 weight List <float> sizeSatFuncCtrlX = new List <float> { 0.0f, 0.002f, preferredSize, 0.4f, 0.5f, 1.0f }; List <float> sizeSatFuncCtrlY = new List <float> { 0.0f, 0.1f, 0.8f, 1.0f, 0.1f, 0.0f }; CLSizeProperty sizeP = new CLSizeProperty(CLSizeProperty.SizeMode.AREA, targetobj.name + " size", properties_targets, sizeSatFuncCtrlX, sizeSatFuncCtrlY); weights.Add(2.5f); properties.Add(sizeP); // orientation property (see from front) with w = 1.0 List <float> hORFuncCtrlX = new List <float> { -180.0f, -90f, 0.0f, 90f, 180.0f }; List <float> hORFuncCtrlY = new List <float> { 0.0f, 0.1f, 1.0f, 0.1f, 0.0f }; CLOrientationProperty orP = new CLOrientationProperty(CLOrientationProperty.OrientationMode.HORIZONTAL, targetobj.name + " orientation", properties_targets, hORFuncCtrlX, hORFuncCtrlY); properties.Add(orP); weights.Add(1.0f); // v-orientation property (see from 90 to top), w=1.5 List <float> vORFuncCtrlX = new List <float> { 0.0f, 90.0f, 95f, 180.0f }; List <float> vORFuncCtrlY = new List <float> { 0.0f, 1.0f, 0.1f, 0.0f }; CLOrientationProperty orPV = new CLOrientationProperty(CLOrientationProperty.OrientationMode.VERTICAL_WORLD, targetobj.name + " vorientation", properties_targets, vORFuncCtrlX, vORFuncCtrlY); properties.Add(orPV); weights.Add(1.5f); // occlusion property with 4.0 weight List <float> occlFuncCtrlX = new List <float> { 0.0f, 0.5f, 0.6f, 1.0f }; List <float> occlFuncCtrlY = new List <float> { 1.0f, 0.7f, 0.1f, 0.0f }; CLOcclusionProperty occlP = new CLOcclusionProperty(targetobj.name + " occlusion", properties_targets, occlFuncCtrlX, occlFuncCtrlY, doubleSidedVisibilityChecking, randomRayCasts); weights.Add(4.0f); properties.Add(occlP); } } CLTradeOffSatisfaction satFunction = new CLTradeOffSatisfaction("all", targets, properties, weights); allProperties.AddRange(properties); allProperties.Insert(0, satFunction); camLibCam.SetSpecification(allProperties); }