Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tweak Farneback for better startup experience.

  • Loading branch information...
commit 52e86ca7ca872122dc77ecb754fca087c32ea9b5 1 parent fc96170
John Brewer authored
20 CVFunhouse/CVFFarneback.m
@@ -13,8 +13,6 @@
13 13 #include "opencv2/video/tracking.hpp"
14 14 #include "opencv2/imgproc/imgproc_c.h"
15 15
16   -CvMat* prevgray = 0, *gray = 0, *flow = 0, *cflow = 0;
17   -
18 16 static void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step,
19 17 double scale, CvScalar color)
20 18 {
@@ -30,6 +28,15 @@ static void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step,
30 28 }
31 29 }
32 30
  31 +@interface CVFFarneback () {
  32 + CvMat *prevgray;
  33 + CvMat *gray;
  34 + CvMat *flow;
  35 + CvMat *cflow;
  36 +}
  37 +
  38 +@end
  39 +
33 40 @implementation CVFFarneback
34 41
35 42 /*
@@ -63,16 +70,15 @@ -(void)processIplImage:(IplImage*)frame
63 70 cvCvtColor(frame, gray, CV_BGR2GRAY);
64 71 cvReleaseImage(&frame);
65 72
  73 + cvCvtColor(gray, cflow, CV_GRAY2BGR);
  74 +
66 75 if( !firstFrame )
67 76 {
68 77 cvCalcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
69   - cvCvtColor(prevgray, cflow, CV_GRAY2BGR);
70 78 drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0));
71 79 }
72   - {
73   - CvMat* temp;
74   - CV_SWAP(prevgray, gray, temp);
75   - }
  80 +
  81 + cvCopy(gray, prevgray, nil);
76 82
77 83 // Call imageReady with your new image.
78 84 IplImage *tempImage = cvAlloc(sizeof(IplImage));
10 CVFunhouse/en.lproj/MainStoryboard_iPad.storyboard
... ... @@ -1,14 +1,13 @@
1 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2   -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2549" systemVersion="11E53" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2840" systemVersion="12C54" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
3 3 <dependencies>
4   - <deployment defaultVersion="1296" identifier="iOS"/>
5   - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1498"/>
  4 + <deployment defaultVersion="1536" identifier="iOS"/>
  5 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1926"/>
6 6 </dependencies>
7 7 <scenes>
8 8 <!--Main View Controller-->
9 9 <scene sceneID="4">
10 10 <objects>
11   - <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
12 11 <viewController id="2" customClass="CVFMainViewController" sceneMemberID="viewController">
13 12 <view key="view" contentMode="scaleToFill" id="8">
14 13 <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
@@ -82,6 +81,7 @@
82 81 </segue>
83 82 </connections>
84 83 </viewController>
  84 + <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
85 85 <swipeGestureRecognizer direction="up" id="haR-n2-fTo">
86 86 <connections>
87 87 <action selector="swipeUpAction:" destination="2" id="gS5-O1-qFE"/>
@@ -98,7 +98,6 @@
98 98 <!--Flipside View Controller-->
99 99 <scene sceneID="7">
100 100 <objects>
101   - <placeholder placeholderIdentifier="IBFirstResponder" id="6" sceneMemberID="firstResponder"/>
102 101 <viewController id="5" customClass="CVFFlipsideViewController" sceneMemberID="viewController">
103 102 <view key="view" contentMode="scaleToFill" id="9">
104 103 <rect key="frame" x="0.0" y="0.0" width="320" height="852"/>
@@ -143,6 +142,7 @@
143 142 <outlet property="navBar" destination="17" id="mzC-dU-KrK"/>
144 143 </connections>
145 144 </viewController>
  145 + <placeholder placeholderIdentifier="IBFirstResponder" id="6" sceneMemberID="firstResponder"/>
146 146 </objects>
147 147 <point key="canvasLocation" x="836" y="101"/>
148 148 </scene>
24 CVFunhouse/en.lproj/MainStoryboard_iPhone.storyboard
... ... @@ -1,7 +1,6 @@
1 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2840" systemVersion="12C54" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
3 3 <dependencies>
4   - <deployment defaultVersion="1536" identifier="iOS"/>
5 4 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1926"/>
6 5 </dependencies>
7 6 <scenes>
@@ -154,29 +153,6 @@
154 153 <image name="SwitchCameraIcon44.png" width="44" height="25"/>
155 154 <image name="iButton30.png" width="30" height="30"/>
156 155 </resources>
157   - <classes>
158   - <class className="CVFFlipsideViewController" superclassName="UIViewController">
159   - <source key="sourceIdentifier" type="project" relativePath="./Classes/CVFFlipsideViewController.h"/>
160   - <relationships>
161   - <relationship kind="action" name="done:"/>
162   - <relationship kind="outlet" name="menuTable" candidateClass="UITableView"/>
163   - <relationship kind="outlet" name="navBar" candidateClass="UINavigationBar"/>
164   - </relationships>
165   - </class>
166   - <class className="CVFMainViewController" superclassName="UIViewController">
167   - <source key="sourceIdentifier" type="project" relativePath="./Classes/CVFMainViewController.h"/>
168   - <relationships>
169   - <relationship kind="action" name="flipAction:"/>
170   - <relationship kind="action" name="swipeDownAction:"/>
171   - <relationship kind="action" name="swipeUpAction:"/>
172   - <relationship kind="outlet" name="descriptionView" candidateClass="UIWebView"/>
173   - <relationship kind="outlet" name="flipCameraButton" candidateClass="UIButton"/>
174   - <relationship kind="outlet" name="fpsLabel" candidateClass="UILabel"/>
175   - <relationship kind="outlet" name="imageView" candidateClass="UIImageView"/>
176   - <relationship kind="outlet" name="previewView" candidateClass="UIView"/>
177   - </relationships>
178   - </class>
179   - </classes>
180 156 <simulatedMetricsContainer key="defaultSimulatedMetrics">
181 157 <nil key="statusBar"/>
182 158 <simulatedOrientationMetrics key="orientation"/>

0 comments on commit 52e86ca

Please sign in to comment.
Something went wrong with that request. Please try again.