ios - AVCaptureVideoDataOutputSampleBufferDelegate.CaptureOutput not called -


i have self-developed framework (mysdk), , ios app (myapp) uses mysdk.

inside of mysdk, have class (scanner) in mysdk processes images video output of device camera.

here's sample of code:

scanner.swift

class scanner: nsobject, avcapturevideodataoutputsamplebufferdelegate {      var capturedevice : avcapturedevice?     var captureoutput : avcapturevideodataoutput?     var previewlayer : avcapturevideopreviewlayer?     var capturesession : avcapturesession?      var rootviewcontroller : uiviewcontroller?      func scanimage (viewcontroller: uiviewcontroller)     {         nslog("%@", "scanning begins!")          if (capturesession == nil) { capturesession = avcapturesession() }          rootviewcontroller = viewcontroller;          capturesession!.sessionpreset = avcapturesessionpresethigh          let devices = avcapturedevice.devices()          device in devices {             if (device.hasmediatype(avmediatypevideo)) {                 if(device.position == avcapturedeviceposition.back) {                     capturedevice = device as? avcapturedevice                 }             }         }          if (capturedevice != nil) {             nslog("%@", "beginning session!")              beginsession()         }     }      func beginsession()     {         if (capturesession == nil) { capturesession = avcapturesession() }         if (captureoutput == nil) { captureoutput = avcapturevideodataoutput() }         if (previewlayer == nil) { previewlayer = avcapturevideopreviewlayer() }          let queue = dispatch_queue_create("myqueue", dispatch_queue_serial);          captureoutput!.setsamplebufferdelegate(self, queue: queue)         captureoutput!.videosettings = [kcvpixelbufferpixelformattypekey nsstring: int(kcvpixelformattype_32bgra)]          capturesession!.addinput(try! avcapturedeviceinput(device: capturedevice))         capturesession!.addoutput(captureoutput)          previewlayer = avcapturevideopreviewlayer(session: capturesession)         previewlayer!.frame = rootviewcontroller!.view.layer.frame          rootviewcontroller!.view.layer.addsublayer(previewlayer!)          capturesession!.startrunning()     }      func captureoutput(captureoutput: avcaptureoutput!, didoutputsamplebuffer samplebuffer: cmsamplebufferref!, fromconnection connection: avcaptureconnection!)     {         nslog("%@", "captured!")     } } 

inside myapp, have viewcontroller implements ibaction, in scanner class initialized, , scanimage function triggered.

myapp.m:

- (ibaction)btnscanimage_touchdown:(id)sender {     scanner * scanner = [[scanner alloc] init];      [scanner scanimage:self]; } 

the camera view comes inside of app, captureoutput function never fired, , console contains these 2 lines:

2016-03-07 11:11:45.860 myapp[1236:337377] scanning begins! 2016-03-07 11:11:45.984 myapp[1236:337377] beginning session! 

creating standalone app, , embedding code inside scanner.swift viewcontroller works fine; captureoutput function fires properly.

does have idea doing wrong here?

after trial , error, have found solution problem.

apparently, not creating scanner object class variable, local variable.

once scanner object created class variable, delegate method captureoutput fired properly.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -