带有OpenCV的Appcelerator iOS模块-OpenCV的摄像头无法打开

问题描述

因此,我正在开发Appcelerator iOS Module which uses OpenCV以便使用相机进行一些图像处理。

问题是,相机根本无法打开。我阅读了官方的OpenCV示例,遵循了步骤(当然,必须修改内容以用作Appc模块),还遵循了Appcelerator Wiki中的iOSModuleQuickStart。我以为我做对了,只是它不起作用。

这是我来自模块的.h视图类:

#import "TiuiView.h"
#import <Foundation/Foundation.h>
#import <opencv2/videoio/cap_ios.h>
#import <UIKit/UIKit.h>

using namespace cv;

@interface ComIosopencvmoduleTestView : TiuiView<CvPhotoCameraDelegate> 
{
    UIImageView *imageView;
    CvPhotoCamera *photoCamera;
}

@property (nonatomic,retain) CvPhotoCamera* photoCamera;

@end

这是它的实现(.mm):

#import "ComIosopencvmoduleTestView.h"
#import "TiUtils.h"
// some other imports....

@implementation ComIosopencvmoduleTestView

@synthesize photoCamera;

#pragma mark - UI Actions

- (void)initializeState
{
    self.photoCamera = [[CvPhotoCamera alloc] initWithParentView:imageView];
    self.photoCamera.delegate = self;
    self.photoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
    self.photoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetPhoto;
    self.photoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
    self.photoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
    [self.photoCamera start];
    // The instantiation and the call to start method,should do the trick,but it doesn't
}

@end

这就是我在JS上从Appcelerator Studio调用的方式:

var VWindow = Ti.UI.createWindow({});
var VView = VItire.createView({});

var VItire = require('com.iosopencvmodule.test');

VWindow.add(VView); 
VWindow.open();

根据我从OpenCV和Appcelerator教程中了解到的这段代码,足以在启动应用程序时打开Camera。

请,可能是什么问题?我对此很生气。预先感谢!

请帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)