Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweak Farneback for better startup experience.

  • Loading branch information...
commit 52e86ca7ca872122dc77ecb754fca087c32ea9b5 1 parent fc96170
John Brewer authored
20 CVFunhouse/CVFFarneback.m
View
@@ -13,8 +13,6 @@
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc_c.h"
-CvMat* prevgray = 0, *gray = 0, *flow = 0, *cflow = 0;
-
static void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step,
double scale, CvScalar color)
{
@@ -30,6 +28,15 @@ static void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step,
}
}
+@interface CVFFarneback () {
+ CvMat *prevgray;
+ CvMat *gray;
+ CvMat *flow;
+ CvMat *cflow;
+}
+
+@end
+
@implementation CVFFarneback
/*
@@ -63,16 +70,15 @@ -(void)processIplImage:(IplImage*)frame
cvCvtColor(frame, gray, CV_BGR2GRAY);
cvReleaseImage(&frame);
+ cvCvtColor(gray, cflow, CV_GRAY2BGR);
+
if( !firstFrame )
{
cvCalcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
- cvCvtColor(prevgray, cflow, CV_GRAY2BGR);
drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0));
}
- {
- CvMat* temp;
- CV_SWAP(prevgray, gray, temp);
- }
+
+ cvCopy(gray, prevgray, nil);
// Call imageReady with your new image.
IplImage *tempImage = cvAlloc(sizeof(IplImage));
10 CVFunhouse/en.lproj/MainStoryboard_iPad.storyboard
View
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2549" systemVersion="11E53" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2840" systemVersion="12C54" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
<dependencies>
- <deployment defaultVersion="1296" identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1498"/>
+ <deployment defaultVersion="1536" identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1926"/>
</dependencies>
<scenes>
<!--Main View Controller-->
<scene sceneID="4">
<objects>
- <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
<viewController id="2" customClass="CVFMainViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
@@ -82,6 +81,7 @@
</segue>
</connections>
</viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
<swipeGestureRecognizer direction="up" id="haR-n2-fTo">
<connections>
<action selector="swipeUpAction:" destination="2" id="gS5-O1-qFE"/>
@@ -98,7 +98,6 @@
<!--Flipside View Controller-->
<scene sceneID="7">
<objects>
- <placeholder placeholderIdentifier="IBFirstResponder" id="6" sceneMemberID="firstResponder"/>
<viewController id="5" customClass="CVFFlipsideViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="9">
<rect key="frame" x="0.0" y="0.0" width="320" height="852"/>
@@ -143,6 +142,7 @@
<outlet property="navBar" destination="17" id="mzC-dU-KrK"/>
</connections>
</viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="6" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="836" y="101"/>
</scene>
24 CVFunhouse/en.lproj/MainStoryboard_iPhone.storyboard
View
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2840" systemVersion="12C54" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
<dependencies>
- <deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1926"/>
</dependencies>
<scenes>
@@ -154,29 +153,6 @@
<image name="SwitchCameraIcon44.png" width="44" height="25"/>
<image name="iButton30.png" width="30" height="30"/>
</resources>
- <classes>
- <class className="CVFFlipsideViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/CVFFlipsideViewController.h"/>
- <relationships>
- <relationship kind="action" name="done:"/>
- <relationship kind="outlet" name="menuTable" candidateClass="UITableView"/>
- <relationship kind="outlet" name="navBar" candidateClass="UINavigationBar"/>
- </relationships>
- </class>
- <class className="CVFMainViewController" superclassName="UIViewController">
- <source key="sourceIdentifier" type="project" relativePath="./Classes/CVFMainViewController.h"/>
- <relationships>
- <relationship kind="action" name="flipAction:"/>
- <relationship kind="action" name="swipeDownAction:"/>
- <relationship kind="action" name="swipeUpAction:"/>
- <relationship kind="outlet" name="descriptionView" candidateClass="UIWebView"/>
- <relationship kind="outlet" name="flipCameraButton" candidateClass="UIButton"/>
- <relationship kind="outlet" name="fpsLabel" candidateClass="UILabel"/>
- <relationship kind="outlet" name="imageView" candidateClass="UIImageView"/>
- <relationship kind="outlet" name="previewView" candidateClass="UIView"/>
- </relationships>
- </class>
- </classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<nil key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Please sign in to comment.
Something went wrong with that request. Please try again.