Skip to content

Commit

Permalink
Merge pull request BradLarson#1432 from charliewilliams/master
Browse files Browse the repository at this point in the history
Check for NaN in colorTracking point to avoid crash when setting phone on desk
  • Loading branch information
BradLarson committed Mar 18, 2014
2 parents 63ac8e9 + 95cf810 commit 704f434
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ - (void)configureVideoFiltering;
[positionAverageColor setColorAverageProcessingFinishedBlock:^(CGFloat redComponent, CGFloat greenComponent, CGFloat blueComponent, CGFloat alphaComponent, CMTime frameTime) {
// NSLog(@"GPU Average R: %f, G: %f, A: %f", redComponent, greenComponent, alphaComponent);
CGPoint currentTrackingLocation = CGPointMake(1.0 - (greenComponent / alphaComponent), (redComponent / alphaComponent));
if (isnan(currentTrackingLocation.x) || isnan(currentTrackingLocation.y)) {
// NSLog(@"NaN in currentTrackingLocation");
return;
}
// NSLog(@"Centroid from GPU: %f, %f", currentTrackingLocation.x, currentTrackingLocation.y);
// NSLog(@"Average color: %f, %f, %f, %f", redComponent, greenComponent, blueComponent, alphaComponent);
CGSize currentViewSize = weakSelf.view.bounds.size;
Expand Down

0 comments on commit 704f434

Please sign in to comment.