0

我尝试创建这样的应用程序:http ://www.youtube.com/watch?v=V9LY8JqKLqE&feature=my_liked_videos&list=LLIeJ9s3lwD-lrqYMU409iAQ

但遗憾的是我不知道如何标记找到的地方

我正在重新考虑本教程:http ://aptogo.co.uk/2011/09/face-tracking/

我的源代码:我将模板图像实现到 DemoVideoCaptureViewController.mm 文件中

- (void)viewDidLoad
{
    [super viewDidLoad];  

    UIImage *testImage = [UIImage imageNamed:@"tt2.jpg"];  
    tempMat = [testImage CVMat];  

    std::vector<cv::KeyPoint> keypoints;  
    cv::SurfFeatureDetector surf (250);  
    surf.detect(tempMat, keypoints);  

    cv::SurfDescriptorExtractor surfDesc;  
    surfDesc.compute(tempMat, keypoints, description1);  
}

我试图在这里找到对象:

- (void)processFrame:(cv::Mat &)mat videoRect:(CGRect)rect videoOrientation:(AVCaptureVideoOrientation)videOrientation
{

    cv::FlannBasedMatcher matcher;  
    std::vector< cv::vector<cv::DMatch> > matches;  
    std::vector<cv::DMatch>  good_matches;  

    cv::SurfFeatureDetector surf2 (250);  
    std::vector<cv::KeyPoint> kp_image;  

    surf2.detect(mat, kp_image);  
    cv::SurfDescriptorExtractor surfDesc2;  
    surfDesc2.compute(mat, kp_image, des_image);  

    if ((des_image.rows > 0) && (description1.rows  > 0)) {  

        matcher.knnMatch(description1, des_image, matches, 2);  

        for (int i = 0; i < MIN(des_image.rows-1, (int) matches.size()); i++) {

            if ((matches[i][0].distance < 0.6*(matches[i][1].distance)) && ((int) matches[i].size() <= 2 && (int) matches[i].size() > 0)) {
                good_matches.push_back(matches[i][0]);
            }

        }

        [CATransaction begin];  
        [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];  

        **//remove old layer**  

        for (CALayer *layer in self.view.layer.sublayers) {  
            NSString *layerName = [layer name];  
            if ([layerName isEqualToString:@"Layer"])  
                [layer setHidden:YES];  
        }  

        [CATransaction commit];  

        if (good_matches.size() >= 4) {  
            NSLog(@"Finding");  
        }  
    }  
}

但我不知道如何在 camrea 视图上放置一个图层

有人可以帮助我吗?

4

1 回答 1

0

您发布的视频中的应用程序可以按照“Mastering OpenCV with Practical Computer Vision Projects”一书的第 3 章(无标记增强现实)创建。

你仍然需要做一些步骤,比如计算单应性。而且您不需要使用 CATransaction 或任何其他 iOS 类。CvVideoCamera 和线就够了。

于 2013-05-05T19:29:09.303 回答