bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • Resellers
    • Links
Select Page ...

News

IOS 4.1 code detail

admin November 27, 2012 Software Development Kits No Comments

Detailed description of work-around for AVCaptureVideoPreviewLayer problem in IOS 4.1

IOS 4.1 seems to contain a critical bug in the AVCaptureVideoPreviewLayer which causes app’s to freeze when an instance of the class is created.

The normal way to use AVCaptureVideoPreviewLayer is as follows:

 

// Create the session

session = [[AVCaptureSession alloc] init];

 

 

// Configure the session to produce lower resolution video frames, if your

// processing algorithm can cope. We’ll specify medium quality for the

// chosen device.

session.sessionPreset = AVCaptureSessionPresetMedium;

 

 

// Find a suitable AVCaptureDevice

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

 

// Create a device input with the device and add it to the session.

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device

error:&error];

if (!input) {

// Handling the error appropriately.

return ;

}

[session addInput:input];

 

// Create a VideoDataOutput and add it to the session

AVCaptureVideoDataOutput *output = [[[AVCaptureVideoDataOutput alloc] init] autorelease];

[session addOutput:output];

 

// Configure your output.

dispatch_queue_t queue = dispatch_queue_create(“myQueue”, NULL);

[output setSampleBufferDelegate:self queue:queue];

dispatch_release(queue);

 

// Specify the pixel format

output.videoSettings =

[NSDictionary dictionaryWithObject:

[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];

 

// We use 10 fps for barcode reading.

output.minFrameDuration = CMTimeMake(1, 10);

 

 

// Start the session running to start the flow of data

[session startRunning];

 

 

// Create the video capture preview

// APP WILL FREEZE ON THIS NEXT LINE:

AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:Session];

previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.

[aView.layer addSublayer:previewLayer];

 

 

Any app using the above code on IOS 4.1 will freeze at the line indicated.

 

The work-around is to delay the assignment of the output device to the session until after the preview layer has been created:

 

 

 

// Create the session

11px/normal Menlo; padding: 0px; margin: 0px;”>session = [[AVCaptureSession alloc] init];

 

 

// Configure the session to produce lower resolution video frames, if your

// processing algorithm can cope. We’ll specify medium quality for the

// chosen device.

session.sessionPreset = AVCaptureSessionPresetMedium;

 

 

// Find a suitable AVCaptureDevice

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

 

// Create a device input with the device and add it to the session.

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device

error:&error];

if (!input) {

// Handling the error appropriately.

return ;

}

[session addInput:input];

 

 

// Create the video capture preview

AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:Session];

previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.

[aView.layer addSublayer:previewLayer];

 

 

// Create a VideoDataOutput and add it to the session

AVCaptureVideoDataOutput *output = [[[AVCaptureVideoDataOutput alloc] init] autorelease];

[session addOutput:output];

 

// Configure your output.

dispatch_queue_t queue = dispatch_queue_create(“myQueue”, NULL00;”>);

[output setSampleBufferDelegate:self queue:queue];

dispatch_release(queue);

 

// Specify the pixel format

output.videoSettings =

[NSDictionary dictionaryWithObject:

[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];

 

// We use 10 fps for barcode reading.

output.minFrameDuration = CMTimeMake(1, 10);

 

 

// Start the session running to start the flow of data

[session startRunning];

← iPhone OS 4.0
Using the Multi-Threaded set of dll functions →
admin

  • Copyright © 2023 Softek Software Ltd. All Rights Reserved