summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cvg.c35
-rw-r--r--cvg.ui1
2 files changed, 36 insertions, 0 deletions
diff --git a/cvg.c b/cvg.c
index b6fc76e..f327ea6 100644
--- a/cvg.c
+++ b/cvg.c
@@ -260,6 +260,39 @@ gauss_filter(struct cvg *cvg, IplImage *image)
}
static IplImage *
+good_features_to_track(struct cvg *cvg, IplImage *image)
+{
+ IplImage *output, *gray_frame, *eig_image, *temp_image;
+ CvPoint2D32f corners[100];
+ int corner_count = sizeof(corners)/sizeof(corners[0]);
+ double quality_level = 0.1, min_distance = 5;
+ int i, eig_block_size = 3, use_harris = 0;
+
+ output = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 3);
+ cvCopy(image, output, NULL);
+
+ gray_frame = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
+ eig_image = cvCreateImage(cvGetSize(image), IPL_DEPTH_32F, 1);
+ temp_image = cvCreateImage(cvGetSize(image), IPL_DEPTH_32F, 1);
+ cvCvtColor(image, gray_frame, CV_BGR2GRAY);
+
+ memset(corners, 0, sizeof corners);
+ cvGoodFeaturesToTrack(gray_frame, eig_image, temp_image,
+ corners, &corner_count,
+ quality_level, min_distance, NULL,
+ eig_block_size, use_harris, 0.04);
+ for (i = 0; i < corner_count; ++i) {
+ CvPoint center = { corners[i].x, corners[i].y };
+ cvCircle(output, center, 5, CV_RGB(255, 0, 0), 3, 8, 0);
+ }
+ cvReleaseImage(&gray_frame);
+ cvReleaseImage(&eig_image);
+ cvReleaseImage(&temp_image);
+
+ return output;
+}
+
+static IplImage *
hide_filter(struct cvg *cvg, IplImage *image)
{
return NULL;
@@ -291,6 +324,8 @@ method_set(GtkComboBox *widget, gpointer userdata)
return;
if (strcmp(text, "Gauss") == 0)
cvg->filter = gauss_filter;
+ else if (strcmp(text, "GoodFeaturesToTrack") == 0)
+ cvg->filter = good_features_to_track;
else if (strcmp(text, "Pass-Through") == 0)
cvg->filter = pass_through_filter;
else if (strcmp(text, "Hide") == 0)
diff --git a/cvg.ui b/cvg.ui
index 4504994..0a821cd 100644
--- a/cvg.ui
+++ b/cvg.ui
@@ -83,6 +83,7 @@
<items>
<item>Hide</item>
<item>Gauss</item>
+ <item>GoodFeaturesToTrack</item>
<item>Pass-Through</item>
</items>
<signal name="changed" handler="method_set" swapped="no"/>