public void SetConfig(ClassifierParameters value) { txtMinSize.Text = value.MinSize.Width.ToString(); txtMaxSize.Text = value.MaxSize.Width.ToString(); txtScale.Text = value.ScaleFactor.ToString(); txtMinNeigh.Text = value.MinNeighbors.ToString(); }
public FaceTrackingPanTiltController(IPanTiltMechanism panTiltMech, CaptureConfig captureConfig) : base(panTiltMech, captureConfig) { var environmentService = new EnvironmentService(); var haarEyeFile = new FileInfo(environmentService.GetAbsolutePathFromAssemblyRelative("haarcascades/haarcascade_eye.xml")); var haarFaceFile = new FileInfo(environmentService.GetAbsolutePathFromAssemblyRelative("haarcascades/haarcascade_frontalface_default.xml")); _faceDetector = new FaceDetector(haarFaceFile.FullName, haarEyeFile.FullName); _classifierParams = new ClassifierParameters(); _classifierParams.MaxSize = new Size(40, 40); }
public void ControlLoad(object sender, EventArgs e) { var environmentService = new EnvironmentService(); var haarEyeFile = new FileInfo(environmentService.GetAbsolutePathFromAssemblyRelative("haarcascades/haarcascade_eye.xml")); var haarFaceFile = new FileInfo(environmentService.GetAbsolutePathFromAssemblyRelative("haarcascades/haarcascade_frontalface_default.xml")); _faceDetector = new FaceDetector(haarFaceFile.FullName, haarEyeFile.FullName); _sunglassOverlay2 = new AccessoryOverlay(environmentService.GetAbsolutePathFromAssemblyRelative("Resources/Images/sunglasses2.png")); _hatOverlay1 = new AccessoryOverlay(environmentService.GetAbsolutePathFromAssemblyRelative("Resources/Images/partyhat.png")); _classiferParams = new ClassifierParameters(); classifierConfigControl.ConfigChanged += classifierConfigControl_ConfigChanged; }
public ClassifierParameters GetConfig() { var classifierParameters = new ClassifierParameters(); try { var minSizeDimension = Int32.Parse(txtMinSize.Text); var maxSizeDimension = Int32.Parse(txtMaxSize.Text); classifierParameters.MinSize = new Size(minSizeDimension, minSizeDimension); classifierParameters.MaxSize = new Size(maxSizeDimension, maxSizeDimension); classifierParameters.ScaleFactor = Double.Parse(txtScale.Text); classifierParameters.MinNeighbors = Int32.Parse(txtMinNeigh.Text); } catch (Exception e) { classifierParameters = _currentParams; SetConfig(classifierParameters); Log.Info(e.Message); } return classifierParameters; }
public ClassifierParameters GetConfig() { var classifierParameters = new ClassifierParameters(); try { var minSizeDimension = Int32.Parse(txtMinSize.Text); var maxSizeDimension = Int32.Parse(txtMaxSize.Text); classifierParameters.MinSize = new Size(minSizeDimension, minSizeDimension); classifierParameters.MaxSize = new Size(maxSizeDimension, maxSizeDimension); classifierParameters.ScaleFactor = Double.Parse(txtScale.Text); classifierParameters.MinNeighbors = Int32.Parse(txtMinNeigh.Text); } catch (Exception e) { classifierParameters = _currentParams; SetConfig(classifierParameters); Log.Info(e.Message); } return(classifierParameters); }
//Expensive collider query optimization that somehow got undone before public static void UpdateAllProbeColliders(Vector3[] aPositions, Vector3[] bPositions, ref Collider[][] collidingCandidates, ref int[] numberOfColliders, ClassifierParameters grabParameters) { for (int i = 0; i < 5; i++) { numberOfColliders[i] = Physics.OverlapCapsuleNonAlloc( point0: aPositions[i], point1: bPositions[i], radius: i == 0 ? grabParameters.THUMBTIP_RADIUS : grabParameters.FINGERTIP_RADIUS, results: collidingCandidates[i], layerMask: grabParameters.LAYER_MASK, queryTriggerInteraction: grabParameters.GRAB_TRIGGERS); } }
public static void UpdateClassifier(GrabClassifier classifier, ClassifierParameters grabParameters, ref Collider[][] collidingCandidates, ref int[] numberOfColliders, bool ignoreTemporal = false) { // Store actual minimum curl in case we override it with the ignoreTemporal flag. float tempMinCurl = grabParameters.MINIMUM_CURL; if (ignoreTemporal) { grabParameters.MINIMUM_CURL = -1f; } //For each probe (fingertip) for (int j = 0; j < classifier.probes.Length; j++) { //Calculate how extended the finger is float tempCurl = Vector3.Dot(classifier.probes[j].direction, (j != 0) ? classifier.handDirection : (classifier.handChirality ? 1f : -1f) * classifier.handXBasis); float curlVelocity = tempCurl - classifier.probes[j].prevTempCurl; classifier.probes[j].prevTempCurl = tempCurl; //Determine if this probe is intersecting an object bool collidingWithObject = false; for (int i = 0; i < numberOfColliders[j]; i++) { if (collidingCandidates[j][i].attachedRigidbody != null && collidingCandidates[j][i].attachedRigidbody == classifier.body) { collidingWithObject = true; break; } } //Nullify above findings if fingers are extended float conditionalMaxCurlVelocity = (classifier.isGrabbed ? grabParameters.GRABBED_MAXIMUM_CURL_VELOCITY : grabParameters.MAXIMUM_CURL_VELOCITY); collidingWithObject = collidingWithObject && (tempCurl < grabParameters.MAXIMUM_CURL) && (tempCurl > grabParameters.MINIMUM_CURL) && (ignoreTemporal || curlVelocity < conditionalMaxCurlVelocity); //Probes go inside when they intersect, probes come out when they uncurl if (!classifier.probes[j].isInside) { classifier.probes[j].isInside = collidingWithObject; classifier.probes[j].curl = tempCurl + (j == 0 ? grabParameters.THUMB_STICKINESS : grabParameters.FINGER_STICKINESS); if (ignoreTemporal) { classifier.probes[j].curl = 0f + (j == 0 ? grabParameters.THUMB_STICKINESS : grabParameters.FINGER_STICKINESS); } } else { if (tempCurl > classifier.probes[j].curl) { classifier.probes[j].isInside = collidingWithObject; } } } //If thumb and one other finger is "inside" the object, it's a grab! //This is the trick! classifier.isThisControllerGrabbing = (classifier.probes[0].isInside && (classifier.probes[1].isInside || classifier.probes[2].isInside || classifier.probes[3].isInside || classifier.probes[4].isInside)); //If grabbing within 10 frames of releasing, discard grab. //Suppresses spurious regrabs and makes throws work better. if (classifier.coolDownProgress <= grabParameters.GRAB_COOLDOWN && !ignoreTemporal) { if (classifier.isThisControllerGrabbing) { classifier.isThisControllerGrabbing = false; } classifier.coolDownProgress += Time.fixedDeltaTime; } //Determine if the object is near the hand or if it's too far away if (classifier.isThisControllerGrabbing && !classifier.prevThisControllerGrabbing) { bool nearObject = false; numberOfColliders[5] = Physics.OverlapSphereNonAlloc(classifier.handGrabCenter, grabParameters.MAXIMUM_DISTANCE_FROM_HAND, collidingCandidates[5], grabParameters.LAYER_MASK, grabParameters.GRAB_TRIGGERS); for (int i = 0; i < numberOfColliders[5]; i++) { if (collidingCandidates[5][i].attachedRigidbody != null && collidingCandidates[5][i].attachedRigidbody == classifier.body) { nearObject = true; break; } } if (!nearObject) { classifier.isThisControllerGrabbing = false; classifier.probes[0].isInside = false; } } // Reset the minimum curl parameter if we modified it due to the ignoreTemporal // flag. if (ignoreTemporal) { grabParameters.MINIMUM_CURL = tempMinCurl; } }
void classifierConfigControl_ConfigChanged(object sender, EventArgs e) { _classiferParams = classifierConfigControl.GetConfig(); }
private void ClassifierConfigControl_Load(object sender, EventArgs e) { _currentParams = new ClassifierParameters(); SetConfig(_currentParams); }
private void HaarCascadeControl_Load(object sender, EventArgs e) { _classiferParams = new ClassifierParameters(); classifierConfigControl.ConfigChanged += classifierConfigControl_ConfigChanged; SetupComboBox(); }