How to display Native ios camera for real time opencv image processing using NativeModules in react native?

318 views Asked by At

I want to Open Native Camera of ios when we click button in react native component. Then i want to process realtime camera for Opencv methods.

i created View controller and UI but it's not working.

i create Storyboard with Imageview and button. Here is the viewcontroller.h file, In Short i have button in react native component . when i click on button it should open Native ios Camera. I just stuck here and i need help. Please any solutions to access nativeCamera in React native.

#import <opencv2/highgui/cap_ios.h>

using namespace cv;

@interface ViewController : UIViewController
{
  IBOutlet UIImageView* imageView;
  IBOutlet UIButton* button;
  CvVideoCamera* videoCamera;
}


- (IBAction)actionStart:(id)sender;

@property (nonatomic, retain) CvVideoCamera* videoCamera;

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  
  self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
  self.videoCamera.delegate = self;
  self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
  self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
  self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
  self.videoCamera.defaultFPS = 30;
  self.videoCamera.grayscale = NO;

}


- (void)processImage:(Mat&)image;
{
  // Do some OpenCV stuff with the image
  Mat image_copy;
  cvtColor(image, image_copy, COLOR_BGR2GRAY);
  // invert image
  bitwise_not(image_copy, image_copy);
  //Convert BGR to BGRA (three channel to four channel)
  Mat bgr;
  cvtColor(image_copy, bgr, COLOR_GRAY2BGR);
  cvtColor(bgr, image, COLOR_BGR2BGRA);
}

-(IBAction)actionStart:(id)sender
{
  [self.videoCamera start];
}


@end



and My AppDelegate i call this method

    RCT_EXPORT_METHOD(pushVC:(NSString *)vcName){
  
  UIViewController *vc = [UIStoryboard storyboardWithName:@"Camera" bundle:nil].instantiateInitialViewController;
  self.window.rootViewController = vc;

  
}`


    
0

There are 0 answers