-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert examples in chapter 8 to JavaCV 0.8.
- Loading branch information
Showing
9 changed files
with
290 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter08/Ex4FAST.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
/* | ||
* Copyright (c) 2011-2013 Jarek Sacha. All Rights Reserved. | ||
* Copyright (c) 2011-2014 Jarek Sacha. All Rights Reserved. | ||
* | ||
* Author's e-mail: jpsacha at gmail.com | ||
*/ | ||
|
||
package opencv2_cookbook.chapter08 | ||
|
||
import com.googlecode.javacv.cpp.opencv_features2d.{KeyPoint, FastFeatureDetector} | ||
import java.io.File | ||
import opencv2_cookbook.OpenCVUtils._ | ||
import org.bytedeco.javacpp.opencv_features2d.{KeyPoint, FastFeatureDetector} | ||
|
||
/** | ||
* The example for section "Detecting FAST features" in Chapter 8, page 203. | ||
*/ | ||
object Ex4FAST extends App { | ||
|
||
// Read input image | ||
val image = loadAndShowOrExit(new File("data/church01.jpg")) | ||
// Read input image | ||
val image = loadMatAndShowOrExit(new File("data/church01.jpg")) | ||
|
||
// Detect FAST features | ||
val ffd = new FastFeatureDetector( | ||
40 /* threshold for detection */ , | ||
true /* non-max suppression */) | ||
val keyPoints = new KeyPoint() | ||
ffd.detect(image, keyPoints, null) | ||
// Detect FAST features | ||
val ffd = new FastFeatureDetector( | ||
40 /* threshold for detection */ , | ||
true /* non-max suppression */) | ||
val keyPoints = new KeyPoint() | ||
ffd.detect(image, keyPoints) | ||
|
||
// Draw keyPoints | ||
show(drawOnImage(image, keyPoints), "FAST Features") | ||
// Draw keyPoints | ||
show(drawOnImage(image, keyPoints), "FAST Features") | ||
} |
39 changes: 20 additions & 19 deletions
39
OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter08/Ex5SURF.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
/* | ||
* Copyright (c) 2011-2013 Jarek Sacha. All Rights Reserved. | ||
* Copyright (c) 2011-2014 Jarek Sacha. All Rights Reserved. | ||
* | ||
* Author's e-mail: jpsacha at gmail.com | ||
*/ | ||
|
||
package opencv2_cookbook.chapter08 | ||
|
||
import com.googlecode.javacv.cpp.opencv_core._ | ||
import com.googlecode.javacv.cpp.opencv_features2d._ | ||
import com.googlecode.javacv.cpp.opencv_nonfree._ | ||
import java.io.File | ||
import opencv2_cookbook.OpenCVUtils._ | ||
import org.bytedeco.javacpp.opencv_core._ | ||
import org.bytedeco.javacpp.opencv_features2d._ | ||
import org.bytedeco.javacpp.opencv_nonfree._ | ||
|
||
|
||
/** | ||
* Example of extracting SURF features from section "Detecting the scale-invariant SURF features" in chapter 8. | ||
*/ | ||
object Ex5SURF extends App { | ||
|
||
// Read input image | ||
val image = loadAndShowOrExit(new File("data/church01.jpg")) | ||
// Read input image | ||
val image = loadMatAndShowOrExit(new File("data/church01.jpg")) | ||
|
||
// Detect SURF features. | ||
val keyPoints = new KeyPoint() | ||
val hessianThreshold = 2500d | ||
val nOctaves = 4 | ||
val nOctaveLayers = 2 | ||
val extended = true | ||
val upright = false | ||
val surf = new SURF(hessianThreshold, nOctaves, nOctaveLayers, extended, upright) | ||
surf.detect(image, null, keyPoints) | ||
// Detect SURF features. | ||
val keyPoints = new KeyPoint() | ||
val hessianThreshold = 2500d | ||
val nOctaves = 4 | ||
val nOctaveLayers = 2 | ||
val extended = true | ||
val upright = false | ||
val surf = new SURF(hessianThreshold, nOctaves, nOctaveLayers, extended, upright) | ||
surf.detect(image, keyPoints) | ||
|
||
// Draw keyPoints | ||
val featureImage = IplImage.create(cvGetSize(image), image.depth(), 3) | ||
drawKeypoints(image, keyPoints, featureImage, CvScalar.WHITE, DrawMatchesFlags.DRAW_RICH_KEYPOINTS) | ||
show(featureImage, "SURF Features") | ||
// Draw keyPoints | ||
// val featureImage = cvCreateImage(cvGetSize(image), image.depth(), 3) | ||
val featureImage = new Mat() | ||
drawKeypoints(image, keyPoints, featureImage, new Scalar(255, 255, 255, 0), DrawMatchesFlags.DRAW_RICH_KEYPOINTS) | ||
show(featureImage, "SURF Features") | ||
} |
38 changes: 19 additions & 19 deletions
38
OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter08/Ex6SIFT.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
/* | ||
* Copyright (c) 2011-2013 Jarek Sacha. All Rights Reserved. | ||
* Copyright (c) 2011-2014 Jarek Sacha. All Rights Reserved. | ||
* | ||
* Author's e-mail: jpsacha at gmail.com | ||
*/ | ||
|
||
package opencv2_cookbook.chapter08 | ||
|
||
import com.googlecode.javacv.cpp.opencv_core._ | ||
import com.googlecode.javacv.cpp.opencv_features2d._ | ||
import com.googlecode.javacv.cpp.opencv_nonfree._ | ||
import java.io.File | ||
import opencv2_cookbook.OpenCVUtils._ | ||
import org.bytedeco.javacpp.opencv_core._ | ||
import org.bytedeco.javacpp.opencv_features2d._ | ||
import org.bytedeco.javacpp.opencv_nonfree._ | ||
|
||
|
||
/** | ||
* Example of extracting SIFT features from section "Detecting the scale-invariant SURF features" in chapter 8. | ||
*/ | ||
object Ex6SIFT extends App { | ||
|
||
// Read input image | ||
val image = loadAndShowOrExit(new File("data/church01.jpg")) | ||
// Read input image | ||
val image = loadMatAndShowOrExit(new File("data/church01.jpg")) | ||
|
||
// Detect SIFT features. | ||
val keyPoints = new KeyPoint() | ||
val nFeatures = 0 | ||
val nOctaveLayers = 3 | ||
val contrastThreshold = 0.03 | ||
val edgeThreshold = 10 | ||
val sigma = 1.6 | ||
val sift = new SIFT(nFeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma) | ||
sift.detect(image, null, keyPoints) | ||
// Detect SIFT features. | ||
val keyPoints = new KeyPoint() | ||
val nFeatures = 0 | ||
val nOctaveLayers = 3 | ||
val contrastThreshold = 0.03 | ||
val edgeThreshold = 10 | ||
val sigma = 1.6 | ||
val sift = new SIFT(nFeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma) | ||
sift.detect(image, keyPoints) | ||
|
||
// Draw keyPoints | ||
val featureImage = IplImage.create(cvGetSize(image), image.depth(), 3) | ||
drawKeypoints(image, keyPoints, featureImage, CvScalar.WHITE, DrawMatchesFlags.DRAW_RICH_KEYPOINTS) | ||
show(featureImage, "SIFT Features") | ||
// Draw keyPoints | ||
val featureImage = new Mat() | ||
drawKeypoints(image, keyPoints, featureImage, new Scalar(255, 255, 255, 0), DrawMatchesFlags.DRAW_RICH_KEYPOINTS) | ||
show(featureImage, "SIFT Features") | ||
} |
Oops, something went wrong.